crosstool a valuable tool for embedded development
Hi all,
So, this time I’m here to talk about the crosstool, a must have tool for anyone starting out to develop applications for embedded targets. The tool can automatically configure and build the complete cross development tool chain for most of the embedded platforms. This time I was trying to build the compiler for sh4 target. The procedure was simple:
- Get the crosstool from the website (I had used 0.43)
- Modify the variables TARBALLS_DIR, RESULT_TOP,GCC_LANGUAGES in demo-sh4.sh according to where you want the package source code to be downloaded, the place where the resulting binaries to be installed and the list of languages the GCC need to build respectively.
- If you don’t have internet(or if ur internet has any firewall blocking FTP), you may download the packages(*.tar.bz2) manually into TARBALLS_DIR directory. By inspecting the demo-sh4.sh file, I understood that the it is using gcc-4.1.0-glibc-2.3.6.dat to get the details of the package versions to obtain.
- Run demo-sh4.dat.
Its very nice to observe how the crosstool has cleanly built the cross compilation tool chain. The problem that I faced next was with the compilation of linux kernel(crosstool-0.43 uses linux-2.6.15.4) that was lacking adequate support for sh4 arch. Then I manually downloaded linux-2.6.19(the latest as of today) and compiled with the newly built development tools. The steps I had followed are the following:
- Download and untar linux-2.6.19 kernel source package and cd into it.
- Run make ARCH=sh CROSS_COMPILE=/opt/crosstool/gcc-4.1.0-glibc-2.3.6/sh4-unknown-linux-gnu/bin/sh4-unknown-linux-gnu- xconfig
- Do the necessary configuration for the kernel. By running make ARCH=sh CROSS_COMPILE=/opt/crosstool/gcc-4.1.0-glibc-2.3.6/sh4-unknown-linux-gnu/bin/sh4-unknown-linux-gnu- help you may get the list of default configurations available for various Architecture specific targets (sh). For example, the one that I used was systemh_defconfig. Running make ARCH=sh CROSS_COMPILE=/opt/crosstool/gcc-4.1.0-glibc-2.3.6/sh4-unknown-linux-gnu/bin/sh4-unknown-linux-gnu- systemh_defconfig you can generate the configuration default for the systemh board following which you may do manual configuration using the menuconfig, xconfig, gconfig, etc.
- Just run make.
Voila
Our kernel and the modules are ready to be deployed on the target board. So, now that the kernel compilation was successful, its time to do it the crosstool way. For making crosstool to use this kernel version(mind you, the only use of linux kernel for crosstool is to install the kernel headers for userland apps), I modified the LINUX_DIR variable in gcc-4.1.0-glibc-2.3.6.dat to linux-2.6.19 and copied linux-2.6.19.tar.bz2 to the TARBALLS_DIR. That’s it. Running demo-sh4.sh again is the only step required to make the tool chain use our new kernel headers.
Note that, by default the crosstool extracts the packages and build them relative to the current directory where we run the demo-sh4.sh. Inorder to have a different build directory we may modify the variable BUILD_DIR inside the all.sh script file.

Leave a Reply