Last active
November 16, 2023 06:13
-
-
Save qnnnnez/d31f2ac2bec891f3ca457f828446f925 to your computer and use it in GitHub Desktop.
Flash boot partition directly on your OpenStick device. (Tested on UZ801V3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 kernel-version" | |
echo "kernel-version is the suffix of vmlinuz and initrd.img in /boot" | |
exit 1 | |
fi | |
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
vmlinuz_path="/boot/vmlinuz-$1" | |
initrd_path="/boot/initrd.img-$1" | |
flash_target="/dev/disk/by-partlabel/boot" | |
work_dir="$(mktemp -d)" | |
uncompressed_image_path="$work_dir/vmlinuz-uncompressed" | |
image_gz_path="$work_dir/Image.gz" | |
kernel_dtb_path="$work_dir/kernel-dtb" | |
boot_img_path="$work_dir/boot.img" | |
echo "compressing kernel ..." | |
if gzip -d <"$vmlinuz_path" >"$uncompressed_image_path"; then | |
echo "vmlinuz already compressed" | |
else | |
readelf -h "$vmlinuz_path" >/dev/null && cp "$vmlinuz_path" "$uncompressed_image_path" | |
fi | |
gzip -9 <"$uncompressed_image_path" >"$image_gz_path" | |
echo | |
echo "concating kernel and dtb ..." | |
cat "$image_gz_path" "$dtb_path" >"$kernel_dtb_path" | |
echo | |
echo "creating boot.img ..." | |
mkbootimg \ | |
--base 0x80000000 \ | |
--kernel_offset 0x00080000 \ | |
--ramdisk_offset 0x02000000 \ | |
--tags_offset 0x01e00000 \ | |
--pagesize 2048 \ | |
--second_offset 0x00f00000 \ | |
--ramdisk "$initrd_path" \ | |
--cmdline "earlycon root=PARTUUID=a7ab80e8-e9d1-e8cd-f157-93f69b1d141e console=ttyMSM0,115200 no_framebuffer=true rw"\ | |
--kernel "$kernel_dtb_path" -o "$boot_img_path" | |
echo | |
echo "flashing boot.img to boot partition ..." | |
dd if="$boot_img_path" of="$flash_target" bs=1M status=progress | |
echo "flashing boot.img to boot partition ..." | |
dd if="$boot_img_path" of="$flash_target" bs=1M status=progress | |
echo | |
echo "cleaning up ..." | |
rm -rf "$work_dir" | |
echo | |
echo "all done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get Kernel Sources
Clone the msm8916-mainline kernel sources:
Compile Kernel
Compile kernel:
Create Debian Package
Create kernel package:
You can find .deb packages in
..
Prepare the Device
Install kernel packages created previously.
Copy dtb, kernel image and flashing script to device.
Install
mkbootimg
:apt install mkbootimg
Modify
flash-boot-img.sh
and changekernel_dtb_path
to point to you dtb file.Generate and Flash boot.img
Choose the version you want to flash:
Run flashing script as root:
Reference
https://www.kancloud.cn/handsomehacker/openstick/2637565
https://wiki.debian.org/BuildADebianKernelPackage