ramips: add new flash layout support to Phicomm K2
authorShiji Yang <yangshiji66@qq.com>
Tue, 27 Jul 2021 04:45:05 +0000 (12:45 +0800)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Tue, 24 Aug 2021 18:26:00 +0000 (20:26 +0200)
Descriptions:
Phicomm K2 (PSG1218) got a new "permanent_config" partition after
update firmware to v22.5. This partition located in front of the
firmware partition, same as The Phicomm K2P and K2G. Due to this
change the new bootloader can't load previous firmware any more.
This commit is aimed at add support for Phicomm K2 which official
firmware version is 22.5.x or newer. For which runs old firmware
version, just update OpenWrt that has a prefix of "k2-v22.4".
For uniform naming, this commit also changed the model name
PSG1218 to a more recognizable name K2, refer to Phicomm K2G,
K2P K2T.

OpenWrt selection table:
official firmware version           OpenWrt
v22.4.x.x or older              phicomm_k2-v22.4
v22.5.x.x or newer              phicomm_k2-v22.5

Installation:
Same as Phicomm K2G, K2P, PSG1208.
a. TFTP + U-Boot
b. Open telnet by some web page vulnerability (Search Baidu by key
   words "K2 telnet"), and then we can upload firmware image to
   /tmp and write it to firmware partition with mtd instruction.

Signed-off-by: Shiji Yang <yangshiji66@qq.com>
[rebase, add/harmonize version in model variables, fix version typo
 in commit message, wrap commit message properly]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
target/linux/ramips/dts/mt7620a_phicomm_k2-v22.4.dts [new file with mode: 0644]
target/linux/ramips/dts/mt7620a_phicomm_k2-v22.5.dts [new file with mode: 0644]
target/linux/ramips/dts/mt7620a_phicomm_psg1218a.dts [deleted file]
target/linux/ramips/image/mt7620.mk
target/linux/ramips/mt7620/base-files/etc/board.d/02_network

diff --git a/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.4.dts b/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.4.dts
new file mode 100644 (file)
index 0000000..4e9fc13
--- /dev/null
@@ -0,0 +1,23 @@
+#include "mt7620a_phicomm_k2x.dtsi"
+
+/ {
+       compatible = "phicomm,k2-v22.4", "ralink,mt7620a-soc";
+       model = "Phicomm K2 v22.4 or older";
+};
+
+&partitions {
+       partition@50000 {
+               compatible = "denx,uimage";
+               label = "firmware";
+               reg = <0x50000 0x7b0000>;
+       };
+};
+
+&ethernet {
+       mediatek,portmap = "llllw";
+};
+
+&wmac {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pa_pins>;
+};
diff --git a/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.5.dts b/target/linux/ramips/dts/mt7620a_phicomm_k2-v22.5.dts
new file mode 100644 (file)
index 0000000..2a68287
--- /dev/null
@@ -0,0 +1,29 @@
+#include "mt7620a_phicomm_k2x.dtsi"
+
+/ {
+       compatible = "phicomm,k2-v22.5", "ralink,mt7620a-soc";
+       model = "Phicomm K2 v22.5 or newer";
+};
+
+&partitions {
+       partition@50000 {
+               label = "permanent_config";
+               reg = <0x50000 0x50000>;
+               read-only;
+       };
+
+       partition@a0000 {
+               compatible = "denx,uimage";
+               label = "firmware";
+               reg = <0xa0000 0x760000>;
+       };
+};
+
+&ethernet {
+       mediatek,portmap = "llllw";
+};
+
+&wmac {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pa_pins>;
+};
diff --git a/target/linux/ramips/dts/mt7620a_phicomm_psg1218a.dts b/target/linux/ramips/dts/mt7620a_phicomm_psg1218a.dts
deleted file mode 100644 (file)
index cda0517..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "mt7620a_phicomm_k2x.dtsi"
-
-/ {
-       compatible = "phicomm,psg1218a", "phicomm,psg1218", "ralink,mt7620a-soc";
-       model = "Phicomm PSG1218 rev.A";
-};
-
-&partitions {
-       partition@50000 {
-               compatible = "denx,uimage";
-               label = "firmware";
-               reg = <0x50000 0x7b0000>;
-       };
-};
-
-&ethernet {
-       mediatek,portmap = "llllw";
-};
-
-&wmac {
-       pinctrl-names = "default";
-       pinctrl-0 = <&pa_pins>;
-};
index c3b9bc9f6baa26cc85b786527a6d430bdae7817f..bfc7fa7db049fc45c63fa32954881269e54e468f 100644 (file)
@@ -807,6 +807,27 @@ define Device/ohyeah_oy-0001
 endef
 TARGET_DEVICES += ohyeah_oy-0001
 
+define Device/phicomm_k2-v22.4
+  SOC := mt7620a
+  IMAGE_SIZE := 7872k
+  DEVICE_VENDOR := Phicomm
+  DEVICE_MODEL := K2
+  DEVICE_VARIANT:= v22.4 or older
+  DEVICE_PACKAGES := kmod-mt76x2
+  SUPPORTED_DEVICES += psg1218 psg1218a phicomm,psg1218a
+endef
+TARGET_DEVICES += phicomm_k2-v22.4
+
+define Device/phicomm_k2-v22.5
+  SOC := mt7620a
+  IMAGE_SIZE := 7552k
+  DEVICE_VENDOR := Phicomm
+  DEVICE_MODEL := K2
+  DEVICE_VARIANT:= v22.5 or newer
+  DEVICE_PACKAGES := kmod-mt76x2
+endef
+TARGET_DEVICES += phicomm_k2-v22.5
+
 define Device/phicomm_k2g
   SOC := mt7620a
   IMAGE_SIZE := 7552k
@@ -826,17 +847,6 @@ define Device/phicomm_psg1208
 endef
 TARGET_DEVICES += phicomm_psg1208
 
-define Device/phicomm_psg1218a
-  SOC := mt7620a
-  IMAGE_SIZE := 7872k
-  DEVICE_VENDOR := Phicomm
-  DEVICE_MODEL := PSG1218
-  DEVICE_VARIANT:= Ax
-  DEVICE_PACKAGES := kmod-mt76x2
-  SUPPORTED_DEVICES += psg1218 psg1218a
-endef
-TARGET_DEVICES += phicomm_psg1218a
-
 define Device/phicomm_psg1218b
   SOC := mt7620a
   IMAGE_SIZE := 7872k
index eaa8cbf7aa3e31261585e57c75fe8738e05f24fa..057428e6224ed13648a58e29ecafa86e50a26c70 100644 (file)
@@ -107,7 +107,8 @@ ramips_setup_interfaces()
                ;;
        dlink,dir-810l|\
        netgear,jwnr2010-v5|\
-       phicomm,psg1218a|\
+       phicomm,k2-v22.4|\
+       phicomm,k2-v22.5|\
        trendnet,tew-810dr|\
        zbtlink,zbt-we2026)
                ucidef_add_switch "switch0" \
@@ -339,8 +340,9 @@ ramips_setup_macs()
                wan_mac=$(macaddr_add "$(mtd_get_mac_binary u-boot 0x1fc20)" 2)
                ;;
        lb-link,bl-w1200|\
+       phicomm,k2-v22.4|\
+       phicomm,k2-v22.5|\
        phicomm,k2g|\
-       phicomm,psg1218a|\
        phicomm,psg1218b)
                wan_mac=$(mtd_get_mac_binary factory 0x2e)
                label_mac=$wan_mac