Environment Preparation
- Install Ubuntu 22.04.2 LTS.
- Install dependencies:
1
|
sudo apt install binfmt-support qemu-user-static gcc-10-aarch64-linux-gnu kernel-package fakeroot simg2img img2simg mkbootimg bison flex gcc-aarch64-linux-gnu pkg-config libncurses-dev libssl-dev unzip git
|
Download Source
1
|
git clone https://github.com/OpenStick/linux.git --depth=1
|
Kernel Build
CPU frequency table tuning
Edit:
linux/drivers/clk/qcom/a53-pll.c
Adjust/extend frequency entries carefully, balancing performance, power, and thermals.
Edit DTS OPP table as needed:
linux/arch/arm64/boot/dts/qcom/msm8916.dtsi
Build steps
1
2
3
4
5
|
cd linux
export CROSS_COMPILE=aarch64-linux-gnu-
export ARCH=arm64
make msm8916_defconfig
make menuconfig
|
USB serial support (for Klipper-like USB devices)
Enable relevant USB CDC ACM / USB Serial options in menuconfig.
Build packages
1
|
make -j`nproc` bindeb-pkg
|
Expected outputs:
- kernel
.deb files (linux-image, linux-headers)
Image.gz
- target DTB (
msm8916-handsome-openstick-*.dtb)
Prepare RootFS Image
Get base Debian image
1
2
3
4
|
mkdir ~/rootfs
cd ~/rootfs
wget https://github.com/OpenStick/OpenStick/releases/download/v1/debian.zip && unzip debian.zip
mv ./debian/rootfs.img ~/rootfs
|
1
|
simg2img rootfs.img root.img
|
Mount and chroot
1
2
3
4
5
|
sudo mount root.img /mnt
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /sys /mnt/sys
|
Copy kernel deb files into /mnt, then:
1
2
3
4
|
sudo chroot /mnt
dpkg -l | grep -E "linux-headers|linux-image" |awk '{print $2}'|xargs dpkg -P
dpkg -i *.deb
rm linux-*.deb
|
Enable rc.local with systemd
Create /etc/systemd/system/rc-local.service and /etc/rc.local, then:
1
|
systemctl daemon-reload && systemctl enable rc-local
|
Locale and apt source cleanup
- Install and configure locales:
1
2
|
sudo apt install locales
sudo dpkg-reconfigure locales
|
- Remove invalid old source list entries if needed.
Unmount
1
2
3
4
5
|
sudo umount /mnt/proc
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/sys
sudo umount /mnt
|
Convert back to sparse image
1
|
img2simg root.img rootfs.img
|
Build Boot Image
Required files:
Image.gz
- Target DTB (for your hardware variant)
initrd.img-* from rootfs /boot
Example (ufi001c):
1
2
3
|
cat Image.gz msm8916-handsome-openstick-ufi001c.dtb > ufi001c-kernel-dtb
mv initrd.img-* initrd.img
mkbootimg --base 0x80000000 --kernel_offset 0x00080000 --ramdisk_offset 0x02000000 --tags_offset 0x01e00000 --pagesize 2048 --second_offset 0x00f00000 --ramdisk initrd.img --cmdline "earlycon root=PARTUUID=a7ab80e8-e9d1-e8cd-f157-93f69b1d141e console=ttyMSM0,115200 no_framebuffer=true rw" --kernel ufi001c-kernel-dtb -o ufi001c-boot.img
|
Replace boot.img and rootfs.img in the flashing package with your generated files.