From 33727ecea5675b477986d0370cfd461495a41fd1 Mon Sep 17 00:00:00 2001
From: Christian Lamparter <chunkeey@gmail.com>
Date: Sat, 2 Mar 2019 22:33:42 +0100
Subject: [PATCH] lantiq: enlarge ZyXEL P-2812HNU-F1 kernel partition (FS#2124)

The current snapshot release kernel with it's 2119245 Byte
size is too big to fit into the 2097152 (2MiB) area that
was set aside for the kernel. Which causes the device to
fail to boot (after an update or even during a fresh install)

 NAND read: device 0 offset 0x60000, size 0x200000
  2097152 bytes read: OK
 ## Booting kernel from Legacy Image at 80800000 ...
    Image Name:   MIPS OpenWrt Linux-4.14.98
    Created:      2019-02-13   9:37:36 UTC
    Image Type:   MIPS Linux Kernel Image (lzma compressed)
    Data Size:    2119245 Bytes = 2 MiB
    Load Address: 80002000
    Entry Point:  80002000
    Verifying Checksum ... Bad Data CRC
 ERROR: can't get kernel image!

This patch fixes the problem by enlarging the kernel partition
at the cost of the ubi/data partition behind it. The patch
also adds a KERNEL_SIZE variable to the image Makefile to
prevent silent corruptions from happening in the future.

Please note: The u-boot environment for the router also
needs to be updated. So please attach an appropriate
serial converter cable and enter the following commands
into the u-boot prompt:

 setenv nboot 'nand read 0x80800000 0x60000 0x300000; bootm 0x80800000'
 saveenv

The wiki has been updated accordingly:
<https://openwrt.org/toh/zyxel/p2812hnu-f1>

Fixes: FS#2124
Suggested-by: Mafketel (User on bugs.openwrt.org)
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 .../lantiq/files-4.14/arch/mips/boot/dts/P2812HNUF1.dts     | 6 +++---
 target/linux/lantiq/image/Makefile                          | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/target/linux/lantiq/files-4.14/arch/mips/boot/dts/P2812HNUF1.dts b/target/linux/lantiq/files-4.14/arch/mips/boot/dts/P2812HNUF1.dts
index 911a2d6afee..d907d64c8cb 100644
--- a/target/linux/lantiq/files-4.14/arch/mips/boot/dts/P2812HNUF1.dts
+++ b/target/linux/lantiq/files-4.14/arch/mips/boot/dts/P2812HNUF1.dts
@@ -47,11 +47,11 @@
 			};
 			partition@60000 {
 				label = "kernel";
-				reg = <0x60000 0x200000>;
+				reg = <0x60000 0x300000>;
 			};
-			partition@260000 {
+			partition@360000 {
 				label = "ubi";
-				reg = <0x260000 0x7da0000>;
+				reg = <0x360000 0x7ca0000>;
 			};
 		};
 	};
diff --git a/target/linux/lantiq/image/Makefile b/target/linux/lantiq/image/Makefile
index b59acf4ddcb..7e328bf2be8 100644
--- a/target/linux/lantiq/image/Makefile
+++ b/target/linux/lantiq/image/Makefile
@@ -553,6 +553,7 @@ define Device/zyxel_p-2812hnu-f1
   DEVICE_DTS := P2812HNUF1
   DEVICE_TITLE := ZyXEL P-2812HNU-F1
   DEVICE_PACKAGES := kmod-rt2800-pci wpad-basic kmod-usb-dwc2 kmod-usb-ledtrig-usbport
+  KERNEL_SIZE := 3072k
   SUPPORTED_DEVICES += P2812HNUF1
 endef
 TARGET_DEVICES += zyxel_p-2812hnu-f1
-- 
GitLab