diff mbox

[OpenWrt-Devel,V2,2/3] ramips: Add base-files for HiWiFi HC5x61 models

Message ID 6C6921A8-8AD6-4B34-8FEB-51562A99A276@163.com
State Superseded
Headers show

Commit Message

Comman Kang Sept. 28, 2015, 2:45 p.m. UTC
HiWiFi HC5661/5761/5861 models are manufactured by http://www.hiwifi.com. These models have similar hardware specs(MT7620A + 128M DDR2 + 16M flash). This patch adds support for them.

The original author is Justin Liu (rssnsj@gmail.com). I ported the patch to trunk and submitted it here with his approval.

v2 fix
   1: Renamed board name to remove manufacturer’s name
   2: Renamed led
   3: Merged network/led option with other existing models


Signed-off-by: Xiaoning Kang <kangxn@163.com>

Comments

Piotr Dymacz Sept. 28, 2015, 8:47 p.m. UTC | #1
Hello,

My comments inline, below.

2015-09-28 16:45 GMT+02:00 Comman Kang <kangxn@163.com>:
> HiWiFi HC5661/5761/5861 models are manufactured by http://www.hiwifi.com. These models have similar hardware specs(MT7620A + 128M DDR2 + 16M flash). This patch adds support for them.
>
> The original author is Justin Liu (rssnsj@gmail.com). I ported the patch to trunk and submitted it here with his approval.
>
> v2 fix
>    1: Renamed board name to remove manufacturer’s name
>    2: Renamed led
>    3: Merged network/led option with other existing models
>
>
> Signed-off-by: Xiaoning Kang <kangxn@163.com>
>
>
> 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 a9959e3..2374362 100755
> --- a/target/linux/ramips/base-files/etc/board.d/01_leds
> +++ b/target/linux/ramips/base-files/etc/board.d/01_leds
> @@ -137,6 +137,24 @@ hg255d)
>         set_usb_led "$board:green:usb"
>         ucidef_set_led_interface "lan" "$board:green:internet"
>         ;;
> +hc5661)
> +       ucidef_set_led_default "system" "system" "$board:blue:system" "1"
> +       ucidef_set_led_netdev "internet" "internet" "$board:blue:internet" "eth0.2"
> +       set_wifi_led "$board:blue:wlan2g"
> +       ;;
> +hc5761)
> +       ucidef_set_led_default "system" "system" "$board:blue:system" "1"
> +       ucidef_set_led_netdev "internet" "internet" "$board:blue:internet" "eth0.2"
> +       set_wifi_led "$board:blue:wlan2g"
> +       ucidef_set_led_netdev "wifi5g" "wifi5g" "$board:blue:wlan5g" "rai0"
> +       ;;
> +hc5861)
> +       ucidef_set_led_default "system" "system" "$board:blue:system" "1"
> +       ucidef_set_led_netdev "internet" "internet" "$board:blue:internet" "eth0.2"
> +       set_wifi_led "$board:blue:wlan2g"
> +       ucidef_set_led_netdev "wifi5g" "wifi5g" "$board:blue:wlan5g" "rai0"
> +       ucidef_set_led_default "turbo" "turbo" "$board:blue:turbo" "0"
> +       ;;

Please, put that before "hg255d" board (alphabetical order).
BTW. I see here some possibilities for size optimization (all 3 board
share first 3 lines).

