CM-QS600: Linux: Kernel

From Compulab Mediawiki
Revision as of 15:51, 5 August 2014 by Grinberg (talk | contribs) (Flashing LK-bootable image on storage device)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

Linux kernel for CM-QS600 modules provide support for on-board peripherals and abstracts the functionality provided by the hardware. Current support coverage is specified at O/S support coverage map page. CompuLab provides ready-to-run binary kernel images, and source code of the modifications and additions made to the Linux kernel to work properly with CM-QS600 modules.

Building kernel for CM-QS600

Cross-Compiler

There are several options for cross-compilation toolchain setup. You can either compile your cross-compiler or use an already built cross-compiler. The cross-compiler should support the ARM embedded-application binary interface ("EABI")

  • Pre-built toolchain (recommended):
  • Tools for creating cross-compilers:
    • Crosstool-ng: Builds a cross-compiler from source. Non-distribution specific.
    • Crossdev: Gentoo's cross-compiler builder. Needs Gentoo.

Getting kernel sources

We assume that you have created /home/development/cm-qs600/kernel directory for CM-QS600 kernel development.

Git clone

  • Install git version control system.
  • Create a clone of linux kernel tree
cd /home/development/cm-qs600/kernel
git clone git://codeaurora.org/kernel/msm linux-cm-qs600
  • Create a branch for CM-QS600 development. The CM-QS600 patches are generated vs. LNX.LA.2.7-06310-8960.0 tag (c4f1f8cec1e3c7e3526f6666939f22d23fcd8714 commit) in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
cd /home/development/cm-qs600/kernel/linux-cm-qs600
git checkout -b cm-qs600-dev LNX.LA.2.7-06310-8960.0
  • Apply the CM-QS600 patch
git apply /path/to/cm-qs600-linux/kernel/linux-3.4.0-06310-cm-qs600-1.patch

Building the kernel

export ARCH=arm
export CROSS_COMPILE=arm-none-linux-eabi-
make cm_qs600_defconfig
make menuconfig
make && INSTALL_MOD_PATH=/home/development/cm-qs600/rootfs make modules_install

In the example above:

  • The Linux kernel image zImage will be created in /home/development/cm-qs600/kernel/linux-cm-qs600/arch/arm/boot
  • The loadable kernel modules will be installed into the /home/development/cm-qs600/rootfs/lib/modules directory.

When the CM-QS600 is booted with the kernel image and Device Tree binary created as described above and with networked root filesystem at /home/development/cm-qs600/rootfs/, the system will be able to load the kernel modules properly, thus avoiding module version problems.

Running developer kernel

CM-QS600 currently uses Little Kernel (LK) based application bootloader. The main aim of the application bootloader (LK) is loading and executing boot images from CM-QS600 storage device. The LK supports USB driver and fastboot protocol that enable obtaining developer images from remote host machine over USB connection. Images are obtained over USB can be either executed on the device or flashed onto main storage device (e.g. MMC, eMMC).

Getting Fastboot

CM-QS600 board comes with fastboot support, which means that the application bootloader (LK) implements the fastboot protocol. There are two sides to using fastboot

  • a host machine side,
  • and a target device side connected to the host via a USB cable.

In general fastboot is provided within the Android SDK. Also some Linux disributions provide fastboot within their package repositories. For example, on Ubuntu platform, fastboot may be obtained via android-tools-fastboot package.

Booting a developer kernel

Once a custom developer kernel image is built, it can be booted on CM-QS600. To boot CM-QS600 with a custom kernel image run the following fastboot command on the host machine:

fastboot boot -c <cmdline> -b 0x80200000 /home/development/cm-qs600/kernel/linux-cm-qs600/arch/arm/boot/zImage

Preparing LK-bootable image

Usually LK deals with special formatted boot.img images. Such image consists of boot header, kernel image, ramdisk and second stage images. Header and kernel sections.

  • Boot header describes the boot.img image layout, can carry other useful data, like board name and kernel command line.
  • Kernel is a required part of the boot.img file.
  • Ramdisk and Second stage images are optional.
Admolition note.png CM-QS600 default Linux does not use either Ramdisk or Second stage images.

A special utility named mkbootimg is used to create boot.img files. In general mkbootimg is provided within the Android SDK. Alternatively you can use a pre-built binary provided within the CM-QS600 Linux package. To create boot.img using a custom developer kernel image run the following command on the host machine:

/path/to/cm-qs600-linux/utilities/mkbootimg/linux-x86/mkbootimg  \
     --kernel /home/development/cm-qs600/kernel/linux-cm-qs600/arch/arm/boot/zImage \
     --ramdisk NONE --cmdline <cmdline> --base 0x80200000 --pagesize 2048 --output /home/development/cm-qs600/output/boot.img

In the example above the LK-bootable image boot.img will be created in the /home/development/cm-QS600/output directory. We assume this directory is created to hold custom bootable images.

Booting an LK-bootable image

Once a custom bootable image is created, it can be booted on CM-QS600. To boot CM-QS600 with a custom boot.img run the following fastboot command on the host machine:

fastboot boot /home/development/cm-QS600/output/boot.img

Flashing LK-bootable image on storage devices

Once a custom bootable image is created, it can be flashed on the CM-QS600 storage device (e.g. MMC, eMMC).

fastboot flash boot /home/development/cm-QS600/output/boot.img
Admolition warning.png It is strongly recommended to test the boot.img image priror to flashing it onto the storage device!

See also