Welcome back to another installment of my adventures in Embedded Linux and everything Beagleboard. I'm going to walk through getting the compiler up and running and building the Linux Kernel.
In most Embedded Linux development, a developer will develop Software for his/her board on their host machine i.e Desktop computer, Laptop or 30x PS3 - Mega Server. They will write the code and then compile and build the code using a cross-platform toolchain or compiler. This will then allow the code now in an executable format to run on the target board (in our case the Beagleboard) .
The compiler used with the Beagleboard is the one from Codesourcery. I downloaded the Linux tar version, I initially tried the installer version but it didn't work for me - no idea why. Once the tar file is downloaded; unzip to a directory (I used "/opt"). To test that is is working do this:
You should get a no input file response in your terminal. The path to your compiler can be saved in your environment setting (/.profile) for ease of use. Our compiler is up and running. And now to compile something cool!
Building the Kernel with Compiler
Its now time to get down to the alpha male of compiling... Compiling and building the Kernel. This is not as daunting as it initially feels like. Download the Kernel for the OMAP:
Now these three basic/magic commands will get the compiler to build the Kernel according to the default beagle board setup:
make CROSS_COMPILE=/opt/arm-2007q3/bin/arm-none-linux-gnueabi- distclean
make CROSS_COMPILE=/opt/arm-2007q3/bin/arm-none-linux-gnueabi- omap3_beagle_defconfig
make CROSS_COMPILE=/opt/arm-2007q3/bin/arm-none-linux-gnueabi- uImage
The first line will return the source code to its original unconfigured state, removing all compiled code. The second line unsurprisingly sets the configurations for the Beagleboard. The final line is the money maker as it compiles the code creating a architecture-specific ELF file of the whole Linux Kernel, this file can be downloaded to the board and will be loaded by the bootloader. This file is our Linux Kernel and root filesystem.
The Kernel build system uses a config file, ".config", in the base directory of your kernel source code. This file, parsed through the Kernel build system, will build the Kernel according to the configuration file. How the Linux Build system works is quite complex - will have to be for another blog... Maybe...
Ok now suppose you want to make some changes to the default configuration to customise the Kernel for your required needs, you can do this by typing:
make CROSS_COMPILE=/opt/arm-2007q3/bin/arm-none-linux-gnueabi menuconfig
If menuconfig won't load, install ncurses-dev (sudo apt-get install ncurses-dev).
This loads up a program to make changes and generate your own config file. There are a truckload of options and it requires some research before changing them, however if you make a change and then the system doesn't run, the above 3 magic commands will get the system back to default and up and running, as long as it was running beforehand of course.
*Warning: changing some of the CPU specific configurations could damage the CPU - so research any changes you want to make.
Once your new image is built, all you have to do is put it on the SD card and load it up - the Beagle Wiki will help you with that.
Over the next couple weeks I will be looking at using OpenEmbedded and Angstrom, it looks really cool and very powerful. Hopefully report back when I have learned something interesting.