User Tools

Site Tools


making_kernel_with_dtb

This is an old revision of the document!


Introduction

Since Linux x.y.z, the kernel support arm devices via a device tree. The idea behind is to make an unique kernel which supports every platforms. This tree describe the devices of the platform in order to initialize them.

The bootloader passes a device tree binary (DTB) to Linux. If the bootloader can't pass the DTB to the kernel, you need to append to it.

Toolchain

You need a toolchain for cross-compiling the kernel

Distribution name toolchain provider commands to get mkimage command toolchain triplet
Ubuntu 12.10 ubuntu sudo apt-get install arm-linux-gnueabi-gcc arm-linux-gnueabi-
Debian squeeze embedian Follow instruction on http://www.emdebian.org/crosstools.html or http://wiki.debian.org/EmdebianToolchain
The quick way :
# echo “deb http://www.emdebian.org/debian/ squeeze main” » etc/apt/sources.list
# apt-get update
# apt-get install emdebian-archive-keyring
# apt-key add /usr/share/emdebian-tools/emdebian-archive-keyring.gpg
# apt-key add /usr/share/keyrings/emdebian-archive-keyring.gpg
# apt-get update
# apt-get install gcc-4.4-arm-linux-gnueabi
arm-linux-gnueabi-

Setting up kernel source

Get the source from lacie-nas.org :

git clone git://lacie-nas.org/linux-lacie.git -b kirkwood/master

If a work is on-going on a board, then a dedicated branch is created. This branch shoud be up-to-date (and maybe also unstable). For example, for a LaCie CloudBox, you may use the branch kirkwood/cloudbox.

Making kernel

Next build your kernel with your toolchain ( here is for kirkwood ) :

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-  kirkwood_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

This will build kernel image, and dtb for all kirkwood platforms.

Preparing kernel for u-boot

Now you have to append the DTB to kernel. DTB are in the arch/arm/boot/ directory. Choose the one corresponding to your device ( here this is a network space 2 lite ) :

cat arch/arm/boot/zImage arch/arm/boot/kirkwood-ns2lite.dtb > zImage+kirkwood-ns2lite.dtb

Now you need to add an header for u-boot loader. First get the “mkimage” command :

Distribution name command to get an arm toolchain
Ubuntu 12.10 sudo apt-get install u-boot-tools
Debian Squeeze apt-get install uboot-mkimage

Make uImage. This is the binary to be loaded by u-boot :

mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux+dtb -d zImage+kirkwood-ns2lite.dtb uImage

You can now boot this image :

U-Boot 2012.10 (Dec 03 2012 - 12:59:10) NS v2 Lite

SoC:   Kirkwood 88F6281_A1
DRAM:  128 MiB
WARNING: Caches not enabled
SF: Detected MX25L4005 with page size 64 KiB, total 512 KiB
In:    nc
Out:   nc
Err:   nc
Net:   egiga0
88E1318 Initialized on egiga0
Hit any key to stop autoboot:  0
ns2>
ns2> tftp uImage
Using egiga0 device
TFTP from server 192.168.1.19; our IP address is 192.168.1.65
Filename 'uImage'.
Load address: 0x800000
Loading: #################################################################
         #################################################################
         ######################################################
done
Bytes transferred = 2689852 (290b3c hex)
ns2> bootm
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   Linux+dtb
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2689788 Bytes = 2.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
   Loading Kernel Image ...
making_kernel_with_dtb.1354833528.txt.gz · Last modified: 2012/12/06 23:38 by 82.234.233.9