Categories
Embedded

In-place OE/Bitbake Kernel Modifications for BeagleBoard

How to reconfigure and rebuild the kernel in the OpenEmbedded environment using bitbake.

As mentioned in a previous post, if you follow the recommendations for setting up and building OE,  the bitbake process cleans up after itself and you can not make in-place modifications to the kernel source.  Granted it is preferable to setup a local overlay in which to do all your work, but it you just want to make a quick change and test it, this process will save you a little time.

After setting up the OE environment (and building everything once to make sure your environment is configured correctly, see Building OpenEmbedded for BeagleBoard and Building Angstrom…) do the following:

$ cd ${OETREE}/build
$ bitbake -c clean linux-omap-2.6.28
$ bitbake -f -c compile linux-omap-2.6.28

The above commands will clean and build a fresh copy of the kernel, leaving the sources in place for future use; you can find them here:

$ cd ${OETREE}/angstrom-dev/work/beagleboard-angstrom-linux-gnueabi/linux-omap-2.6.28-r18/git
$ ls
COPYING        Makefile        arch      fs       lib            samples   virt
CREDITS        Module.symvers  block     include  mm             scripts   vmlinux
Documentation  README          crypto    init     modules.order  security  vmlinux.o
Kbuild         REPORTING-BUGS  drivers   ipc      net            sound
MAINTAINERS    System.map      firmware  kernel   patches        usr

From here you can reconfigure the kernel. After ensuring ncurses was installed:

$ yum install ncurses-devel

I was able to

$ make menuconfig

and make my modifications. After saving my configuration changes to update the .config file, it was a simple matter of rerunning the forced compile step from above to rebuild the kernel:

$ bitbake -f -c compile linux-omap-2.6.28
$ bitbake -f -c deploy linux-omap-2.6.28

If your kernel configuration modifications happen to result in the generation of any loadable modules, then you will wind up with another file in the deployment images folder:

$ cd ${OETREE}/angstrom-dev/deploy/glibc/images/beagleboard
$ ls mod*
modules-2.6.28-r18-beagleboard.tgz

This file will need to be copied to your SD card and extracted in-place after you’ve extracted the rootfs to the SD card. I use the following script (~/bin/mvrootfs) to accomplish this:

#!/bin/bash
if [ "$(id -u)" != "0" ]; then
  echo "This script must be run as root" 1>&2
  exit -1
fi
if [ "${#}" != "1" ]; then
  echo "usage: $0 sd[x]"
  exit -2
fi 

source /home/cmma/oe/source-me.txt

DV=/dev/${1}2
ROOTFS=cmma-ptrp-image-beagleboard.tar.bz2
MODULES=modules-2.6.28-r18-beagleboard.tgz
DEST=/media/LABEL2
DEPLOY=${OETREE}/angstrom-dev/deploy/glibc/images/beagleboard

/bin/cp -f ${DEPLOY}/${ROOTFS} ${DEST}
/bin/cp -f ${DEPLOY}/${MODULES} ${DEST}

cd ${DEST}
/bin/tar -jxvf ${ROOTFS} && rm -f ${ROOTFS}
/bin/tar -xvzf ${MODULES} && rm -f ${MODULES} 

cd
/bin/sync
/bin/umount /dev/${1}?

Where the name of my image is cmma-ptrp-image, OETREE=/home/cmma/oe and I am using an SD card configured according to these instructions. If my SD card mounts on /dev/sdb, I invoke the script as such:

$ sudo ~/bin/mvrootfs sdb

Then simply put the SD card back in the BeagleBoard and power up.

4 replies on “In-place OE/Bitbake Kernel Modifications for BeagleBoard”

nice post.. That was exactly that piece of information that I was looking for.. . (kernel is compiling while I write this…)

Comments are closed.