[OpenWrt-Devel,v4,1/3] ramips: add support for JS7628 development board
diff mbox series

Message ID 1570526416-4180-1-git-send-email-wurobinson@qq.com
State Superseded, archived
Headers show
Series
  • [OpenWrt-Devel,v4,1/3] ramips: add support for JS7628 development board
Related show

Commit Message

Robinson Wu Oct. 8, 2019, 9:20 a.m. UTC
This commit adds support for the ZhuoTK JS7628 development board,
The device has the following specifications:

- SOC:MT7628AN/NN
- RAM:64/128/256 MB (DDR2)
- FLASH:8/16/32 MB (SPI NOR)
- Ethernet:3x 10/100 Mbps ethernet ports (MT7628AN/NN built-in switch)
- WIFI:1x 2T2R 2.4 GHz Wi-Fi
- LEDs:1x system status green LED, 1x wifi green LED,
       3x ethernet green LED
- Buttons:1x reset button, 2x user defined button
- 1x microSD slot
- 4x USB 2.0 port
- 1x mini-usb debug UART
- 1x DC jack for main power (DC 5V)
- 1x TTL/RS232 UART
- 1x TTL/RS485 UART
- 13x GPIO header
- 1x audio codec(wm8960)

Installation via OpenWrt:

The original firmware is OpenWrt, so both LuCI or sysupgrade can be used.

Installation via U-boot web:

1. Power on board with reset button pressed, release it
   after wifi led start blinking.
2. Setup static IP 192.168.1.123/4 on your PC.
3. Go to 192.168.1.8 in browser and upload "sysupgrade" image.

Installation via U-boot tftp:
1. Connect to serial console at the mini usb, which has been connected to UART0
   on board (115200 8N1)
2. Setup static IP 192.168.1.123/4 on your PC.
3. Place openwrt-firmware.bin on your PC tftp server (192.168.1.123).
3. Connect one of LAN ports on board to your PC.
4. Start terminal software (e.g. screen /dev/ttyUSB0 115200) on PC.
5. Apply power to board.
6. Interrupt U-boot with keypress of "2".
7. At u-boot prompts:
   Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N) Y
   Input device IP (192.168.1.8) ==:192.168.1.8
   Input server IP (192.168.1.123) ==:192.168.1.123
   Input Linux Kernel filename (root_uImage) ==:openwrt-firmware.bin
8. board will download file from tftp server, write it to flash and reboot.

Other notes:

1. This board is available with three types of RAM with flash
   configuration. Chose one of the right "Target Profile" in
   "make menuconfig" as listed below:

   "ZhuoTK JS7628 8M flash"
   "ZhuoTK JS7628 16M flash"
   "ZhuoTK JS7628 32M flash"

   to fit the board you have.

Vist www.zhuotk.com for further information.

Signed-off-by: Robinson Wu <wurobinson@qq.com>
---
 target/linux/ramips/base-files/etc/board.d/01_leds |   6 ++
 .../linux/ramips/base-files/etc/board.d/02_network |   3 +
 .../ramips/dts/mt7628an_zhuotk_js7628-16m.dts      |  60 ++++++++++++
 .../ramips/dts/mt7628an_zhuotk_js7628-32m.dts      |  60 ++++++++++++
 .../linux/ramips/dts/mt7628an_zhuotk_js7628-8m.dts |  60 ++++++++++++
 .../linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi   | 105 +++++++++++++++++++++
 target/linux/ramips/image/mt76x8.mk                |  30 ++++++
 7 files changed, 324 insertions(+)
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js7628-16m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js7628-32m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js7628-8m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi

Comments

Adrian Schmutzler Oct. 8, 2019, 12:31 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org] On Behalf Of Robinson Wu
> Sent: Dienstag, 8. Oktober 2019 11:20
> To: openwrt-devel@lists.openwrt.org
> Cc: Robinson Wu <wurobinson@qq.com>
> Subject: [OpenWrt-Devel] [PATCH v4 1/3] ramips: add support for JS7628 development board
> 
> This commit adds support for the ZhuoTK JS7628 development board,
> The device has the following specifications:
> 

Having looked at all three patches, I wonder whether there is any OpenWrt-relevant difference between the boards with same flash size (except the name). So, is there a difference between e.g.
Device/zhuotk_js7628-8m
Device/zhuotk_js7688-8m
Device/zhuotk_ztk7628p-8m
?

If there is no difference, you have essentially two options:

