Difference between revisions of "CM-T43: Linux: Kernel"

From Compulab Mediawiki
Jump to: navigation, search
(Getting kernel sources)
Line 33: Line 33:
  
 
==== Snapshot download ====
 
==== Snapshot download ====
* Download [https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.tar.gz v3.19] snapshot with a web browser.
+
* Download [https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.2.tar.gz v4.2] snapshot with a web browser.
* Extract the downloaded archive {{filename|linux-3.19.tar.gz}}
+
* Extract the downloaded archive {{filename|linux-4.2.tar.gz}}
 
<pre>
 
<pre>
 
cd /home/development/cm-t43/kernel
 
cd /home/development/cm-t43/kernel
tar xvf /path/to/downloaded/linux-3.19.tar.gz
+
tar xvf /path/to/downloaded/linux-4.2.tar.gz
mv linux-3.19 linux-cm-t43
+
mv linux-4.2 linux-cm-t43
 
</pre>
 
</pre>
 
: This will create {{filename|/home/development/cm-t43/kernel/linux-cm-t43}} directory containing linux kernel tree.
 
: This will create {{filename|/home/development/cm-t43/kernel/linux-cm-t43}} directory containing linux kernel tree.
Line 44: Line 44:
 
<pre>
 
<pre>
 
cd /home/development/cm-t43/kernel/linux-cm-t43
 
cd /home/development/cm-t43/kernel/linux-cm-t43
patch -p1 < /path/to/cm-t43-linux/kernel/linux-3.19.0-cm-t43-2.patch
+
patch -p1 < /path/to/cm-t43-linux/kernel/linux-4.2.0-cm-t43-3.2.patch
 
</pre>
 
</pre>
  
Line 54: Line 54:
 
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-cm-t43
 
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-cm-t43
 
</pre>
 
</pre>
* Create a branch for CM-T43 development. The CM-T43 patches are generated vs. v3.19 tag (bfa76d49576599a4b9f9b7a71f23d73d6dcff735 commit) in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
+
* Create a branch for CM-T43 development. The CM-T43 patches are generated vs. v4.2 tag (64291f7db5bd8150a74ad2036f1037e6a0428df2 commit) in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
 
<pre>
 
<pre>
 
cd /home/development/cm-t43/kernel/linux-cm-t43
 
cd /home/development/cm-t43/kernel/linux-cm-t43
git checkout -b cm-t43-dev v3.19
+
git checkout -b cm-t43-dev v4.2
 
</pre>
 
</pre>
 
* Apply the CM-T43 patch
 
* Apply the CM-T43 patch
 
<pre>
 
<pre>
git apply /path/to/cm-t43-linux/kernel/linux-3.19.0-cm-t43-2.patch
+
git apply /path/to/cm-t43-linux/kernel/linux-4.2.0-cm-t43-3.2.patch
 
</pre>
 
</pre>
  
{{Note|Future stable kernel versions of 3.19 can also be used by adding the Linux kernel stable repository as a remote and checking out any later tag of the v3.19.y stable kernel branch.}}
+
{{Note|Future stable kernel versions of 4.2 can also be used by adding the Linux kernel stable repository as a remote and checking out any later tag of the v4.2.y stable kernel branch.}}
  
 
=== Building the kernel ===
 
=== Building the kernel ===

Revision as of 11:28, 6 December 2015

Overview

Linux kernel for the CompuLab CM-T43 System-on-Module / Computer-on-Module provides support for on-board peripherals and abstracts the functionality provided by the hardware. 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-T43 modules.

Device Tree

Device Tree (DT), is a data structure and language for describing hardware. More specifically, it is a description of hardware that is readable by an operating system so that the operating system doesn't need to hard code details of the machine.

A device tree file, named *.dts, is a text file that describes the hardware platform. It is compiled into a device tree blob, *.dtb, which is loaded into memory before the Linux kernel is started. The Linux kernel then uses that device tree blob to initialize itself at runtime.

CM-T43 DT related files are :

  • arch/arm/boot/dts/am437x-cm-t43.dts - CM-T43 core SoM/CoM Device Tree
  • arch/arm/boot/dts/compulab-sb-som.dtsi - SB-SOM baseboard Device Tree
  • arch/arm/boot/dts/am437x-sb-som-t43.dts - SB-SOM-T43 single board computer (eval board) Device Tree

For more details visit official Device Tree WiKi pages and make an overview of a Device Tree tutorial

Building kernel for CM-T43

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

There are various ways to get Linux kernel sources that can be used as a baseline for CM-T43 kernel. For instance, a copy of linux-stable git tree can be created or a Linux kernel sources snapshot can be downloaded.

Assuming that the /home/development/cm-t43/kernel directory structure has been created for CM-T43 kernel development.

Snapshot download

  • Download v4.2 snapshot with a web browser.
  • Extract the downloaded archive linux-4.2.tar.gz
cd /home/development/cm-t43/kernel
tar xvf /path/to/downloaded/linux-4.2.tar.gz
mv linux-4.2 linux-cm-t43
This will create /home/development/cm-t43/kernel/linux-cm-t43 directory containing linux kernel tree.
  • Apply the CM-T43 patch
cd /home/development/cm-t43/kernel/linux-cm-t43
patch -p1 < /path/to/cm-t43-linux/kernel/linux-4.2.0-cm-t43-3.2.patch

Git clone

  • Install git version control system.
  • Create a clone of linux kernel tree
cd /home/development/cm-t43/kernel
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-cm-t43
  • Create a branch for CM-T43 development. The CM-T43 patches are generated vs. v4.2 tag (64291f7db5bd8150a74ad2036f1037e6a0428df2 commit) in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
cd /home/development/cm-t43/kernel/linux-cm-t43
git checkout -b cm-t43-dev v4.2
  • Apply the CM-T43 patch
git apply /path/to/cm-t43-linux/kernel/linux-4.2.0-cm-t43-3.2.patch


Admolition note.png Future stable kernel versions of 4.2 can also be used by adding the Linux kernel stable repository as a remote and checking out any later tag of the v4.2.y stable kernel branch.

Building the kernel

  • Run the following commands:
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-eabi-
make cm_t43_defconfig && make menuconfig
make && make zImage && make am437x-sb-som-t43.dtb \
     INSTALL_MOD_PATH=/home/development/cm-t43/rootfs make modules_install

In the example above:

  • The Linux kernel image zImage will be created in /home/development/cm-t43/kernel/linux-cm-t43/arch/arm/boot
  • The Device Tree binary am437x-sb-som-t43.dtb will be created in /home/development/cm-t43/kernel/linux-cm-t43/arch/arm/boot/dts
  • The loadable kernel modules will be installed into the /home/development/cm-t43/rootfs/lib/modules directory.

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

See also