Procházet zdrojové kódy

ramips: Add support for Genexis / Inteno Pulse EX400

Add support for Genexis Pulse EX400 / Inteno Pulse EX400. A branded
variant for the Finnish ISP DNA has already been added in fea2264d9fdd
(ramips: mt7621: Add DNA Valokuitu Plus EX400, 2023-07-31). This commit
adds support for the generic variants with Inteno and Genexis branding.
Inteno changed its name to Genexis and both brandings exist.

In terms of electronics, there is no difference between the DNA-branded
version and other brandings. LED markings on the case are different,
though. While the DNA-version has a "software-update" LED, the other
versions have a WPS LED. To reduce user confusion, create a separate
image.

Add the different device-tree with the different LED and rename things
to work the same way for both variants.

Specifications:
- Device: Genexis Pulse EX400 / Inteno Pulse EX400
- SoC: MT7621A
- Flash: 256 MB NAND
- RAM: 256 MB
- Ethernet: Built-in, 2 x 1 GbE
- Wifi: MT7603 2.4 GHz 2x2 MIMO, MT7615 5 GHz 4x4 MU-MIMO
- USB: 1x 2.0
- LEDs (GPIO): green/red status, green WPS
- LEDs (SX9512, unsupported): Broadband, Wi-Fi 2.4G, Wi-Fi 5G
- Buttons (GPIO): Reset
- Buttons (SX9512, unsupported): Wi-Fi 2.4G, Wi-Fi 5G, WPS

MAC addresses:
- LAN:     U-Boot 'ethaddr' (label)
- WAN:     label + 1
- 2.4 GHz: label + 6
- 5 GHz:   label + 7

Serial:
 There is a black block connector next to the red ethernet connector. It
 is accessible also through holes in the casing.

Pinout (TTL 3.3V)
 +---+---+
 |Tx |Rx |
 +---+---+
 |Vcc|Gnd|
 +---+---+

Firmware:
 The vendor firmware is a fork of OpenWrt (Reboot) with a kernel version
 4.4.93. The flash is arranged as below and there is a dual boot
 mechanism alternating between rootfs_0 and rootfs_1.

 +-------+------+------+-----------+-----------+
 |       | env1 | env2 | rootfs_0  |  rootfs_1 |
 |       +------+------+-----------+-----------+
 |       |         UBI volumes                 |
 +-------+-------------------------------------+
 |U-Boot |             UBI                     |
 +-------+-------------------------------------+
 |mtd0   |             mtd1                    |
 +-------+-------------------------------------+
 |                     NAND                    |
 +---------------------------------------------+

 In OpenWrt rootfs_0 will be used as a boot partition that will contain the
 kernel and the dtb. The squashfs rootfs and overlay are standard OpenWrt
 behaviour.

 +-------+------+------+-----------+--------+------------+
 |       | env1 | env2 | rootfs_0  | rootfs | rootfs_data|
 |       +------+------+-----------+--------+------------+
 |       |         UBI volumes                           |
 +-------+-----------------------------------------------+
 |U-Boot |             UBI                               |
 +-------+-----------------------------------------------+
 |mtd0   |             mtd1                              |
 +-------+-----------------------------------------------+
 |                     NAND                              |
 +-------------------------------------------------------+

U-boot:
 With proper serial access, booting can be halted to U-boot by pressing
 any key. TFTP and flash writes are available, but only the first one has
 been tested.

 NOTE: Recovery mode can be accessed by holding down the reset button while
 powering on the device. The led 'Update' will show a solid green light
 once ready. A web server will be running at 192.168.1.1:80 and it will
 allow flashing a firmware package. You can cycle between rootfs_0 and
 rootfs_1 by pressing the reset button once.

Root password:
 With the vendor web UI create a backup of your settings and download the
 archive to your computer. Within the archive in the file
 /etc/shadow replace the password hash for root with that of a password you
 know. Restore the configuration with the vendor web UI and you will have
 changed the root password.

SSH access:
 You might need to enable the SSH service for LAN interface as by default
 it's enabled for WAN only.

Installing OpenWrt:
 With the vendor web UI, or from the U-Boot recovery UI, install the
 OpenWrt factory image. Alternatively, ssh to the device and use
 sysupgrade -n from cli.

 Finalize by installing the OpenWrt sysupgrade image to get a fully
 functioning system.

Reverting to the vendor firmware:

 Boot with OpenWrt initramfs image
  - Remove volumes rootfs_0, rootfs and rootfs_data and create vendor
    volumes.

    ubirmvol /dev/ubi0 -n 2
    ubirmvol /dev/ubi0 -n 3
    ubirmvol /dev/ubi0 -n 4
    ubimkvol /dev/ubi0 -N rootfs_0 -S 990
    ubimkvol /dev/ubi0 -N rootfs_1 -S 990

    Power off and enter to the U-boot recovery to install the vendor
    firmware.

