[PATCH] ath79: switch to kernel loader for ar9344 CPE/WBS

Sander Vanheule sander at svanheule.net
Sun Sep 27 09:59:33 EDT 2020


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 at 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(-)

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 at 40000 {
+				compatible = "openwrt,elf";
 				label = "firmware";
 				reg = <0x040000 0x780000>;
-
-				compatible = "fixed-partitions";
-				#address-cells = <1>;
-				#size-cells = <1>;
-
-				partition at 0 {
-					label = "kernel";
-					reg = <0x000000 0x300000>;
-				};
-
-				partition at 300000 {
-					label = "rootfs";
-					reg = <0x300000 0x480000>;
-				};
 			};
 
 			partition at 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},
-- 
2.26.2




More information about the openwrt-devel mailing list