ramips: Cudy X6 fixes / improvements
authorFelix Baumann <felix.bau@gmx.de>
Fri, 21 Apr 2023 01:07:58 +0000 (03:07 +0200)
committerDavid Bauer <mail@david-bauer.net>
Mon, 24 Apr 2023 00:57:26 +0000 (02:57 +0200)
- Correct WiFi MACs, they didn't match oem firmware
- Move nvmem-cells to bdinfo partition and remove &bdinfo reference
- Add OEM device model name R13 to SUPPORTED_DEVICES
  This allows sysupgrading from Cudy's OpenWrt fork without force
- Label red_led and use it during failsafe mode and upgrades

MAC addresses as verified by OEM firmware:

use   address             source
LAN   b4:4b:d6:2d:c8:4a   label
WAN   b4:4b:d6:2d:c8:4b   label + 1
2g    b4:4b:d6:2d:c8:4a   label
5g    b6:4b:d6:3d:c8:4a   label + LA-Bit set + 4th oktet increased

The label MAC address is found in bdinfo 0xde00.

Signed-off-by: Felix Baumann <felix.bau@gmx.de>
[read wifi mac from flash offset]
Signed-off-by: David Bauer <mail@david-bauer.net>
target/linux/ramips/dts/mt7621_cudy_x6.dts
target/linux/ramips/image/mt7621.mk
target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac

index 6cff9c25f3e54e4fa04ec268983047fa1aadb6d2..5d5bb5150ccb0bb67c994e2f660c9b4c0bed0594 100644 (file)
@@ -11,9 +11,9 @@
 
        aliases {
                led-boot = &led_internet_blue;
-               led-failsafe = &led_internet_blue;
+               led-failsafe = &led_internet_red;
                led-running = &led_internet_blue;
-               led-upgrade = &led_internet_blue;
+               led-upgrade = &led_internet_red;
                label-mac-device = &gmac0;
        };
 
@@ -45,7 +45,7 @@
                        gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
                };
 
-               internet_red {
+               led_internet_red: internet_red {
                        label = "red:internet";
                        gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
                };
                                read-only;
                        };
 
-                       bdinfo: partition@1ff0000 {
+                       partition@1ff0000 {
                                label = "bdinfo";
                                reg = <0x1ff0000 0x10000>;
                                read-only;
+
+                               compatible = "nvmem-cells";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               macaddr_bdinfo_de00: macaddr@de00 {
+                                       reg = <0xde00 0x6>;
+                               };
                        };
                };
        };
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&factory 0x0000>;
                mediatek,disable-radar-background;
+
+               nvmem-cells = <&macaddr_bdinfo_de00>;
+               nvmem-cell-names = "mac-address";
        };
 };
 
                function = "gpio";
        };
 };
-
-&bdinfo {
-       compatible = "nvmem-cells";
-       #address-cells = <1>;
-       #size-cells = <1>;
-
-       macaddr_bdinfo_de00: macaddr@de00 {
-               reg = <0xde00 0x6>;
-       };
-};
index d46d84e6ce78a003e8d14879d6a522082b187a14..df89877c9a28cf7ae8de191ea65d7f973dbc50c5 100644 (file)
@@ -527,6 +527,7 @@ define Device/cudy_x6
   DEVICE_MODEL := X6
   UIMAGE_NAME := R13
   DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools
+  SUPPORTED_DEVICES += R13
 endef
 TARGET_DEVICES += cudy_x6
 
index 30a10423ad51b320836fde0c751fbe2988b65860..b6337f397b842d31d7c1f623b55fd9bf20889dad 100644 (file)
@@ -28,8 +28,9 @@ case "$board" in
                [ "$PHYNBR" = "1" ] && macaddr_setbit_la $hw_mac_addr > /sys${DEVPATH}/macaddress
                ;;
        cudy,x6)
-               hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
-               macaddr_add $hw_mac_addr "$PHYNBR" > /sys${DEVPATH}/macaddress
+               hw_mac_addr="$(mtd_get_mac_binary bdinfo 0xde00)"
+               [ "$PHYNBR" = "1" ] && \
+               macaddr_setbit_la "$(macaddr_add $hw_mac_addr 0x100000)" > /sys${DEVPATH}/macaddress
                ;;
        dlink,dap-x1860-a1)
                hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"