This patch improves 5684d087418d176cfdef4e045e1950ca7ba3b09f by setting
the correct partition scheme for the RouterBoot section of the flash.

This section is subdivided in several segments, as they are on ar71xx
RB devices, albeit with different offsets and sizes. The naming convention
from ar71xx has been preserved, with an overlapping "RouterBoot" top level
partition added for clarity due to the many holes.

The OEM source code also define a "fake" partition at the beginning of
the secondary flash chip: to avoid trouble if OEM ever make use of that
space, we define it here.

The resulting partition scheme looks like this:
[    2.355095] Creating 6 MTD partitions on "spi0.0":
[    2.359872] 0x000000000000-0x000000040000 : "RouterBoot"
[    2.366197] 0x000000000000-0x00000000f000 : "routerboot"
[    2.372437] 0x00000000f000-0x000000010000 : "hard_config"
[    2.378818] 0x000000010000-0x00000001f000 : "routerboot2"
[    2.385200] 0x000000020000-0x000000021000 : "soft_config"
[    2.391503] 0x000000030000-0x000000031000 : "bios"
[    2.419283] Creating 2 MTD partitions on "spi0.1":
[    2.424062] 0x000000000000-0x000000040000 : "RouterBootFake"
[    2.430717] 0x000000040000-0x000001000000 : "firmware"

The device name is corrected to match the hardware-stored (in hard_config)
device name.

Leave a note in DTS to mention this device supports hardware crypto.
Leave a note in DTS to explain how the original author selected the SPI speed.

Note: more work is required to get rbcfg working on this device due to
endianness.

Tested-by: Tobias Schramm <toblemi...@gmail.com>
Signed-off-by: Thibaut VARÈNE <ha...@slashdirt.org>
---
 target/linux/ramips/dts/RBM33G.dts | 64 +++++++++++++++++++++++++++++---------
 1 file changed, 50 insertions(+), 14 deletions(-)

diff --git a/target/linux/ramips/dts/RBM33G.dts 
b/target/linux/ramips/dts/RBM33G.dts
index cc6da267a2..e1de3c8c11 100644
--- a/target/linux/ramips/dts/RBM33G.dts
+++ b/target/linux/ramips/dts/RBM33G.dts
@@ -7,7 +7,7 @@
 
 / {
        compatible = "mikrotik,rbm33g", "mediatek,mt7621-soc";
-       model = "MikroTik RBM33G";
+       model = "MikroTik RouterBOARD M33G";
 
        aliases {
                led-status = &led_usr;
@@ -39,7 +39,7 @@
                poll-interval = <20>;
 
                res {
-                       label = "res";
+                       label = "reset";
                        gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
                        linux,code = <KEY_RESTART>;
                };
@@ -69,6 +69,7 @@
                regulator-always-on;
        };
 
+       // not defined in OEM source, this controls the M.2 slot
        pcie2_vcc_reg {
                compatible = "regulator-fixed";
                regulator-name = "pcie2_vcc";
@@ -104,18 +105,42 @@
                reg = <0>;
                spi-max-frequency = <3125000>;
 
-               partition@0 {
-                       label = "routerboot";
-                       reg = <0x0 0xf000>;
-                       read-only;
-               };
-
-               factory: partition@f000 {
-                       label = "factory";
-                       reg = <0xf000 0x71000>;
-                       read-only;
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "RouterBoot";
+                               reg = <0x0 0x40000>;
+                               read-only;
+                       };
+
+                       routerboot@0 {
+                               reg = <0x0 0xf000>;
+                               read-only;
+                       };
+
+                       hard_config: hard_config@f000 {
+                               reg = <0xf000 0x1000>;
+                               read-only;
+                       };
+
+                       routerboot2@10000 {
+                               reg = <0x10000 0xf000>;
+                               read-only;
+                       };
+
+                       soft_config@20000 {
+                               reg = <0x20000 0x1000>;
+                       };
+
+                       // valid data only extends up to 0x4f but make it 
0x1000 to match ar71xx
+                       bios@30000 {
+                               reg = <0x30000 0x1000>;
+                               read-only;
+                       };
                };
-
        };
 
        w25q128@0 {
@@ -123,8 +148,16 @@
                #size-cells = <1>;
                compatible = "jedec,spi-nor";
                reg = <1>;
+               // XXX empiric value to obtain actual 10MHz SCK at the chip 
                spi-max-frequency = <3125000>;
 
+               // this contains no data but is defined in OEM source
+               partition@0 {
+                       label = "RouterBootFake";
+                       reg = <0x0 0x40000>;
+                       read-only;
+               };
+
                partition@40000 {
                        label = "firmware";
                        reg = <0x040000 0xFC0000>;
@@ -133,7 +166,7 @@
 };
 
 &ethernet {
-       mtd-mac-address = <&factory 0x0010>;
+       mtd-mac-address = <&hard_config 0x0010>;
        mtd-mac-address-increment = <1>;
 };
 
@@ -158,3 +191,6 @@
 &pcie {
        status = "okay";
 };
+
+// XXX this device has hardware crypto
+//&crypto {};
-- 
2.14.3 (Apple Git-98)


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to