[openwrt/openwrt] ramips: add support for Netgear PR2000

LEDE Commits lede-commits at lists.infradead.org
Sat Aug 6 10:59:10 PDT 2022


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/b00a02aaa0fff867acfe02229f39bc47158f0874

commit b00a02aaa0fff867acfe02229f39bc47158f0874
Author: David Yang <mmyangfl at gmail.com>
AuthorDate: Wed Jun 9 00:53:27 2021 +0800

    ramips: add support for Netgear PR2000
    
    This patch adds support for Netgear PR2000, sold as "Travel Router and
    Range Extender".
    
    Specifications:
    --------------
    
    * SoC: Mediatek MT7620N
    * RAM: 64MB DDR2
    * Flash: 16MB SPI NOR flash (Macronix MX25L12805D)
    * WiFi 2.4GHz: builtin
    * Ethernet: builtin
    * LED: Power, Internet, WiFi, USB
    * Buttons: Reset (GPIO 1/2)
    * UART: Serial console (57600 8n1)
    * USB: 1 x USB2
    
    SPECIAL NOTES:
    -------------
    
    Problem: WiFi is super weak, but SSID beacons seems to be right.
    
    Solve: Change 36h in factory partition (namely 0xf60036) to be 0x0.
    
    Explain: Clearly Netgear have different ideas on how EEPROM is used. Bit 2
    of 36h indicates the presence of External LNA for 11g (2.4 GHz) band,
    which seems to be incorrectly set by Netgear (originally 0x04). Lifting it
    solves the problem of weak RX signal.
    
    Installation:
    ------------
    
    There are two possible ways to install the firmware. Flashing via web
    interface of original firmware is not tested due to a broken firmware.
    
    1) Open the shell and use a UART2USB convert to gain TTY access (TP7: RXD,
       TP9: TXD, TP10: GND). Please notice you have to remove resistance R54
       next to TP7 otherwise you won't be able to input anything.
    2) Use well-known Netgear debug switch. Access
       http://192.168.168.1/setup.cgi?todo=debug to start telnet service
       (username: root, password: <none>).
    
    Please back up firmware if you want to go back to the original.
    
    After you can control the device, flash the firmware as usual. Here are
    some hints for that.
    
    Option 1 (via nmrpflash):
    
    1) Download nmrpflash from https://github.com/jclehner/nmrpflash
    2) Use *-factory.img and flash:
         nmrpflash -L
         nmrpflash -i net* -f <your-firmware-name>
    3) Turn off then turn on the device, wait it finishing flash.
    
    Option 2 (replacing u-boot via breed):
    
    1) Download breed-mt7620-reset1.bin from https://breed.hackpascal.net/
    2) Setup HTTP server on your computer, for example:
         python3 -m http.server
       You can skip this step if your breed is already accessible from HTTP,
       since the original wget does not support HTTPS.
    3) Connect to the route and flash breed:
         cd /tmp
         wget http://<your-computer-host>/breed-mt7620-reset1.bin
         dd if=breed-mt7620-reset1.bin of=/dev/mtdblock0 bs=64k
    4) Reboot. Hold reset key or press any key in TTY to enter breed.
    5) Access breed web interface (http://192.168.1.1/). Choose memory layout
       to be 0x40000 and flash new firmware.
    
    Remark:
    ------
    
    As a "Range Extender", it has a switch to switch between Wired mode (GPIO
    21 low) and Wireless mode (GPIO 20 low), which is not implemented in this
    patch. However, the router will be turned off when it switches to the
    middle, which makes this switch much less useful.
    
    MAC addresses:
    -------------
    
    The OEM firmware uses one single MAC for all interfaces, located at
    0xf700b0.
    
    Signed-off-by: David Yang <mmyangfl at gmail.com>
---
 target/linux/ramips/dts/mt7620n_netgear_pr2000.dts | 191 +++++++++++++++++++++
 target/linux/ramips/image/mt7620.mk                |  15 ++
 .../ramips/mt7620/base-files/etc/board.d/01_leds   |   3 +
 .../mt7620/base-files/etc/board.d/02_network       |   1 +
 4 files changed, 210 insertions(+)

diff --git a/target/linux/ramips/dts/mt7620n_netgear_pr2000.dts b/target/linux/ramips/dts/mt7620n_netgear_pr2000.dts
new file mode 100644
index 0000000000..6b4dde5432
--- /dev/null
+++ b/target/linux/ramips/dts/mt7620n_netgear_pr2000.dts
@@ -0,0 +1,191 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7620n.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	compatible = "netgear,pr2000", "ralink,mt7620n-soc";
+	model = "Netgear PR2000";
+
+	aliases {
+		label-mac-device = ðernet;
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		internet {
+			label = "green:internet";
+			gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
+		};
+
+		wifi {
+			label = "green:wifi";
+			gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "phy0tpt";
+		};
+
+		usb {
+			label = "green:usb";
+			gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
+			trigger-sources = <&ohci_port1>, <&ehci_port1>;
+			linux,default-trigger = "usbport";
+		};
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+
+		wireless {
+			label = "wireless";
+			gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
+			linux,code = <BTN_0>;
+			linux,input-type = <EV_SW>;
+		};
+
+		wired {
+			label = "wired";
+			gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
+			linux,code = <BTN_0>;
+			linux,input-type = <EV_SW>;
+		};
+	};
+};
+
+&gpio2 {
+	status = "okay";
+};
+
+&gpio3 {
+	status = "okay";
+};
+
+&spi0 {
+	status = "okay";
+
+	flash at 0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <50000000>;
+		m25p,fast-read;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "u-boot";
+				reg = <0x0 0x30000>;
+				read-only;
+			};
+
+			partition at 30000 {
+				label = "u-boot-env";
+				reg = <0x30000 0x10000>;
+			};
+
+			/* sercomm header for kernel starts at 0x3ffba
+			 * can be safely ignored since not used by OpenWRT
+			 */
+
+			partition at 40000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x40000 0xf20000>;
+			};
+
+			factory: partition at f60000 {
+				label = "factory";
+				reg = <0xf60000 0x10000>;
+				read-only;
+			};
+
+			board_data: partition at f70000 {
+				label = "board_data";
+				reg = <0xf70000 0x10000>;
+				read-only;
+			};
+
+			partition at f80000 {
+				label = "POT";
+				reg = <0xf80000 0x10000>;
+				read-only;
+			};
+
+			partition at f90000 {
+				label = "Traffic Meter";
+				reg = <0xf90000 0x10000>;
+				read-only;
+			};
+
+			partition at fa0000 {
+				label = "Traffic Meter2";
+				reg = <0xfa0000 0x10000>;
+				read-only;
+			};
+
+			partition at fb0000 {
+				label = "nvram";
+				reg = <0xfb0000 0x10000>;
+			};
+
+			partition at fc0000 {
+				label = "DPF";
+				reg = <0xfc0000 0x10000>;
+				read-only;
+			};
+
+			partition at fd0000 {
+				label = "ralink_nvram";
+				reg = <0xfd0000 0x10000>;
+				read-only;
+			};
+
+			partition at fe0000 {
+				label = "reserved1";
+				reg = <0xfe0000 0x10000>;
+				read-only;
+			};
+
+			partition at ff0000 {
+				label = "reserved2";
+				reg = <0xff0000 0x10000>;
+				read-only;
+			};
+		};
+	};
+};
+
+&ethernet {
+	mtd-mac-address = <&board_data 0xb0>;
+	mediatek,portmap = "wllll";
+};
+
+&ehci {
+	status = "okay";
+};
+
+&ohci {
+	status = "okay";
+};
+
+&wmac {
+	ralink,mtd-eeprom = <&factory 0x0>;
+	mtd-mac-address = <&board_data 0xb0>;
+};
+
+&state_default {
+	default {
+		groups = "ephy", "wled", "pa", "i2c";
+		function = "gpio";
+	};
+};
diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk
index d2a2c90460..b3551fa6cb 100644
--- a/target/linux/ramips/image/mt7620.mk
+++ b/target/linux/ramips/image/mt7620.mk
@@ -802,6 +802,21 @@ define Device/netgear_jwnr2010-v5
 endef
 TARGET_DEVICES += netgear_jwnr2010-v5
 
