Difference between revisions of "CL-SOM-iMX7: Linux: Kernel"

From Compulab Mediawiki
Jump to: navigation, search
(Getting kernel sources)
 
(Common Boot Parameters)
Line 2: Line 2:
 
The Linux kernel for CL-SOM-iMX7 provides support for on-board peripherals and abstracts the functionality provided by the hardware.
 
The Linux kernel for CL-SOM-iMX7 provides support for on-board peripherals and abstracts the functionality provided by the hardware.
  
== Kernel boot process ==
+
== Building kernel for CL-SOM-iMX7 ==
=== Default boot process ===
 
The CL-SOM-iMX7 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 or ext2/3/4
 
* has kernel image and a DTB file that meet the board configuration
 
* or {{filename|boot.scr}} in the root of the boot partition
 
 
 
=== Default boot device layout ===
 
The CL-SOM-iMX7 default boot device layout:
 
* {{filename|/boot/zImage-cl-som-imx7}} - Linux kernel zImage
 
* {{filename|/boot/imx7d-sbc-imx7l.dtb}} - SBC-iMX7 board device tree blob (Evaluation Board)
 
* {{filename|/boot/imx7d-cl-som-imx7.dtb}} - CL-SOM-iMX7 module device tree blob
 
  
== Building kernel for CL-SOM-iMX7 ==
 
=== 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 ("[http://en.wikipedia.org/wiki/Application_binary_interface#EABI EABI]")
 
* Pre-built toolchain:
 
