Yocto Build Linux TI

From Variscite Wiki
Revision as of 17:29, 26 April 2023 by Nate (talk | contribs)
Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release am62-yocto-dunfell-5.10.168_08.06.00.42-v1.0.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
Yocto Build Linux from source code - VAR-SOM-AM62

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-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz && \
   tar -Jxvf gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz -C $HOME && \
   wget https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz && \
   tar -Jxvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz -C $HOME

Fetch Source Code

Setup a working directory

$ export WORKDIR=~/am62x-var-som-linux
$ mkdir ${WORKDIR}

Fetch the Linux source:

$ cd $WORKDIR
$ git clone https://github.com/varigit/ti-linux-kernel -b ti-linux-5.10.y_var01 ti-linux-kernel

Build Linux out of Yocto tree

After fetching the source code and installing dependencies, you may return to $WORKDIR anytime and follow these steps to build Linux:

Setup the environment:

Export the working directory

$ export WORKDIR=~/am62x-var-som-linux

Export variables for building Linux

$ export PATH=$HOME/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin:$PATH

Build for GP am62 SoC:

Change to kernel directory:

$ cd $WORKDIR/ti-linux-kernel

Configure the Kernel:

Clean directory:
$ make mrproper

Create .config from am62x_var_defconfig
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) 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) am62x_var_defconfig
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) savedefconfig
$ cp defconfig arch/arm64/configs/am62x_var_defconfig

Build Kernel:

Build All:
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc)

Build Image only:
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) Image

Build modules only:
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) modules

Build device trees only:
$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) dtbs

Install new kernel

Change to kernel directory:

$ cd $WORKDIR/ti-linux-kernel

Create a directory to install the kernel, device trees, and modules:

Optional: delete any old installation from previous builds:
$ rm -rf $WORKDIR/rootfs

Create new directory:
$ mkdir -p $WORKDIR/rootfs/boot


Copy the Image and device trees to the rootfs:

$ cp arch/arm64/boot/Image $WORKDIR/rootfs/boot/
$ cp arch/arm64/boot/dts/ti/k3*am*var-som*.dtb $WORKDIR/rootfs/boot/

Install the modules to the rootfs:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- -j$(nproc) modules_install INSTALL_MOD_PATH=$WORKDIR/rootfs

You can install $WORKDIR/rootfs to a running device:

Option 1: Copy to a local SD card mounted at /media/user/rootfs/:
$ sudo cp -r $WORKDIR/rootfs/* /media/user/rootfs/

Option 2: Copy to a running device over ethernet
$ tar czf - -C $WORKDIR/rootfs . | ssh root@<ip address> 'tar xzf - -C /'