Yocto Build Linux
From Variscite Wiki
Build Linux from source code
It is recommended to build the kernel image using Yocto (see the Customizing the Linux kernel page) instead of using the direct method described in this page.
This is because some of the Yocto packages may depend on the kernel, like the WiFi module that is built from outside of the kernel source tree on some of the Yocto releases.
This is because some of the Yocto packages may depend on the kernel, like the WiFi module that is built from outside of the kernel source tree on some of the Yocto releases.
Toolchain installation for out of Yocto builds
To install the toolchain, follow the Yocto Toolchain installation guide.
Build Linux out of Yocto tree
Get the Linux source code:
$ git clone https://github.com/varigit/linux-imx.git $ cd linux-imx $ git checkout lf-5.10.y_var04
Build the Linux kernel:
$ source /opt/b2qt/3.3.6/environment-setup-cortexa53-crypto-poky-linux
$ unset LDFLAGS
$ make mrproper $ make imx8mq_var_dart_defconfig
Customize the kernel configuration (optional step): $ make menuconfig
Build everything: $ make -j4
Build Image.gz only: $ make -j4 Image.gz Build modules only: $ make -j4 modules Build device trees only: $ make -j4 dtbs
Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with SD and HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-sd-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with SD and LVDS display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-sd-lvds.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with SD and dual LVDS+HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-sd-lvds-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with WIFI and HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-wifi-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with WIFI and LVDS display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-wifi-lvds.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with WIFI and dual LVDS+HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-wifi-lvds-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with M4, SD and HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-m4-sd-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with M4, SD and dual LVDS+HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-m4-sd-lvds-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with M4, WIFI and HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-m4-wifi-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with M4, WIFI and LVDS display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-m4-wifi-lvds.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V2.x and above with M4, WIFI and dual LVDS+HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-m4-wifi-lvds-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with SD and DP display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-sd-dp.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with SD and HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-sd-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with SD and LVDS display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-sd-lvds.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with SD and dual LVDS+DP display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-sd-lvds-dp.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with SD and dual LVDS+HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-sd-lvds-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with WIFI and DP display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-wifi-dp.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with WIFI and HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-wifi-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with WIFI and LVDS display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-wifi-lvds.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with WIFI and dual LVDS+DP display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-wifi-lvds-dp.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with WIFI and dual LVDS+HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-wifi-lvds-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, SD and DP display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-sd-dp.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, SD and HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-sd-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, SD and dual LVDS+DP display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-sd-lvds-dp.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, SD and dual LVDS+HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-sd-lvds-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, WIFI and DP display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-dp.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, WIFI and HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-hdmi.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, WIFI and LVDS display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, WIFI and dual LVDS+DP display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds-dp.dtb Build only the device tree for DART-MX8M on DT8MCustomBoard V1.3/V1.4 with M4, WIFI and dual LVDS+HDMI display: $ make -j4 freescale/imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds-hdmi.dtb
Notes:
If you replace the kernel image (Image.gz) on your system, you also need to reinstall the kernel modules, and vice versa.
If you just want to make a change in the device tree, you can compile and replace it without replacing the kernel image and modules.
Install the built kernel on an SD card
Copy the Image.gz and device trees to the SD card boot partition, and install the modules in the SD card rootfs partition.
Assuming the rootfs partition is mounted on /media/user/rootfs:
Install the kernel image and modules: $ kver=$(strings arch/arm64/boot/Image | grep -i "Linux version" | awk '{print $3}') $ sudo cp arch/arm64/boot/Image.gz /media/user/rootfs/boot/Image.gz-${kver} $ sudo ln -fs /boot/Image.gz-${kver} /media/user/rootfs/boot/Image.gz $ sudo make ARCH=arm64 modules_install INSTALL_MOD_PATH=/media/user/rootfs Install the device trees: $ sudo cp arch/arm64/boot/dts/freescale/*imx*var*.dtb /media/user/rootfs/boot/