Page 1 of 2
Writing an app using buildroot
Posted: 2024-01-27 12:46
by npelov
I like the idea of a cheap SBC that doesn't even require SD card. However I couldn't find a tutorial for making a new program from scratch and building it with buildroot. Like a hello world program (in C) that uses a library - for example libcurl.
Re: Writing an app using buildroot
Posted: 2024-01-28 5:36
by Eng38
Hello,
To run programs on the development board, you can use various compilation methods such as WSL, virtual machines, and hosts for cross-compiling. Then, transfer the compiled files to the development board for execution.
Re: Writing an app using buildroot
Posted: 2024-01-28 23:03
by npelov
Yes, but then I can't use the libraries that are already in the buildroot. For example if I want to use curl library I can't because it'll be different on the compile machine. I want to know how to setup the environment so I can use the toolchain link with libraries that I've selected in buildroot
Re: Writing an app using buildroot
Posted: 2024-01-29 6:54
by Eng38
When cross-compiling a program, it's crucial to specify the library, header file directories, and library paths. Here's an example:
Code: Select all
arm-rockchip830-linux-uclibcgnueabihf-gcc test.c -o test -I/home/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include -L/home/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/lib -lcurl -lcrypto -lssl -lz
1. test.c is the program to be cross-compiled
2. /home/luckfox-pico is my SDK path
Re: Writing an app using buildroot
Posted: 2024-01-29 14:55
by Robbal
Thank you for this . How would you put this in a CMakeLists.txt file. I want to use curl with the RKNN model tutorial
Re: Writing an app using buildroot
Posted: 2024-01-29 20:37
by torchris4
I'd also like to have a minimal 'helloWorld.c" example to work from.
I believe I have all the build tools installed correctly on my Docker image, but when I try to run the above command, I get:
arm-rockchip830-linux-uclibcgnueabihf-gcc: command not found
Thanks!
Re: Writing an app using buildroot
Posted: 2024-01-30 1:20
by Eng38
torchris4 wrote: ↑2024-01-29 20:37
I'd also like to have a minimal 'helloWorld.c" example to work from.
I believe I have all the build tools installed correctly on my Docker image, but when I try to run the above command, I get:
arm-rockchip830-linux-uclibcgnueabihf-gcc: command not found
Thanks!
You need to add the path to your cross-compilation tools to your system's PATH environment variable:
https://wiki.luckfox.com/Luckfox-Pico/L ... -c-program
Re: Writing an app using buildroot
Posted: 2024-01-30 2:02
by Eng38
Robbal wrote: ↑2024-01-29 14:55
Thank you for this . How would you put this in a CMakeLists.txt file. I want to use curl with the RKNN model tutorial
Add the following content to rknpu2/examples/RV1106_RV1103/rknn_yolov5_demo/CMakeLists.txt:
Code: Select all
#Set header file search path
include_directories(/home/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include)
#Set library file search path
link_directories(/home/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/lib)
#Explicitly specify the linked library
target_link_libraries(rknn_yolov5_demo curl crypto ssl z)
Re: Writing an app using buildroot
Posted: 2024-01-30 3:37
by torchris4
Thanks! Fixing the PATH up worked! There's a lot of steps to work through!
Re: Writing an app using buildroot
Posted: 2024-01-30 11:46
by Robbal
Thanks
I get this error still. How did you guys include the curl. I have added it in my buildroot and can see curl libary in the include directory.
Code: Select all
RV1106_RV1103/rknn_yolov5_demo/src/main.cc:32:10: fatal error: curl/curl.h: No such file or directory
#include <curl/curl.h>
My Bad.. my path was wrong. I get this now
Code: Select all
make_minimum_required(VERSION 3.4.1)
project(rknn_yolov5_demo)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined")
# install target and libraries
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install/rknn_yolov5_demo_${CMAKE_SYSTEM_NAME})
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# rknn api
set(RKNN_API_PATH ${CMAKE_SOURCE_DIR}/../../../runtime/RV1106/${CMAKE_SYSTEM_NAME}/librknn_api)
set(RKNN_RT_LIB ${RKNN_API_PATH}/armhf/librknnmrt.so)
include_directories(${RKNN_API_PATH}/include)
include_directories(${CMAKE_SOURCE_DIR}/../../3rdparty)
# rknn_yolov5_demo
include_directories(${CMAKE_SOURCE_DIR}/include)
add_executable(rknn_yolov5_demo
src/main.cc
src/postprocess.cc
)
#Set header file search path
include_directories(/home/Projects/luckfox/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include)
#Set library file search path
link_directories(/home/Projects/luckfox/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/lib)
target_link_libraries(rknn_yolov5_demo curl
${RKNN_RT_LIB}
)
# install target and libraries
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install/rknn_yolov5_demo_${CMAKE_SYSTEM_NAME})
install(TARGETS rknn_yolov5_demo DESTINATION ./)
install(PROGRAMS ${RKNN_RT_LIB} DESTINATION lib)
install(DIRECTORY model DESTINATION ./)