From 34600bc55ee86a72a2bf1d166fcb4bf7726c1ea5 Mon Sep 17 00:00:00 2001 From: snlavaise Date: Tue, 8 Sep 2026 21:28:13 -0300 Subject: [PATCH] motorola-rtwo: raw Image + empty dtbo for the Motorola bootloader From the stock LineageOS images: - boot.img carries a raw uncompressed arm64 Image (MZ header), not Image.gz. Install arch/arm64/boot/Image as vmlinuz. - dtbo.img is an 8-entry overlay table; the bootloader applies overlay #7 (androidboot.dtbo_idx=7, 87 fragments) onto the base DTB by phandle. Against our mainline DTB that produces a corrupt merged tree -> instant panic. Ship an empty dtbo (0 entries) to flash to dtbo_b, and set deviceinfo_flash_fastboot_partition_dtbo. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01QF5HebjUsRaxbW4cBX6HJP --- device/testing/device-motorola-rtwo/APKBUILD | 4 ++-- .../testing/device-motorola-rtwo/deviceinfo | 1 + .../linux-postmarketos-qcom-sm8550/APKBUILD | 20 +++++++++++++------ .../rtwo.config | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/device/testing/device-motorola-rtwo/APKBUILD b/device/testing/device-motorola-rtwo/APKBUILD index e8ba19e3f..cc04c3c89 100644 --- a/device/testing/device-motorola-rtwo/APKBUILD +++ b/device/testing/device-motorola-rtwo/APKBUILD @@ -2,7 +2,7 @@ maintainer="snlavaise " pkgname=device-motorola-rtwo pkgver=1 -pkgrel=6 +pkgrel=7 pkgdesc="Motorola Moto Edge 40 Pro" url="https://postmarketos.org" arch="aarch64" @@ -36,6 +36,6 @@ package() { } sha512sums=" -5731bcab1f4b4625b39a72f560be249fb3a89c55d84f81fa983313ab722eacf62ceb427e20833b7f8e7f5399c051d2185db82b1d5ed8b33b850b795127b3eb91 deviceinfo +e66050dc46b1933b4e3bf7d4918e72ed68218015cc714615b26801030c3f9b481815eba0a01c9795a479353511cb7928d1f1cb0b3dc1b3817ca4c7cd5f1f8301 deviceinfo c572e21cb0624b554a22a218b0c4faab9b6412654bed6bfef530f3068d076b21c573bd7f4b3ca65f510f8756f636a861191cce925ef49587db7d68d09558826c modules-initfs " diff --git a/device/testing/device-motorola-rtwo/deviceinfo b/device/testing/device-motorola-rtwo/deviceinfo index 764b1eca0..870e5c3ad 100644 --- a/device/testing/device-motorola-rtwo/deviceinfo +++ b/device/testing/device-motorola-rtwo/deviceinfo @@ -30,6 +30,7 @@ deviceinfo_create_initfs_extra="true" # Bootloader related deviceinfo_flash_method="fastboot" +deviceinfo_flash_fastboot_partition_dtbo="dtbo" deviceinfo_kernel_cmdline="console=tty0 console=ttyMSM0,115200n8 earlycon clk_ignore_unused pd_ignore_unused ignore_loglevel" deviceinfo_generate_bootimg="true" # The Motorola bootloader places the DTB / kernel at the addresses in the diff --git a/device/testing/linux-postmarketos-qcom-sm8550/APKBUILD b/device/testing/linux-postmarketos-qcom-sm8550/APKBUILD index d086d9761..666be99bc 100644 --- a/device/testing/linux-postmarketos-qcom-sm8550/APKBUILD +++ b/device/testing/linux-postmarketos-qcom-sm8550/APKBUILD @@ -5,7 +5,7 @@ maintainer="snlavaise " _flavor="postmarketos-qcom-sm8550" pkgname=linux-$_flavor pkgver=7.2 -pkgrel=2 +pkgrel=3 pkgdesc="Mainline kernel for Qualcomm SM8550 (Snapdragon 8 Gen 2) + Motorola rtwo" arch="aarch64" _carch="arm64" @@ -74,12 +74,20 @@ build() { } package() { - # The Motorola bootloader wants a plain gzip'd arm64 Image in the - # Android boot.img, NOT the EFI ZBOOT blob (vmlinuz.efi). CONFIG_EFI_ZBOOT - # is disabled in rtwo.config so Image.gz is what gets built. - install -Dm644 "$builddir/arch/$_carch/boot/Image.gz" \ + # 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" + # Empty Android DT-overlay table (magic d7b7ab1e, 0 entries). The + # bootloader would otherwise apply the stock kalama dtbo overlay onto + # our mainline base DTB - the phandles don't match, the merged DTB is + # corrupt and the kernel panics. Flash this to the dtbo partition. + mkdir -p "$pkgdir"/boot + printf '\xd7\xb7\xab\x1e\x00\x00\x00\x20\x00\x00\x00\x20\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x08\x00\x00\x00\x00\x00' \ + > "$pkgdir"/boot/dtbo.img + make modules_install dtbs_install \ ARCH="$_carch" \ LLVM=1 \ @@ -98,6 +106,6 @@ package() { sha512sums=" 52d5aa7f94f6aa6141debf4ceb4fc7a2e75505a7cd38b8854e501be83c2b57863020f463f2fdb2fc93667e6cfe13274d077e5207a611e4797bd9404ee0e64c58 linux-postmarketos-qcom-sm8550-7.2.tar.gz f9ae52489f6b9e6fef64952943cd09732a5bef90a0e8765db03c256483028368687d6d5a1d80dd813a513e7e80d91f8b47f49b91cff67266b76f1d6275a7fea0 config-motorola-rtwo.aarch64 -ca36b981736b94d93120bea60d84614a5f943b0577a87ce0c650a7c065dc8b8b889eeee766b8fb941e15af4db5d426583d2d85e3e243faf89aa9cac472f78388 rtwo.config +53441c23146d76bb0eaa358a25f6cce4f21740cfb65b755df52bbb218daf2cda30b3d80fa6ca4e283ea1afe2b0fa708307b678b421898100710b8fb99b08d6c5 rtwo.config e1633eb9a356de1e46c430fe2eb2c5d77ddeb9301f8cf9c95df3ae180d581a57ede0906aeddc0bcc15b95931c0dd40565930a1e1b72bfb540e5a99bcb9865e58 sm8550-motorola-rtwo.dts " diff --git a/device/testing/linux-postmarketos-qcom-sm8550/rtwo.config b/device/testing/linux-postmarketos-qcom-sm8550/rtwo.config index 5c0f0b781..b4860ae6f 100644 --- a/device/testing/linux-postmarketos-qcom-sm8550/rtwo.config +++ b/device/testing/linux-postmarketos-qcom-sm8550/rtwo.config @@ -30,8 +30,8 @@ CONFIG_MAGIC_SYSRQ=y CONFIG_LOG_BUF_SHIFT=18 # --- kernel image format ---------------------------------------------- -# The Motorola bootloader executes a plain gzip'd Image from the Android -# boot.img; the EFI ZBOOT self-decompressor makes it reboot instantly. +# The Motorola bootloader executes a raw uncompressed arm64 Image from the +# Android boot.img; EFI ZBOOT self-decompression makes it reboot instantly. # CONFIG_EFI_ZBOOT is not set # --- build size / speed: device kernel, not the generic arm64 one ------