diff mbox series

ath79: switch to kernel loader for ar9344 CPE/WBS

Message ID 20200927135933.419394-1-sander@svanheule.net
State Rejected
Delegated to: Petr Štetiar
Headers show
Series ath79: switch to kernel loader for ar9344 CPE/WBS | expand

Commit Message

Sander Vanheule Sept. 27, 2020, 1:59 p.m. UTC
Now that firmware partitions starting with an ELF kernel loader can be
split automatically, move the TP-Link ar9344-based CPE and WBS devices
from an OKLI loader to a plain kernel loader.

This reduces the size of the device images a bit (2kB for initramfs and
sysupgrade). More importantly it takes away the requirement to
periodically resize the kernel partition to allow for larger kernels.

Note that the firmware size in tplink-safeloader.c is one erase block
smaller than the one in the DTSI, due to some runtime space reclamation
happening on these devices.

Also rebases tplink-eap2x5 on the new tplink-safeloader-elf base device.

Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
I've build tested this patch for all affected devices, but I cannot test
these new images on the CPE/WBS devices as I do not have these. Any
volunteer willing to test this patch on their device would be welcome to
do so.

 target/linux/ath79/dts/ar9344_tplink_cpe.dtsi | 15 +--------
 target/linux/ath79/image/common-tp-link.mk    |  8 ++---
 target/linux/ath79/image/generic-tp-link.mk   | 27 +++++++--------
 tools/firmware-utils/Makefile                 |  2 +-
 tools/firmware-utils/src/tplink-safeloader.c  | 33 +++++++------------
 5 files changed, 27 insertions(+), 58 deletions(-)

Comments

Petr Štetiar Dec. 22, 2020, 11:21 a.m. UTC | #1
Sander Vanheule <sander@svanheule.net> [2020-09-27 15:59:33]:

Hi,

> Now that firmware partitions starting with an ELF kernel loader can be
> split automatically, move the TP-Link ar9344-based CPE and WBS devices
> from an OKLI loader to a plain kernel loader.
> 
> This reduces the size of the device images a bit (2kB for initramfs and
> sysupgrade). More importantly it takes away the requirement to
> periodically resize the kernel partition to allow for larger kernels.
> 
> Note that the firmware size in tplink-safeloader.c is one erase block
> smaller than the one in the DTSI, due to some runtime space reclamation
> happening on these devices.
> 
> Also rebases tplink-eap2x5 on the new tplink-safeloader-elf base device.

does not apply anymore, so you should rebase and resend.

Cheers,

Petr
Sander Vanheule Dec. 22, 2020, 12:22 p.m. UTC | #2
Hi,

On Tue, 2020-12-22 at 12:21 +0100, Petr Štetiar wrote:
> 
> does not apply anymore, so you should rebase and resend.

I was actually made aware that my approach is not recommended, so I'm
just going to retract this patch.

As described in commit 0c0bb6299 [1], the bootloader on these devices
has issues with the info in partition-table being out of sync with the
actual flash layout. So a dynamic firmware partition without a
secondary loader will most likely cause issues in the future for newly
flashed devices, and has caused issues for someone testing this on a
device that was already running OpenWrt [2].

[1] https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=0c0bb6299
[2] https://github.com/openwrt/openwrt/pull/3615

Best,
Sander
Petr Štetiar Dec. 22, 2020, 12:57 p.m. UTC | #3
Sander Vanheule <sander@svanheule.net> [2020-12-22 13:22:37]:

> I was actually made aware that my approach is not recommended, so I'm
> just going to retract this patch.

ok, then please remove the patches from patchwork ASAP, otherwise it's waste
of time, thanks
diff mbox series

Patch

