-
Notifications
You must be signed in to change notification settings - Fork 4
How to cross build an official Debian kernel package for Lenovo ix4‐300d
- A Debian Bookworm machine with at least 25 GB of free space
sudo apt install fakeroot git kernel-wedge quilt ccache flex bison libssl-dev dh-exec rsync libelf-dev bc crossbuild-essential-armhf python3-jinja2 libncurses-dev
Check the latest kernel version for Bookworm here https://tracker.debian.org/pkg/linux
The latest kernel version is 6.1.99 as off today.
wget https://deb.debian.org/debian/pool/main/l/linux/linux_6.1.99.orig.tar.xz
git clone -n https://salsa.debian.org/kernel-team/linux.git debian-kernel
cd debian-kernel
git checkout bookworm
cd ..
Create the following script one level above debian-kernel
an run it.
# This triplet is defined in
# https://salsa.debian.org/kernel-team/linux/tree/master/debian/config/armhf/
ARCH=armhf
FEATURESET=none
FLAVOUR=armmp-lpae
cd debian-kernel
export $(dpkg-architecture -a$ARCH)
export PATH=/usr/lib/ccache:$PATH
# Build profiles is from: https://salsa.debian.org/kernel-team/linux/blob/master/debian/README.source
export DEB_BUILD_PROFILES="cross nopython nodoc pkg.linux.notools"
# Enable build in parallel
export MAKEFLAGS="-j$(($(nproc)*2))"
# Disable -dbg (debug) package is only possible when distribution="UNRELEASED" in debian/changelog
export DEBIAN_KERNEL_DISABLE_DEBUG=
[ "$(dpkg-parsechangelog --show-field Distribution)" = "UNRELEASED" ] &&
export DEBIAN_KERNEL_DISABLE_DEBUG=yes
# Remove any compiled binaries, temporary files, and other generated artifacts, preparing the directory for a fresh build.
fakeroot make -f debian/rules clean
# Unpack the original tarball ../linux_X.Y.Z.orig.tar.xz) in ../orig
fakeroot make -f debian/rules orig
# Add the missing config for enable leds
echo "CONFIG_GPIO_74X164=m" >> debian/config/config
fakeroot make -f debian/rules source
# Setup the build environment for a particular architecture, feature set, and flavour.
fakeroot make -f debian/rules.gen setup_${ARCH}_${FEATURESET}_${FLAVOUR}
# Builds the architecture-specific binary package for the specified architecture, feature set, and flavour.
# It compiles the source code into binaries and packages them into a Debian package file.
fakeroot make -f debian/rules.gen binary-arch_${ARCH}_${FEATURESET}_${FLAVOUR}
cd ..
Copy the file on ix4-300d
and install it using using dpkg
just as any other package. The following commands must be executed on ix4-300d
.
dpkg -i linux-image-6.1.99-1_armhf-lpae.deb
This command will unpack the kernel, generate the initrd if necessary, and configure the standard bootloader to make the newly installed kernel the default one.
U-Boot bootloader needs 2 additional files: uImage
and uInitrd
. Create them with the following commands:
cd /boot
cat vmlinuz dtb > vmlinuz_ix4_300d
mkimage -A arm -O linux -T kernel -C none -a 0x04000000 -e 0x04000000 -n "Linux Customized" -d vmlinuz_ix4_300d uImage
mkimage -A arm -O linux -T ramdisk -C none -a 0x2000000 -e 0x2000000 -n "Linux Customized" -d initrd.img uInitrd
rm vmlinuz_ix4_300d
If this command completed without any problems, you can reboot using the
reboot
command to boot the new kernel.
After reboot leds are availbale under /sys/class/leds
.