[openwrt/openwrt] apm821xx: WNDR4700: fix broken sysupgrade, factory images

LEDE Commits lede-commits at lists.infradead.org
Sat Oct 21 07:42:36 PDT 2023


chunkeey pushed a commit to openwrt/openwrt.git, branch openwrt-23.05:
https://git.openwrt.org/03cb2d63f487a5d716711c2693f126c913e599cf

commit 03cb2d63f487a5d716711c2693f126c913e599cf
Author: Christian Lamparter <chunkeey at gmail.com>
AuthorDate: Fri Oct 20 16:20:27 2023 +0200

    apm821xx: WNDR4700: fix broken sysupgrade, factory images
    
    prepend-dtb got extended to handle the Meraki devices too,
    the problem here was that the Netgear WNDR4700 expects an
    u-boot header in front of the DTB, whereas Meraki devices
    don't.
    
    Since the header was dropped, the WNDR4700's uboot started
    to complain:
      Bad Magic Number,it is forbidden to be written to flash!!
    
    when flashing the factory.img since it expects an u-boot
    header there.
    
    Fixes: 5dece2d9355a ("apm821xx: switch over from DTB_SIZE to DEVICE_DTC_FLAGS")
    Fixes: #13716
    Reported-by: @kisgezenguz
    Reported-by: Tamas Szabo
    Signed-off-by: Christian Lamparter <chunkeey at gmail.com>
    (cherry picked from commit d6a11833ad67c33ad10dadf396f6c30bb44ef30f)
---
 target/linux/apm821xx/image/nand.mk | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/target/linux/apm821xx/image/nand.mk b/target/linux/apm821xx/image/nand.mk
index bbc429c45d..4681a7428d 100644
--- a/target/linux/apm821xx/image/nand.mk
+++ b/target/linux/apm821xx/image/nand.mk
@@ -3,7 +3,12 @@ define Build/create-uImage-dtb
 	-$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) \
 		-O linux -T kernel -C none \
 		-n '$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)' \
-		-d "$@.dtb" "$@.dtb.uimage"
+		-d "$(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb" "$@.dtb.uimage"
+endef
+
+define Build/prepend-dtb-uImage
+	cat "$@.dtb.uimage" "$@" > "$@.new"
+	mv "$@.new" "$@"
 endef
 
 define Build/meraki-header
@@ -104,7 +109,7 @@ define Device/netgear_wndr4700
   # append a fake/empty rootfs to fool netgear's uboot
   # CHECK_DNI_FIRMWARE_ROOTFS_INTEGRITY in do_chk_dniimg()
   KERNEL := kernel-bin | lzma -d16 | uImage lzma | pad-offset $$(BLOCKSIZE) 64 | \
-	    append-uImage-fakehdr filesystem | create-uImage-dtb | prepend-dtb
+	    append-uImage-fakehdr filesystem | create-uImage-dtb | prepend-dtb-uImage
   KERNEL_INITRAMFS := kernel-bin | libdeflate-gzip | MuImage-initramfs gzip
   IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | \
 		       netgear-dni | check-size




More information about the lede-commits mailing list