Skip to content

Commit

Permalink
ath79: use dynamic partitioning for TP-Link CPE series
Browse files Browse the repository at this point in the history
CPExxx and WBSxxx boards with AR9344 SOC
use the OKLI lzma kernel loader
with the offset of 3 blocks of length 4k (0x3000)
in order to have a fake "kernel" that cannot grow larger
than how it is defined in the now static OEM partition table.

Before recent changes to the mtdsplit driver,
the uImage parser for OKLI only supported images
that started exactly on an eraseblock boundary.

The mtdsplit parser for uImage now supports identifying images
with any magic number value
and at any offset from the eraseblock boundary
using DTS properties to define those values.

So, it is no longer necessary to use fixed sizes
for kernel and rootfs

Tested-by: Andrew Cameron <apcameron@softhome.net>  [CPE510 v2]
Tested-by: Bernhard Geier <freifunk@geierb.de>      [WBS210 v2]
Tested-by: Petrov <d7c48mWsPKx67w2@gmail.com>       [CPE210 v1]
Signed-off-by: Michael Pratt <mcpratt@pm.me>
  • Loading branch information
mpratt14 authored and adschm committed Jun 5, 2021
1 parent 6bc4c0a commit 7b9a0c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
18 changes: 4 additions & 14 deletions target/linux/ath79/dts/ar9344_tplink_cpe.dtsi
Expand Up @@ -4,6 +4,7 @@

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/mtd/partitions/uimage.h>

/ {
aliases {
Expand Down Expand Up @@ -59,20 +60,9 @@
partition@40000 {
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>;
};
compatible = "openwrt,uimage", "denx,uimage";
openwrt,ih-magic = <IH_MAGIC_OKLI>;
openwrt,offset = <0x3000>;
};

partition@7c0000 {
Expand Down
33 changes: 11 additions & 22 deletions tools/firmware-utils/src/tplink-safeloader.c
Expand Up @@ -156,8 +156,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},
Expand Down Expand Up @@ -279,8 +278,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},
Expand Down Expand Up @@ -358,8 +356,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},
Expand Down Expand Up @@ -400,8 +397,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},
Expand Down Expand Up @@ -445,8 +441,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},
Expand Down Expand Up @@ -485,8 +480,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},
Expand Down Expand Up @@ -525,8 +519,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},
Expand Down Expand Up @@ -557,8 +550,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},
Expand Down Expand Up @@ -589,8 +581,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},
Expand Down Expand Up @@ -622,8 +613,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},
Expand Down Expand Up @@ -655,8 +645,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},
Expand Down

0 comments on commit 7b9a0c2

Please sign in to comment.