added full crosstool-ng instructions

This commit is contained in:
Robin Müller 2021-07-15 01:18:31 +02:00
parent 702213b831
commit fd51bae66c
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 45 additions and 13 deletions

View File

@ -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}"
)

View File

@ -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"

View File

@ -440,13 +440,14 @@ scp <user_name>@<ip-address>:/lib/arm-linux-gnueabihf/libc.so.6 <rootfs_path>/li
If any custom libraries are used which rely on symlinks, it might be necessary to copy them
or create them manually as well.
# <a id="ctng"></a> Building a cross-compile toolchain with crosstool-ng
# <a id="ctng"></a> 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=<installPath>` 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=<installPath>`
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");
```