diff --git a/CMakeLists.txt b/CMakeLists.txt index db2d5d5..71b2aba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,7 +164,7 @@ endif() string(CONCAT POST_BUILD_COMMENT "Build directory: ${CMAKE_BINARY_DIR}\n" - "Target OSAL: ${OS_FSFW}\n" + "Target OSAL: ${FSFW_OSAL}\n" "Target Build Type: ${CMAKE_BUILD_TYPE}\n" "${TARGET_STRING}" ) diff --git a/cmake/BBBCrossCompileConfig.cmake b/cmake/BBBCrossCompileConfig.cmake index 88a6fff..fcbab88 100644 --- a/cmake/BBBCrossCompileConfig.cmake +++ b/cmake/BBBCrossCompileConfig.cmake @@ -33,6 +33,15 @@ else() ) endif() +# Generally, the debian roots will be a multiarch rootfs where some libraries are put +# into a folder named "arm-linux-gnueabihf". The user can override the folder name if this is +# not the case +if(NOT ENV{MULTIARCH_FOLDER_NAME}) + set(MULTIARCH_FOLDER_NAME "arm-linux-gnueabihf") +else() + set(MUTLIARCH_FOLDER_NAME $ENV{MULTIARCH_FOLDER_NAME}) +endif() + message(STATUS "Using sysroot path: ${SYSROOT_PATH}") set(CROSS_COMPILE_CC "${CROSS_COMPILE}-gcc") @@ -62,9 +71,9 @@ set(CMAKE_SYSTEM_PROCESSOR "arm") # List of library dirs where LD has to look. Pass them directly through gcc. # LD_LIBRARY_PATH is not evaluated by arm-*-ld set(LIB_DIRS - "${SYSROOT_PATH}/lib/${CROSS_COMPILE}" + "${SYSROOT_PATH}/lib/${MUTLIARCH_FOLDER_NAME}" "${SYSROOT_PATH}/usr/local/lib" - "${SYSROOT_PATH}/usr/lib/${CROSS_COMPILE}" + "${SYSROOT_PATH}/usr/lib/${MUTLIARCH_FOLDER_NAME}" "${SYSROOT_PATH}/usr/lib" ) # You can additionally check the linker paths if you add the @@ -74,11 +83,6 @@ foreach(LIB ${LIB_DIRS}) set(COMMON_FLAGS "${COMMON_FLAGS} -L${LIB} -Wl,-rpath-link,${LIB}") endforeach() -set(CMAKE_PREFIX_PATH - "${CMAKE_PREFIX_PATH}" - "${SYSROOT_PATH}/usr/lib/${CROSS_COMPILE}" -) - set(CMAKE_C_FLAGS "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard ${COMMON_FLAGS}" CACHE STRING "Flags for Beagle Bone Black" diff --git a/doc/README-rpi.md b/doc/README-rpi.md index 6316bdb..7afe8d3 100644 --- a/doc/README-rpi.md +++ b/doc/README-rpi.md @@ -440,13 +440,14 @@ scp @:/lib/arm-linux-gnueabihf/libc.so.6 /li If any custom libraries are used which rely on symlinks, it might be necessary to copy them or create them manually as well. -# Building a cross-compile toolchain with crosstool-ng +# Building a cross-compile toolchain with `crosstool-ng` If you want to cross-compile the toolchain for the Raspberry Pi, you can do so with the `crosstool-ng` tool. Alternatively, you can also download a cross-compile toolchain built with -crosstool-ng for the Raspberry Pi 3 [from here](https://www.dropbox.com/sh/zjaex4wlv5kcm6q/AAABBFfmZSRZ7GE7ok-7vTE6a?dl=0) +crosstool-ng for the Raspberry Pi 3 and the Raspbery Pi 4 +[from here](https://www.dropbox.com/sh/zjaex4wlv5kcm6q/AAABBFfmZSRZ7GE7ok-7vTE6a?dl=0) inside the `x-tools` folder. ## Ubuntu @@ -474,8 +475,8 @@ inside the `x-tools` folder. sudo make install ``` - You can also install `ct-ng` locally by supplying `--prefix=` to the `configure` - command. You don't need `sudo` for the `make install` command if you do this + You can also install `ct-ng` locally by replacing `--enable-local` with `--prefix=` + to the `configure` command. You don't need `sudo` for the `make install` command if you do this. 4. You can get a list of architectures by running @@ -506,7 +507,20 @@ inside the `x-tools` folder. It is recommended to go to `Paths and misc options` and disable `Paths and misc options`. Remember to save the configuration. -5. Finally, after finishing the configuration you can build the toolchain with +5. The correct configuration files for the Raspberry Pi 3 and Raspberry Pi 4 are provided here + are were set up according to [these instructions](https://medium.com/@stonepreston/how-to-cross-compile-a-cmake-c-application-for-the-raspberry-pi-4-on-ubuntu-20-04-bac6735d36df). + You can download those files from [here](https://www.dropbox.com/sh/ok554i453phuqec/AACcv-fxpIXi3Nh1z8UWu4Sea?dl=0). + + Put the `patches` folder, the `.config` folder and the `env.sh` in the same directory where + you run `ct-ng`. After that, you can check the configuration with `./ct-ng menuconfig`. + + Set up the multiarch environment for debian by running + + ```sh + . env.sh + ``` + +6. Finally, after finishing the configuration you can build the toolchain with ```sh ./ct-ng build @@ -514,3 +528,17 @@ inside the `x-tools` folder. This takes 20-30 minutes. You can find the toolchain in the `~/x-tools` folder after building has finished + +7. You can check whether the toolchain was configured correctly for multiarch by running the + following command + + ```sh + cd ~/x-tools/armv8-rpi3-linux-gnueabihf/armv8-rpi3-linux-gnueabihf/bin + ./ld --verbose | grep -i "search" + ``` + + The output should include + + ```sh + SEARCH_DIR("=/lib/arm-linux-gnueabihf"); SEARCH_DIR("=/usr/lib/arm-linux-gnueabihf"); + ```