Signed-off-by: Andreas Gnau <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/17551
Signed-off-by: Hauke Mehrtens <[email protected]>
Andreas Gnau před 11 měsíci
rodič
revize
3e7337feea

+ 2 - 1
package/boot/uboot-envtools/files/ramips

@@ -149,7 +149,8 @@ xiaomi,mi-router-cr6608|\
 xiaomi,mi-router-cr6609)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
 	;;
-dna,valokuitu-plus-ex400)
+dna,valokuitu-plus-ex400|\
+genexis,pulse-ex400)
 	ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x1f000" "0x1f000" "1"
 	ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x1f000" "0x1f000" "1"
 	;;

+ 15 - 0
target/linux/ramips/dts/mt7621_dna_valokuitu-plus-ex400.dts

@@ -5,4 +5,19 @@
 / {
 	compatible = "dna,valokuitu-plus-ex400", "mediatek,mt7621-soc";
 	model = "DNA Valokuitu Plus EX400";
+
+	aliases {
+		led-boot = &led_status_red;
+		led-failsafe = &led_status_red;
+		led-running = &led_status_green;
+		led-upgrade = &led_update_green;
+	};
+};
+
+&leds {
+		led_update_green: led-2 {
+			color = <LED_COLOR_ID_GREEN>;
+			function = LED_FUNCTION_PROGRAMMING;
+			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+		};
 };

+ 1 - 11
target/linux/ramips/dts/mt7621_genexis_pulse-ex400-common.dtsi

@@ -10,10 +10,6 @@
 	aliases {
 		ethernet0 = &gmac0;
 		label-mac-device = &gmac0;
-		led-boot = &led_status_red;
-		led-failsafe = &led_status_red;
-		led-running = &led_status_green;
-		led-upgrade = &led_update_green;
 	};
 
 	chosen {
@@ -30,7 +26,7 @@
 		};
 	};
 
-	leds {
+	leds: leds {
 		compatible = "gpio-leds";
 
 		led_status_green: led-0 {
@@ -44,12 +40,6 @@
 			function = LED_FUNCTION_STATUS;
 			gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
 		};
-
-		led_update_green: led-2 {
-			color = <LED_COLOR_ID_GREEN>;
-			function = LED_FUNCTION_PROGRAMMING;
-			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
-		};
 	};
 };
 

+ 23 - 0
target/linux/ramips/dts/mt7621_genexis_pulse-ex400.dts

@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7621_genexis_pulse-ex400-common.dtsi"
+
+/ {
+	compatible = "genexis,pulse-ex400", "mediatek,mt7621-soc";
+	model = "Genexis/Inteno Pulse EX400";
+
+	aliases {
+		led-boot = &led_status_red;
+		led-failsafe = &led_status_red;
+		led-running = &led_status_green;
+		led-upgrade = &led_status_red;
+	};
+};
+
+&leds {
+	led_wps_green: led-2 {
+		color = <LED_COLOR_ID_GREEN>;
+		function = LED_FUNCTION_WPS;
+		gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+	};
+};

+ 31 - 16
target/linux/ramips/image/mt7621.mk

@@ -51,7 +51,7 @@ define Build/arcadyan-trx
 	rm [email protected] [email protected]
 endef
 
-define Build/dna-header
+define Build/inteno-y3-header
 	BC='$(STAGING_DIR_HOST)/bin/bc' ;\
 	ubifsofs="1024" ;\
 	ubifs="$$(stat -c%s $@)" ;\
@@ -91,7 +91,7 @@ define Build/dna-header
 	mv [email protected] $@
 endef
 
-define Build/dna-bootfs
+define Build/inteno-bootfs
 	mkdir -p [email protected]/boot
 
 	# populate the boot fs with the dtb and the kernel image
@@ -1085,23 +1085,11 @@ define Device/d-team_pbr-m1
 endef
 TARGET_DEVICES += d-team_pbr-m1
 
+# Branded version of Genexis / Inteno EX400 (difference is one LED)
 define Device/dna_valokuitu-plus-ex400
-  $(Device/dsa-migration)
-  IMAGE_SIZE := 117m
-  PAGESIZE := 2048
-  MKUBIFS_OPTS := --min-io-size=$$(PAGESIZE) --leb-size=124KiB --max-leb-cnt=96 \
-	--log-lebs=2 --space-fixup --squash-uids
+  $(Device/genexis_pulse-ex400/common)
   DEVICE_VENDOR := DNA
   DEVICE_MODEL := Valokuitu Plus EX400
-  KERNEL := kernel-bin | lzma | uImage lzma
-  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma
-  IMAGES += factory.bin
-  IMAGE/factory.bin := append-image-stage initramfs-kernel.bin | \
-	dna-bootfs | dna-header | append-md5sum-ascii-salted
-  IMAGE/sysupgrade.bin := append-kernel | dna-bootfs | \
-  	sysupgrade-tar kernel=$$$$@ | check-size | append-metadata
-  DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(2)
-  DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615-firmware kmod-usb3
 endef
 TARGET_DEVICES += dna_valokuitu-plus-ex400
 
