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

From Compulab Mediawiki
Jump to: navigation, search
(Device Tree)
 
Line 34: Line 34:
  
 
==== Snapshot download ====
 
==== Snapshot download ====
* Download [https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.3.tar.gz v4.3] snapshot with a web browser.
+
* Download [https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.4.tar.gz v4.4] snapshot with a web browser.
* Extract the downloaded archive {{filename|linux-4.3.tar.gz}}
+
* Extract the downloaded archive {{filename|linux-4.4.tar.gz}}
 
<pre>
 
<pre>
 
cd /home/development/cl-som-am57x/kernel
 
cd /home/development/cl-som-am57x/kernel
tar xvf /path/to/downloaded/linux-4.3.tar.gz
+
tar xvf /path/to/downloaded/linux-4.4.tar.gz
mv linux-4.3 linux-cl-som-am57x
+
mv linux-4.4 linux-cl-som-am57x
 
</pre>
 
</pre>
 
: This will create {{filename|/home/development/cl-som-am57x/kernel/linux-cl-som-am57x}} directory containing linux kernel tree.
 
: This will create {{filename|/home/development/cl-som-am57x/kernel/linux-cl-som-am57x}} directory containing linux kernel tree.
Line 45: Line 45:
 
<pre>
 
<pre>
 
cd /home/development/cl-som-am57x/kernel/cl-som-am57x
 
cd /home/development/cl-som-am57x/kernel/cl-som-am57x
patch -p1 < /path/to/cl-som-am57x/kernel/linux-4.3-cl-som-am57x-1.patch
+
patch -p1 < /path/to/cl-som-am57x/kernel/linux-4.4-cl-som-am57x-2.patch
 
</pre>
 
</pre>
  
Line 55: Line 55:
 
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-cl-som-am57x
 
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-cl-som-am57x
 
</pre>
 
</pre>
* Create a branch for CL-SOM-AM57x development. The CL-SOM-AM57x patches are generated vs. v4.3 tag (d74151c670f51a5d1c7a5aa72dc1f3c0d90fba48 commit) in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
+
* Create a branch for CL-SOM-AM57x development. The CL-SOM-AM57x patches are generated vs. v4.3 tag (b5be40b90dbaa6bd337f3b77de361bfc0723468b commit) in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
 
<pre>
 
<pre>
 
cd /home/development/cl-som-am57x/kernel/linux-cl-som-am57x
 
cd /home/development/cl-som-am57x/kernel/linux-cl-som-am57x
git checkout -b cl-som-am57x-dev v4.3
+
git checkout -b cl-som-am57x-dev v4.4
 
</pre>
 
</pre>
 
* Apply the CL-SOM-AM57x patch
 
* Apply the CL-SOM-AM57x patch
 
<pre>
 
<pre>
git apply /path/to/cl-som-am57x-linux/kernel/linux-4.3-cl-som-am57x-1.patch
+
git apply /path/to/cl-som-am57x-linux/kernel/linux-4.4-cl-som-am57x-2.patch
 
</pre>
 
</pre>
  
{{Note|Future stable kernel versions of 4.3 can also be used by adding the Linux kernel stable repository as a remote and checking out any later tag of the v4.3.y stable kernel branch.}}
+
{{Note|Future stable kernel versions of 4.4 can also be used by adding the Linux kernel stable repository as a remote and checking out any later tag of the v4.4.y stable kernel branch.}}
  
 
=== Building the kernel ===
 
=== Building the kernel ===
Line 72: Line 72:
 
export ARCH=arm
 
export ARCH=arm
 
export CROSS_COMPILE=arm-none-linux-eabi-
 
export CROSS_COMPILE=arm-none-linux-eabi-
make sbc-am57x_defconfig && make menuconfig
+
make cl-som-am57x_defconfig && make menuconfig
 
make && make zImage && make am57xx-sbc-am57x.dtb \
 
make && make zImage && make am57xx-sbc-am57x.dtb \
 
     INSTALL_MOD_PATH=/home/development/cl-som-am57x/rootfs make modules_install
 
     INSTALL_MOD_PATH=/home/development/cl-som-am57x/rootfs make modules_install

Revision as of 13:49, 4 February 2016

Overview

Linux kernel for the CompuLab CL-SOM-AM57x 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 CL-SOM-AM57x 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.

CL-SOM-AM57x DT related files are :

  • arch/arm/boot/dts/am57xx-cl-som-am57x.dts - CL-SOM-AM57x core SoM/CoM Device Tree that can be used with almost any base board.
  • arch/arm/boot/dts/compulab-sb-som.dtsi - SB-SOM baseboard Device Tree.
  • arch/arm/boot/dts/am57xx-sbc-am57x.dts - SBC-AM57x 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 CL-SOM-AM57x

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 CL-SOM-AM57x 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/cl-som-am57x/kernel directory structure has been created for CL-SOM-AM57x kernel development.

Snapshot download

  • Download v4.4 snapshot with a web browser.
  • Extract the downloaded archive linux-4.4.tar.gz
cd /home/development/cl-som-am57x/kernel
tar xvf /path/to/downloaded/linux-4.4.tar.gz
mv linux-4.4 linux-cl-som-am57x
This will create /home/development/cl-som-am57x/kernel/linux-cl-som-am57x directory containing linux kernel tree.
  • Apply the CL-SOM-AM57x patch
cd /home/development/cl-som-am57x/kernel/cl-som-am57x
patch -p1 < /path/to/cl-som-am57x/kernel/linux-4.4-cl-som-am57x-2.patch

Git clone

  • Install git version control system.
  • Create a clone of linux kernel tree
cd /home/development/cl-som-am57x/kernel
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-cl-som-am57x
  • Create a branch for CL-SOM-AM57x development. The CL-SOM-AM57x patches are generated vs. v4.3 tag (b5be40b90dbaa6bd337f3b77de361bfc0723468b commit) in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
cd /home/development/cl-som-am57x/kernel/linux-cl-som-am57x
git checkout -b cl-som-am57x-dev v4.4
  • Apply the CL-SOM-AM57x patch
git apply /path/to/cl-som-am57x-linux/kernel/linux-4.4-cl-som-am57x-2.patch


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

Building the kernel

  • Run the following commands:
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-eabi-
make cl-som-am57x_defconfig && make menuconfig
make && make zImage && make am57xx-sbc-am57x.dtb \
     INSTALL_MOD_PATH=/home/development/cl-som-am57x/rootfs make modules_install

In the example above:

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

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

See also