I can not count on one hand the number of days I spent trying to compile a new Linux kernel for BeagleBone. This was back in April 2012 when userspace SPI was not enabled in the kernel by default. I recently had to recompile a new kernel in order to enable SPI 2.1 for the Replicape and I documented the steps. Hopefully someone will save some time and agony by reading this.
Working setup for compiling a kernel using Ångström
Ok, first the Angstrom environment must be set up. Just follow the instructions on Building Ångström.
For Beaglebone this becomes:
git clone git://github.com/Angstrom-distribution/setup-scripts.git cd setup-scripts MACHINE=beaglebone ./oebb.sh config beaglebone MACHINE=beaglebone ./oebb.sh update MACHINE=beaglebone ./oebb.sh bitbake virtual/kernel
Later that night… No really, it takes while, took me two hours on my slightly outdated Thinkstation.
You can remove the “MACHINE=beaglebone ./oebb.sh” part now, the instructions are displayed.
Once it’s done you should now have a Linux image (uImage) in:
You will also have an image in:
More on that later..
Make sure it is working
It’s good to check that this image is actually working as expected before making any changes by copying it to the /boot/ directory of your BeagleBone, linking to it and rebooting BeagleBone. Here is a short Make-script i use for deploying a new image. This script is very specific to my setup, using the IP my BB has and stuff, but it serves the purpose of showing what is going on. This Makefile is located in my setup-scripts folder:
IP=10.24.2.129 UIMAGE=uImage IMG_PATH=build/tmp-angstrom_v2012_05-eglibc/deploy/images/beaglebone/ VERSION=3.2.34 image: scp $(IMG_PATH)$(UIMAGE) root@$(IP):/boot/uImage-$(VERSION) ssh root@$(IP) 'cd /boot/; rm uImage; ln -s uImage-$(VERSION) uImage'
So on calling “make image”, the image is uploaded to BB, and linked in as the working kernel image. In my case, the new kernel image was version 3.2.34 but the old version of the kernel was 3.2.18.
Installing the modules
If the newly created kernel has a different version number than you previously had, you also need to install the modules for the new kernel. They are zipped and in the same folder as the image. They must be uploaded to /lib/modules/ folder.
scp -r build/tmp-angstrom_v2012_05-eglibc/deploy/images/beaglebone/lib/modules/3.2.34 firstname.lastname@example.org:/lib/modules/
Again, the Make-script is specific to my setup, so do not use it without changing paths etc. to match your setup.
Switch your IP for your BeagleBone’s obviously.
Now, on reboot you should see the
.---O---. | | .-. o o | | |-----.-----.-----.| | .----..-----.-----. | | | __ | ---'| '--.| .-'| | | | | | | | |--- || --'| | | ' | | | | '---'---'--'--'--. |-----''----''--' '-----'-'-'-' -' | '---' The Angstrom Distribution beaglebone ttyO0 Angstrom v2012.05 - Kernel 3.2.34
as you boot up. That means the new kernel is installed, but the modules are not enabled for this kernel version. If you do an”lsmod”, you see that no modules are loaded:
root@beaglebone:~# lsmod Module Size Used by root@beaglebone:~#
To load the modules call:
root@beaglebone:~# depmod -a
and reboot the board again. The modules should now be loaded.
Making changes to the kernel and testing
Now that you have verified that everything is working as expected with the new kernel, you can start making changes. I recommend following the SlimLogic method, but there is one thing I never got to work. He says to use the command
bitbake virtual/kernel -c compile -f
to compile new changes and that is fine, that works for me (-f is for “force”), but to update the image he uses the command:
bitbake virtual/kernel -c deploy
I never got “deploy” to work. It is supposed to update the uImage in the folder named:
It never did (even with the -f option) and I spent hours googling for it. Finally I found out that the uImage is also located in the arch/arm/boot folder of the Linux kernel. So in your make-script, just change the img_path:
IP=10.24.2.129 UIMAGE=uImage IMG_PATH=build/tmp-angstrom_v2012_05-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-ti33x-psp-3.2.34-r18a+gitr720e07b4c1f687b61b147b31c698cb6816d72f01/git/arch/arm/boot/ VERSION=3.2.34 image: scp $(IMG_PATH)$(UIMAGE) root@$(IP):/boot/uImage-$(VERSION) ssh root@$(IP) 'cd /boot/; rm uImage; ln -s uImage-$(VERSION) uImage'
Happy kernel coding : )
BTW, the new kernel enables pin-muxing via EEPROM, a nice feature. I don’t know what version kernel you crazy kids are running these days, but my previous version (3.2.18 did not do this I think). Of course if you just want the newest stable version of the kernel for Angstrom, you culd always use the built in package manager to upgrade..
If you link to a kernel that is not working and you get a kernel panic, you might “brick” your BeagleBone. If that happens, just remove the SD-card, place it in an SD-card reader and access it though your computer. Once it is mounted, you can cd to it from a shell, but you need to be root to be able to change anything.
cd /mount/Angstrom/boot/ rm uImage ln -s uImage-3.2.18 uImage
Once that is done, put the SD-card back in your BeagleBone and start her up. You should be back to scratch, but no harm done.