Building uClibc |
The Emcraft Linux distribution provides the uClibc library prebuilt for the Cortex-M architecture. You can just link your applications with the provided library and never worry about having to build the library from scratch. In the installation tree, the library is available in the following directory relative to the top of the installation: -bash-3.2$ pwd In some situations however, our customers asks us how to rebuild the library. Typically, they want to do that in order to enable some additional functionality available from the library but not included in the prebuilt configuration. This application note explains how to build the uClibc library. First step is to activate the cross development environment on the host. This is done by running the ACTIVATE.sh script from the top of the installation tree: -bash-3.2$ pwd Go to the uClibc directory: -bash-3.2$ cd A2F/uclibc/ Copy the default configuration file to the working config that will be used by the build procedure: -bash-3.2$ cp dot_config_pthreads .config Note: Users of the Emcraft A2F-SOM please use dot_config_pthreads-no-ldrex. Edit the config file to provide the correct path to the header files. To do that, search for KRNL_HDR and replace it with ../root/usr/include/: -bash-3.2$ vi .config Proceed to update the library configuration file to your liking. The example below enables the RPC related build-time options in the configuration: ... Remember to save your edits when exiting the editor. Build the internal configuration file that will be used to by the library build procedure: -bash-3.2$ make -s ARCH_CFLAGS= 'CPU_CFLAGS=-mthumb -march=armv7 -mfix-cortex-m3-ldrd' oldconfig Build the updated library. Ignore the compiler warnings: -bash-3.2$ make ARCH_CFLAGS= 'CPU_CFLAGS=-mthumb -march=armv7 -mfix-cortex-m3-ldrd' -j2 -s Install the newly build library wherever you would like to install it. You can of course install it to the same directory where it is installed in the Emcraft distribution, as shown in the below command: -bash-3.2$ make ARCH_CFLAGS= 'CPU_CFLAGS=-mthumb -march=armv7 -mfix-cortex-m3-ldrd' -s PREFIX=$INSTALL_ROOT/A2F/root install If you would like to preserve the original library and install the updated library to some other directory, specify the target directory with PREFIX in the above command. Whenever you have installed the updated library, provide the correct path to it with the -L and -I compiler flags when building your application. For instance, for the installation command above, you need to specify the following when building your application: -bash-3.2$ arm-uclinuxeabi-gcc -o test test.c -mcpu=cortex-m3 -mthumb -I$INSTALL_ROOT/A2F/root/usr/include -L$INSTALL_ROOT/A2F/root/usr/lib |