CL-SOM-iMX6UL: Linux: Kernel

From Compulab Mediawiki
Revision as of 11:04, 7 January 2016 by Grinberg (talk | contribs) (Getting kernel sources)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

The Linux kernel for CL-SOM-iMX6UL provides support for on-board peripherals and abstracts the functionality provided by the hardware.

Kernel boot process

Default boot process

The CL-SOM-iMX6UL U-Boot scans the various boot devices and loads the kernel from the first valid boot device. The boot device is valid when:

  • physically present
  • boot partition formatted with vfat
  • has zImage-cl-som-imx6ul and a DTB file that meets the board configuration
  • or boot.scr in the root of the boot partition

Default boot device layout

The CL-SOM-iMX6UL default boot device layout:

  • /boot/zImage-cl-som-imx6ul - Linux kernel zImage
  • /boot/imx6ul-sbc-imx6ul.dtb - SBC-iMX6UL board device tree blob with P9 mmc slot enabled (Evaluation Board)
  • /boot/imx6ul-sbc-imx6ul-wilink.dtb - SBC-iMX6UL board device tree blob with WiLinki8 WiFi enabled (Evaluation Board)
  • /boot/imx6ul-cl-som-imx6ul.dtb - CL-SOM-iMX6UL module device tree blob with mmc 0 device enabled
  • /boot/imx6ul-cl-som-imx6ul-wilink.dtb - CL-SOM-iMX6UL module device tree blob with WiLink8 WiFi enabled

Building kernel for CL-SOM-iMX6UL

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:
  • 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

Linux git tree can be cloned or downloaded as a tarball from Freescale public git repository. The instructions below assume that the /home/development/CL-SOM-iMX6UL/kernel directory has been created for CL-SOM-iMX6UL kernel development.

Git clone

  • Install git version control system.
  • Create a clone of the FreeScale Linux kernel tree
cd /home/development/CL-SOM-iMX6UL/kernel
git clone git://git.freescale.com/imx/linux-2.6-imx.git .
git checkout -b development rel_imx_3.14.38_6ul_ga

Apply the CL-SOM-iMX6UL patch

git am /path/to/cl-som-imx6ul-linux/kernel/patches/*.patch

Building the kernel

export ARCH=arm
export CROSS_COMPILE=arm-none-linux-eabi-
export DTB="imx6ul-sbc-imx6ul.dtb imx6ul-sbc-imx6ul-wilink.dtb imx6ul-cl-som-imx6ul.dtb imx6ul-cl-som-imx6ul-wilink.dtb"
make cl_som_imx6ul_defconfig
make menuconfig
make zImage modules ${DTB} && INSTALL_MOD_PATH=/home/development/CL-SOM-iMX6UL/rootfs make modules_install

In the example above:

  • Linux kernel image (zImage) will be created in /home/development/CL-SOM-iMX6UL/kernel/arch/arm/boot
  • device tree blobs will be created in /home/development/CL-SOM-iMX6UL/kernel/arch/arm/boot/dts
  • loadable kernel modules will be installed into the /home/development/CL-SOM-iMX6UL/rootfs/lib/modules directory.


When the CL-SOM-iMX6UL is booted with the kernel image created as described above and with networked root filesystem at /home/development/CL-SOM-iMX6UL/rootfs/, the system will be able to load the kernel modules properly, thus avoiding module version problems.

zImage, DTB files and modules locations

  • In the example above, the Linux kernel image (zImage) will be created in the /home/development/CL-SOM-iMX6UL/kernel/arch/arm/boot directory.
# ls -al /home/development/CL-SOM-iMX6UL/kernel/arch/arm/boot/zImage
  • DTB files
# cd /home/development/CL-SOM-iMX6UL/kernel/arch/arm/boot/dtb/
# ls -al ${DTB}
# cd -
  • The loadable kernel modules will be installed into the /home/development/CL-SOM-iMX6UL/rootfs/lib/modules directory.
# ls -al /home/development/CL-SOM-iMX6UL/rootfs/lib/modules

Kernel Version

  • In the example above, the Linux kernel release version number will be saved in /home/development/CL-SOM-iMX6UL/kernel/include/config/kernel.release
# cat /home/development/CL-SOM-iMX6UL/kernel/include/config/kernel.release

Prepare kernel and modules tarball

  • In the example below, the Linux kernel and modules are packed into the tar archive for deploying onto the CL-SOM-iMX6UL.
# mkdir -p /home/development/CL-SOM-iMX6UL/rootfs/boot
# cp -v /home/development/CL-SOM-iMX6UL/kernel/arch/arm/boot/zImage /home/development/CL-SOM-iMX6UL/rootfs/boot/zImage-cl-som-imx6ul
# cd /home/development/CL-SOM-iMX6UL/kernel/arch/arm/boot/dtb/
# cp -v ${DTB} /home/development/CL-SOM-iMX6UL/rootfs/boot/ 
# cd -
# tar -C /home/development/CL-SOM-iMX6UL/rootfs -czvf /home/development/CL-SOM-iMX6UL/linux-image-CL-SOM-iMX6UL.tar.gz .

Basic platform support

The CL-SOM-iMX6UL basic platform support is implemented in the imx6ul-sbc-imx6ul.dtb imx6ul-sbc-imx6ul-wilink.dtb imx6ul-cl-som-imx6ul.dtb imx6ul-cl-som-imx6ul-wilink.dtb files of the Linux kernel source tree.

These files contain:

  • default setup of multi-functional pins;
  • registration of the devices integrated in the CL-SOM-iMX6UL module;
  • definitions of platform-specific configuration for these devices.

SBC-iMX6UL

  • MMC: arch/arm/boot/dts/imx6ul-sbc-imx6ul.dts
/*
 * Suppport for CompuLab SB-SOM-iMX6UL baseboard
 */

