Yocto Build Linux from source code -¶
Introduction¶
This guide walks through the process for manually building and installing Linux from source. It is derived from TI's Build Linux guide.
Fetch source code and install dependencies¶
This section describes the one-time process to install the toolchains and fetch the necessary source code for building Linux.
Install toolchains to home directory¶
cd ~
wget https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz && \
tar -Jxvf arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz -C $HOME && \
wget https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz && \
tar -Jxvf arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz -C $HOME
Fetch source code¶
Set up a working directory
Fetch the Linux source:
cd $WORKDIR
git clone https://github.com/varigit/ti-linux-kernel -b ti-linux-6.12.y_11.00.09.04_var01 ti-linux-kernel
Fetch the kernel driver for the PowerVR Rogue GPU:
cd $WORKDIR
git clone https://git.ti.com/cgit/graphics/ti-img-rogue-driver -b linuxws/scarthgap/k6.12/24.2.6643903 ti-img-rogue-driver
cd ti-img-rogue-driver && \
git checkout 3bcbba9708fe6a882cd0f4820469d026fff7aee5 && \
cd ../
Fetch the kernel driver for the iw61x wifi:
cd $WORKDIR
git clone https://github.com/nxp-imx/mwifiex -b lf-6.12.20_2.0.0 mwifiex
cd mwifiex && \
git checkout 7a8beaa1605cb0870dc7ba3312c76df91cb0d6cf && \
cd ../
Build Linux outside the Yocto tree¶
After fetching the source code and installing dependencies, you may return to $WORKDIR anytime and follow these steps to build Linux:
Set up the environment:¶
Export the working directory
Export variables for building Linux
Build kernel image, modules, and device trees:¶
Change to kernel directory:
Configure the Kernel:
Clean directory:
Create .config from am62x_var_defconfig
Optional: Make changes to .config and save to am62x_var_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) menuconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) savedefconfig
cp defconfig arch/arm64/configs/am62x_var_defconfig
Build kernel:
Build All:
Build Image only:
Build modules only:
Build device trees only:
Build kernel drivers for the PowerVR Rogue GPU:
cd ${WORKDIR}/ti-img-rogue-driver
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) \
KERNELDIR=${WORKDIR}/ti-linux-kernel \
BUILD=release PVR_BUILD_DIR=am62p_linux \
WINDOW_SYSTEM=lws-generic
Build kernel driver for the iw61x wifi:
cd ${WORKDIR}/mwifiex
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) KERNELDIR=${WORKDIR}/ti-linux-kernel
Install new kernel¶
Create a directory to install the kernel, device trees, and modules:
Optional: delete any old installation from previous builds:
Create new directory:
Copy the Image and device trees to the rootfs:
cd $WORKDIR/ti-linux-kernel
cp arch/arm64/boot/Image $WORKDIR/rootfs/boot/
cp arch/arm64/boot/dts/ti/k3*am*var-som*.dtb $WORKDIR/rootfs/boot/dtb/
Install the modules to the rootfs:
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) \
modules_install INSTALL_MOD_PATH=$WORKDIR/rootfs/usr
Install the GPU driver to the rootfs:
cd $WORKDIR/ti-img-rogue-driver
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) \
KERNELDIR=${WORKDIR}/ti-linux-kernel \
BUILD=release PVR_BUILD_DIR=am62p_linux \
-C ${WORKDIR}/ti-linux-kernel M=${WORKDIR}/ti-img-rogue-driver/binary_am62_linux_lws-generic_release/target_aarch64/kbuild \
INSTALL_MOD_PATH=${WORKDIR}/rootfs/usr \
modules_install
Install the iw61x wifi driver to the rootfs:
cd $WORKDIR/mwifiex
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) \
KERNELDIR=${WORKDIR}/ti-linux-kernel \
-C ${WORKDIR}/ti-linux-kernel M=${WORKDIR}/mwifiex \
INSTALL_MOD_PATH=${WORKDIR}/rootfs/usr \
INSTALL_MOD_STRIP=1 \
modules_install
Deploy new kernel¶
You can deploy $WORKDIR/rootfs to a running device:
Option 1: Copy to a local SD card mounted at /media/user/rootfs/:
Option 2: Copy to a running device over Ethernet