1. Keep devices separate:
In this case, you should create flash-based DTSIs on top of the existing DTSI, e.g.
mt7628an_zhuotk_js76x8-8m.dtsi
mt7628an_zhuotk_js76x8-16m.dtsi
mt7628an_zhuotk_js76x8-32m.dtsi

Each of those will contain the former content of the corresponding DTS file except the compatible/model.
Based on those DTSIs you could then have nine DTS files for the devices (just as you did) that then just contain a link to the matching DTSI and model/compatible.

2. Have three devices only:
I personally think option 1 is overkill here. Instead, you could exploit the DEVICE_ALT syntax and only create three devices, but use all nine names for them:

Three DTSes:
mt7628an_zhuotk_js76x8-8m.dts
mt7628an_zhuotk_js76x8-16m.dts
mt7628an_zhuotk_js76x8-32m.dts

Three definitions with nine names:
+define Device/zhuotk_js76x8-8m
+  MTK_SOC := mt7628an
+  IMAGE_SIZE := 7872k
+  DEVICE_VENDOR := ZhuoTK
+  DEVICE_MODEL := JS7628
+  DEVICE_VARIANT := 8M flash
+  DEVICE_ALT0_VENDOR := ZhuoTK
+  DEVICE_ALT0_MODEL := JS7688
+  DEVICE_ALT0_VARIANT := 8M flash
+  DEVICE_ALT1_VENDOR := ZhuoTK
+  DEVICE_ALT1_MODEL := ZTK7628P
+  DEVICE_ALT1_VARIANT := 8M flash
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += zhuotk_js76x8-8m
+
+define Device/zhuotk_js76x8-16m
... accordingly
+endef
+TARGET_DEVICES += zhuotk_js76x8-16m
+
+define Device/zhuotk_js76x8-32m
... accordingly
+endef
+TARGET_DEVICES += zhuotk_js76x8-32m
+

compatible in DTSes will have to match Device node names, so
zhuotk,js76x8-8m etc.

I think this will provide I nice tradeoff between usability and codebase tidiness.

Best

Adrian Schmutzler
Adrian Schmutzler Oct. 8, 2019, 12:52 p.m. UTC | #2
Hi again,

> +	m25p80@0 {

You should use a generic node name like "flash" here. https://github.com/devicetree-org/devicetree-specification/blob/master/source/devicetree-basics.rst#generic-names-recommendation

Best

Adrian Schmutzler
Robinson Wu Oct. 9, 2019, 4:19 a.m. UTC | #3
Hi Adrian,
JS7628 use MT7628AN/NN chip
JS7688 use MT7688AN chip
ZTK7628P use MT7628DAN chip
Here are some differences between those chips and modules' shape. If I use "JS76x8-8m" the OpenWRT firmware name will be "openwrt-ramips-mt76x8-zhuotk_js76x8-8m". When users see this firmware name, the they will be confused what module this firmware should match to.
I think, the solution is "auto flash file system partition size detect in DTS",  by setting some DTS configurations, the system will auto set partition size for file system as the size of the file system is changeable. If the DTS has this feature, the "JS7628", "JS7688", "ZTK7628P" boards' configurations in DTS will be "mt7628an_zhuotk_js7628.dts", "mt7628an_zhuotk_js7688.dts", "mt7628an_zhuotk_ztk7628p.dts", and the "target/linux/ramips/image/mt76x8.mk" will be left "zhuotk_js7628", "zhuotk_js7688", "zhuotk_ztk7628p" too.
But I don't know how to do "auto flash file system partition size in DTS" yet, and I don't see any configuration in OpenWRT source like that. So I think, what I commited is better than yours.



Best 


Robinson Wu
Robinson Wu Oct. 9, 2019, 11:23 a.m. UTC | #4
Hi,
 I send a new patch for the JS76x8 boards, as your advices. Hope it will be accepted soon. Thank you.
  
 Best
  
 Robinson Wu
Adrian Schmutzler Oct. 9, 2019, 11:48 a.m. UTC | #5
Hi,

before you resend you patches, two other comments:

1. When we introduced DEVICE_VARIANT, we typically removed the "flash" reference formerly present in the DEVICE_TITLE.

So you might update your DEVICE_VARIANT entries for consistency, e.g.

DEVICE_VARIANT := 32M flash

to

DEVICE_VARIANT := 32M

2. Currently, you set up wan MAC address to eth0 + 1 with the default case in 02_network (line 731).

Do the boards have a wan MAC address on flash (0x2e or somewhere else)? If yes, please add it to the ramips_setup_macs() section (starting line 516) explicitly.

Same would be necessary if the wan address is _not_ different from the lan/eth0 address. In this case add your boards to the "empty case" starting in line 584.

As those are development boards, they most probably won't have a label with a MAC address on them?

Despite, I do not have commit access, so expect comments from other people or further waiting.

Best

Adrian Schmutzler
Adrian Schmutzler Oct. 9, 2019, 11:50 a.m. UTC | #6
Ah, sorry, too late. Didn't realize you already sent a patch as you started with v1 again ...

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org] On Behalf Of Adrian Schmutzler
> Sent: Mittwoch, 9. Oktober 2019 13:48
> To: '且听风吟' <wurobinson@qq.com>
> Cc: 'openwrt-devel' <openwrt-devel@lists.openwrt.org>
> Subject: Re: [OpenWrt-Devel] RE:RE: [PATCH v4 1/3] ramips: add support for JS7628 development board
> 
> Hi,
> 
> before you resend you patches, two other comments:
> 
> 1. When we introduced DEVICE_VARIANT, we typically removed the "flash" reference formerly present in the DEVICE_TITLE.
> 
> So you might update your DEVICE_VARIANT entries for consistency, e.g.
> 
> DEVICE_VARIANT := 32M flash
> 
> to
> 
> DEVICE_VARIANT := 32M
> 
> 2. Currently, you set up wan MAC address to eth0 + 1 with the default case in 02_network (line 731).
> 
> Do the boards have a wan MAC address on flash (0x2e or somewhere else)? If yes, please add it to the ramips_setup_macs() section
> (starting line 516) explicitly.
> 
> Same would be necessary if the wan address is _not_ different from the lan/eth0 address. In this case add your boards to the "empty
> case" starting in line 584.
> 
> As those are development boards, they most probably won't have a label with a MAC address on them?
> 
> Despite, I do not have commit access, so expect comments from other people or further waiting.
> 
> Best
> 
> Adrian Schmutzler