+define Device/netgear_pr2000
+  $(Device/netgear_sercomm_nor)
+  SOC := mt7620n
+  BLOCKSIZE := 4k
+  IMAGE_SIZE := 15488k
+  DEVICE_MODEL := PR2000
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+  SERCOMM_HWNAME := PR2000
+  SERCOMM_HWID := AQ7
+  SERCOMM_HWVER := A001
+  SERCOMM_SWVER := 0x0000
+  SERCOMM_PAD := 640k
+endef
+TARGET_DEVICES += netgear_pr2000
+
 define Device/netgear_wn3000rp-v3
   SOC := mt7620a
   IMAGE_SIZE := 7872k
diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
index 1293c34cbf..889818c631 100644
--- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds
@@ -177,6 +177,9 @@ netgear,jwnr2010-v5)
 	ucidef_set_led_switch "lan4" "lan4" "green:lan4" "switch0" "0x01"
 	ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x10"
 	;;
+netgear,pr2000)
+	ucidef_set_led_switch "internet" "internet" "green:internet" "switch0" "0x01"
+	;;
 phicomm,psg1208)
 	ucidef_set_led_netdev "wifi_led" "wifi" "white:wlan2g" "wlan0"
 	;;
diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
index f7bc41669f..7b1766766b 100644
--- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
@@ -202,6 +202,7 @@ ramips_setup_interfaces()
 		ucidef_add_switch "switch1" \
 			"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6 at eth0"
 		;;
+	netgear,pr2000|\
 	nexx,wt3020-4m|\
 	nexx,wt3020-8m)
 		ucidef_add_switch "switch0" \




More information about the lede-commits mailing list