@@ -1406,6 +1394,33 @@ define Device/gemtek_wvrtm-130acn
 endef
 TARGET_DEVICES += gemtek_wvrtm-130acn
 
+# Common definitions shared between genexis_pulse-ex400 and dna_valokuitu-plus-ex400
+define Device/genexis_pulse-ex400/common
+  $(Device/dsa-migration)
+  IMAGE_SIZE := 117m
+  PAGESIZE := 2048
+  MKUBIFS_OPTS := --min-io-size=$$(PAGESIZE) --leb-size=124KiB --max-leb-cnt=96 \
+    --log-lebs=2 --space-fixup --squash-uids
+  KERNEL := kernel-bin | lzma | uImage lzma
+  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma
+  IMAGES += factory.bin
+  IMAGE/factory.bin := append-image-stage initramfs-kernel.bin | \
+	inteno-bootfs | inteno-y3-header | append-md5sum-ascii-salted
+  IMAGE/sysupgrade.bin := append-kernel | inteno-bootfs | \
+    sysupgrade-tar kernel=$$$$@ | check-size | append-metadata
+  DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(2)
+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615-firmware kmod-usb3
+endef
+
+define Device/genexis_pulse-ex400
+  $(Device/genexis_pulse-ex400/common)
+  DEVICE_VENDOR := Genexis
+  DEVICE_MODEL := Pulse EX400
+  DEVICE_ALT0_VENDOR := Inteno
+  DEVICE_ALT0_MODEL := Pulse EX400
+endef
+TARGET_DEVICES += genexis_pulse-ex400
+
 define Device/glinet_gl-mt1300
   $(Device/dsa-migration)
   IMAGE_SIZE := 32448k

+ 1 - 0
target/linux/ramips/mt7621/base-files/etc/board.d/02_network

@@ -73,6 +73,7 @@ ramips_setup_interfaces()
 	cudy,m1300-v2|\
 	cudy,m1800|\
 	dna,valokuitu-plus-ex400|\
+	genexis,pulse-ex400|\
 	humax,e10|\
 	keenetic,kn-3510|\
 	meig,slt866|\

+ 2 - 1
target/linux/ramips/mt7621/base-files/etc/init.d/bootcount

@@ -32,7 +32,8 @@ boot() {
 	samknows,whitebox-v8)
 		fw_setenv bootcount 0
 		;;
-	dna,valokuitu-plus-ex400)
+	dna,valokuitu-plus-ex400|\
+	genexis,pulse-ex400)
 		fw_setenv boot_cnt_primary 0
 		fw_setenv boot_cnt_alt 0
 		;;

+ 9 - 4
target/linux/ramips/mt7621/base-files/lib/upgrade/dna.sh → target/linux/ramips/mt7621/base-files/lib/upgrade/inteno.sh

@@ -16,11 +16,16 @@
 . /lib/functions.sh
 . /lib/upgrade/nand.sh
 
-dna_do_upgrade () {
-	tar -xaf $1
+inteno_do_upgrade () {
+	local tar_file=$1
+	local cmd=cat
+	# WARNING: This fails if tar contains more than one 'sysupgrade-*' directory.
+	local board_dir="$(tar tf "$tar_file" | grep -m 1 '^sysupgrade-.*/$')"
+	board_dir="${board_dir%/}"
+	tar -xaf "$tar_file"
 
 	# get the size of the new bootfs
-	local _bootfs_size=$(wc -c < ./sysupgrade-dna_valokuitu-plus-ex400/kernel)
+	local _bootfs_size=$(wc -c < "$board_dir/kernel")
 	[ -n "$_bootfs_size" -a "$_bootfs_size" -gt "0" ] || nand_do_upgrade_failed
 
 	# remove existing rootfses and recreate rootfs_0
@@ -32,7 +37,7 @@ dna_do_upgrade () {
 
 	# update the rootfs_0 contents
 	local _kern_ubivol=$( nand_find_volume "ubi0" "rootfs_0" )
-	ubiupdatevol /dev/${_kern_ubivol} sysupgrade-dna_valokuitu-plus-ex400/kernel
+	ubiupdatevol "/dev/$_kern_ubivol" "$board_dir/kernel"
 
 	fw_setenv root_vol rootfs_0
 	fw_setenv boot_cnt_primary 0

+ 3 - 2
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh

@@ -157,8 +157,9 @@ platform_do_upgrade() {
 	buffalo,wsr-2533dhpls)
 		buffalo_do_upgrade "$1"
 		;;
-	dna,valokuitu-plus-ex400)
-		dna_do_upgrade "$1"
+	dna,valokuitu-plus-ex400|\
+	genexis,pulse-ex400)
+		inteno_do_upgrade "$1"
 		;;
 	elecom,wrc-x1800gs)
 		[ "$(fw_printenv -n bootmenu_delay)" != "0" ] || \