** [http://www.codesourcery.com/sgpp/lite/arm/portal/release324 CodeSourcery]
 
* Tools for creating cross-compilers:
 
** [http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool Crosstool-ng]: Builds a cross-compiler from source. Non-distribution specific.
 
** [http://www.gentoo.org/proj/en/base/embedded/handbook/index.xml?part=1&chap=4 Crossdev]: Gentoo's cross-compiler builder. Needs Gentoo.
 
  
 
=== Getting kernel sources ===
 
=== Getting kernel sources ===
Line 60: Line 38:
 
=== Building the kernel ===
 
=== Building the kernel ===
 
<pre>
 
<pre>
 +
cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7
 
export ARCH=arm
 
export ARCH=arm
 
export CROSS_COMPILE=arm-none-linux-eabi-
 
export CROSS_COMPILE=arm-none-linux-eabi-
Line 65: Line 44:
 
make cl_som_imx7_defconfig
 
make cl_som_imx7_defconfig
 
make menuconfig
 
make menuconfig
make zImage modules ${DTB} && INSTALL_MOD_PATH=/home/development/CL-SOM-iMX7/rootfs make modules_install
+
make zImage modules ${DTB} && INSTALL_MOD_PATH=/home/development/cl-som-imx7/rootfs make modules_install
 
</pre>
 
</pre>
  
 
In the example above:
 
In the example above:
* Linux kernel image ({{filename|zImage}}) will be created in {{filename|/home/development/CL-SOM-iMX7/kernel/arch/arm/boot}}
+
* Linux kernel image ({{filename|zImage}}) will be created in {{filename|/home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot}}
* device tree blobs will be created in {{filename|/home/development/CL-SOM-iMX7/kernel/arch/arm/boot/dts}}
+
* device tree blobs will be created in {{filename|/home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/dts}}
* loadable kernel modules will be installed into the {{filename|/home/development/CL-SOM-iMX7/rootfs/lib/modules}} directory.
+
* loadable kernel modules will be installed into the {{filename|/home/development/cl-som-imx7/rootfs/lib/modules}} directory.
 
<br>
 
<br>
When the CL-SOM-iMX7 is booted with the kernel image created as described above and with networked root filesystem at {{filename|/home/development/CL-SOM-iMX7/rootfs/}}, the system will be able to load the kernel modules properly, thus avoiding module version problems.
+
When the CL-SOM-iMX7 is booted with the kernel image created as described above and with networked root filesystem at {{filename|/home/development/cl-som-imx7/rootfs/}}, the system will be able to load the kernel modules properly, thus avoiding module version problems.
  
 
==== zImage, DTB files and modules locations  ====
 
==== zImage, DTB files and modules locations  ====
  
* In the example above, the Linux kernel image ({{filename|zImage}}) will be created in the {{filename|/home/development/CL-SOM-iMX7/kernel/arch/arm/boot}} directory.
+
* In the example above, the Linux kernel image ({{filename|zImage}}) will be created in the {{filename|/home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot}} directory.
 
<pre>
 
<pre>
# ls -al /home/development/CL-SOM-iMX7/kernel/arch/arm/boot/zImage
+
# ls -al /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/zImage
 
</pre>
 
</pre>
 
* DTB files
 
* DTB files
 
<pre>
 
<pre>
# cd /home/development/CL-SOM-iMX7/kernel/arch/arm/boot/dtb/
+
# cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/dtb/
 
# ls -al ${DTB}
 
# ls -al ${DTB}
 
# cd -
 
# cd -
 
</pre>
 
</pre>
* The loadable kernel modules will be installed into the {{filename|/home/development/CL-SOM-iMX7/rootfs/lib/modules}} directory.
+
* The loadable kernel modules will be installed into the {{filename|/home/development/cl-som-imx7/rootfs/lib/modules}} directory.
 
<pre>
 
<pre>
# ls -al /home/development/CL-SOM-iMX7/rootfs/lib/modules
+
# ls -al /home/development/cl-som-imx7/rootfs/lib/modules
 
</pre>
 
</pre>
  
 
==== Kernel Version  ====
 
==== Kernel Version  ====
  
* In the example above, the Linux kernel release version number will be saved in {{filename|/home/development/CL-SOM-iMX7/kernel/include/config/kernel.release}}
+
* In the example above, the Linux kernel release version number will be saved in {{filename|/home/development/cl-som-imx7/kernel/linux-cl-som-imx7/include/config/kernel.release}}
 
<pre>
 
<pre>
# cat /home/development/CL-SOM-iMX7/kernel/include/config/kernel.release
+
# cat /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/include/config/kernel.release
 
</pre>
 
</pre>
  
Line 103: Line 82:
 
* In the example below, the Linux kernel and modules are packed into the tar archive for deploying onto the CL-SOM-iMX7.
 
* In the example below, the Linux kernel and modules are packed into the tar archive for deploying onto the CL-SOM-iMX7.
 
<pre>
 
<pre>
# mkdir -p /home/development/CL-SOM-iMX7/rootfs/boot
+
# mkdir -p /home/development/cl-som-imx7/rootfs/boot
# cp -v /home/development/CL-SOM-iMX7/kernel/arch/arm/boot/zImage /home/development/CL-SOM-iMX7/rootfs/boot/zImage-cl-som-imx7
+
# cp -v /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/zImage /home/development/cl-som-imx7/rootfs/boot/zImage-cl-som-imx7
# cd /home/development/CL-SOM-iMX7/kernel/arch/arm/boot/dtb/
+
# cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/dtb/
# cp -v ${DTB} /home/development/CL-SOM-iMX7/rootfs/boot/  
+
# cp -v ${DTB} /home/development/cl-som-imx7/rootfs/boot/  
 
# cd -
 
# cd -
# tar -C /home/development/CL-SOM-iMX7/rootfs -czvf /home/development/CL-SOM-iMX7/linux-image-CL-SOM-iMX7.tar.gz .
+
# tar -C /home/development/cl-som-imx7/rootfs -czvf /home/development/cl-som-imx7/linux-image-cl-som-imx7.tar.gz .
 
</pre>
 
</pre>
  
Line 122: Line 101:
 
== Deploying the CL-SOM-iMX7 kernel and modules ==
 
== Deploying the CL-SOM-iMX7 kernel and modules ==
  
Boot up the CL-SOM-iMX7 computer. Copy the previously created {{filename|linux-image-CL-SOM-iMX7.tar.gz}} to {{filename|/root}} directory of the CL-SOM-iMX7.
+
* Boot up the CL-SOM-iMX7 computer.
 +
* Copy the previously created {{filename|linux-image-cl-com-imx7.tar.gz}} to {{filename|/root}} directory of the CL-SOM-iMX7.
  
 
==== Mount boot partition ====
 
==== Mount boot partition ====
Line 139: Line 119:
  
 
==== Installing kernel and modules ====
 
==== Installing kernel and modules ====
Assuming that the {{filename|linux-image-CL-SOM-iMX7.tar.gz}} tar ball has been copied to the CL-SOM-iMX7 {{filename|/root}} directory.
+
Assuming that the {{filename|linux-image-cl-com-imx7.tar.gz}} tar ball has been copied to the CL-SOM-iMX7 {{filename|/root}} directory.
 
* Extract and install the Linux kernel binary:
 
* Extract and install the Linux kernel binary:
 
<pre>
 
<pre>
# tar -C / -xvf /root/linux-image-CL-SOM-iMX7.tar.gz
+
# tar -C / -xvf /root/linux-image-cl-com-imx7.tar.gz
 
</pre>
 
</pre>
  
Line 169: Line 149:
 
setenv image zImage-cl-som-imx7
 
setenv image zImage-cl-som-imx7
 
setenv fdt_file imx7d-sbc-imx7.dtb
 
setenv fdt_file imx7d-sbc-imx7.dtb
setenv bootargs console=ttymxc0,115200 root=/dev/${mmcblk} rw rootwait ip=dhcp
+
setenv bootargs console=ttymxc0,115200 root=/dev/${mmcblk} rw rootwait
 
mmc dev ${mmcdev}
 
mmc dev ${mmcdev}
 
load mmc ${mmcdev} ${loadaddr} ${image}
 
load mmc ${mmcdev} ${loadaddr} ${image}
Line 202: Line 182:
 
* [http://www.alsa-project.org ALSA project official website]
 
* [http://www.alsa-project.org ALSA project official website]
  
[[Category:Linux|Debian]]
+
[[Category:Linux]]
[[Category:CL-SOM-iMX7|Linux: Debian]]
+
[[Category:CL-SOM-iMX7]]

Revision as of 07:54, 1 March 2016

Overview

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

Building kernel for CL-SOM-iMX7

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-imx7/kernel directory has been created for CL-SOM-iMX7 kernel development.

Snapshot download

  • Download rel_imx_3.14.52_1.1.0_ga snapshot with your web browser.
  • Extract the downloaded archive rel_imx_3.14.52_1.1.0_ga.tar.gz
cd /home/development/cl-som-imx7/kernel
tar xpf /path/to/downloaded/rel_imx_3.14.52_1.1.0_ga.tar.gz
mv rel_imx_3.14.52_1.1.0_ga linux-cl-som-imx7

Git clone

  • Install git version control system.
  • Create a clone of the FreeScale Linux kernel tree
cd /home/development/cl-som-imx7/kernel
git clone git://git.freescale.com/imx/linux-2.6-imx.git linux-cl-som-imx7
  • Create a branch for CL-SOM-iMX7 development. The CL-SOM-iMX7 patches are generated vs. rel_imx_3.14.52_1.1.0_ga tag (5f6f0a50e6039370078369ddf380179d59024789 commit) in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7
git checkout -b development rel_imx_3.14.52_1.1.0_ga

Apply the CL-SOM-iMX7 patch

cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7
git am /path/to/cl-som-imx7-linux/kernel/patches/*.patch

Building the kernel

cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-eabi-
export DTB="imx7d-sbc-imx7.dtb imx7d-cl-som-imx7.dtb"
make cl_som_imx7_defconfig
make menuconfig
make zImage modules ${DTB} && INSTALL_MOD_PATH=/home/development/cl-som-imx7/rootfs make modules_install

In the example above:

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


When the CL-SOM-iMX7 is booted with the kernel image created as described above and with networked root filesystem at /home/development/cl-som-imx7/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-imx7/kernel/linux-cl-som-imx7/arch/arm/boot directory.
# ls -al /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/zImage
  • DTB files
# cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/dtb/
# ls -al ${DTB}
# cd -
  • The loadable kernel modules will be installed into the /home/development/cl-som-imx7/rootfs/lib/modules directory.
# ls -al /home/development/cl-som-imx7/rootfs/lib/modules

Kernel Version

  • In the example above, the Linux kernel release version number will be saved in /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/include/config/kernel.release
# cat /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/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-iMX7.
# mkdir -p /home/development/cl-som-imx7/rootfs/boot
# cp -v /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/zImage /home/development/cl-som-imx7/rootfs/boot/zImage-cl-som-imx7
# cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/dtb/
# cp -v ${DTB} /home/development/cl-som-imx7/rootfs/boot/ 
# cd -
# tar -C /home/development/cl-som-imx7/rootfs -czvf /home/development/cl-som-imx7/linux-image-cl-som-imx7.tar.gz .

Basic platform support

The CL-SOM-iMX7 basic platform support is implemented in the imx7d-sbc-imx7.dtb imx7d-cl-som-imx7.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-iMX7 module;
  • definitions of platform-specific configuration for these devices.

Deploying the CL-SOM-iMX7 kernel and modules

  • Boot up the CL-SOM-iMX7 computer.
  • Copy the previously created linux-image-cl-com-imx7.tar.gz to /root directory of the CL-SOM-iMX7.

Mount boot partition

  • Use the below command to mount the boot partition for installing the CL-SOM-iMX7 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/zImage-cl-som-imx7 /boot/*.dtb /boot/`uname -r`/

Installing kernel and modules

Assuming that the linux-image-cl-com-imx7.tar.gz tar ball has been copied to the CL-SOM-iMX7 /root directory.

  • Extract and install the Linux kernel binary:
# tar -C / -xvf /root/linux-image-cl-com-imx7.tar.gz

U-Boot Environment

MMC Boot Parameters

To boot from MMC/SD card type:

setenv mmcdev 0
setenv mmcblk mmcblk0p2

Continue to the Common Boot Parameters.

eMMC Boot Parameters

To boot from internal eMMC storage type:

setenv mmcdev 2
setenv mmcblk mmcblk2p2

Continue to the Common Boot Parameters.

Common Boot Parameters

To boot Linux type:

setenv loadaddr 0x80800000
setenv fdt_addr 0x83000000
setenv image zImage-cl-som-imx7
setenv fdt_file imx7d-sbc-imx7.dtb
setenv bootargs console=ttymxc0,115200 root=/dev/${mmcblk} rw rootwait
mmc dev ${mmcdev}
load mmc ${mmcdev} ${loadaddr} ${image}
load mmc ${mmcdev} ${fdt_addr} ${fdt_file}
bootz ${loadaddr} - ${fdt_addr}

NFS Boot Parameters

To boot via network interface type:

setenv loadaddr 0x80800000
setenv fdt_addr 0x83000000
setenv image zImage-cl-som-imx7
setenv fdt_file imx7d-sbc-imx7.dtb
setenv nfsserver <nfs server ip address>
setenv tftpserver <tftp server ip address>
setenv bootargs console=ttymxc0,115200 root=/dev/nfs rw ip=dhcp nfsroot=${nfsserver}:${nfsroot}

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

See also