>  hpm)
>         ucidef_set_led_default "power" "POWER" "$board:orange:power" "1"
>         ucidef_set_led_netdev "eth" "ETH" "$board:green:eth" "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 75cccae..646f5f6 100755
> --- a/target/linux/ramips/base-files/etc/board.d/02_network
> +++ b/target/linux/ramips/base-files/etc/board.d/02_network
> @@ -170,6 +170,13 @@ ramips_setup_interfaces()
>                 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
>                 ucidef_add_switch_vlan "switch1" "2" "4 6t"
>                 ;;
> +       hc5*61|\
> +       y1s)
> +               ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
> +               ucidef_add_switch "switch0" "1" "1"
> +               ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
> +               ucidef_add_switch_vlan "switch0" "2" "0 6t"
> +               ;;
>         m2m)
>                 ucidef_add_switch "switch0" "4"
>                 ucidef_set_interface_lan "eth0"
> @@ -224,12 +231,6 @@ ramips_setup_interfaces()
>                 ucidef_add_switch_vlan "switch0" "1" "1 2 6t"
>                 ucidef_add_switch_vlan "switch0" "2" "0 6t"
>                 ;;
> -       y1s)
> -               ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
> -               ucidef_add_switch "switch0" "1" "1"
> -               ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
> -               ucidef_add_switch_vlan "switch0" "2" "0 6t"
> -               ;;
>         zbt-wr8305rt)
>                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
>                 ucidef_add_switch "switch0" "1" "1"
> @@ -293,6 +294,12 @@ ramips_setup_macs()
>         e1700)
>                 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
>                 ;;
> +       hc5*61)
> +               __fac_mac=`strings /dev/mtd7 | grep 'fac_mac = ..:..:..:..:..:..'`
> +               lan_mac=`expr "$__fac_mac" : '.*\(..:..:..:..:..:..\)' | tr '[A-Z]' '[a-z]'`
> +               [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
> +               wan_mac=$(macaddr_add "$lan_mac" 1)
> +               ;;

We have separate discussion about this part.

>         ht-tm02)
>                 lan_mac=$(cat /sys/class/net/eth0/address)
>                 ;;
> diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh
> index 7fc6f29..5376759 100644
> --- a/target/linux/ramips/base-files/etc/diag.sh
> +++ b/target/linux/ramips/base-files/etc/diag.sh
> @@ -104,6 +104,11 @@ get_status_led() {
>         f7c027)
>                 status_led="$board:orange:status"
>                 ;;
> +       hc5*61|\
> +       mlw221|\
> +       mlwg2)
> +               status_led="$board:blue:system"
> +               ;;

Perfect!
Sorry for mistake in my previous comment (I gave you hint using
different file with LED definitions).

>         m2m)
>                 status_led="$board:blue:wifi"
>                 ;;
> @@ -115,10 +120,6 @@ get_status_led() {
>         zte-q7)
>                 status_led="$board:red:status"
>                 ;;
> -       mlw221|\
> -       mlwg2)
> -               status_led="$board:blue:system"
> -               ;;
>         mr-102n)
>                 status_led="$board:amber:status"
>                 ;;
> diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
> index d242235..545ecf9 100755
> --- a/target/linux/ramips/base-files/lib/ramips.sh
> +++ b/target/linux/ramips/base-files/lib/ramips.sh
> @@ -172,6 +172,15 @@ ramips_board_detect() {
>         *"HG255D")
>                 name="hg255d"
>                 ;;
> +       *"HiWiFi HC5661")

Please, use just *"HC5661".

> +               name="hc5661"
> +               ;;
> +       *"HiWiFi HC5761")

Same here: *"HC5761"

> +               name="hc5761"
> +               ;;
> +       *"HiWiFi HC5861")

And here: *"HC5861"
Plus, please remember about alphabetical order :)

> +               name="hc5861"
> +               ;;
>         *"HLK-RM04")
>                 name="hlk-rm04"
>                 ;;
> diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
> index 2f6c624..44d41c1 100755
> --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
> @@ -55,6 +55,7 @@ platform_check_image() {
>         firewrt|\
>         fonera20n|\
>         freestation5|\
> +       hc5*61|\
>         hg255d|\
>         hlk-rm04|\
>         hpm|\
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
diff mbox

Patch

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 a9959e3..2374362 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -137,6 +137,24 @@  hg255d)
 	set_usb_led "$board:green:usb"
 	ucidef_set_led_interface "lan" "$board:green:internet"
 	;;
