From 3ae630b5b8d425c8a1642a7305b19461861c72eb Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Wed, 22 Jul 2026 14:15:53 +0000 Subject: [PATCH] econet: add ChinaMobile GS3101 The ChinaMobile GS3101 has: 256MB RAM 256MB flash (TC58CVG1S3H) 1x MT7603 802.11 b/g/n - DISABLED 1x optical port On-die MT7530 switch with: - 1x gigabit ethernet port - 3x 100Mb ethernet ports 1x USB 2.0 port 1x telephone VoIP port 3 controllable LEDs 1 GPIO button (reset), 1 WPS button (not detected in GPIOs) UART header inside (solder required) 115200 baud 12v power (5.5mm x 2.1mm barrel connector) Installation instructions: You will need a USB stick 1. Reformat the USB stick as VFAT with MBR partition table. This is important, if it is GPT then it will silently fail to load. 2. Download openwrt-econet-en751221-chinamobile_gs3101-squashfs-tclinux.trx and store it in the USB stick. 3. Start the device with the vendor OS 4. Connect a cable and request an IP address - it will issue in 192.168.1.0/24 5. Use telnet to connect to the modem on 192.168.1.1 6. Login as root@2024 / system 7. Plugin the USB stick 8. cp /mnt/usb1_1/openwrt-econet-en751221-chinamobile_gs3101-squashfs-tclinux.trx /tmp/openwrt.trx 9. mtd -r -f write /tmp/openwrt.trx tclinux 10. You will lose your shell, look at the power light on the device, it should begin blinking and then go back to solid. You should NOT see any red light. 11. re-request an IP address 12. ssh root@192.168.1.1 13. You should be on OpenWrt now MAC address matches that of vendor OS but it is not the address on the label of the device. It is in a compressed xml file in the 'romfile' partition. WAN is this mac, LAN is mac+1 and 2.4Ghz WLAN is mac+2, there is no 5Ghz WLAN. Wifi Note: Of the devices tested, there were numerous upon which starting the wlan chip caused the CPU to hang. In the interest of avoiding bricked boards, the wlan is disabled in the DT. Signed-off-by: Caleb James DeLisle Link: https://github.com/openwrt/openwrt/pull/23533 Signed-off-by: Jonas Jelonek --- .../econet/base-files/etc/board.d/02_network | 5 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 5 + .../econet/base-files/lib/functions/econet.sh | 30 +++ .../econet/base-files/lib/upgrade/platform.sh | 22 ++ .../linux/econet/base-files/sbin/en75_chboot | 11 + .../econet/dts/en7526f_chinamobile_gs3101.dts | 189 ++++++++++++++++++ target/linux/econet/image/Makefile | 8 + target/linux/econet/image/en751221.mk | 15 ++ 8 files changed, 285 insertions(+) create mode 100644 target/linux/econet/base-files/lib/functions/econet.sh create mode 100644 target/linux/econet/base-files/lib/upgrade/platform.sh create mode 100644 target/linux/econet/dts/en7526f_chinamobile_gs3101.dts diff --git a/target/linux/econet/base-files/etc/board.d/02_network b/target/linux/econet/base-files/etc/board.d/02_network index e27926df68f..748154eb9be 100644 --- a/target/linux/econet/base-files/etc/board.d/02_network +++ b/target/linux/econet/base-files/etc/board.d/02_network @@ -1,5 +1,6 @@ . /lib/functions/system.sh . /lib/functions/uci-defaults.sh +. /lib/functions/econet.sh econet_setup_interfaces() { @@ -21,6 +22,10 @@ econet_setup_macs() local label_mac="" case "$board" in + chinamobile,gs3101) + wan_mac="$(get_mac_gs3101)" + [ -n "$wan_mac" ] && lan_mac="$(macaddr_add $wan_mac 1)" + ;; huawei,hg2821t-u) local conffile="/tmp/configuration_a/factory.conf" lan_mac=$(get_mac_ascii "$conffile" brmac) diff --git a/target/linux/econet/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/econet/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index b479abe9778..79dbc9b45cf 100755 --- a/target/linux/econet/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/econet/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -5,10 +5,15 @@ PHYNBR=${DEVPATH##*/phy} [ -n "$PHYNBR" ] || exit 0 . /lib/functions/system.sh +. /lib/functions/econet.sh board=$(board_name) case "$board" in +chinamobile,gs3101) + mac=$(get_mac_gs3101) + [ -n "$mac" ] && echo "$(macaddr_add $mac 2)" > /sys${DEVPATH}/macaddress + ;; huawei,hg2821t-u) conffile="/tmp/configuration_a/factory.conf" [ "$PHYNBR" -eq 0 ] && get_mac_ascii "$conffile" APMAC_5G > /sys${DEVPATH}/macaddress diff --git a/target/linux/econet/base-files/lib/functions/econet.sh b/target/linux/econet/base-files/lib/functions/econet.sh new file mode 100644 index 00000000000..48115058f05 --- /dev/null +++ b/target/linux/econet/base-files/lib/functions/econet.sh @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0 + +get_mac_gs3101() { + local part_name="romfile" + local idx; + + idx=$(find_mtd_index "$part_name") + if [ -z "$idx" ]; then + echo "get_mac_gs3101: partition $part_name not found" >&2 + return 1 + fi + + # /dev/null | \ + gunzip 2>/dev/null | \ + strings | \ + sed -n -e 's/^.*Mac="\([a-f0-9]\{12\}\)".*$/\1/p' | \ + while read mac; do + mac=$(macaddr_canonicalize "$mac") + [ "$mac" = "" ] && continue + # For some reason, GS3101 stores 5a:c8:76:... + # But the MAC address is 58:c8:76:... + echo "$(macaddr_unsetbit "$mac" 7)" + break + done | \ + grep '[a-f0-9:]\{17\}' && return 0 + + echo "get_mac_gs3101: could not find mac address" >&2 + return 1 +} diff --git a/target/linux/econet/base-files/lib/upgrade/platform.sh b/target/linux/econet/base-files/lib/upgrade/platform.sh new file mode 100644 index 00000000000..f84786504cc --- /dev/null +++ b/target/linux/econet/base-files/lib/upgrade/platform.sh @@ -0,0 +1,22 @@ +platform_check_image() { + local board=$(board_name) + + case "$board" in + chinamobile,gs3101) + return 0 + ;; + esac + + return 1 +} + +platform_do_upgrade() { + local board=$(board_name) + + case "$board" in + chinamobile,gs3101) + CI_KERNPART="tclinux_kernel" + nand_do_upgrade "$1" + ;; + esac +} diff --git a/target/linux/econet/base-files/sbin/en75_chboot b/target/linux/econet/base-files/sbin/en75_chboot index 1d711e465cf..42eefcd53b6 100755 --- a/target/linux/econet/base-files/sbin/en75_chboot +++ b/target/linux/econet/base-files/sbin/en75_chboot @@ -164,6 +164,17 @@ main() { code_openwrt=0000 code_factory=0101 ;; + chinamobile,gs3101) + part=$(part_named '"reservearea"') + offset_blocks=12 + block_size=$((1024 * 128)) + code_offset=0 + code_openwrt=31 + code_factory=30 + # Slot B is never used on this platform so switching will brick + echo "GS3101 does not support A/B partitioning" + exit 1 + ;; *) echo "Unsupported machine: $machine" exit 1 diff --git a/target/linux/econet/dts/en7526f_chinamobile_gs3101.dts b/target/linux/econet/dts/en7526f_chinamobile_gs3101.dts new file mode 100644 index 00000000000..29cf07b45b1 --- /dev/null +++ b/target/linux/econet/dts/en7526f_chinamobile_gs3101.dts @@ -0,0 +1,189 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +/dts-v1/; + +#include +#include +#include + +#include "en7526f.dtsi" + +/ { + model = "ChinaMobile GS3101"; + compatible = "chinamobile,gs3101", "econet,en7526f", "econet,en751221"; + + memory@0 { + device_type = "memory"; + reg = <0x00000000 0x10000000>; + }; + + chosen { + stdout-path = "/serial@1fbf0000:115200"; + }; + + keys { + compatible = "gpio-keys-polled"; + poll-interval = <100>; + + key-reset { + label = "reset"; + linux,code = ; + gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; + }; + }; + + aliases { + led-boot = &led_power_green; + led-failsafe = &led_signal_red; + led-running = &led_power_green; + led-upgrade = &led_registered_green; + }; + + leds { + compatible = "gpio-leds"; + + led_power_green: led-0 { + /* Written "电源" (Power supply) */ + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; + }; + + led_registered_green: led-1 { + /* Written "注册" (Registered) */ + color = ; + function = LED_FUNCTION_WAN; + gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; + }; + + led_signal_red: led-2 { + /* Written "光信号" (Optical signal) */ + color = ; + function = "signal"; + gpios = <&gpio0 31 GPIO_ACTIVE_LOW>; + }; + }; + + virtual_flash { + compatible = "mtd-concat"; + devices = <&rootA &rootB &root2>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "ubi"; + reg = <0x0 0x0>; + }; + }; + }; +}; + +&nand { + status = "okay"; + econet,bmt; + econet,bbt-table-size = <250>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bootloader"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "romfile"; + reg = <0x40000 0x40000>; + }; + + partition@80000 { + label = "tclinux"; + reg = <0x80000 0x1000000>; + econet,enable-remap; + }; + + partition1@80000 { + label = "tclinux_kernel"; + reg = <0x80000 0x400000>; + econet,enable-remap; + }; + + rootA: partition1@480000 { + label = "tclinux_rootfs"; + reg = <0x480000 0xc00000>; + }; + + partition@1080000 { + label = "tclinux_alt"; + reg = <0x1080000 0x1000000>; + econet,enable-remap; + }; + + partition1@1080000 { + label = "tclinux_alt_kernel"; + reg = <0x1080000 0x400000>; + econet,enable-remap; + }; + + rootB: partition1@1480000 { + label = "tclinux_alt_rootfs"; + reg = <0x1480000 0xc00000>; + }; + + root2: partition@2080000 { + label = "common_rootfs"; + reg = <0x2080000 0xbdc0000>; + }; + + partition@de40000 { + label = "reservearea"; + reg = <0xde40000 0x1c0000>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + eeprom_reserve_140000: eeprom@140000 { + /* MT7592 */ + reg = <0x140000 0x200>; + }; + }; + }; + }; +}; + +&gmac0 { + status = "okay"; + /* + * MAC address used in factory OS is found in an XML-like file + * in a tar.gz which is written to partition romfile. + * This address does not match the address on the device label + * and can only be extracted by a script. + */ +}; + +/* + * There is an MT7592 (MT7603 compatible) chip on this board, but on a large + * fraction of devices it is apparently defective and attempting to start it + * causes a board hang. In the interest of not causing bricked devices, this + * is commented out. + * Adventurous users may uncomment this and try to re-flash at their own risk. + +&pcie0 { + status = "okay"; +}; +&slot0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + nvmem-cells = <&eeprom_reserve_140000>; + nvmem-cell-names = "eeprom"; + }; +}; +*/ diff --git a/target/linux/econet/image/Makefile b/target/linux/econet/image/Makefile index a496a0891ee..d819673ff19 100644 --- a/target/linux/econet/image/Makefile +++ b/target/linux/econet/image/Makefile @@ -13,6 +13,14 @@ define Build/tclinux-trx mv $@.new $@ endef +# Build TRX without rootfs, for use with UBI root +define Build/kernel-trx + ./tclinux-trx.sh --kernel $@ \ + --version $(VERSION_DIST)-$(REVISION) --endian $(TRX_ENDIAN) \ + $(if $(TRX_MODEL),--model $(TRX_MODEL)) > $@.new + mv $@.new $@ +endef + # If TCSUPPORT_FREE_BOOTBASE is enabled, bootloader will decompress the kernel # at 0x80002000 instead of 0x80020000. # diff --git a/target/linux/econet/image/en751221.mk b/target/linux/econet/image/en751221.mk index 13b8de4ddc6..ec96a5ac20a 100644 --- a/target/linux/econet/image/en751221.mk +++ b/target/linux/econet/image/en751221.mk @@ -1,5 +1,20 @@ TRX_ENDIAN := be +define Device/chinamobile_gs3101 + DEVICE_VENDOR := ChinaMobile + DEVICE_MODEL := GS3101 + DEVICE_DTS := en7526f_chinamobile_gs3101 + KERNEL_SIZE := 4096k + NAND_SIZE := 256m + KERNEL := kernel-bin | append-dtb | lzma | kernel-trx + KERNEL_INITRAMFS := kernel-bin | append-dtb + IMAGES := tclinux.trx sysupgrade.bin + IMAGE/tclinux.trx := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_PACKAGES := kmod-usb3 kmod-mt7603 +endef +TARGET_DEVICES += chinamobile_gs3101 + define Device/en751221_generic DEVICE_VENDOR := EN751221 Family DEVICE_MODEL := Initramfs Image -- 2.47.3