Difference between revisions of "CL-SOM-iMX7: Linux: Kernel"
(→NFS Boot Parameters) |
|||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
== Overview == | == Overview == | ||
− | The | + | The CL-SOM-iMX7 Linux kernel provides support for on-board peripherals/interfaces of the CL-SOM-iMX7 System-on-Module and the following CompuLab products built around CL-SOM-iMX7: |
* SBC-iMX7 Single Board Computer | * SBC-iMX7 Single Board Computer | ||
* SBC-IOT-iMX7 Internet of Things Single Board Computer | * SBC-IOT-iMX7 Internet of Things Single Board Computer | ||
* IOT-GATE-iMX7 Internet of Things Gateway | * IOT-GATE-iMX7 Internet of Things Gateway | ||
− | + | BSP packages for different CompuLab i.MX7 devices may differ from each other. It is recommended to use the most recent BSP package released for the specific device being used. It can be downloaded from the corresponding product web page: | |
− | + | * [https://www.compulab.com/products/computer-on-modules/cl-som-imx7-freescale-i-mx-7-system-on-module/#devres CL-SOM-iMX7 System-on-Module BSP package] | |
− | * | + | * [https://www.compulab.com/products/sbcs/sbc-imx7-freescale-i-mx-7-single-board-computer/#devres SBC-iMX7 Single Board Computer BSP package] |
− | * | + | * [https://www.compulab.com/products/sbcs/sbc-iot-imx7-nxp-i-mx-7-internet-of-things-single-board-computer/#devres SBC-IOT-iMX7 Single Board Computer BSP package] |
− | * | + | * [https://www.compulab.com/products/iot-gateways/iot-gate-imx7-nxp-i-mx-7-internet-of-things-gateway/#devres IOT-GATE-iMX7 IoT Gateway BSP package] |
− | + | Unzip the downloaded BSP source package to a directory on your host workstation. The following instructions use {{filename|/path/to/cl-som-imx7-bsp-src/}} template for this location. Please use the real path to the Linux package instead. | |
− | Unzip the downloaded | ||
== Building kernel for CL-SOM-iMX7 == | == Building kernel for CL-SOM-iMX7 == | ||
Line 16: | Line 15: | ||
=== Getting kernel sources === | === Getting kernel sources === | ||
− | Linux git tree can be cloned or downloaded as a tarball from [ | + | Linux git tree can be cloned <!--or downloaded as a tarball -->from the [https://github.com/nxp-imx/linux-imx NXP GitHub]. |
The instructions below assume that the {{filename|/home/development/cl-som-imx7/kernel}} directory has been created for CL-SOM-iMX7 kernel development. | The instructions below assume that the {{filename|/home/development/cl-som-imx7/kernel}} directory has been created for CL-SOM-iMX7 kernel development. | ||
+ | <!-- | ||
==== Snapshot download ==== | ==== Snapshot download ==== | ||
− | * Download [http://git.freescale.com/git/cgit.cgi/imx/linux | + | * Download [http://git.freescale.com/git/cgit.cgi/imx/linux-imx.git/snapshot/linux-imx-rel_imx_4.9.x_1.0.0_ga.tar.gz rel_imx_4.9.11_1.0.0_ga] snapshot with your web browser. |
− | * Extract the downloaded archive {{filename|linux | + | * Extract the downloaded archive {{filename|linux-imx-rel_imx_4.9.x_1.0.0_ga.tar.gz}} |
<pre> | <pre> | ||
cd /home/development/cl-som-imx7/kernel | cd /home/development/cl-som-imx7/kernel | ||
− | tar xpf /path/to/downloaded/linux | + | tar xpf /path/to/downloaded/linux-imx-rel_imx_4.9.x_1.0.0_ga.tar.gz |
− | mv | + | mv linux-imx-rel_imx_4.9.x_1.0.0_ga linux-cl-som-imx7 |
</pre> | </pre> | ||
* Apply the CL-SOM-iMX7 patch | * Apply the CL-SOM-iMX7 patch | ||
<pre> | <pre> | ||
cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7 | cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7 | ||
− | patch -p1 < /path/to/cl-som-imx7-linux/kernel/linux-4. | + | patch -p1 < /path/to/cl-som-imx7-linux/kernel/linux-4.9.11-cl-som-imx7-*.patch |
</pre> | </pre> | ||
− | + | --> | |
==== Git clone ==== | ==== Git clone ==== | ||
* Install [http://git-scm.com/ git] version control system. | * Install [http://git-scm.com/ git] version control system. | ||
− | * Create a clone of the | + | * Create a clone of the NXP Linux kernel tree |
<pre> | <pre> | ||
cd /home/development/cl-som-imx7/kernel | cd /home/development/cl-som-imx7/kernel | ||
− | git clone | + | git clone https://github.com/nxp-imx/linux-imx.git linux-cl-som-imx7 |
</pre> | </pre> | ||
− | * Create a branch for CL-SOM-iMX7 development. The CL-SOM-iMX7 patches are generated vs. [ | + | * Create a branch for CL-SOM-iMX7 development. The CL-SOM-iMX7 patches are generated vs. [https://source.codeaurora.org/external/imx/linux-imx/tag/?h=rel_virt_4.14.98_4.11_0.10_ga rel_virt_4.14.98_4.11_0.10_ga] tag in the Linux tree. It is recommended to use exactly the same baseline to avoid merge conflicts. |
<pre> | <pre> | ||
cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7 | cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7 | ||
− | git checkout -b development | + | git checkout -b development rel_virt_4.14.98_4.11_0.10_ga |
</pre> | </pre> | ||
* Apply the CL-SOM-iMX7 patch | * Apply the CL-SOM-iMX7 patch | ||
<pre> | <pre> | ||
− | git am /path/to/cl-som-imx7- | + | git am /path/to/cl-som-imx7-bsp-src/kernel/patches/*.patch |
</pre> | </pre> | ||
Line 54: | Line 54: | ||
export ARCH=arm | export ARCH=arm | ||
export CROSS_COMPILE=arm-none-linux-eabi- | export CROSS_COMPILE=arm-none-linux-eabi- | ||
− | export DTB= | + | export DTB=$(ls -al arch/arm/boot/dts | awk '(/imx7d-.*imx7.*\.dts$/)&&($0=$NF)$$(gsub(/dts/,"dtb"))') |
make compulab_imx7_defconfig | make compulab_imx7_defconfig | ||
make menuconfig | make menuconfig | ||
Line 65: | Line 65: | ||
* 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 | + | When 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 ==== | ||
Line 93: | Line 93: | ||
==== Prepare kernel and modules tarball ==== | ==== 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 | + | * In the example below, the Linux kernel and modules are packed into the tar archive for deploying onto the CL-SOM-iMX7 on-board eMMC storage. |
<pre> | <pre> | ||
# mkdir -p /home/development/cl-som-imx7/rootfs/boot | # mkdir -p /home/development/cl-som-imx7/rootfs/boot | ||
Line 100: | Line 100: | ||
# 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 --keep-directory-symlink -C /home/development/cl-som-imx7/rootfs -czvf /home/development/cl-som-imx7/linux-image-cl-som-imx7.tar.gz . |
</pre> | </pre> | ||
Line 108: | Line 108: | ||
The extended interface support depends on carrier board used and thus is implemented in the Single Board Computer device tree files: | The extended interface support depends on carrier board used and thus is implemented in the Single Board Computer device tree files: | ||
* {{filename|imx7d-sbc-imx7.dtb}} - for SBC-iMX7 Single Board Computer | * {{filename|imx7d-sbc-imx7.dtb}} - for SBC-iMX7 Single Board Computer | ||
− | |||
− | |||
** {{filename|imx7d-sbc-imx7-m4.dtb}} - for SBC-iMX7 Single Board Computer with Cortex-M4 core support | ** {{filename|imx7d-sbc-imx7-m4.dtb}} - for SBC-iMX7 Single Board Computer with Cortex-M4 core support | ||
− | * {{filename|imx7d-sbc-iot-imx7.dtb}} - for IOT-GATE-iMX7 | + | ** {{filename|imx7d-sbc-imx7-lvds.dtb}} - device tree blob for SBC-iMX7 Single Board Computer with LVDS support |
+ | * {{filename|imx7d-sbc-iot-imx7.dtb}} - for IOT-GATE-iMX7 IoT Gateway and SBC-IOT-iMX7 Single Board Computer | ||
** {{filename|imx7d-sbc-iot-imx7-can.dtb}} - for IOT-GATE-iMX7 and SBC-IOT-iMX7 with CAN bus support | ** {{filename|imx7d-sbc-iot-imx7-can.dtb}} - for IOT-GATE-iMX7 and SBC-IOT-iMX7 with CAN bus support | ||
− | + | ** {{filename|imx7d-sbc-iot-imx7-rs485-hdx.dtb}} - for IOT-GATE-iMX7 and SBC-IOT-iMX7 with RS485 half duplex support | |
− | |||
− | * {{filename|imx7d-sbc- | ||
These files contain: | These files contain: | ||
* default setup of multi-functional pins; | * default setup of multi-functional pins; | ||
* registration of the devices integrated in the CL-SOM-iMX7 module; | * registration of the devices integrated in the CL-SOM-iMX7 module; | ||
* definitions of platform-specific configuration for these devices. | * definitions of platform-specific configuration for these devices. | ||
+ | <br> | ||
+ | Alternative DTS file with additional peripherals: [https://github.com/compulab-yokneam/linux-nxp-compulab/blob/cl-som-imx7/next/arch/arm/boot/dts/imx7d-sbc-imx7.dts imx7d-sbc-imx7.dtb]. | ||
== Deploying the CL-SOM-iMX7 kernel and modules onto eMMC == | == Deploying the CL-SOM-iMX7 kernel and modules onto eMMC == | ||
Line 129: | Line 128: | ||
* Use the below command to mount the boot partition for installing the CL-SOM-iMX7 Linux kernel binary: | * Use the below command to mount the boot partition for installing the CL-SOM-iMX7 Linux kernel binary: | ||
<pre> | <pre> | ||
− | # boot_partition= | + | # boot_partition=$(boot_partition=$(findmnt -o SOURCE -n /); cat <<< ${boot_partition:0:-1}1) |
# mount $boot_partition /boot | # mount $boot_partition /boot | ||
</pre> | </pre> | ||
Line 144: | Line 143: | ||
* 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 / --keep-directory-symlink -xvf /root/linux-image-cl-som-imx7.tar.gz |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
− | == | + | == Device Tree Examples == |
− | + | The provided device tree in the BSP package is no using all the interfaces in the evaluation board. | |
== See also == | == See also == |
Latest revision as of 13:20, 25 April 2023
Contents
Overview
The CL-SOM-iMX7 Linux kernel provides support for on-board peripherals/interfaces of the CL-SOM-iMX7 System-on-Module and the following CompuLab products built around CL-SOM-iMX7:
- SBC-iMX7 Single Board Computer
- SBC-IOT-iMX7 Internet of Things Single Board Computer
- IOT-GATE-iMX7 Internet of Things Gateway
BSP packages for different CompuLab i.MX7 devices may differ from each other. It is recommended to use the most recent BSP package released for the specific device being used. It can be downloaded from the corresponding product web page:
- CL-SOM-iMX7 System-on-Module BSP package
- SBC-iMX7 Single Board Computer BSP package
- SBC-IOT-iMX7 Single Board Computer BSP package
- IOT-GATE-iMX7 IoT Gateway BSP package
Unzip the downloaded BSP source package to a directory on your host workstation. The following instructions use /path/to/cl-som-imx7-bsp-src/ template for this location. Please use the real path to the Linux package instead.
Building kernel for CL-SOM-iMX7
Getting kernel sources
Linux git tree can be cloned from the NXP GitHub. The instructions below assume that the /home/development/cl-som-imx7/kernel directory has been created for CL-SOM-iMX7 kernel development.
Git clone
- Install git version control system.
- Create a clone of the NXP Linux kernel tree
cd /home/development/cl-som-imx7/kernel git clone https://github.com/nxp-imx/linux-imx.git linux-cl-som-imx7
- Create a branch for CL-SOM-iMX7 development. The CL-SOM-iMX7 patches are generated vs. rel_virt_4.14.98_4.11_0.10_ga tag 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_virt_4.14.98_4.11_0.10_ga
- Apply the CL-SOM-iMX7 patch
git am /path/to/cl-som-imx7-bsp-src/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=$(ls -al arch/arm/boot/dts | awk '(/imx7d-.*imx7.*\.dts$/)&&($0=$NF)$$(gsub(/dts/,"dtb"))') make compulab_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 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/dts/ # 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 on-board eMMC storage.
# 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/ # cd /home/development/cl-som-imx7/kernel/linux-cl-som-imx7/arch/arm/boot/dts/ # cp -v ${DTB} /home/development/cl-som-imx7/rootfs/boot/ # cd - # tar --keep-directory-symlink -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-cl-som-imx7.dtb file of the Linux kernel source tree. The extended interface support depends on carrier board used and thus is implemented in the Single Board Computer device tree files:
- imx7d-sbc-imx7.dtb - for SBC-iMX7 Single Board Computer
- imx7d-sbc-imx7-m4.dtb - for SBC-iMX7 Single Board Computer with Cortex-M4 core support
- imx7d-sbc-imx7-lvds.dtb - device tree blob for SBC-iMX7 Single Board Computer with LVDS support
- imx7d-sbc-iot-imx7.dtb - for IOT-GATE-iMX7 IoT Gateway and SBC-IOT-iMX7 Single Board Computer
- imx7d-sbc-iot-imx7-can.dtb - for IOT-GATE-iMX7 and SBC-IOT-iMX7 with CAN bus support
- imx7d-sbc-iot-imx7-rs485-hdx.dtb - for IOT-GATE-iMX7 and SBC-IOT-iMX7 with RS485 half duplex support
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.
Alternative DTS file with additional peripherals: imx7d-sbc-imx7.dtb.
Deploying the CL-SOM-iMX7 kernel and modules onto eMMC
- Boot up the CL-SOM-iMX7 computer.
- Copy the previously created linux-image-cl-som-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=$(boot_partition=$(findmnt -o SOURCE -n /); cat <<< ${boot_partition:0:-1}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* /boot/*.dtb /boot/`uname -r`/
Installing kernel and modules
Assuming that the linux-image-cl-som-imx7.tar.gz tar ball has been copied to the CL-SOM-iMX7 /root directory.
- Extract and install the Linux kernel binary:
# tar -C / --keep-directory-symlink -xvf /root/linux-image-cl-som-imx7.tar.gz
Device Tree Examples
The provided device tree in the BSP package is no using all the interfaces in the evaluation board.
See also
- CL-SOM-iMX7: Evaluation Kit: Getting Started
- CL-SOM-iMX7: Evaluation Kit: Hardware Guide
- CL-SOM-iMX7: Linux: Automatic Installation
- CL-SOM-iMX7: Linux: Manual Installation
- CL-SOM-iMX7: Linux: Debian
- Linux: Development for ARM modules
- Linux: Debian: Minimal ARM filesystem
- Debian Reference.
- ALSA project official website