top of page
Writer's pictureAkshay Bhide

How to integrate External Toolchain (generated in Part-1) inside the target Linux image in BuildRoot — Part 3

Updated: Nov 12


Buildroot_Part3

For some months, we at WhileOne Techsoft Pvt. Ltd. have been helping our customer setup a system to validate the performance of their SoC platform. In this context, we had to bring up an aarch64 Linux based target image to run on their proprietary hardware SoC platform.


Part -1 of this series explains how to build an external toolchain with BuildRoot.


Part -2 of this series explains how to build a target Linux image using an external toolchain (that we built in Part -1)


Part -3 of this series explains how to integrate the generated toolchain binaries in the target linux image that we are going to build with BuildRoot.


Use Case: The reason for integrating external toolchain binaries (especially in an embedded system) is required to run benchmarks on the target. The benchmark software requires a toolchain to be available on the target!


Integrating external toolchain

In the following steps we shall configure the Buildroot to use the External Toolchain tarball (refer Part -1) to build the Kernel, Rootfs images and copy the extracted tarball binaries to the target under directory /usr


Configuration steps

We have to modify the configuration and then rebuild using clean option. This will delete all output folders and files. So, its very important to move the tarball to some other location outside the ‘buildroot’ folder. If not yet done, please do this before proceeding ahead


1. Start by opening menuconfig


make menuconfig

We only modify a few options. Rest of the options will remain the same as was configured earlier.

Target Options and Build Options shall remain same. So no need to change them


2. Modify Toolchain Options:


a. Select option ‘External Toolchain’

b. Modify option of Toolchain origin to ‘Toolchain to be downloaded and installed’

c. Update URL to ‘file:///path/to/sdk-tarball’



Toolchain URL

d. Modify External Toolchain GCC version to ’11.x’

e. Modify External Toolchain kernel headers series to ‘5.4.x’(This was same configuration that we had kept for tarball earlier..)

f. Modify External Toolchain C library to ‘glibc/eglibc’

g. Disable ‘Toolchain has RPC support’ (Please disable if it was not selected earlier during tarball generation)

h. Enable support for C++ and Fortran(This was enabled earlier for tarball configuration)



Toolchain

a. Modify Init system from ‘None’ to ‘BusyBox’

b. Enable option ‘Use symlinks to /usr for /bin, /sbin and /lib

c. Modify default BusyBox shell from ‘None’ to ‘/bin/sh/’

d. Update the folder name (gcc-11.x) for option ‘Root filesystem overlay directories’. We haven’t created this folder yet! Just add the name.


ving binaries to /usr


System Configuration

4. Create a folder (gcc-11.x) in root location of ‘buildroot’


5. Extract the sdk tarball and copy contents to this folder


6. Inside folder gcc-11.x, create a folder named ‘usr’ and move the folders bin, lib and sbin to usr/

This step is very important because when BR2_ROOTFS_MERGED_USR (This flag corresponds to the option enabled in step 2 above) is enabled, then the overlay must not contain the /bin, /lib or /sbin directories, as Buildroot will create them as symbolic links to the relevant folders in /usr. In such a situation, should the overlay have any programs or libraries, they should be placed in /usr/bin, /usr/sbin and /usr/lib.

The same should also be followed for other folders inside gcc-11.x. Once this is completed, then we can proceed ahead. If the above changes are not done, then we will encounter an RSYNC error.

7. Now, save and exit from menuconfig


8. Build with new configuration settings


make clean all

9. The resulting images can be seen in the folder ‘output/images’


Build and verify

10. Finally, verify that the Target folder contains the Toolchain binaries in path ‘output/target/usr/bin’, ‘output/target/usr/lib’, ‘output/target/usr/sbin’. This means that the final Linux Image will be having these binaries integrated in it.



Verify target folder contains toolchains

11. The only way to verify is to boot the Linux image on your end and once booted and logged in, you need to ensure that you do not forget to set the LD_LIBRARY_PATH variable to point to the /usr/lib where the Toolchain libraries will be installed.



Successful toolchain-linux image inclusion


Conclusion:


Buildbot

  • We were able to successfully build an External Toolchain (generated as an SDK tarball)

[This concludes our final Part in the BuildRoot series]


A quote that has inspired me for a long time…

“Obstacles don’t have to stop you. If you run into a wall, don’t turn around and give up. Figure out how to climb it, go through it, or work around it.” — Michael Jordan

15 views0 comments

Recent Posts

See All

Yorumlar


bottom of page