Linux kernel has contributors worldwide and is free and opensource.The Kernel can also be modified , it is used in lot of embedded devices and android devices which uses modified Linux as it’s operating system.Google is developing it’s own kernel Zircon and Fuchsia an alternative to android removing the dependency of Linux kernel but the stability and the large community of Linux will make it stand against other kernels at least for another decade.
The Linux kernel can be tested using TFTP boot which is uses TFTP protocol to boot the Image on the embedded device making it easier to test on the device and the kernel image will be available on the device only on a particular boot cycle.
Building the Kernel Image
The kernel Image can be downloaded form here .
$sudo apt install kernel-wedge quilt bc
If the kernel image is built for a different architecture it should be cross compiled and the compilers chains must be downloaded separately for the arm32 gnu c compiler install the package
$sudo apt-get install gcc-arm-*
for arm64 gnu c compiler install the package
$sudo apt-get install gcc-aarch64-linux-gnu
Before building the kernel you should know the config file for your particular board . The config file contains the list of modules / drivers to be installed and you can change the config based on the requirements of your board.This config file is present in the location arch/”architecture”/configs in the Linux source tree.
The multiple available configurations in kernel are
config – to create a new configuration from scratch
defconfig – new configuration with default answers to all configuration options
oldconfig -update the current config using provided .config file as the base.
menuconfig- console based configuration .
$make -j$(proc) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
After building the config file next step is to build the kernel which is using the command
$make -j$(proc) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LOADADDR=0x10008000 Image
The Load address is the address in RAM where the kernel is copied to RAM from the boot device.This address can be obtained from the U-boot environment variable using ‘prinenv’ in u-boot shell
The stripped Image after the build will be available in the directory /arch/”Architecture”/boot/Image along with the DTB file in /arch/”Architecture”/boot/dts/ for the board is used for TFTP boot. The DTB file contains the device tree blob which is obtained from the dts file in location /arch/”Architecture”/boot/dts/ containing the information about the hardware which needs to be passed to the kernel.
Setting up of TFTP Server on the Ubuntu
$sudo apt update; sudo apt install tftp-hpa tftpd-hpa
$vi /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
#use the /home/user direct
TFTP_DIRECTORY="/home/user/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"
$sudo /etc/init.d/tftpd-hpa restart
attach the ethernet cable from your board to Ubuntu and configure your ip such that the board and Ubuntu are in the same subnet.
=>usb start
[ 80.672131] USB0: USB EHCI 1.10
[ 80.680641] scanning bus 0 for devices... 3 USB Device(s) found
[ 82.047929] scanning usb for storage devices... 0 Storage Device(s) found
[ 82.055644] scanning usb for ethernet devices... 1 Ethernet Device(s) found
=>set ipaddr 172.17.0.4
=>set serverip 172.17.0.10[ip set in Ubuntu]
=>ping 172.17.0.10 [the ip set in Ubuntu ]
[ 151.951410] host 172.17.0.10 is alive
=>tftp 0x48080000 Image
[ 174.983148] TFTP from server 172.17.0.10; our IP address is 172.17.0.4
[ 174.989955] Filename 'Image'.
[ 174.993041] Load address: 0x48080000
[ 174.996762] Loading: #################################################################
[ 177.646939] #################################################################
[ 180.311269] #################################################################
[ 182.917569] #################################################################
[ 185.525865] #################################################################
[ 188.141173] #################################################################
[ 190.818506] #################################################################
[ 193.494837] #################################################################
[ 196.129155] #################################################################
[ 198.743457] #################################################################
[ 201.359762] #################################################################
[ 203.980066] #################################################################
[ 206.608378] ###################################################
[ 208.648391] 353.5 KiB/s
[ 208.651113] done
[ 208.653019] Bytes transferred = 12189704 (ba0008 hex)
=>tftp 0x48000000 devicetree.dtb
[ 228.236692] TFTP from server 172.17.0.10; our IP address is 172.17.0.4
[ 228.243499] Filename 'devicetree.dtb'.
[ 228.249489] Load address: 0x48000000
[ 228.253210] Loading: #########
[ 228.600337] 340.8 KiB/s
[ 228.603060] done
[ 228.604966] Bytes transferred = 120607 (1d71f hex)
=>booti 0x48080000 - 0x48000000
[ 239.293480] ## Flattened Device Tree blob at 48000000
[ 239.298744] Booting using the fdt blob at 0x48000000
[ 239.304189] reserving fdt memory region: addr=48000000 size=40000
[ 239.310960] Using Device Tree in place at 0000000048000000, end 000000004802071e
[ 239.318946]
[ 239.321653] Starting kernel ...
[ 239.324920]
