New hypotheses from re-comparing with the stock boot: - 'earlycon' (bare) brings up uart7 in setup_arch(), before the clock framework. Stock uses console=null and almost certainly leaves the QUP0 clock gated -> touching uart7 MMIO faults before any console. Drop earlycon + the serial console; keep console=tty0 only. - Also drop clk_ignore_unused / pd_ignore_unused (can break qcom power domain init) and ignore_loglevel stays for the fb console. - Move the simple-framebuffer out of /chosen and drop the #address-cells override there, so the bootloader's /memory + initrd patching into /chosen is not disturbed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QF5HebjUsRaxbW4cBX6HJP
125 lines
4.0 KiB
Bash
125 lines
4.0 KiB
Bash
# Reference: <https://postmarketos.org/vendorkernel>
|
|
# Mainline kernel + the (not-yet-upstream) Motorola rtwo device tree.
|
|
# Config base: linux-postmarketos-mainline's config-mainline.aarch64.
|
|
maintainer="snlavaise <snlavaise@gmail.com>"
|
|
_flavor="postmarketos-qcom-sm8550"
|
|
pkgname=linux-$_flavor
|
|
pkgver=7.2
|
|
pkgrel=7
|
|
pkgdesc="Mainline kernel for Qualcomm SM8550 (Snapdragon 8 Gen 2) + Motorola rtwo"
|
|
arch="aarch64"
|
|
_carch="arm64"
|
|
url="https://kernel.org"
|
|
license="GPL-2.0-only"
|
|
options="
|
|
!check
|
|
!strip
|
|
!tracedeps
|
|
pmb:cross-native
|
|
pmb:kconfigcheck-community
|
|
"
|
|
makedepends="
|
|
bash
|
|
bison
|
|
clang
|
|
diffutils
|
|
elfutils-dev
|
|
findutils
|
|
flex
|
|
gmp-dev
|
|
kmod
|
|
linux-headers
|
|
lld
|
|
llvm
|
|
mpc1-dev
|
|
mpfr-dev
|
|
openssl-dev
|
|
pahole
|
|
perl
|
|
postmarketos-installkernel
|
|
python3
|
|
xz
|
|
zstd
|
|
"
|
|
|
|
source="
|
|
$pkgname-$pkgver.tar.gz::https://git.kernel.org/torvalds/t/linux-${pkgver/_/-}.tar.gz
|
|
config-motorola-rtwo.aarch64
|
|
rtwo.config
|
|
sm8550-motorola-rtwo.dts
|
|
"
|
|
builddir="$srcdir/linux-${pkgver/_/-}"
|
|
|
|
prepare() {
|
|
default_prepare
|
|
|
|
# The Motorola rtwo (Moto Edge 40 Pro) device tree is not upstream yet.
|
|
local _dtsdir="arch/$_carch/boot/dts/qcom"
|
|
cp "$srcdir/sm8550-motorola-rtwo.dts" "$_dtsdir/sm8550-motorola-rtwo.dts"
|
|
if ! grep -q "sm8550-motorola-rtwo.dtb" "$_dtsdir/Makefile"; then
|
|
sed -i '/sm8550-mtp\.dtb/a dtb-$(CONFIG_ARCH_QCOM) += sm8550-motorola-rtwo.dtb' \
|
|
"$_dtsdir/Makefile"
|
|
fi
|
|
|
|
# Base config (from linux-postmarketos-mainline) + rtwo bring-up fragment.
|
|
cp "$srcdir/config-motorola-rtwo.aarch64" .config
|
|
cat "$srcdir/rtwo.config" >> .config
|
|
make ARCH="$_carch" LLVM=1 olddefconfig
|
|
}
|
|
|
|
build() {
|
|
unset LDFLAGS
|
|
make ARCH="$_carch" LLVM=1 \
|
|
KBUILD_BUILD_VERSION="$((pkgrel + 1))-$_flavor"
|
|
}
|
|
|
|
package() {
|
|
# The Motorola bootloader boots a *raw* uncompressed arm64 Image
|
|
# (BOARD_KERNEL_IMAGE_NAME := Image); Image.gz / vmlinuz.efi make it
|
|
# reset in <2s. CONFIG_EFI_ZBOOT is off in rtwo.config.
|
|
install -Dm644 "$builddir/arch/$_carch/boot/Image" \
|
|
"$pkgdir/boot/vmlinuz"
|
|
|
|
make modules_install dtbs_install \
|
|
ARCH="$_carch" \
|
|
LLVM=1 \
|
|
INSTALL_MOD_PATH="$pkgdir"/usr \
|
|
INSTALL_MOD_STRIP=1 \
|
|
INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
|
|
|
|
# Android DT-overlay image with a single no-op overlay. The bootloader
|
|
# would otherwise apply the stock kalama dtbo overlay onto our mainline
|
|
# base DTB - the phandles don't match, the merged tree is corrupt and
|
|
# the kernel panics. A no-op overlay keeps the base DTB intact. (A
|
|
# zero-entry table fails Motorola's pre-flash validation.)
|
|
mkdir -p "$pkgdir"/boot
|
|
printf '/dts-v1/;\n/plugin/;\n/ { };\n' > "$srcdir"/empty-overlay.dts
|
|
scripts/dtc/dtc -@ -O dtb -o "$srcdir"/empty.dtbo "$srcdir"/empty-overlay.dts
|
|
python3 - "$srcdir/empty.dtbo" "$pkgdir/boot/dtbo.img" <<-'EOF'
|
|
import struct, sys
|
|
fdt = open(sys.argv[1], "rb").read()
|
|
hdr_sz = ent_sz = 32
|
|
ent_off = hdr_sz + ent_sz
|
|
hdr = struct.pack(">IIIIIIII", 0xd7b7ab1e, ent_off + len(fdt),
|
|
hdr_sz, ent_sz, 1, hdr_sz, 2048, 0)
|
|
ent = struct.pack(">IIIIIIII", len(fdt), ent_off, 0, 0, 0, 0, 0, 0)
|
|
blob = hdr + ent + fdt
|
|
blob += b"\x00" * ((4096 - len(blob) % 4096) % 4096)
|
|
open(sys.argv[2], "wb").write(blob)
|
|
EOF
|
|
|
|
rm -f "$pkgdir"/usr/lib/modules/*/build "$pkgdir"/usr/lib/modules/*/source
|
|
|
|
install -Dm644 "$builddir"/include/config/kernel.release \
|
|
"$pkgdir"/usr/share/kernel/"$_flavor"/kernel.release
|
|
}
|
|
|
|
# 'pmbootstrap checksum linux-postmarketos-qcom-sm8550' fills in the tarball hash
|
|
# (same tarball as linux-postmarketos-mainline, ~150 MB download).
|
|
sha512sums="
|
|
52d5aa7f94f6aa6141debf4ceb4fc7a2e75505a7cd38b8854e501be83c2b57863020f463f2fdb2fc93667e6cfe13274d077e5207a611e4797bd9404ee0e64c58 linux-postmarketos-qcom-sm8550-7.2.tar.gz
|
|
f9ae52489f6b9e6fef64952943cd09732a5bef90a0e8765db03c256483028368687d6d5a1d80dd813a513e7e80d91f8b47f49b91cff67266b76f1d6275a7fea0 config-motorola-rtwo.aarch64
|
|
53441c23146d76bb0eaa358a25f6cce4f21740cfb65b755df52bbb218daf2cda30b3d80fa6ca4e283ea1afe2b0fa708307b678b421898100710b8fb99b08d6c5 rtwo.config
|
|
43f5147f474ad4fbbc926e21b1305991b04c88bac869c684aee6fa4bb548663c4079d4d389a002ed3502af746566cf8fc31261221825c8f3c6b3949fc36c518d sm8550-motorola-rtwo.dts
|
|
"
|