Debian Customizing Linux kernel AM62

From Variscite Wiki
Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release am62-debian-bookworm-6.1.83_09.02.01.10-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
VAR-SOM-AM62 - Debian Customize from source code

Introduction

The kernel is deployed as a Debian package during the build process. If there are changes to the kernel source code or configurations, the kernel must be recompiled with the updated changes using the ti-debian repository. Once recompiled, the updated Debian package for the kernel should be uploaded to the Debian package server.

Use your own remote repository on GitHub

Create your own GitHub account and fork the three repo to a new repository:

For example, you can fork our repository to your own account by visiting the following link and clicking on "Fork" at the top right of the screen.
Alternatively, you can clone our repository to your local machine, and push it later to your own account.

https://github.com/varigit/ti-linux-kernel/tree/ti-linux-6.1.y_09.02.01.10_var01

https://github.com/varigit/ti-debian-repos/tree/bookworm-09.02.01.10-var01

https://github.com/varigit/var-debpkgs/tree/master


Note: Don't forget to make your fork of var-debpkgs accessible via "GitHub Pages", according GitHub Docs.

After forking the repository to your account, clone the kernel source code from your fork. Then, create a build directory:

$ mkdir ~/am62_debian_kernel
$ cd ~/am62_debian_kernel
$ git clone https://github.com/xxxx/ti-linux-kernel -b your_branch_name
$ cd ti-linux-kernel

edit any file or modify kernel configuration and save it.

$ git add "modified_file_path"
$ git commit -a -m "my_am62x_var_som_changes"
$ git push origin your_branch_name
Get the latest commit hash:
$ git rev-parse HEAD

Assume the latest commit hash is a1fcfd378e2364c15981945cca609c3a5fc12386.

$ cd ~/am62_debian_kernel
$ git clone https://github.com/xxxx/var-debpkgs -b your_branch_name
$ git clone https://github.com/xxxx/ti-debian-repos -b your_branch_name
$ cd ti-debian-repos

Also update the repository name on ti-debian-repos repo. open the file ~/am62_debian_kernel/ti-debian-repos/ti-linux-kernel-variscite/version.sh and change to the corresponding forked kernel repo.

$ export git_repo="https://github.com/xxxx/ti-linux-kernel.git"
$ ./ti-linux-kernel-variscite/update-commit.py ./ti-linux-kernel-variscite/suite/bookworm/debian/ 6.1.83 a1fcfd378e2364c15981945cca609c3a5fc12386  "Author Name <author_name@xxx.com>"

After the modifications push the changes to the forked https://github.com/xxxx/ti-debian-repos repo.

$ git add "modified_file_path"
$ git commit -a -m "update repo name & latest hash of kernel" 
$ git push origin your_branch_name  #origin should be ti-debian-repos that is forked on your account

Build Kernel

Before building the kernel, follow the steps in Build the Debian image. As part of building the image, the root filesystem (rootfs) needs to be extracted into a folder and used as the target for the chroot command.

$ mkdir -p ~/rootfs
$ sudo tar -xvf ~/debian_am62x_var_som/ti-bdebstrap/build/am62-bookworm-09.02.01.010_var01/tisdk-am62-bookworm-variscite-am62xx-var-som-rootfs.tar.xz -C ~/rootfs
$ . ~/am62_debian_kernel/ti-debian-repos/chroot.sh -r ~/rootfs/tisdk-am62-bookworm-variscite-am62xx-var-som-rootfs

this will enter into another terminal

$ apt update && apt install git build-essential linux-source bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves bison devscripts
$ cd /workdir
$ DEB_SUITE=bookworm ./run.sh ti-linux-kernel-variscite
$ exit;
$ cp ~/am62_debian_kernel/ti-debian-repos/build/bookworm/ti-linux-kernel-variscite/*.deb ~/am62_debian_kernel/var-debpkgs/var-ti/pool/bookworm/l/
$ cd ~/am62_debian_kernel/var-debpkgs
$ ./update-ppa.sh

this will update the new .deb package with updated kernel changes. Then push the changes to your corresponding var-debpkgs repo. E.g https://github.com/xxxx/var-debpkgs

$ git add "modified_file_path"
$ git commit -a -m "update kernel deb packages" 
$ git push origin your_branch_name  #origin should be var-debpkgs that is forked on your account

Update the ti-bdebstrap to fetch the latest kernel debian package

$ vi ~/debian_am62x_var_som/ti-bdebstrap/configs/bdebstrap_configs/am62-bookworm-variscite.yaml

Update the kernel image and headers with the new hash. Rebuilding the Debian image will then install the latest kernel Debian packages.

- linux-image-6.1.83-k3-var3+ef02b21f5d6fe1b1cd5678b0ad50f442a0fe8c8a-1
- linux-headers-6.1.83-k3-var3+ef02b21f5d6fe1b1cd5678b0ad50f442a0fe8c8a-1
+ linux-image-6.1.83-k3-var4+a1fcfd378e2364c15981945cca609c3a5fc12386-1
+ linux-headers-6.1.83-k3-var4+a1fcfd378e2364c15981945cca609c3a5fc12386-1

Then update the variscite debian package github server to your own forked debian package server.

- 'echo "deb [trusted=yes] https://varigit.github.io/var-debpkgs/var bookworm main" | sudo tee $1//etc/apt/sources.list.d/var.list'
- 'echo "deb [trusted=yes] https://varigit.github.io/var-debpkgs/var-ti bookworm main" | sudo tee $1//etc/apt/sources.list.d/var-ti.list'
- 'echo "deb [trusted=yes] https://varigit.github.io/var-debpkgs/am62x-var-som bookworm main" | sudo tee $1//etc/apt/sources.list.d/am62x-var-som.list'
+ 'echo "deb [trusted=yes] https://xxxx.github.io/var-debpkgs/var bookworm main" | sudo tee $1//etc/apt/sources.list.d/var.list'
+ 'echo "deb [trusted=yes] https://xxxx.github.io/var-debpkgs/var-ti bookworm main" | sudo tee $1//etc/apt/sources.list.d/var-ti.list'
+ 'echo "deb [trusted=yes] https://xxxx.github.io/var-debpkgs/am62x-var-som bookworm main" | sudo tee $1//etc/apt/sources.list.d/am62x-var-som.list'
- 'printf "Package: *\nPin: origin varigit.github.io/\nPin-Priority: 1002" >> $1/etc/apt/preferences.d/var'
- 'printf "Package: *\nPin: origin varigit.github.io/\nPin-Priority: 1003" >> $1/etc/apt/preferences.d/var-ti'
- 'printf "Package: *\nPin: origin varigit.github.io/\nPin-Priority: 1004" >> $1/etc/apt/preferences.d/am62x-var-som'
+ 'printf "Package: *\nPin: origin xxxx.github.io/\nPin-Priority: 1002" >> $1/etc/apt/preferences.d/var'
+ 'printf "Package: *\nPin: origin xxxx.github.io/\nPin-Priority: 1003" >> $1/etc/apt/preferences.d/var-ti'
+ 'printf "Package: *\nPin: origin xxxx.github.io/\nPin-Priority: 1004" >> $1/etc/apt/preferences.d/am62x-var-som'

After updating all the changes , Follow the steps to Build the Debian image

This is the procedure to be followed to add custom packages or modifying any Variscite or TI packages.