[openwrt/openwrt] ath79: rework Netgear nand devices image recipe

LEDE Commits lede-commits at lists.infradead.org
Wed Aug 23 15:10:32 PDT 2023


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/0f9b8aa3f592b22e3f1d5f7d049e92653ba0f884

commit 0f9b8aa3f592b22e3f1d5f7d049e92653ba0f884
Author: Shiji Yang <yangshiji66 at qq.com>
AuthorDate: Sun Jul 9 22:10:53 2023 +0800

    ath79: rework Netgear nand devices image recipe
    
    In Netgear u-boot GPL code, nand devices uses this formula to locate the
    rootfs offset.
    
    offset = (((128 + KERNEL_SIZE) / BLOCK_SIZE) + 1) * BLOCK_SIZE;
    
    Howerver, WNDR4500 source code incorrectly define the nand block size to
    64k. In some cases, it causes u-boot can't get the correct rootfs offset,
    which result in boot failure. This patch workaround it by padding kernel
    size to (128k * n - 128 - 1). The additional char '\0' is used to ensure
    the (128 + KERNEL_SIZE) can't be divided by the BLOCK_SIZE.
    
    Fixes: https://github.com/openwrt/openwrt/issues/13050
    Fixes: 3c1512a25d92 ("ath79: optimize the firmware recipe for Netgear NAND devices")
    Tested-by: Yousaf <yousaf465 at gmail.com>
    Signed-off-by: Shiji Yang <yangshiji66 at qq.com>
---
 target/linux/ath79/image/nand.mk | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index 84a589809f..884a9da756 100644
--- a/target/linux/ath79/image/nand.mk
+++ b/target/linux/ath79/image/nand.mk
@@ -285,7 +285,7 @@ define Device/meraki_mr18
 endef
 TARGET_DEVICES += meraki_mr18
 
-# fake rootfs is mandatory, pad-offset 64 equals (1 * uimage_header)
+# fake rootfs is mandatory, pad-offset 129 equals (2 * uimage_header + '\0')
 define Device/netgear_ath79_nand
   DEVICE_VENDOR := NETGEAR
   DEVICE_PACKAGES := kmod-usb2 kmod-usb-ledtrig-usbport
@@ -293,8 +293,9 @@ define Device/netgear_ath79_nand
   BLOCKSIZE := 128k
   PAGESIZE := 2048
   IMAGE_SIZE := 25600k
-  KERNEL := kernel-bin | append-dtb | lzma | uImage lzma | \
-	pad-offset $$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem $$(UIMAGE_MAGIC)
+  KERNEL := kernel-bin | append-dtb | lzma | \
+	pad-offset $$(BLOCKSIZE) 129 | uImage lzma | pad-extra 1 | \
+	append-uImage-fakehdr filesystem $$(UIMAGE_MAGIC)
   IMAGES := sysupgrade.bin factory.img
   IMAGE/factory.img := append-kernel | pad-to $$$$(KERNEL_SIZE) | \
 	append-ubi | check-size | netgear-dni




More information about the lede-commits mailing list