How to Install the LTSI-3.10 Kernel on Raspberry Pi and MinnowBoard

549

I have installed the new official LTSI-3.10 release on Raspberry Piand MinnowBoard. The following describes the installation steps of a kernel image that I built by downloading the kernel source and applying the patch. The second tutorial in this series explains how to create an LTSI kernel package for easier management.

(1) Obtaining LTSI-3.10

To get started, download LTSI-RC1. Go to the LTSI Releases page to find the download URL. The official LTSI-3.10 release is based on 3.10.31. While you can also download in Git, I used the tarball format which I’m more familiar with. Unpack the tar file under a desired directory.

$ cd work/patch
$ tar xvzf ~/Download/patch-3.10.31-ltsi.gz

Installing on Raspbian on Raspberry Pi

Next, set up a kernel build environment for Raspberry Pi. You can use either a cross-build environment or a self-build one. I tested both. Setting up a self-build environment, however, requires patience. In the case of a self-build environment, you use ssh connection for setup. There is a lot of information available on the Internet about how to set up a kernel build environment, but here’s the process I used.

(a) Cross-build environment

I chose Ubuntu Desktop 12.04 (32-bit version) for setting up the build environment. Install the necessary package.

$ sudo apt-get install build-essential libncurses5-dev

Next, obtain a cross-compiler.

$ wget --no-check-certificate https://github.com/raspberrypi/tools/archive/master.tar.gz 

Unpack it under a desired directory. I chose /opt.

$ cd /opt
$ tar xvzf ~/Download/master.tar.gz

(b) Self-build environment

If you have Raspbian installed, you probably have the build environment set up already. At least it worked in my case. If you have trouble using the make command, install the necessary package as when setting up a (a) cross-build environment.

$ sudo apt-get install build-essential libncurses5-dev

(2) Obtain the kernel source

The Raspbian kernel source is made available on github.

$ wget --no-check-certificate https://github.com/raspberrypi/linux/archive/rpi-3.10.y.tar.gz

Unpack the file under the work directory.

$ cd ~/work
$ tar xvzf ~/Download/rpi-3.10.y.tar.gz
$ cd linux-rpi-3.10.y

Henceforth, I will work under the ~/work/linux-rpi-3.10.y directory. Install the LTSI patch.