diff --git a/target/linux/ath79/dts/ar9344_tplink_cpe.dtsi b/target/linux/ath79/dts/ar9344_tplink_cpe.dtsi
index 044f6c5c19..27c85a8491 100644
--- a/target/linux/ath79/dts/ar9344_tplink_cpe.dtsi
+++ b/target/linux/ath79/dts/ar9344_tplink_cpe.dtsi
@@ -63,22 +63,9 @@ 
 			};
 
 			partition@40000 {
+				compatible = "openwrt,elf";
 				label = "firmware";
 				reg = <0x040000 0x780000>;
-
-				compatible = "fixed-partitions";
-				#address-cells = <1>;
-				#size-cells = <1>;
-
-				partition@0 {
-					label = "kernel";
-					reg = <0x000000 0x300000>;
-				};
-
-				partition@300000 {
-					label = "rootfs";
-					reg = <0x300000 0x480000>;
-				};
 			};
 
 			partition@7c0000 {
diff --git a/target/linux/ath79/image/common-tp-link.mk b/target/linux/ath79/image/common-tp-link.mk
index 0b7b0e1935..7ce71811bb 100644
--- a/target/linux/ath79/image/common-tp-link.mk
+++ b/target/linux/ath79/image/common-tp-link.mk
@@ -84,13 +84,9 @@  define Device/tplink-safeloader-uimage
   KERNEL_INITRAMFS := $$(KERNEL)
 endef
 
-define Device/tplink-safeloader-okli
+define Device/tplink-safeloader-elf
   $(Device/tplink-safeloader)
   LOADER_TYPE := elf
-  LOADER_FLASH_OFFS := 0x43000
-  COMPILE := loader-$(1).elf
-  COMPILE/loader-$(1).elf := loader-okli-compile
-  KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x4f4b4c49 | \
-	loader-okli $(1) 12288
+  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel
   KERNEL_INITRAMFS := $$(KERNEL)
 endef
diff --git a/target/linux/ath79/image/generic-tp-link.mk b/target/linux/ath79/image/generic-tp-link.mk
index 22d1ac8a9e..3a066c1fd6 100644
--- a/target/linux/ath79/image/generic-tp-link.mk
+++ b/target/linux/ath79/image/generic-tp-link.mk
@@ -247,7 +247,7 @@  endef
 TARGET_DEVICES += tplink_archer-d7b-v1
 
 define Device/tplink_cpe210-v1
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := CPE210
@@ -285,7 +285,7 @@  endef
 TARGET_DEVICES += tplink_cpe210-v3
 
 define Device/tplink_cpe220-v2
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := CPE220
@@ -308,7 +308,7 @@  endef
 TARGET_DEVICES += tplink_cpe220-v3
 
 define Device/tplink_cpe510-v1
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := CPE510
@@ -320,7 +320,7 @@  endef
 TARGET_DEVICES += tplink_cpe510-v1
 
 define Device/tplink_cpe510-v2
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := CPE510
@@ -332,7 +332,7 @@  endef
 TARGET_DEVICES += tplink_cpe510-v2
 
 define Device/tplink_cpe510-v3
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := CPE510
@@ -343,7 +343,7 @@  endef
 TARGET_DEVICES += tplink_cpe510-v3
 
 define Device/tplink_cpe610-v1
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := CPE610
@@ -353,7 +353,7 @@  endef
 TARGET_DEVICES += tplink_cpe610-v1
 
 define Device/tplink_cpe610-v2
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := CPE610
@@ -363,10 +363,7 @@  endef
 TARGET_DEVICES += tplink_cpe610-v2
 
 define Device/tplink-eap2x5
-  $(Device/tplink-safeloader)
-  LOADER_TYPE := elf
-  KERNEL := kernel-bin | append-dtb | lzma | loader-kernel
-  KERNEL_INITRAMFS := $$(KERNEL)
+  $(Device/tplink-safeloader-elf)
   IMAGE/factory.bin := append-rootfs | tplink-safeloader factory | \
 	pad-extra 128
 endef
@@ -737,7 +734,7 @@  endef
 TARGET_DEVICES += tplink_tl-wr902ac-v1
 
 define Device/tplink_wbs210-v1
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := WBS210
@@ -749,7 +746,7 @@  endef
 TARGET_DEVICES += tplink_wbs210-v1
 
 define Device/tplink_wbs210-v2
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := WBS210
@@ -760,7 +757,7 @@  endef
 TARGET_DEVICES += tplink_wbs210-v2
 
 define Device/tplink_wbs510-v1
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := WBS510
@@ -772,7 +769,7 @@  endef
 TARGET_DEVICES += tplink_wbs510-v1
 
 define Device/tplink_wbs510-v2
-  $(Device/tplink-safeloader-okli)
+  $(Device/tplink-safeloader-elf)
   SOC := ar9344
   IMAGE_SIZE := 7680k
   DEVICE_MODEL := WBS510
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index 39c3503886..7f1754a347 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -7,7 +7,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME := firmware-utils
-PKG_RELEASE := 3
+PKG_RELEASE := 4
 
 include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/kernel.mk
diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
index 82166a9ebb..5674d2fecb 100644
--- a/tools/firmware-utils/src/tplink-safeloader.c
+++ b/tools/firmware-utils/src/tplink-safeloader.c
@@ -140,8 +140,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -263,8 +262,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -342,8 +340,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -384,8 +381,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -426,8 +422,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -466,8 +461,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -506,8 +500,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -538,8 +531,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -570,8 +562,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -603,8 +594,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},
@@ -636,8 +626,7 @@  static struct device_info boards[] = {
 			{"default-mac", 0x30000, 0x00020},
 			{"product-info", 0x31100, 0x00100},
 			{"signature", 0x32000, 0x00400},
-			{"os-image", 0x40000, 0x300000},
-			{"file-system", 0x340000, 0x470000},
+			{"firmware", 0x40000, 0x770000},
 			{"soft-version", 0x7b0000, 0x00100},
 			{"support-list", 0x7b1000, 0x00400},
 			{"user-config", 0x7c0000, 0x10000},