diff mbox

[LEDE-DEV] ramips: add support for RATOC REX-WIFISD2

Message ID 20170110153917.10350-1-naobsd@gmail.com
State Superseded
Delegated to: Mathias Kresin
Headers show

Commit Message

FUKAUMI Naoki Jan. 10, 2017, 3:39 p.m. UTC
RATOC REX-WIFISD2 is a battery-powered wireless SD card reader with

 - MT7620A + MT7610E
 - 64MiB DDR2 SDRAM
 - 16MiB SPI flash
 - 2T2R 2.4GHz + 1T1R 5GHz Wi-Fi
 - 1x 10/100Mbps ethernet switch
 - 1x SD card
 - 1x USB 2.0
 - 2x programmable LED
 - 1x button

stock firmware is very similar to HooToo Tripmate travel routers. you
can do almost anything as a root user with telnet and/or shell script
(factory image or "EnterRouterMode.sh") on stock firmware.

"EnterRouterMode.sh" will be the easiest way to install. put the
following shell script into SD card (or USB storage) as
"EnterRouterMode.sh" with "kernel.bin" and "rootfs.bin" files.

 ----
 #!/bin/sh

 dir=`dirname $0`

 mtd_write write ${dir}/kernel.bin Kernel_RootFS
 mtd_write -r write ${dir}/rootfs.bin Rootfs
 ----

it will be run automatically when SD card is mounted on stock firmware.

TFTP can also be used to flash kernel and rootfs. it will be run by
press & hold RESET button while power on. (serverip=10.10.10.254)

you may use all partitions between "kernel" and "rootfs" as a single
"firmware" partition (please edit dts yourself), but "params" partition
should be kept if you want to restore stock firmware.

Signed-off-by: FUKAUMI Naoki <naobsd@gmail.com>
---
 .../linux/ramips/base-files/etc/board.d/02_network |   1 +
 target/linux/ramips/base-files/etc/diag.sh         |   3 +-
 target/linux/ramips/base-files/lib/ramips.sh       |   3 +
 .../ramips/base-files/lib/upgrade/platform.sh      |   1 +
 target/linux/ramips/dts/REX-WIFISD2.dts            | 145 +++++++++++++++++++++
 target/linux/ramips/image/mt7620.mk                |  10 ++
 6 files changed, 162 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/ramips/dts/REX-WIFISD2.dts
diff mbox

Patch

diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
index daf9b33..d59a450 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -189,6 +189,7 @@  ramips_setup_interfaces()
 	mzk-ex750np|\
 	na930|\
 	pbr-d1|\
+	rex-wifisd2|\
 	wli-tx4-ag300n|\
 	wmr-300|\
 	wrh-300cr)
diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh
index a22be5e..94be032 100644
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -41,7 +41,8 @@  get_status_led() {
 	xdxrn502j)
 		status_led="$board:green:power"
 		;;
-	3g-6200nl)
+	3g-6200nl|\
+	rex-wifisd2)
 		status_led="$board:green:internet"
 		;;
 	a5-v11|\
diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
index 9b82b2a..90f8370 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -400,6 +400,9 @@  ramips_board_detect() {
 	*"RE6500")
 		name="re6500"
 		;;
+	*"REX-WIFISD2")
+		name="rex-wifisd2"
+		;;
 	*"RN502J")
 		name="xdxrn502j"
 		;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index c097cfa..87f4ecd 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -111,6 +111,7 @@  platform_check_image() {
 	px-4885|\
 	rb750gr3|\
 	re6500|\
+	rex-wifisd2|\
 	rp-n53|\
 	rt5350f-olinuxino|\
 	rt5350f-olinuxino-evb|\
diff --git a/target/linux/ramips/dts/REX-WIFISD2.dts b/target/linux/ramips/dts/REX-WIFISD2.dts
new file mode 100644
index 0000000..ddf7e01
--- /dev/null
+++ b/target/linux/ramips/dts/REX-WIFISD2.dts
@@ -0,0 +1,145 @@ 
+/dts-v1/;
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	compatible = "ratoc,rex-wifisd2", "ralink,mt7620a-soc";
+	model = "RATOC REX-WIFISD2";
+
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <20>;
+
+		reset {
+			label = "reset";
+			gpios = <&gpio2 1 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		internet {
+			label = "rex-wifisd2:green:internet";
+			gpios = <&gpio2 2 GPIO_ACTIVE_HIGH>;
+		};
+
+		wifi {
+			label = "rex-wifisd2:blue:wifi";
+			gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
+		};
+	};
+};
+
+&ehci {
+	status = "okay";
+};
+
+&ethernet {
+	mtd-mac-address = <&factory 0x2e>;
+	mediatek,portmap = "llllw";
+};
+
+&gpio1 {
+	status = "okay";
+};
+
+&gpio2 {
+	status = "okay";
+};
+
+&gpio3 {
+	status = "okay";
+};
+
+&ohci {
+	status = "okay";
+};
+
+&pcie {
+	status = "okay";
+
+	pcie-bridge {
+		mt76@0,0 {
+			reg = <0x0000 0 0 0 0>;
+			device_type = "pci";
+			mediatek,mtd-eeprom = <&factory 0x8000>;
+			mediatek,2ghz = <0>;
+		};
+	};
+};
+
+&pinctrl {
+	state_default: pinctrl0 {
+		gpio {
+			ralink,group = "wled", "ephy";
+			ralink,function = "gpio";
+		};
+	};
+};
+
+&spi0 {
+	status = "okay";
+
+	m25p80@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+		m25p,chunked-io = <32>;
+
+		partition@0 {
+			label = "u-boot";
+			reg = <0x0 0x30000>;
+			read-only;
+		};
+
+		partition@30000 {
+			label = "u-boot-env";
+			reg = <0x30000 0x10000>;
+			read-only;
+		};
+
+		factory: partition@40000 {
+			label = "factory";
+			reg = <0x40000 0x10000>;
+			read-only;
+		};
+
+		partition@50000 {
+			label = "kernel";
+			reg = <0x50000 0x180000>;
+		};
+
+		partition@1d0000 {
+			label = "params";
+			reg = <0x1d0000 0x10000>;
+		};
+
+		partition@1e0000 {
+			label = "user_backup";
+			reg = <0x1e0000 0x10000>;
+		};
+
+		partition@1f0000 {
+			label = "user";
+			reg = <0x1f0000 0x10000>;
+		};
+
+		partition@200000 {
+			label = "rootfs";
+			reg = <0x200000 0xe00000>;
+		};
+	};
+};
+
+&wmac {
+	ralink,mtd-eeprom = <&factory 0>;
+};
diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk
index 1889bcf..d479010 100644
--- a/target/linux/ramips/image/mt7620.mk
+++ b/target/linux/ramips/image/mt7620.mk
@@ -462,3 +462,13 @@  define Device/kng_rc
 	zyimage -d 8997 -v "ZyXEL Keenetic Viva"
 endef
 TARGET_DEVICES += kng_rc
+
+define Device/rex-wifisd2
+  DTS := REX-WIFISD2
+  IMAGES := kernel.bin rootfs.bin
+  IMAGE/kernel.bin := append-kernel
+  IMAGE/rootfs.bin := append-rootfs | pad-rootfs
+  DEVICE_TITLE := RATOC REX-WIFISD2
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += rex-wifisd2