added full crosstool-ng instructions
This commit is contained in:
parent
702213b831
commit
fd51bae66c
@ -164,7 +164,7 @@ endif()
|
|||||||
|
|
||||||
string(CONCAT POST_BUILD_COMMENT
|
string(CONCAT POST_BUILD_COMMENT
|
||||||
"Build directory: ${CMAKE_BINARY_DIR}\n"
|
"Build directory: ${CMAKE_BINARY_DIR}\n"
|
||||||
"Target OSAL: ${OS_FSFW}\n"
|
"Target OSAL: ${FSFW_OSAL}\n"
|
||||||
"Target Build Type: ${CMAKE_BUILD_TYPE}\n"
|
"Target Build Type: ${CMAKE_BUILD_TYPE}\n"
|
||||||
"${TARGET_STRING}"
|
"${TARGET_STRING}"
|
||||||
)
|
)
|
||||||
|
@ -33,6 +33,15 @@ else()
|
|||||||
)
|
)
|
||||||
endif()
|
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}")
|
message(STATUS "Using sysroot path: ${SYSROOT_PATH}")
|
||||||
|
|
||||||
set(CROSS_COMPILE_CC "${CROSS_COMPILE}-gcc")
|
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.
|
# List of library dirs where LD has to look. Pass them directly through gcc.
|
||||||
# LD_LIBRARY_PATH is not evaluated by arm-*-ld
|
# LD_LIBRARY_PATH is not evaluated by arm-*-ld
|
||||||
set(LIB_DIRS
|
set(LIB_DIRS
|
||||||
"${SYSROOT_PATH}/lib/${CROSS_COMPILE}"
|
"${SYSROOT_PATH}/lib/${MUTLIARCH_FOLDER_NAME}"
|
||||||
"${SYSROOT_PATH}/usr/local/lib"
|
"${SYSROOT_PATH}/usr/local/lib"
|
||||||
"${SYSROOT_PATH}/usr/lib/${CROSS_COMPILE}"
|
"${SYSROOT_PATH}/usr/lib/${MUTLIARCH_FOLDER_NAME}"
|
||||||
"${SYSROOT_PATH}/usr/lib"
|
"${SYSROOT_PATH}/usr/lib"
|
||||||
)
|
)
|
||||||
# You can additionally check the linker paths if you add the
|
# 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}")
|
set(COMMON_FLAGS "${COMMON_FLAGS} -L${LIB} -Wl,-rpath-link,${LIB}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(CMAKE_PREFIX_PATH
|
|
||||||
"${CMAKE_PREFIX_PATH}"
|
|
||||||
"${SYSROOT_PATH}/usr/lib/${CROSS_COMPILE}"
|
|
||||||
)
|
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS
|
set(CMAKE_C_FLAGS
|
||||||
"-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard ${COMMON_FLAGS}"
|
"-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard ${COMMON_FLAGS}"
|
||||||
CACHE STRING "Flags for Beagle Bone Black"
|
CACHE STRING "Flags for Beagle Bone Black"
|
||||||
|
@ -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
|
If any custom libraries are used which rely on symlinks, it might be necessary to copy them
|
||||||
or create them manually as well.
|
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
|
If you want to cross-compile the toolchain for the Raspberry Pi, you can do so
|
||||||
with the `crosstool-ng` tool.
|
with the `crosstool-ng` tool.
|
||||||
|
|
||||||
Alternatively, you can also download a cross-compile toolchain built with
|
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.
|
inside the `x-tools` folder.
|
||||||
|
|
||||||
## Ubuntu
|
## Ubuntu
|
||||||
@ -474,8 +475,8 @@ inside the `x-tools` folder.
|
|||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also install `ct-ng` locally by supplying `--prefix=<installPath>` to the `configure`
|
You can also install `ct-ng` locally by replacing `--enable-local` with `--prefix=<installPath>`
|
||||||
command. You don't need `sudo` for the `make install` command if you do this
|
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
|
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`.
|
It is recommended to go to `Paths and misc options` and disable `Paths and misc options`.
|
||||||
Remember to save the configuration.
|
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
|
```sh
|
||||||
./ct-ng build
|
./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
|
This takes 20-30 minutes. You can find the toolchain in the `~/x-tools` folder after building
|
||||||
has finished
|
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");
|
||||||
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user