- 29 Nov 2021
- 2 Minutes to read
How to Rebuild and Install the Kernel and Kernel Modules on Ubuntu
- Updated on 29 Nov 2021
- 2 Minutes to read
This article requires an update as it pertains to older revisions of hardware and software.
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.
- PICO-IMX6 (revision A)
- EDM1-IMX6 (revision A)
- PICO-IMX7 (revision A)
Download and install the toolchain by following the steps in this article:
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 Version||Supported SOM||Kernel Branch|
|16.04||EDM1-IMX6, PICO-IMX6, PICO-IMX6UL, PICO-IMX7 revision A||tn-imx_4.1.15_2.0.0_ga|
Set up the kernel using the default TechNexion kernel configuration:
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:
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.
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:
List of device tree names:
|Pico-imx6 Dual Lite or Solo||Pico-Pi||imx6dl-pico_pi.dtb|
|Pico-imx6 Dual Lite or Solo||Pico-Nymph||imx6dl-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:
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 email@example.com:~/tmp scp arch/arm/boot/dts/imx6q-pico_pi.dtb firstname.lastname@example.org:~/tmp scp modules_temp/lib/modules/modules.tar.gz email@example.com:~/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:
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.