From dc50694bd1a8f81b40c185bc8cacbdc8e821a3c6 Mon Sep 17 00:00:00 2001
From: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Date: Fri, 18 May 2018 03:00:41 +0200
Subject: [PATCH] ipq806x: increase kernel partition size for the Netgear r7800

Starting with kernel 4.14 and gcc 7, the kernel doesn't fit into the
2 MB reserved for the kernel partition by the OEM firmware anymore.

This patch increases the kernel partition from 2 MB to 4 MB, at the
expense of the rootfs, for all supported kernels.

WARNING: This breaks sysupgrade! Flashing a firmware containing this
changed partitioning from an older image with 2 MB reserved for the
kernel partion requires the tftp recovery procedure, thereby losing
all settings.

This patch is based on a corresponding change by Pavel Kubelun
<be.dissent@gmail.com> and has been tested by Michael Yartys
<michael.yartys@protonmail.com>

Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
---
 .../files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts     | 6 +++---
 .../files-4.9/arch/arm/boot/dts/qcom-ipq8065-r7800.dts      | 6 +++---
 target/linux/ipq806x/image/Makefile                         | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts b/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
index 63cb42a3e2..a590fadd0e 100644
--- a/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
+++ b/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
@@ -359,12 +359,12 @@
 
 					kernel@1480000 {
 						label = "kernel";
-						reg = <0x1480000 0x0200000>;
+						reg = <0x1480000 0x0400000>;
 					};
 
-					ubi@1680000 {
+					ubi@1880000 {
 						label = "ubi";
-						reg = <0x1680000 0x1E00000>;
+						reg = <0x1880000 0x1C00000>;
 					};
 
 					netgear@3480000 {
diff --git a/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8065-r7800.dts b/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
index 63cb42a3e2..a590fadd0e 100644
--- a/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
+++ b/target/linux/ipq806x/files-4.9/arch/arm/boot/dts/qcom-ipq8065-r7800.dts
@@ -359,12 +359,12 @@
 
 					kernel@1480000 {
 						label = "kernel";
-						reg = <0x1480000 0x0200000>;
+						reg = <0x1480000 0x0400000>;
 					};
 
-					ubi@1680000 {
+					ubi@1880000 {
 						label = "ubi";
-						reg = <0x1680000 0x1E00000>;
+						reg = <0x1880000 0x1C00000>;
 					};
 
 					netgear@3480000 {
diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile
index a737e165b0..e5df7275a1 100644
--- a/target/linux/ipq806x/image/Makefile
+++ b/target/linux/ipq806x/image/Makefile
@@ -149,7 +149,7 @@ TARGET_DEVICES += netgear_r7500v2
 define Device/netgear_r7800
 	$(call Device/DniImage)
 	DEVICE_DTS := qcom-ipq8065-r7800
-	KERNEL_SIZE := 2097152
+	KERNEL_SIZE := 4194304
 	NETGEAR_BOARD_ID := R7800
 	NETGEAR_HW_ID := 29764958+0+128+512+4x4+4x4+cascade
 	BLOCKSIZE := 128k
-- 
2.30.2