Patch
diff mbox series

diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds
index f8a270b..b09beb9 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -467,6 +467,12 @@  zbtlink,zbt-we1226)
 	ucidef_set_led_switch "lan2" "LAN2" "$boardname:green:lan2" "switch0" "0x02"
 	ucidef_set_led_switch "wan" "WAN" "$boardname:green:wan" "switch0" "0x10"
 	;;
+zhuotk,js7628-8m|\
+zhuotk,js7628-16m|\
+zhuotk,js7628-32m)
+	ucidef_set_led_timer "system" "system" "js76x8:green:system" "1000" "1000"
+	set_wifi_led "js76x8:green:wifi"
+	;;
 zorlik,zl5900v2)
 	ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" eth0
 	;;
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 25aa075..fa6ccf7 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -102,6 +102,9 @@  ramips_setup_interfaces()
 	zbtlink,zbt-wg3526-16m|\
 	zbtlink,zbt-wg3526-32m|\
 	zbtlink,zbt-wr8305rt|\
+	zhuotk,js7628-8m|\
+	zhuotk,js7628-16m|\
+	zhuotk,js7628-32m|\
 	zyxel,keenetic|\
 	zyxel,keenetic-omni)
 		ucidef_add_switch "switch0" \
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js7628-16m.dts b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-16m.dts
new file mode 100644
index 0000000..4058577
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-16m.dts
@@ -0,0 +1,60 @@ 
+/dts-v1/;
+
+#include "mt7628an_zhuotk_js76x8.dtsi"
+
+/ {
+	compatible = "zhuotk,js7628-16m", "zhuotk,js76x8", "mediatek,mt7628an-soc";
+	model = "ZhuoTK JS7628 (16M flash)";
+};
+
+&spi0 {
+	status = "okay";
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;
+
+	m25p80@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <40000000>;
+		m25p,chunked-io = <32>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			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 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x50000 0xfb0000>;
+			};
+		};
+	};
+
+	spidev@1 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "linux,spidev";
+		reg = <1>;
+		spi-max-frequency = <40000000>;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js7628-32m.dts b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-32m.dts
new file mode 100644
index 0000000..9bbd0fd
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-32m.dts
@@ -0,0 +1,60 @@ 
+/dts-v1/;
+
+#include "mt7628an_zhuotk_js76x8.dtsi"
+
+/ {
+	compatible = "zhuotk,js7628-32m", "zhuotk,js76x8", "mediatek,mt7628an-soc";
+	model = "ZhuoTK JS7628 (32M flash)";
+};
+
+&spi0 {
+	status = "okay";
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;
+
+	m25p80@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <40000000>;
+		m25p,chunked-io = <32>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			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 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x50000 0x1fb0000>;
+			};
+		};
+	};
+
+	spidev@1 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "linux,spidev";
+		reg = <1>;
+		spi-max-frequency = <40000000>;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js7628-8m.dts b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-8m.dts
new file mode 100644
index 0000000..b385a13
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-8m.dts
@@ -0,0 +1,60 @@ 
+/dts-v1/;
+
+#include "mt7628an_zhuotk_js76x8.dtsi"
+
+/ {
+	compatible = "zhuotk,js7628-8m", "zhuotk,js76x8", "mediatek,mt7628an-soc";
+	model = "ZhuoTK JS7628 (8M flash)";
+};
+
+&spi0 {
+	status = "okay";
+
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;
+
+	m25p80@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <40000000>;
+		m25p,chunked-io = <32>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			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 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x50000 0x7b0000>;
+			};
+		};
+	};
+
+	spidev@1 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "linux,spidev";
+		reg = <1>;
+		spi-max-frequency = <40000000>;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi
new file mode 100644
index 0000000..4fbf7f6
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi
@@ -0,0 +1,105 @@ 
+#include "mt7628an.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	compatible = "zhuotk,js76x8", "mediatek,mt7628an-soc";
+
+	aliases {
+		led-boot = &led_system;
+		led-failsafe = &led_system;
+		led-running = &led_system;
+		led-upgrade = &led_system;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200";
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		led_system: system {
+			label = "js76x8:green:system";
+			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
+		};
+
+		wifi {
+			label = "js76x8:green:wifi";
+			gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
+			linux,code = <KEY_RESTART>;
+		};
+	};
+};
+
+&pinctrl {
+	state_default: pinctrl0 {
+		gpio {
+			ralink,group = "gpio","p3led_an","p4led_an",
+				"pwm0","pwm1","refclk","wdt","wled_an";
+			ralink,function = "gpio";
+		};
+
+		p0led {
+			ralink,group = "p0led_an";
+			ralink,function = "p0led_an";
+		};
+
+		p1led {
+			ralink,group = "p1led_an";
+			ralink,function = "p1led_an";
+		};
+
+		p2led {
+			ralink,group = "p2led_an";
+			ralink,function = "p2led_an";
+		};
+
+		pwm_2_3 {
+			ralink,group = "uart2";
+			ralink,function = "pwm";
+		};
+	};
+
+	uart2 {
+		uart2 {
+			ralink,group = "spis";
+			ralink,function = "pwm_uart2";
+		};
+	};
+};
+
+&i2c {
+	status = "okay";
+};
+
+&uart1 {
+	status = "okay";
+};
+
+&uart2 {
+	status = "okay";
+};
+
+&ethernet {
+	mtd-mac-address = <&factory 0x28>;
+};
+
+&sdhci {
+	status = "okay";
+	mediatek,cd-low;
+};
+
+&wmac {
+	status = "okay";
+};
diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk
index 9ab16db..36cb8af 100644
--- a/target/linux/ramips/image/mt76x8.mk
+++ b/target/linux/ramips/image/mt76x8.mk
@@ -583,6 +583,36 @@  define Device/zbtlink_zbt-we1226
 endef
 TARGET_DEVICES += zbtlink_zbt-we1226
 
+define Device/zhuotk_js7628-8m
+  MTK_SOC := mt7628an
+  IMAGE_SIZE := 7872k
+  DEVICE_VENDOR := ZhuoTK
+  DEVICE_MODEL := JS7628
+  DEVICE_VARIANT := 8M flash
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += zhuotk_js7628-8m
+
+define Device/zhuotk_js7628-16m
+  MTK_SOC := mt7628an
+  IMAGE_SIZE := 16064k
+  DEVICE_VENDOR := ZhuoTK
+  DEVICE_MODEL := JS7628
+  DEVICE_VARIANT := 16M flash
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += zhuotk_js7628-16m
+
+define Device/zhuotk_js7628-32m
+  MTK_SOC := mt7628an
+  IMAGE_SIZE := 32448k
+  DEVICE_VENDOR := ZhuoTK
+  DEVICE_MODEL := JS7628
+  DEVICE_VARIANT := 32M flash
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+endef
+TARGET_DEVICES += zhuotk_js7628-32m
+
 define Device/zyxel_keenetic-extra-ii
   MTK_SOC := mt7628an
   IMAGE_SIZE := 14912k