Linux kernel development

From BlueWiki

Jump to: navigation, search

1 Kernel configuration in OpenEmbedded

You can configure the Linux kernel using OpenEmbedded and the devshell:

robert@bltLinux:~/oe/btmxc$ bitbake -c devshell [machine]-kernel
robert@bltLinux:~/.../git$ cp arch/arm/configs/[defaultconfig] .config
robert@bltLinux:~/.../git$ make menuconfig

If you want to know what the default config file for your kernel is, please have a look at your kernel recipe, e.g.

harald@WS-HP4600-35:~/oe/btmxc$ grep "\.config" ../openembedded/recipes/linux/sbc-imx51-kernel_git.bb
    cp arch/arm/configs/imx51_i.fly_defconfig .config || die "No default configuration for ${MACHINE} available."
harald@WS-HP4600-35:~/imx/oe51/btmxc$

In the above example, the default config is imx51_i.fly_defconfig.

If your new configuration works as expected, don't forget to store it back to your git kernel-source tree (btmxc-linux) and check it in!

2 Kernel development (OE)

If you modify the kernel sources in btmxc-linux and want to build a new image with OpenEmbedded, you have to make the following steps:

  • Commit the changes to your Linux kernel (Note that the .config file isn't tracked by GIT, please copy it to arch/arm/configs/ as explained above)
git commit -a
  • Clean the kernel and image packages
bitbake -c clean sbc-imx51-kernel sbc-imx51-console-image
  • Recompile the image, e.g.
bitbake sbc-imx51-console-image
  • For NFS, unpack the rootfs again:
scripts/rootfs_unpack.sh

or

prepare_nfs_zImage.sh

3 Kernel development without OpenEmbedded

During kernel development, i.e. if you have the need of many edit-compile-run cycles, we recommend to circumvent OpenEmbedded. Building the Linux kernel directly (using the OpenEmbedded tool chain) is easy, and replacing just the kernel and the kernel modules of your target software is many times faster than recompiling kernel and image with OpenEmbedded each time.

Steps (we assume that you load your kernel via TFTP and boot the rootfs via NFS):

  • Go to oe/btmxc-linux/
  • Execute a little script that sets up the necessary environment:
. set_cross_envs
  • Copy the default configuration file to .config
cp arch/arm/configs/[configfile] .config
  • If you want to change the kernel configuration
make menuconfig
  • Compile the kernel
make
  • Install the modules to the CWD
make modules_install
  • Copy the kernel to /tftpboot
cp arch/arm/boot/zImage /tftpboot
  • NOW SHUT DOWN YOUR TARGET, it should not access NFS anymore.
  • Delete the old modules
sudo rm -rf ../btmxc/tmp/deploy/glibc/images/[machine]/rootfs/lib/modules
  • Copy the new modules
sudo cp -rpP lib/modules ../btmxc/tmp/deploy/glibc/images/[machine]/rootfs/lib/
  • Now boot your target again
  • On the target, log in as root, and update the module dependencies (for command like modprobe to work correctly)
depmod -a
Personal tools