$ cat ~/work/patch/* | patch -p1

Next, obtain the kernel configuration from the Raspbian on Raspberry Pi that is currently running. Here, I will use “raspberry” as the host name for Raspberry Pi.

Cross-build environment:

$ scp pi@raspberry:/proc/config.gz .
$ zcat config.gz > .config

Self-build environment:

$ cp /proc/config.gz .
$ zcat config.gz > .config

Use the

make oldconfig

command to update the kernel configuration. Due to the different kernel versions, you will be asked a question regarding the settings of the newly added configuration, but leave all the settings at default for now.

Cross-build environment:

$ make CROSS_COMPILE=~/tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- ARCH=arm oldconfig

Self-build environment:

$ make oldconfig

Next, use the make

menuconfig

command to set detailed configuration.

Cross-build environment:

$ make CROSS_COMPILE=~/tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- ARCH=arm menuconfig

Self-build environment:

$ make menuconfig

Now you are ready to start compiling a kernel. With a self-build environment, you will need to prepare a night batch.

Cross-build environment:

$ make CROSS_COMPILE=~/tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- ARCH=arm

Self-build environment:

$ nohup make 1>/tmp/log.txt 2>&1 &

When working in a self-build environment, you will be logged in remotely, so I used the nohup command so that the build will continue even after I log out.

Once you finish building the main body, compile the modules.

Cross-build environment: 

$ make CROSS_COMPILE=~/tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- ARCH=arm modules

Self-build environment:

$ make modules

Last, install the modules. When installing in a cross-build environment, do it the following way. First, store the modules in a temporary directory, and then remote copy from there.

Cross-build environment:

$ mkdir /tmp/rasp-mod
$ sudo make CROSS_COMPILE=~/tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- ARCH=arm \

INSTALL_MOD_PATH=/tmp/rasp-mod modules_install

$ sudo rm /tmp/rasp-mod/lib/modules/3.10.y/build
$ sudo rm /tmp/rasp-mod/lib/modules/3.10.y/source
$ scp -rp /tmp/rasp-mod/lib arch/arm/boot/zImage pi@raspberry:~/

Here, you log into Raspberry-pi and unpack the secure-copied files.

$ sudo cp -rp lib /
$ sudo cp /boot/kernel.img /boot/kernel.org
$ sudo cp -rp zImage /boot/kernel.img

Self-build environment:

$ sudo make modules_install
$ sudo cp /boot/kernel.img /boot/kernel.org
$ sudo cp arch/arm/boot/zImage /boot/kernel.img

This completes the setup process. Now reboot.

$ sudo reboot

Installing on Angstrom on MinnowBoard

Next, let’s look at LTSI on MinnowBoard. For this I only tested in a self-build environment. The steps are the same as with Raspberry Pi. The differences are that the kernel source was downloaded from the mainline kernel (http://www.kernel.org), and that the boot method has been changed to EFI.

(1) Obtaining LTSI-3.10

Refer to Raspberry Pi. Complete the steps up to unpacking the file under a desired directory.

$ cd work/patch
$ tar xvzf ~/Download/patch-3.10.31-ltsi.gz

Next, set up a kernel build environment for MinnowBoard. You can use either a cross-build environment or a self-build one. I tested in a self-build environment. In the case of a self-build environment, you use ssh connection for setup. The standard distribution of MinnowBoard is Angstrom built with the Yocto Project. You can find information on how to build a distribution on the MinnowBoard Wiki site, but it is not clear on how to build just the kernel. So here's the process I used on my system.

Setting up a build environment

If you have Angstrom installed, you probably have the build environment set up already. At least it worked in my case. If it happens that you have trouble using the make command, install the necessary package. 

$ sudo apt-get install build-essential libncurses5-dev

(2) Obtain the kernel source

Download the appropriate kernel from Kernel.org. I chose the official LTSI release version 3.10.31. Unpack the file under the work directory.

$ cd ~/work
$ tar xvzf ~/Download/linux-3.10.31.tgz

(3) Creating a Minnow patch

MinnowBoard’s GPIO/LED does not work with the mainline kernel alone, so you need to create a patch for this function. Check the original MinnowBoard kernel version. In my case, it was 3.8.13-yocto-standard. So you download the 3.8.13 kernel from Kernel.org. Next, use the package management command

opkg

on Angstrom to obtain the kernel source for MinnowBoard.

$ opkg install kernel-3.8.13-yocto-standard

Compare the contents of the two files.

$ diff -rNu linux-3.10.13 /usr/src/kernel > patch-minnow

In my case, the difference was great and also included irrelevant content, so I extracted the necessary portion as shown below.

$ mkdir ~/patch-m
$ cd ~/patch-m
$ csplit ~/patch-minnow /^diff/ {*}

This will split the patch results into a number of files.

Search only for the patch that relates to Minnow.

$ grep MINNOWBOARD *

Combine only the relevant patch files.

$ cat files found > ~/patch-minnow-result

Henceforth, I will work under the ~/work/linux-3.10.31 directory. Install the patch for MinnowBoard and the LTSI patch.

$ cat ~/patch-minnow-result | patch -p1
$ cat ~/work/patch/* | patch -p1

Next, obtain the kernel configuration from the Angstrom on MinnowBoard that is currently running.

$ cp /proc/config.gz .
$ zcat config.gz > .config

Use the make oldconfigcommand to update the kernel configuration. Due to the different kernel versions, you will be asked a question regarding the settings of the newly added configuration, but leave the settings at default for now.

$ make oldconfig

Next, use the make menuconfig command to set a detailed configuration.

$ make menuconfig

Now you are ready to start compiling a kernel.

$ nohup make 1>/tmp/log.txt 2>&1 &

Once you finish building the main body, compile the modules.

$ make modules

 Last, install the modules and the kernel.

$ sudo make modules_install

Install the kernel in the EFI partition.

$ sudo mount /dev/sda1 /efi
$ sudo cp /efi/vmlinuz /efi/vmlinuz.org
$ sudo cp arch/arm/boot/zImage /efi/vmlinuz

This completes the setup process. Now reboot.

$ sudo reboot

If it doesn’t boot, turn off the power and turn it back on. For some reason reboot does not seem to work properly. It might be a tendency with the Angstrom Distribution.

 Hisashi Hashimoto is a Senior Engineer at Hitachi.