+hc5661)
+	ucidef_set_led_default "system" "system" "$board:blue:system" "1"
+	ucidef_set_led_netdev "internet" "internet" "$board:blue:internet" "eth0.2"
+	set_wifi_led "$board:blue:wlan2g"
+	;;	
+hc5761)
+	ucidef_set_led_default "system" "system" "$board:blue:system" "1"
+	ucidef_set_led_netdev "internet" "internet" "$board:blue:internet" "eth0.2"
+	set_wifi_led "$board:blue:wlan2g"
+	ucidef_set_led_netdev "wifi5g" "wifi5g" "$board:blue:wlan5g" "rai0"
+	;;
+hc5861)
+	ucidef_set_led_default "system" "system" "$board:blue:system" "1"
+	ucidef_set_led_netdev "internet" "internet" "$board:blue:internet" "eth0.2"
+	set_wifi_led "$board:blue:wlan2g"
+	ucidef_set_led_netdev "wifi5g" "wifi5g" "$board:blue:wlan5g" "rai0"
+	ucidef_set_led_default "turbo" "turbo" "$board:blue:turbo" "0"
+	;;
 hpm)
 	ucidef_set_led_default "power" "POWER" "$board:orange:power" "1"
 	ucidef_set_led_netdev "eth" "ETH" "$board:green:eth" "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 75cccae..646f5f6 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -170,6 +170,13 @@  ramips_setup_interfaces()
 		ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
 		ucidef_add_switch_vlan "switch1" "2" "4 6t"
 		;;
+	hc5*61|\
+	y1s)
+		ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+		ucidef_add_switch "switch0" "1" "1"
+		ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
+		ucidef_add_switch_vlan "switch0" "2" "0 6t"
+		;;
 	m2m)
 		ucidef_add_switch "switch0" "4"
 		ucidef_set_interface_lan "eth0"
@@ -224,12 +231,6 @@  ramips_setup_interfaces()
 		ucidef_add_switch_vlan "switch0" "1" "1 2 6t"
 		ucidef_add_switch_vlan "switch0" "2" "0 6t"
 		;;
-	y1s)
-		ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
-		ucidef_add_switch "switch0" "1" "1"
-		ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
-		ucidef_add_switch_vlan "switch0" "2" "0 6t"
-		;;
 	zbt-wr8305rt)
 		ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
 		ucidef_add_switch "switch0" "1" "1"
@@ -293,6 +294,12 @@  ramips_setup_macs()
 	e1700)
 		wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
 		;;
+	hc5*61)
+		__fac_mac=`strings /dev/mtd7 | grep 'fac_mac = ..:..:..:..:..:..'`
+		lan_mac=`expr "$__fac_mac" : '.*\(..:..:..:..:..:..\)' | tr '[A-Z]' '[a-z]'`
+		[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
+		wan_mac=$(macaddr_add "$lan_mac" 1)
+		;;
 	ht-tm02)
 		lan_mac=$(cat /sys/class/net/eth0/address)
 		;;
diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh
index 7fc6f29..5376759 100644
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -104,6 +104,11 @@  get_status_led() {
 	f7c027)
 		status_led="$board:orange:status"
 		;;
+	hc5*61|\
+	mlw221|\
+	mlwg2)
+		status_led="$board:blue:system"
+		;;
 	m2m)
 		status_led="$board:blue:wifi"
 		;;
@@ -115,10 +120,6 @@  get_status_led() {
 	zte-q7)
 		status_led="$board:red:status"
 		;;
-	mlw221|\
-	mlwg2)
-		status_led="$board:blue:system"
-		;;
 	mr-102n)
 		status_led="$board:amber:status"
 		;;
diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
index d242235..545ecf9 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -172,6 +172,15 @@  ramips_board_detect() {
 	*"HG255D")
 		name="hg255d"
 		;;
+	*"HiWiFi HC5661")
+		name="hc5661"
+		;;
+	*"HiWiFi HC5761")
+		name="hc5761"
+		;;
+	*"HiWiFi HC5861")
+		name="hc5861"
+		;;
 	*"HLK-RM04")
 		name="hlk-rm04"
 		;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index 2f6c624..44d41c1 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -55,6 +55,7 @@  platform_check_image() {
 	firewrt|\
 	fonera20n|\
 	freestation5|\
+	hc5*61|\
 	hg255d|\
 	hlk-rm04|\
 	hpm|\