How to Rebuild and Install the Kernel and Kernel Modules on Ubuntu
  • 29 Nov 2021
  • 2 Minutes to read
  • Dark
    Light
  • PDF

How to Rebuild and Install the Kernel and Kernel Modules on Ubuntu

  • Dark
    Light
  • PDF

Article summary

Article Requires Update

This article requires an update as it pertains to older revisions of hardware and software.

Introduction

TechNexion provides Ubuntu demo images for some SOM/baseboard configurations. While these are good for initial hardware evaluation, and make installing new applications and packages easy, sometimes developers need to extend the platform by customizing the kernel and device drivers. This is a step-by-step procedure showing you how do to this.

Applicable Platforms

  • PICO-IMX6 (revision A)
  • EDM1-IMX6 (revision A)
  • PICO-IMX7 (revision A)

Download and install the toolchain by following the steps in this article:

Preparing a Toolchain

Get the kernel source code from the TechNexion Linux Git repository:

$ git clone https://github.com/TechNexion/linux.git
$ cd linux
$ git checkout

Branches used for Ubuntu demo images:

Ubuntu VersionSupported SOMKernel Branch
16.04EDM1-IMX6, PICO-IMX6, PICO-IMX6UL, PICO-IMX7 revision Atn-imx_4.1.15_2.0.0_ga

Set up the kernel using the default TechNexion kernel configuration:

make tn_imx_defconfig

Then, you can select new drivers to be included as either built-in (compiled into the kernel image) or as kernel modules using the menuconfig tool:

make menuconfig

After finishing the selection, save your configuration and build the kernel and modules:

make zImage modules

Make a temp directory for the modules. The modules_install target wants a target directory as it normally installs to a specific path in the host system.

mkdir modules_temp

Install the modules to the directory:

make modules_install INSTALL_MOD_PATH=./modules_temp`

After that is done, build the device tree for your SOM. The device tree depends on the both the SOM and SOC as well as the baseboard you are using:

make

List of device tree names:

SOMBaseboardDevice Tree
Pico-imx6 Dual Lite or SoloPico-Piimx6dl-pico_pi.dtb
Pico-imx6 QuadPico-Piimx6q-pico_pi.dtb
Pico-imx7Pico-Piimx7d-pico_pi.dtb
Pico-imx6ulPico-Piimx6ul-pico_pi.dtb
Pico-imx6ullPico-Piimx6ull-pico_pi.dtb
Pico-imx6 Dual Lite or SoloPico-Nymphimx6dl-pico_nymph.dtb
Pico-imx6 QuadPico-Nymphimx6q-pico_nymph.dtb
Pico-imx7Pico-Nymphimx7d-pico_nymph.dtb

For this article, we will assume we are building for Pico-imx6 Quad running on a Pico Pi, so the command is:

make imx6q-pico_pi.dtb

Pack up the modules into a nice .tar.gz file:

cd modules_temp/lib/modules
tar czvf modules.tar.gz *

Make a temporary directory on your target system:

cd ~
mkdir tmp

If you have the target system on your local network, you can copy the files to the target system using scp. Note that "technexion.local" represents the target name located via MDNS/Bonjour. The default username/password is ubuntu/ubuntu.

scp arch/arm/boot/zImage ubuntu@technexion.local:~/tmp
scp arch/arm/boot/dts/imx6q-pico_pi.dtb ubuntu@technexion.local:~/tmp
scp modules_temp/lib/modules/modules.tar.gz ubuntu@technexion.local:~/tmp

Alternatively, you can transfer the files using a USB flash drive if you don't have the target system on your local network. On your TARGET system: Go home:

cd

Make a directory to mount the boot partition (where we will replace the kernel and device tree file):

$ mkdir boot

Mount the partition:

sudo mount /dev/mmcblk2p1 boot

Copy the kernel:

cp tmp/zImage boot

Copy the device tree:

cp tmp/imx6q-pico_pi.dtb boot

Unpack the modules to the right directory:

cd /lib/modules
sudo tar -xzvf ~/tmp/modules.tar.gz .

Once this is all done, you should reboot the system. If everything goes well, it should come right up. If you've missed a module or two, you can always reconfigure the kernel and rebuild the modules, and transfer the modules back over.


Was this article helpful?