Build Linux from source code¶
Toolchain Installation for Out of FlexBuild Builds¶
To install the toolchain, follow the Debian FlexBuild Toolchain installation guide.
Set Up the Environment¶
Set up a working directory:
Define the cross-compiler and the architecture:
Build Linux Out of the FlexBuild Tree¶
Fetch linux-imx Source Code¶
Build Kernel, Modules, and DTBs¶
Clean and prepare the kernel:
Customize the kernel configuration, if required:
Build the kernel image, modules, and device trees:
Build individual parts as needed:
The following device trees are generated:
| Device Tree Name | Model |
|---|---|
imx7d-var-som-emmc.dtb |
VAR-SOM-MX7 with eMMC |
imx7d-var-som-emmc-wm8731.dtb |
VAR-SOM-MX7 with eMMC and WM8731 audio codec |
imx7d-var-som-emmc-m4.dtb |
VAR-SOM-MX7 with eMMC and Cortex-M4 support |
imx7d-var-som-emmc-m4-wm8731.dtb |
VAR-SOM-MX7 with eMMC, Cortex-M4 support, and WM8731 audio codec |
imx7d-var-som-nand.dtb |
VAR-SOM-MX7 with NAND flash |
imx7d-var-som-nand-wm8731.dtb |
VAR-SOM-MX7 with NAND flash and WM8731 audio codec |
imx7d-var-som-nand-m4.dtb |
VAR-SOM-MX7 with NAND flash and Cortex-M4 support |
imx7d-var-som-nand-m4-wm8731.dtb |
VAR-SOM-MX7 with NAND flash, Cortex-M4 support, and WM8731 audio codec |
Install Kernel Modules to a Temporary Directory¶
Create a temporary directory to install the modules:
Install the modules to the temporary rootfs:
cd ${WORKDIR}/linux-imx
make ARCH=arm \
INSTALL_MOD_STRIP=1 \
INSTALL_MOD_PATH=${WORKDIR}/rootfs \
modules_install
If you replace the kernel image on your system, reinstall the matching kernel modules as well.
Install Built Kernel Artifacts on an SD Card¶
Copy the kernel image and device trees to the SD card boot partition, and
install the modules in the SD card rootfs partition. The examples below assume
the boot partition is mounted on /media/user/BOOT and the rootfs partition is
mounted on /media/user/rootfs.
cd ${WORKDIR}/linux-imx
sudo cp arch/arm/boot/zImage /media/user/BOOT/
sudo cp arch/arm/boot/dts/nxp/imx/imx7d-var-som*.dtb /media/user/BOOT/
sudo cp -a ${WORKDIR}/rootfs/* /media/user/rootfs/
sync
Notes:
- If you are using the Debian Recovery SD card
and you want the eMMC/NAND installation process to use the updated kernel
artifacts, update
/opt/images/Debianon the SD card as well. - Properly unmount the SD card before physically removing it.