Compile Linux Source Code

2024.1.22by debix.io

Compile linux source code steps:

1.Install the dependent packages

sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev


2.Install the cross-compiler:

sudo mkdir /opt/toolchain

cd /opt/toolchain

sudo wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz

tar xpf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz


3.Export the cross-compilation environment variables:

export CROSS_COMPILE=/opt/toolchain/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-

export ARCH=arm64


4.Download the source code:

git clone --depth=1 --branch <branch> https://github.com/debix-tech/linux

<branch> has two branches: debix and SOM_A_IO_BOARD.

debix branch supports DEBIX Model A and DEBIX Model B:

Command: git clone --depth=1 --branch debix https://github.com/debix-tech/linux

SOM_A_IO_BOARD branch supports DEBIX SOM A I/O Board

Command: git clone --depth=1 --branch SOM_A_IO_BOARD https://github.com/debix-tech/linux


5.To generate the kernel default configuration file:

cd linux-debix

make imx_v8_defconfig


6.Compile the kernel source code:

make -j4


7.Compile kernel modules

make modules


8.Install the kernel module to the out directory

make INSTALL_MOD_STRIP=1 modules_install  INSTALL_MOD_PATH=out

Check if the kernel modules you need to compile are already installed in the out folder.

cd linux-debix/out/lib/modules/5.10.72


9.Location of image files and device tree files

linux-debix/arch/arm64/boot/image

linux-debix/arch/arm64/boot/dts/freescale/imx8mp-evk.dtb

linux-debix/arch/arm64/boot/dts/freescale/imx8mp-debix-lora-board.dtb


10.Update the module kernel to debix

Run the command on DEBIX:

sudo scp @<Server Ip>:/linux-debix/out/lib/modules/5.10.72 /lib/modules