EBC Configuring the Kernel

From eLinux.org
Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder


In a previous exercises (EBC Cross-Compiling and EBC Installing Kernel Source) you learned how to get and compile the kernel. Here we'll look at configuring it.

Finding the kernel sources

First set up the environment and go to the kernel directory

host$ source ~/crossCompileEnv.sh  (set up in EBC Cross-Compiling)
host$ cd ~/BeagleBoard/bb-kernel/KERNEL

Getting kernel make help

Once there try some of the make commands. Help is a good place to start.

host$ make help | less
Cleaning targets:
  clean           - Remove most generated files but keep the config and
                    enough build support to build external modules
  mrproper        - Remove all generated files + config + various backup files
  distclean       - mrproper + remove editor backup and patch files

Configuration targets:
  config          - Update current config utilising a line-oriented program
  menuconfig      - Update current config utilising a menu based program
  xconfig         - Update current config utilising a QT based front-end
  gconfig         - Update current config utilising a GTK based front-end
...

This produces a list of common make targets.

Finding and installing support software

There are several ways to configure the kernel. make config will prompt you line-by-line for each of the settings, very tedious, not recommended. Try

host$ make menuconfig
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 *** 
 *** Install ncurses (ncurses-devel) and try again.
 *** 
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2

If you get the error above, you need to install the ncurses library. Here are notes on how to discover what to install and installing it.

Configuring the kernel

Try the various interfaces for configuring the kernel.

host$ make menuconfig
host$ make xconfig
host$ make gconfig

I had to run the following to get these to work.

host$ sudo apt-get install libncurses5-dev
host$ sudo apt-get install qt4-dev-tools
host$ sudo apt-get install libglade2-dev

Making and Installing the kernel

Once you have the kernel configured it's easy to make and install it on the bone.

First set the version name.

host$ cd bb-kernel
host$ vi version.sh

Look for the line starting with BUILD and assign it to something unique (such as your name)

BUILD=yoder1

Quit vi and rebuild.

host$ tools/rebuild.sh

rebuild.sh sets up some things and the does a make on the kernel. It handles things like using the right cross compiler and the right number of cores. You'll be given a chance to configure, you can exit without saving if you don't want to change anything.

After a while (depending on the number of cores) you will see.

 CHK     include/generated/uapi/linux/version.h
 CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
 CALL    scripts/checksyscalls.sh
...
 LD [M]  sound/usb/caiaq/snd-usb-caiaq.ko
 LD [M]  sound/usb/misc/snd-ua101.ko
 LD [M]  sound/usb/snd-usb-audio.ko
 LD [M]  sound/usb/snd-usbmidi-lib.ko

Now you are ready to install. Have your Bone running and on the network. On your host run:

host$ cd bb-kernel/tools
host$ ln -s path to exercises/kernel/may_install_kernel.sh .
host$ cd ..

This will link a file from the git repository to a file of the same name in the tools directory. Edit may_install_kernel.sh and change BONE to the address of your beagle. Then run from bb-kernel

host$ tools/may_install_kernel.sh
Mounting sshfs
-----------------------------
sshfs mounted
Installing 3.8.13-xenomai to sshfs
‘/home/yoder/BeagleBoard/bb-kernel/deploy/3.8.13-xenomai.zImage’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/boot/vmlinuz-3.8.13-xenomai’
Installing 3.8.13-xenomai-dtbs.tar.gz to sshfs
info: /boot/uEnv.txt: # uname_r=3.14.17-bone8
uname_r=3.8.13-xenomai
Installing 3.8.13-xenomai-modules.tar.gz to sshfs
tar: lib/modules/3.8.13-xenomai/build: Cannot utime: No such file or directory
tar: lib/modules/3.8.13-xenomai/source: Cannot utime: No such file or directory
tar: Exiting with failure status due to previous errors
‘/home/yoder/BeagleBoard/bb-kernel/deploy/config-3.8.13-xenomai’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/boot/config-3.8.13-xenomai’
info: [3.8.13-xenomai] now installed...

This copies several files to your Bone. Make sure that the date and time on your Bone are set correctly, otherwise the Bone may ignore the proper files (plus you'll get a bunch of garbage output telling you that the files were made in the future). This uncompresses and installs the modules and firmware. You are now ready to reboot.

bone$ reboot

If you Bone boots up and you can reconnect to it, you can verify that you are running the new kernel by running:

bone$ uname -a

Recovering

If your Beagle fails to boot, follow the EBC_Exercise_22_Recovering instructions to recover.




thumb‎ Embedded Linux Class by Mark A. Yoder