#include "imx6ul-cl-som-imx6ul.dts"
#include "imx6ul-sb-som-imx6ul.dtsi"

/ {
	model = "Compulab iMX6UL on SB-SOM";
	compatible = "fsl,imx6ul", "compulab,cl-som-imx6ul", "compulab,sbc-imx6ul";
};
  • WiFi: arm/boot/dts/imx6ul-sbc-imx6ul-wilink.dts
/*
 * Suppport for CompuLab SB-SOM-iMX6UL baseboard
 */

#include "imx6ul-cl-som-imx6ul-wilink.dts"
#include "imx6ul-sb-som-imx6ul.dtsi"

/ {
	model = "Compulab iMX6UL on SB-SOM";
	compatible = "fsl,imx6ul", "compulab,cl-som-imx6ul", "compulab,sbc-imx6ul";
};

Deploying the CL-SOM-iMX6UL kernel and modules

Boot up the CL-SOM-iMX6UL computer. Copy the previously created linux-image-CL-SOM-iMX6UL.tar.gz to /root directory of the CL-SOM-iMX6UL.

Mount boot partition

  • Use the below command to mount the boot partition for installing the CL-SOM-iMX6UL Linux kernel binary:
# boot_partition=`cat /proc/cmdline | awk '{ for (i=1;i<=NF;i++) { if($i~/^root=/) { print substr($i,6,length($i)-6)"1" } } }'`
# mount $boot_partition /boot

Back up old kernel

  • It is essential to backup the old (known to work) kernel binary.
# mkdir /boot/`uname -r`
# mv /boot/uImage-cl-som-imx6ul /boot/zImage-cl-som-imx6ul /boot/*.dtb /boot/`uname -r`/

Installing kernel and modules

Assuming that the linux-image-CL-SOM-iMX6UL.tar.gz tar ball has been copied to the CL-SOM-iMX6UL /root directory.

  • Extract and install the Linux kernel binary:
# tar -C / -xvf /root/linux-image-CL-SOM-iMX6UL.tar.gz

U-Boot Environment

Common parameters

setenv loadaddr 0x82000000
setenv fdt_addr 0x83000000
setenv zimage zImage-cl-som-imx6ul

MMC Boot Parameters

setenv fdt_file imx6ul-sbc-imx6ul.dtb
setenv mmcdev 0
setenv bootargs console=ttymxc2,115200 root=/dev/mmcblk0p2 rw rootwait ip=dhcp

mmc dev ${mmcdev}
load mmc ${mmcdev} ${loadaddr} ${zimage}
load mmc ${mmcdev} ${fdt_addr} ${fdt_file}
bootz ${loadaddr} - ${fdt_addr}

eMMC Boot Parameters

setenv fdt_file imx6ul-sbc-imx6ul-wilink.dtb
setenv mmcdev 1
setenv bootargs console=ttymxc2,115200 root=/dev/mmcblk1p2 rw rootwait ip=dhcp

mmc dev ${mmcdev}
load mmc ${mmcdev} ${loadaddr} ${zimage}
load mmc ${mmcdev} ${fdt_addr} ${fdt_file}
bootz ${loadaddr} - ${fdt_addr}

NFS Boot Parameters

setenv fdt_file imx6ul-sbc-imx6ul-wilink.dtb
setenv nfsserver <nfs server ip address>
setenv tftpserver <tftp server ip address>
setenv bootargs console=ttymxc2,115200 root=/dev/nfs rw ip=dhcp nfsroot=${nfsserver}:${nfsroot}

dhcp
tftpboot ${loadaddr} ${tftpserver}:${zimage}
tftpboot ${fdt_addr} ${tftpserver}:${fdt_file}
bootz ${loadaddr} - ${fdt_addr}

See also