Setting up a Linux Toolchain
Choosing the C-Library
The C-Library is an interface layer between applications and the system kernel implemented in the C-Language, which conforms to the POSIX standards. It can be looked at as an abstraction layer for programms running on a system, even if the programm itself is not implemented in C. Python, Java and many more languages eventually call functions from the C-Library, which makes it an essential part of the toolchain.
There are multible C-Libraries to choose from:
glibc
musl libc
uClibc-ng
eglibc
The GNU standard C-Library is glibc. Depending on your system specs, you might choose a different C-Library. If you are very limited on RAM and Disk space, musl libc may be your go-to, since it uses very little resources. uClibc-ng only if you are using uClinux and otherwise glibc.
Installation
Requirements
For the installation of the toolchain you first need some tools:
sudo apt-get install autoconf automake bison bzip2 cmake flex g++ gawk gcc \
gettext git gperf help2man libncurses5-dev libstdc++6 libtool \
libtool-bin make patch python3-dev rsync texinfo unzip wget xz-utils
Building a toolchain
In this example of a toolchain build process, we are using crosstool-NG. Start with installing the dependencies mentioned above.
Starting off, you want to clone the crosstool-ng git repository:
git clone https://github.com/crosstool-ng/crosstool-ng.git
After the download has finished, install the package from source. In this example, we are using version 1.24.0:
cd crosstool-ng
git checkout crosstool-ng-1.24.0
./bootstrap
./configure --prefix=${PWD}
make
make install
The configure script with the “–prefix” option defines the build path for the installation. In this case, we install it into the current working directory, which is the git repository we just cloned.
Under “bin/”, there are the just built binaries. To start the crosstool, run
bin/t-ng
The following section, describes the toolchain build for the beaglebone black board:
At first, we select a a target configuration:
bin/ct-ng arm-cortex_a8-linux-gnueabi
Other samples can be listed with
bin/ct-ng list-samples
After all this, every config specific detail can be customized by using the menuconfig:
bin/ct-ng menuconfig
For the Beaglebone Black we change the following settings:
In Paths and misc options, disable Render the toolchain read-only (
CT_PREFIX_DIR_RO
).In Target options | Floating point, select hardware (FPU) (
CT_ARCH_FLOAT_HW
).In Target options, enter neon for Use specific FPU.
Now we can use crosstool-ng to build the environment we just specified:
bin/ct-ng build
source: Mastering Embedded Linux Programming - Third Edition By Frank Vasquez, Chris Simmonds