Re: [OpenWrt-Devel] [PATCH] [ramips] HiWiFi HC5661 Support for Openwrt

2015-04-18 Thread Yousong Zhou
Hi, Yunhao

The patch is not in plaintext format and is whitespace broken.  You
can work around this by generating a patch with git-format-patch, then
send it with git-send-email.

On 18 April 2015 at 19:39, 田韵豪 tianyh2...@163.com wrote:
 HiWiFi HC5661 (Ji 1s) support.

 Signed-off-by: B Tian  tianyh2...@163.com

Real name is more preferable :)

 ---

 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 56ba3b7..292859d 100755
 --- a/target/linux/ramips/base-files/etc/board.d/01_leds
 +++ b/target/linux/ramips/base-files/etc/board.d/01_leds
 @@ -237,6 +237,11 @@ case $board in
set_usb_led lenovo:blue:usb
set_wifi_led lenovo:blue:wifi
;;
 + hc5661)
 +  ucidef_set_led_default power power hiwifi:blue:power 1
 +  set_wifi_led hiwifi:blue:wifi
 +  ucidef_set_led_interface br-lan hiwifi:blue:network

hiwifi:blue:network should be better named as hiwifi:blue:wan and
the interface name should be wan.

 +  ;;
   zte-q7)
set_wifi_led zte:blue:status
;;
 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 24e1ba8..505f7d9 100755
 --- a/target/linux/ramips/base-files/etc/board.d/02_network
 +++ b/target/linux/ramips/base-files/etc/board.d/02_network
 @@ -229,6 +229,14 @@ ramips_setup_interfaces()
ucidef_add_switch_vlan switch0 1 1 2 3 4 5 6t
ucidef_add_switch_vlan switch0 2 0 6t
;;
 +
 + hc5661)
 +  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 6t
 +  ucidef_add_switch_vlan switch0 2 0 6t
 +  ;;
 +
   d105 | \
   na930 | \
   omni-emb-hpm|\
 @@ -310,6 +318,7 @@ ramips_setup_macs()
   dir-320-b1 | \
   psr-680w |\
   sl-r7205 |\
 + hc5661 |\
   y1 |\
   y1s)
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 5301593..02b3ee0 100644
 --- a/target/linux/ramips/base-files/etc/diag.sh
 +++ b/target/linux/ramips/base-files/etc/diag.sh
 @@ -224,6 +224,9 @@ get_status_led() {
   y1s)
status_led=lenovo:blue:power
;;
 + hc5661)
 +  status_led=hiwifi:blue:power
 +  ;;
   zte-q7)
status_led=zte:red:status
;;
 diff --git a/target/linux/ramips/base-files/lib/ramips.sh
 b/target/linux/ramips/base-files/lib/ramips.sh
 index 616f4a1..8311a5f 100755
 --- a/target/linux/ramips/base-files/lib/ramips.sh
 +++ b/target/linux/ramips/base-files/lib/ramips.sh
 @@ -391,6 +391,9 @@ ramips_board_detect() {
   *Lenovo Y1S)
name=y1s
;;
 + *HiWiFi HC5661)
 +  name=hc5661

We already have hiwifi-hc6361 as the board name for HiWiFi HC6361 in
ar71xx target, so it's better we stick to that naming convention and
use hiwifi-hc5661 here.

 +  ;;
   *Mediatek MT7621 evaluation board)
name=mt7621
;;
 diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh
 b/target/linux/ramips/base-files/lib/upgrade/platform.sh
 index 17b456b..a913c41 100755
 --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
 +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
 @@ -115,6 +115,7 @@ platform_check_image() {
   xiaomi-miwifi-mini |\
   y1 |\
   y1s |\
 + hc5661 |\
   zte-q7 |\
   zbt-wa05)
[ $magic != 27051956 ]  {
 diff --git a/target/linux/ramips/dts/HC5661.dts
 b/target/linux/ramips/dts/HC5661.dts
 new file mode 100644
 index 000..873b83c
 --- /dev/null
 +++ b/target/linux/ramips/dts/HC5661.dts
 @@ -0,0 +1,137 @@
 +/dts-v1/;
 +
 +/include/ mt7620a.dtsi
 +
 +/ {
 + compatible = hiwifi,HC5661, ralink,mt7620a-soc;

The first compatible string is better be HiWiFi-HC5661.

 + model = HiWiFi HC5661;
 +
 + chosen {
 +  bootargs = console=ttyS0,115200;
 + };
 +
 + palmbus@1000 {
 +  sysc@0 {
 +   ralink,gpiomux = i2c, jtag;
 +   ralink,uartmux = gpio;
 +   ralink,wdtmux = 1;
 +  };
 +
 +  gpio0: gpio@600 {
 +   status = okay;
 +  };
 +
 +  gpio2: gpio@660 {
 +   status = okay;
 +  };
 +
 +  gpio3: gpio@688 {
 +   status = okay;
 +  };
 +
 +
 +  spi@b00 {
 +   status = okay;
 +
 +   m25p80@0 {
 +#address-cells = 1;
 +#size-cells = 1;
 +compatible = w25q128;
 +reg = 0 0;
 +linux,modalias = m25p80, w25q128;
 +spi-max-frequency = 1000;
 +
 +partition@0 {
 + label = u-boot;
 + reg = 0x0 0x3;
 + read-only;
 +};
 +
 +partition@3 {
 + label = u-boot-env;
 + reg = 0x3 0x1;
 + read-only;
 +};

This area is named 'hw_panic' in OEM firmware.

 +
 +factory: partition@4 {
 + label = factory;
 + reg = 0x4 0x1;
 + read-only;
 +};
 +
 +partition@5 {
 + label = firmware;
 + reg = 0x5 0xfb;
 +};

firmware partition only has 0xf9 bytes.  There is another
0x1 bytes for bdinfo which stores at least mac address and other
warranty information.  IMHO, this should not be overwritten without
users' being aware of.  In 

[OpenWrt-Devel] [PATCH V2] ar71xx: add TP-LINK TL-WR710N v2

2015-04-18 Thread Cezary Jackiewicz
TP-Link TL-WR710n v2 looks like v1, but has less memory (4MB).

Signed-off-by: Cezary Jackiewicz cezary.jackiew...@gmail.com
---

diff --git a/target/linux/ar71xx/image/Makefile 
b/target/linux/ar71xx/image/Makefile
index 49c3ca0..ad2f8c1 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -372,11 +372,19 @@ endef
 define Device/tl-wr710n-v1
 $(Device/tplink-8mlzma)
 BOARDNAME := TL-WR710N
-DEVICE_PROFILE := TLWR710
+DEVICE_PROFILE := TLWR710NV1
 TPLINK_HWID := 0x0711
 CONSOLE := ttyATH0,115200
 endef
 
+define Device/tl-wr710n-v2
+$(Device/tplink-4mlzma)
+BOARDNAME := TL-WR710N
+DEVICE_PROFILE := TLWR710NV2
+TPLINK_HWID := 0x0712
+CONSOLE := ttyATH0,115200
+endef
+
 define Device/tl-wr720n-v3
 $(Device/tplink-4mlzma)
 BOARDNAME := TL-WR720N-v3
@@ -529,7 +537,7 @@ define Device/oolite
 CONSOLE := ttyATH0,115200
 endef
 
-TARGET_DEVICES += archer-c5 archer-c7-v1 archer-c7-v2 el-m150 el-mini 
gl-inet-6408A-v1 gl-inet-6416A-v1 mc-mac1200r tl-mr10u-v1 tl-mr11u-v1 
tl-mr11u-v2 tl-mr12u-v1 tl-mr13u-v1 tl-mr3020-v1 tl-mr3040-v1 tl-mr3040-v2 
tl-mr3220-v2 tl-mr3420-v2 tl-wa701nd-v2 tl-wa7210n-v2 tl-wr703n-v1 tl-wr710n-v1 
tl-wr720n-v3 tl-wr740n-v4 tl-wr741nd-v4 tl-wr743nd-v2 tl-wa750re-v1 
tl-wr841n-v8 tl-wa830re-v2 tl-wr841n-v9 tl-wr847n-v8 tl-wr842n-v2 tl-wr843nd-v1 
tl-wa801nd-v2 tl-wa850re-v1 tl-wa860re-v1 tl-wa901nd-v3 tl-wr941nd-v5 
tl-wr941nd-v6 tl-wr1041n-v2 tl-wr2543-v1 tl-wdr4900-v2 smart-300 oolite
+TARGET_DEVICES += archer-c5 archer-c7-v1 archer-c7-v2 el-m150 el-mini 
gl-inet-6408A-v1 gl-inet-6416A-v1 mc-mac1200r tl-mr10u-v1 tl-mr11u-v1 
tl-mr11u-v2 tl-mr12u-v1 tl-mr13u-v1 tl-mr3020-v1 tl-mr3040-v1 tl-mr3040-v2 
tl-mr3220-v2 tl-mr3420-v2 tl-wa701nd-v2 tl-wa7210n-v2 tl-wr703n-v1 tl-wr710n-v1 
tl-wr710n-v2 tl-wr720n-v3 tl-wr740n-v4 tl-wr741nd-v4 tl-wr743nd-v2 
tl-wa750re-v1 tl-wr841n-v8 tl-wa830re-v2 tl-wr841n-v9 tl-wr847n-v8 tl-wr842n-v2 
tl-wr843nd-v1 tl-wa801nd-v2 tl-wa850re-v1 tl-wa860re-v1 tl-wa901nd-v3 
tl-wr941nd-v5 tl-wr941nd-v6 tl-wr1041n-v2 tl-wr2543-v1 tl-wdr4900-v2 smart-300 
oolite
 
 rootfs_type=$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
 
@@ -1858,6 +1866,7 @@ $(eval $(call MultiProfile,TLWA801,TLWA801NV1 TLWA801NV2))
 $(eval $(call MultiProfile,TLWA830,TLWA830RV1 TLWA830RV2))
 $(eval $(call MultiProfile,TLWA901,TLWA901NV1 TLWA901NV2 TLWA901NV3))
 $(eval $(call MultiProfile,TLWA7510,TLWA7510NV1))
+$(eval $(call MultiProfile,TLWR710,TLWR710NV1 TLWR710NV2))
 $(eval $(call MultiProfile,TLWR720,TLWR720NV3))
 $(eval $(call MultiProfile,TLWR740,TLWR740NV1 TLWR740NV3 TLWR740NV4))
 $(eval $(call MultiProfile,TLWR741,TLWR741NV1 TLWR741NV2 TLWR741NV4))


-- 
Pozdrawiam,
 Cezary Jackiewicz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] [ramips] HiWiFi HC5661 Support for Openwrt

2015-04-18 Thread 郭传鈜
Oh...I'm planning to send support for HiWiFi HC5761 and I was dealing
with the MAC address problem last week..
You should read the MAC address from bdinfo partition which is
described by Yousong.(This can be done with a simple script.)
I'll send the support for HC5761 now and you can have a look:-)

2015-04-18 21:47 GMT+08:00 Yousong Zhou yszhou4t...@gmail.com:
 Hi, Yunhao

 The patch is not in plaintext format and is whitespace broken.  You
 can work around this by generating a patch with git-format-patch, then
 send it with git-send-email.

 On 18 April 2015 at 19:39, 田韵豪 tianyh2...@163.com wrote:
 HiWiFi HC5661 (Ji 1s) support.

 Signed-off-by: B Tian  tianyh2...@163.com

 Real name is more preferable :)

 ---

 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 56ba3b7..292859d 100755
 --- a/target/linux/ramips/base-files/etc/board.d/01_leds
 +++ b/target/linux/ramips/base-files/etc/board.d/01_leds
 @@ -237,6 +237,11 @@ case $board in
set_usb_led lenovo:blue:usb
set_wifi_led lenovo:blue:wifi
;;
 + hc5661)
 +  ucidef_set_led_default power power hiwifi:blue:power 1
 +  set_wifi_led hiwifi:blue:wifi
 +  ucidef_set_led_interface br-lan hiwifi:blue:network

 hiwifi:blue:network should be better named as hiwifi:blue:wan and
 the interface name should be wan.

 +  ;;
   zte-q7)
set_wifi_led zte:blue:status
;;
 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 24e1ba8..505f7d9 100755
 --- a/target/linux/ramips/base-files/etc/board.d/02_network
 +++ b/target/linux/ramips/base-files/etc/board.d/02_network
 @@ -229,6 +229,14 @@ ramips_setup_interfaces()
ucidef_add_switch_vlan switch0 1 1 2 3 4 5 6t
ucidef_add_switch_vlan switch0 2 0 6t
;;
 +
 + hc5661)
 +  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 6t
 +  ucidef_add_switch_vlan switch0 2 0 6t
 +  ;;
 +
   d105 | \
   na930 | \
   omni-emb-hpm|\
 @@ -310,6 +318,7 @@ ramips_setup_macs()
   dir-320-b1 | \
   psr-680w |\
   sl-r7205 |\
 + hc5661 |\
   y1 |\
   y1s)
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 5301593..02b3ee0 100644
 --- a/target/linux/ramips/base-files/etc/diag.sh
 +++ b/target/linux/ramips/base-files/etc/diag.sh
 @@ -224,6 +224,9 @@ get_status_led() {
   y1s)
status_led=lenovo:blue:power
;;
 + hc5661)
 +  status_led=hiwifi:blue:power
 +  ;;
   zte-q7)
status_led=zte:red:status
;;
 diff --git a/target/linux/ramips/base-files/lib/ramips.sh
 b/target/linux/ramips/base-files/lib/ramips.sh
 index 616f4a1..8311a5f 100755
 --- a/target/linux/ramips/base-files/lib/ramips.sh
 +++ b/target/linux/ramips/base-files/lib/ramips.sh
 @@ -391,6 +391,9 @@ ramips_board_detect() {
   *Lenovo Y1S)
name=y1s
;;
 + *HiWiFi HC5661)
 +  name=hc5661

 We already have hiwifi-hc6361 as the board name for HiWiFi HC6361 in
 ar71xx target, so it's better we stick to that naming convention and
 use hiwifi-hc5661 here.

 +  ;;
   *Mediatek MT7621 evaluation board)
name=mt7621
;;
 diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh
 b/target/linux/ramips/base-files/lib/upgrade/platform.sh
 index 17b456b..a913c41 100755
 --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
 +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
 @@ -115,6 +115,7 @@ platform_check_image() {
   xiaomi-miwifi-mini |\
   y1 |\
   y1s |\
 + hc5661 |\
   zte-q7 |\
   zbt-wa05)
[ $magic != 27051956 ]  {
 diff --git a/target/linux/ramips/dts/HC5661.dts
 b/target/linux/ramips/dts/HC5661.dts
 new file mode 100644
 index 000..873b83c
 --- /dev/null
 +++ b/target/linux/ramips/dts/HC5661.dts
 @@ -0,0 +1,137 @@
 +/dts-v1/;
 +
 +/include/ mt7620a.dtsi
 +
 +/ {
 + compatible = hiwifi,HC5661, ralink,mt7620a-soc;

 The first compatible string is better be HiWiFi-HC5661.

 + model = HiWiFi HC5661;
 +
 + chosen {
 +  bootargs = console=ttyS0,115200;
 + };
 +
 + palmbus@1000 {
 +  sysc@0 {
 +   ralink,gpiomux = i2c, jtag;
 +   ralink,uartmux = gpio;
 +   ralink,wdtmux = 1;
 +  };
 +
 +  gpio0: gpio@600 {
 +   status = okay;
 +  };
 +
 +  gpio2: gpio@660 {
 +   status = okay;
 +  };
 +
 +  gpio3: gpio@688 {
 +   status = okay;
 +  };
 +
 +
 +  spi@b00 {
 +   status = okay;
 +
 +   m25p80@0 {
 +#address-cells = 1;
 +#size-cells = 1;
 +compatible = w25q128;
 +reg = 0 0;
 +linux,modalias = m25p80, w25q128;
 +spi-max-frequency = 1000;
 +
 +partition@0 {
 + label = u-boot;
 + reg = 0x0 0x3;
 + read-only;
 +};
 +
 +partition@3 {
 + label = u-boot-env;
 + reg = 0x3 0x1;
 + read-only;
 +};

 This area is named 'hw_panic' in OEM firmware.

 +
 +factory: partition@4 {
 + label = factory;
 

Re: [OpenWrt-Devel] [PATCH] ar71xx: add TP-LINK TL-WR710N v2

2015-04-18 Thread John Crispin
Hi,

the patch does not apply anymore as we merges the patches that lynxis
sent. can you rebase it please

John

On 18/04/2015 06:43, Cezary Jackiewicz wrote:
 TP-Link TL-WR710n v2 looks like v1, but has less memory (4MB).
 
 Signed-off-by: Cezary Jackiewicz cezary.jackiew...@gmail.com
 ---
 
 diff --git a/target/linux/ar71xx/image/Makefile 
 b/target/linux/ar71xx/image/Makefile
 index 8766756..fe269f4 100644
 --- a/target/linux/ar71xx/image/Makefile
 +++ b/target/linux/ar71xx/image/Makefile
 @@ -1476,7 +1476,8 @@ $(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLMR3420V2,tl-mr3420-v2,TL-MR3420
  $(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWA701NV2,tl-wa701nd-v2,TL-WA701ND-v2,ttyATH0,115200,0x07010002,1,4Mlzma))
  $(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWA7210NV2,tl-wa7210n-v2,TL-WA7210N-v2,ttyATH0,115200,0x7212,1,4Mlzma))
  $(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR703,tl-wr703n-v1,TL-WR703N,ttyATH0,115200,0x07030101,1,4Mlzma))
 -$(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR710,tl-wr710n-v1,TL-WR710N,ttyATH0,115200,0x0711,1,8Mlzma))
 +$(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR710NV1,tl-wr710n-v1,TL-WR710N,ttyATH0,115200,0x0711,1,8Mlzma))
 +$(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR710NV2,tl-wr710n-v2,TL-WR710N,ttyATH0,115200,0x0712,1,4Mlzma))
  $(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR720NV3,tl-wr720n-v3,TL-WR720N-v3,ttyATH0,115200,0x07200103,1,4Mlzma))
  $(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR740NV4,tl-wr740n-v4,TL-WR741ND-v4,ttyATH0,115200,0x0744,1,4Mlzma))
  $(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR741NV4,tl-wr741nd-v4,TL-WR741ND-v4,ttyATH0,115200,0x07410004,1,4Mlzma))
 @@ -1562,6 +1563,7 @@ $(eval $(call MultiProfile,TLWA801,TLWA801NV1 
 TLWA801NV2))
  $(eval $(call MultiProfile,TLWA830,TLWA830RV1 TLWA830RV2))
  $(eval $(call MultiProfile,TLWA901,TLWA901NV1 TLWA901NV2 TLWA901NV3))
  $(eval $(call MultiProfile,TLWA7510,TLWA7510NV1))
 +$(eval $(call MultiProfile,TLWR710,TLWR710NV1 TLWR710NV2))
  $(eval $(call MultiProfile,TLWR720,TLWR720NV3))
  $(eval $(call MultiProfile,TLWR740,TLWR740NV1 TLWR740NV3 TLWR740NV4))
  $(eval $(call MultiProfile,TLWR741,TLWR741NV1 TLWR741NV2 TLWR741NV4))
 
 
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] [ramips] HiWiFi HC5661 Support for Openwrt

2015-04-18 Thread 田韵豪
HiWiFi HC5661 (Ji 1s) support.

Signed-off-by: B Tian lt; tianyh2...@163.comgt;
---

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 56ba3b7..292859d 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -237,6 +237,11 @@ case $board in
set_usb_led lenovo:blue:usb
set_wifi_led lenovo:blue:wifi
;;
+ hc5661)
+  ucidef_set_led_default power power hiwifi:blue:power 1
+  set_wifi_led hiwifi:blue:wifi
+  ucidef_set_led_interface br-lan hiwifi:blue:network
+  ;;
zte-q7)
set_wifi_led zte:blue:status
;;
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 24e1ba8..505f7d9 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -229,6 +229,14 @@ ramips_setup_interfaces()
ucidef_add_switch_vlan switch0 1 1 2 3 4 5 6t
ucidef_add_switch_vlan switch0 2 0 6t
;;
+
+ hc5661)
+  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 6t
+  ucidef_add_switch_vlan switch0 2 0 6t
+  ;;
+
d105 | \
na930 | \
omni-emb-hpm|\
@@ -310,6 +318,7 @@ ramips_setup_macs()
dir-320-b1 | \
psr-680w |\
sl-r7205 |\
+ hc5661 |\
y1 |\
y1s)
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 5301593..02b3ee0 100644
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -224,6 +224,9 @@ get_status_led() {
y1s)
status_led=lenovo:blue:power
;;
+ hc5661)
+  status_led=hiwifi:blue:power
+  ;;
zte-q7)
status_led=zte:red:status
;;
diff --git a/target/linux/ramips/base-files/lib/ramips.sh 
b/target/linux/ramips/base-files/lib/ramips.sh
index 616f4a1..8311a5f 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -391,6 +391,9 @@ ramips_board_detect() {
*Lenovo Y1S)
name=y1s
;;
+ *HiWiFi HC5661)
+  name=hc5661
+  ;;
*Mediatek MT7621 evaluation board)
name=mt7621
;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh 
b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index 17b456b..a913c41 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -115,6 +115,7 @@ platform_check_image() {
xiaomi-miwifi-mini |\
y1 |\
y1s |\
+ hc5661 |\
zte-q7 |\
zbt-wa05)
[ $magic != 27051956 ]  {
diff --git a/target/linux/ramips/dts/HC5661.dts 
b/target/linux/ramips/dts/HC5661.dts
new file mode 100644
index 000..873b83c
--- /dev/null
+++ b/target/linux/ramips/dts/HC5661.dts
@@ -0,0 +1,137 @@
+/dts-v1/;
+
+/include/ mt7620a.dtsi
+
+/ {
+ compatible = hiwifi,HC5661, ralink,mt7620a-soc;
+ model = HiWiFi HC5661;
+
+ chosen {
+  bootargs = console=ttyS0,115200;
+ };
+
+ palmbus@1000 {
+  sysc@0 {
+   ralink,gpiomux = i2c, jtag;
+   ralink,uartmux = gpio;
+   ralink,wdtmux = lt;1gt;;
+  };
+
+  gpio0: gpio@600 {
+   status = okay;
+  };
+
+  gpio2: gpio@660 {
+   status = okay;
+  };
+
+  gpio3: gpio@688 {
+   status = okay;
+  };
+
+
+  spi@b00 {
+   status = okay;
+
+   m25p80@0 {
+#address-cells = lt;1gt;;
+#size-cells = lt;1gt;;
+compatible = w25q128;
+reg = lt;0 0gt;;
+linux,modalias = m25p80, w25q128;
+spi-max-frequency = lt;1000gt;;
+
+partition@0 {
+ label = u-boot;
+ reg = lt;0x0 0x3gt;;
+ read-only;
+};
+
+partition@3 {
+ label = u-boot-env;
+ reg = lt;0x3 0x1gt;;
+ read-only;
+};
+
+factory: partition@4 {
+ label = factory;
+ reg = lt;0x4 0x1gt;;
+ read-only;
+};
+
+partition@5 {
+ label = firmware;
+ reg = lt;0x5 0xfbgt;;
+};
+   };
+  };
+ };
+
+ ehci@101c {
+  status = okay;
+ };
+
+ ohci@101c1000 {
+  status = okay;
+ };
+
+ sdhci@1013 {
+  status = okay;
+ };
+
+ pcie@1014 {
+  status = okay;
+ };
+
+ wmac@1018 {
+  ralink,mtd-eeprom = lt;factory 0gt;;
+ };
+
+ ethernet@1010 {
+  pinctrl-names = default;
+  pinctrl-0 = lt;ephy_pinsgt;;
+  mtd-mac-address = lt;factory 0x4gt;;
+  ralink,port-map = w;
+ };
+
+ pinctrl {
+  state_default: pinctrl0 {
+   gpio {
+ralink,group = uartf, wled, nd_sd;
+ralink,function = gpio;
+   };
+   pa {
+ralink,group = pa;
+ralink,function = pa;
+   };
+  };
+ };
+
+ gpio-keys-polled {
+  compatible = gpio-keys-polled;
+  #address-cells = lt;1gt;;
+  #size-cells = lt;0gt;;
+  poll-interval = lt;20gt;;
+  reset {
+   label = reset;
+   gpios = lt;gpio0 12 1gt;;
+   linux,code = lt;0x198gt;;
+  };
+ };
+
+ gpio-leds {
+  compatible = gpio-leds;
+  power1 {
+   label = hiwifi:blue:power;
+   gpios = lt;gpio0 9 1gt;;
+  };
+  wlan1 {
+   label = hiwifi:blue:wifi;
+   gpios = lt;gpio3 0 1gt;;
+  };
+  

[OpenWrt-Devel] [PATCH] brcm63xx: BCM963268BU_P300 reference board fixes

2015-04-18 Thread Álvaro Fernández Rojas
- Fix profile name.
- Rremove whitespace on board patch.
- Refresh patches.

Signed-off-by: Álvaro Fernández Rojas nolt...@gmail.com
---
 .../103-MIPS-BCM63XX-add-OHCI-EHCI-configuration-bits-to-com.patch  | 2 +-
 .../202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch  | 2 +-
 .../203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch | 2 +-
 .../patches-3.18/339-MIPS-BCM63XX-add-support-for-BCM63268.patch| 6 +++---
 .../patches-3.18/341-MIPS-BCM63XX-add-support-for-BCM6318.patch | 2 +-
 .../343-MIPS-BCM63XX-add-PCIe-support-for-BCM6318.patch | 2 +-
 .../patches-3.18/346-MIPS-BCM63XX-USB-ENETSW-6318-clocks.patch  | 2 +-
 .../355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch  | 2 +-
 .../356-MIPS-BCM63XX-move-fallback-sprom-support-into-its-ow.patch  | 2 +-
 .../359-MIPS-BCM63XX-allow-different-types-of-sprom.patch   | 2 +-
 .../362-MIPS-BCM63XX-also-register-a-fallback-sprom-for-bcma.patch  | 2 +-
 .../363-MIPS-BCM63XX-add-BCMA-based-sprom-templates.patch   | 2 +-
 .../366-MIPS-add-support-for-vmlinux.bin-appended-DTB.patch | 4 ++--
 .../376-net-bcm63xx_enet-use-named-gpio-for-ephy-reset-gpio.patch   | 4 ++--
 .../patches-3.18/414-MTD-m25p80-allow-passing-pp_data.patch | 2 +-
 .../patches-3.18/416-BCM63XX-add-a-fixup-for-ath9k-devices.patch| 2 +-
 .../patches-3.18/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch   | 2 +-
 target/linux/brcm63xx/patches-3.18/560-board_963268gu_p300.patch| 2 +-
 target/linux/brcm63xx/patches-3.18/561-board_WAP-5813n.patch| 2 +-
 target/linux/brcm63xx/patches-3.18/564-board_P870HW-51a_v2.patch| 2 +-
 target/linux/brcm63xx/profiles/broadcom.mk  | 2 +-
 21 files changed, 25 insertions(+), 25 deletions(-)

diff --git 
a/target/linux/brcm63xx/patches-3.18/103-MIPS-BCM63XX-add-OHCI-EHCI-configuration-bits-to-com.patch
 
b/target/linux/brcm63xx/patches-3.18/103-MIPS-BCM63XX-add-OHCI-EHCI-configuration-bits-to-com.patch
index 40bbe08..deda928 100644
--- 
a/target/linux/brcm63xx/patches-3.18/103-MIPS-BCM63XX-add-OHCI-EHCI-configuration-bits-to-com.patch
+++ 
b/target/linux/brcm63xx/patches-3.18/103-MIPS-BCM63XX-add-OHCI-EHCI-configuration-bits-to-com.patch
@@ -66,7 +66,7 @@ Signed-off-by: Florian Fainelli flor...@openwrt.org
  
val = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_UTMI_CTL_6368_REG);
if (is_on)
-@@ -49,5 +61,90 @@ void bcm63xx_usb_priv_select_pullup(u32
+@@ -49,5 +61,90 @@ void bcm63xx_usb_priv_select_pullup(u32 
else
val |= (portmask  USBH_PRIV_UTMI_CTL_NODRIV_SHIFT);
bcm_rset_writel(RSET_USBH_PRIV, val, USBH_PRIV_UTMI_CTL_6368_REG);
diff --git 
a/target/linux/brcm63xx/patches-3.18/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
 
b/target/linux/brcm63xx/patches-3.18/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
index b949694..180d842 100644
--- 
a/target/linux/brcm63xx/patches-3.18/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
+++ 
b/target/linux/brcm63xx/patches-3.18/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
@@ -11,7 +11,7 @@ Signed-off-by: Jonas Gorski jonas.gor...@gmail.com
 
 --- a/drivers/mtd/devices/m25p80.c
 +++ b/drivers/mtd/devices/m25p80.c
-@@ -246,7 +246,8 @@ static int m25p_probe(struct spi_device
+@@ -246,7 +246,8 @@ static int m25p_probe(struct spi_device 
  
ppdata.of_node = spi-dev.of_node;
  
diff --git 
a/target/linux/brcm63xx/patches-3.18/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
 
b/target/linux/brcm63xx/patches-3.18/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
index 740fb2d..96c8c79 100644
--- 
a/target/linux/brcm63xx/patches-3.18/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
+++ 
b/target/linux/brcm63xx/patches-3.18/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
@@ -58,7 +58,7 @@ Signed-off-by: Jonas Gorski jonas.gor...@gmail.com
  static int m25p80_erase(struct spi_nor *nor, loff_t offset)
  {
struct m25p *flash = nor-priv;
-@@ -240,6 +264,9 @@ static int m25p_probe(struct spi_device
+@@ -240,6 +264,9 @@ static int m25p_probe(struct spi_device 
else
flash_name = spi-modalias;
  
diff --git 
a/target/linux/brcm63xx/patches-3.18/339-MIPS-BCM63XX-add-support-for-BCM63268.patch
 
b/target/linux/brcm63xx/patches-3.18/339-MIPS-BCM63XX-add-support-for-BCM63268.patch
index 22ceeea..bee8a10 100644
--- 
a/target/linux/brcm63xx/patches-3.18/339-MIPS-BCM63XX-add-support-for-BCM63268.patch
+++ 
b/target/linux/brcm63xx/patches-3.18/339-MIPS-BCM63XX-add-support-for-BCM63268.patch
@@ -46,7 +46,7 @@ Signed-off-by: Jonas Gorski j...@openwrt.org
val = bcm_mpi_readl(MPI_CSBASE_REG(0));
 --- a/arch/mips/bcm63xx/clk.c
 +++ b/arch/mips/bcm63xx/clk.c
-@@ -133,6 +133,8 @@ static void enetsw_set(struct clk *clk,
+@@ -133,6 +133,8 @@ static void enetsw_set(struct clk *clk, 

[OpenWrt-Devel] [PATCH][RFC] ramips:Add support for HiWiFi HC5761.

2015-04-18 Thread 郭传鈜
Hi,all!
  I'm trying to add support for HiWiFi HC5761 router,This patch works 
fine.Because the mac address is not saved in factory partition and I think my 
way to deal with this problem is not so good,I hope I could get some 
suggestions for this patch.
  HiWiFi HC5761 is a dual band router with mt7620a SoC.It has 3 network 
interface,SD card and USB.
There is an MT7610E for 5G wireless but there is no open-source driver to 
support this.I enabled the PCI-E interface so that I could use the proprietary 
driver from MTK.
MAC address is not in factory partition.It is defined in bdinfo partition in 
ascii format.
With 'strings' command we could see such a line:Vfac_mac = XX:XX:XX:XX:XX:XX
There is a space between 'Vfac_mac' and '=' so 'mtd_get_mac_ascii' function in 
/lib/functions/system.sh doesn't work.I copied the function and added a space 
in the sed command.
Because of the mac address,the calibration data for wireless should't be read 
from mtd partition directly.I used the hotplug script to generate the 
calibration data for the wireless driver.
I think I added too much code for the MAC address:-( I wonder if there is a 
better way to do this.
Best regards.
Guo Chuanhong

Signed-off-by: 郭传鈜 gch981...@gmail.com
---
 target/linux/ramips/base-files/etc/board.d/01_leds |   5 +
 .../linux/ramips/base-files/etc/board.d/02_network |  20 +++
 target/linux/ramips/base-files/etc/diag.sh |   3 +
 .../etc/hotplug.d/firmware/10-rt2x00-eeprom|  39 +-
 target/linux/ramips/base-files/lib/ramips.sh   |   3 +
 .../ramips/base-files/lib/upgrade/platform.sh  |   1 +
 target/linux/ramips/dts/HiWiFi-HC5761.dts  | 155 +
 target/linux/ramips/image/Makefile |   3 +
 8 files changed, 228 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/ramips/dts/HiWiFi-HC5761.dts

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 56ba3b7..e20732d 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -222,6 +222,11 @@ case $board in
set_usb_led wr8305rt:usb
set_wifi_led wr8305rt:wifi
;;
+   hiwifi-hc5761)
+   ucidef_set_led_default system system hiwifi:blue:system 
1
+   ucidef_set_led_netdev internet internet 
hiwifi:blue:internet eth0.2
+   set_wifi_led hiwifi:blue:wlan-2p4
+   ;;
wt1520)
set_wifi_led rt2800pci-phy0::radio
;;
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 24e1ba8..615baa4 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -223,6 +223,7 @@ ramips_setup_interfaces()
ucidef_add_switch_vlan switch0 2 4 6t
;;
 
+   hiwifi-hc5761 | \
y1s)
ucidef_set_interfaces_lan_wan eth0.1 eth0.2
ucidef_add_switch switch0 1 1
@@ -288,6 +289,25 @@ ramips_setup_macs()
wan_mac=$(macaddr_add $lan_mac 4)
;;
 
+   hiwifi-hc5761)
+   local part
+   local mac_dirty
+
+   part=$(find_mtd_part bdinfo)
+   if [ -z $part ]; then
+   echo hiwifi_get_mac: partition bdinfo not found! 2
+   return
+   fi
+
+   mac_dirty=$(strings $part | sed -n 's/^'Vfac_mac '=//p')
+
+   # canonicalize mac
+   [ -n $mac_dirty ]  {
+   lan_mac=$(macaddr_canonicalize $mac_dirty)
+   }
+   wan_mac=$(macaddr_add $lan_mac 1)
+   ;;
+
m3 |\
m4 |\
x5 |\
diff --git a/target/linux/ramips/base-files/etc/diag.sh 
b/target/linux/ramips/base-files/etc/diag.sh
index 5301593..e66336f 100644
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -220,6 +220,9 @@ get_status_led() {
na930)
status_led=na930:blue:power
;;
+   hiwifi-hc5761)
+   status_led=hiwifi:blue:system
+   ;;
y1 | \
y1s)
status_led=lenovo:blue:power
diff --git 
a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom 
b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
index 0cd95a5..ce7171c 100644
--- a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
+++ b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
@@ -21,6 +21,37 @@ rt2x00_eeprom_extract() {
rt2x00_eeprom_die failed to extract from $mtd
 }
 
+hiwifi_eeprom_extract() {
+   local part=$1
+   local offset=$2
+   local mac_addr=$3
+   local mtd
+
+   . 

[OpenWrt-Devel] [PATCH] [libubox][v5] b64: add base64 support

2015-04-18 Thread Luka Perkov
The base code has been taken from zstream project which was
written by Steven Barth.

Signed-off-by: Luka Perkov l...@openwrt.org
CC: Steven Barth ste...@midlink.org
---
= changes in v2:

Use new API:

size_t b64decode(void **out, const char *in, size_t len);
size_t b64encode(char **out, const void *in, size_t len);

= changes in v3:

Use new API:

static inline int b64_decode_size(const void *in, size_t len);
static inline int b64_encode_size(size_t len);

size_t b64decode(void *out, const void *in, size_t len);
size_t b64encode(void *out, const void *in, size_t len);

In this set a few corner cases of invalid writes in b64decode() were fixed.
Furthermore, b64decode() works fine when in == out.

= changes in v4:

Use new API:

static inline int b64_decode_size(size_t len)
static inline int b64_encode_size(size_t len)

size_t b64decode(void *out, const void *in, size_t len);
size_t b64encode(void *out, const void *in, size_t len);

Add NULL terminating buffer in make changes reported by Jonas, John and Felix.

= changes in v5:

Use new API:

static inline int b64_decode_size(size_t len)
static inline int b64_encode_size(size_t len)

int b64decode(void *out, const void *in, size_t len);
int b64encode(void *out, const void *in, size_t len);

And do not use b64_encode_size() in b64encode().
---
 CMakeLists.txt |   2 +-
 b64.c  | 116 +
 b64.h  |  53 ++
 3 files changed, 170 insertions(+), 1 deletion(-)
 create mode 100644 b64.c
 create mode 100644 b64.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 58381da..77f4842 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,7 +14,7 @@ IF(JSONC_FOUND)
   INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
 ENDIF()
 
-SET(SOURCES avl.c avl-cmp.c blob.c blobmsg.c uloop.c usock.c ustream.c 
ustream-fd.c vlist.c utils.c safe_list.c runqueue.c md5.c kvlist.c ulog.c)
+SET(SOURCES avl.c avl-cmp.c blob.c blobmsg.c uloop.c usock.c ustream.c 
ustream-fd.c vlist.c utils.c safe_list.c runqueue.c md5.c kvlist.c ulog.c b64.c)
 
 ADD_LIBRARY(ubox SHARED ${SOURCES})
 ADD_LIBRARY(ubox-static STATIC ${SOURCES})
diff --git a/b64.c b/b64.c
new file mode 100644
index 000..ac8a805
--- /dev/null
+++ b/b64.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2011 Steven Barth ste...@midlink.org
+ * Copyright (C) 2015 Luka Perkov l...@openwrt.org
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include stdint.h
+#include stdlib.h
+
+#include b64.h
+
+static const uint8_t b64decode_tbl[] = {
+   0x3e, 0xff, 0xff, 0xff, 0x3f, 0x34, 0x35, 0x36,
+   0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff,
+   0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01,
+   0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+   0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
+   0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
+   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1a, 0x1b,
+   0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
+   0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+   0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33
+};
+
+int b64decode(void *out, const void *in, size_t len)
+{
+   uint8_t *o = (uint8_t *) out;
+   const uint8_t *data = (const uint8_t *) in;
+   size_t lenout, i, j;
+   uint32_t cv = 0;
+
+   lenout = b64_decode_size(len);
+   if (!lenout)
+   return -1;
+
+   o[--lenout] = '\0';
+
+   for (i = 0; i  len; i += 4) {
+   cv = 0;
+   for (j = 0; j  4; j++) {
+   uint8_t c = data[i + j] - 43;
+   if (c  79 || (c = b64decode_tbl[c]) == 0xff)
+   return -1;
+
+   cv |= c;
+   if (j != 3)
+   cv = 6;
+   }
+
+   o[2] = (uint8_t)(cv  0xff);
+   o[1] = (uint8_t)((cv  8)  0xff);
+   o[0] = (uint8_t)((cv  16)  0xff);
+   o += 3;
+   }
+
+   for (i = 1; i = 2; i++) {
+   if (data[len - i] == '=') {
+   o[-i] = '\0';
+   lenout--;
+   } else
+   break;
+   }
+
+   return lenout;
+}
+
+static const uint8_t b64encode_tbl[] =
+   

Re: [OpenWrt-Devel] [PATCH] [libubox][v4] b64: add base64 support

2015-04-18 Thread Luka Perkov
On Fri, Apr 17, 2015 at 02:14:14AM +0200, Felix Fietkau wrote:
  +size_t b64decode(void *out, const void *in, size_t len)
  +{
  +   uint8_t *o = (uint8_t *) out;
  +   const uint8_t *data = (const uint8_t *) in;
  +   size_t lenout, i, j;
  +   uint32_t cv = 0;
  +
  +   lenout = b64_decode_size(len);
  +   if (!lenout)
  +   return 0;
  +
  +   o[--lenout] = '\0';
  +
  +   for (i = 0; i  len; i += 4) {
  +   cv = 0;
  +   for (j = 0; j  4; j++) {
  +   uint8_t c = data[i + j] - 43;
  +   if (c  79 || (c = b64decode_tbl[c]) == 0xff)
  +   return 0;
  +
  +   cv |= c;
  +   if (j != 3)
  +   cv = 6;
  +   }
  +
  +   o[2] = (uint8_t)(cv  0xff);
  +   o[1] = (uint8_t)((cv  8)  0xff);
  +   o[0] = (uint8_t)((cv  16)  0xff);
  +   o += 3;
  +   }
  +
  +   for (i = 1; i = 2; i++) {
  +   if (data[len - i] == '=') {
  +   o[-i] = '\0';
  +   lenout--;
  +   } else
  +   break;
  +   }
 I think this function should match the capabilities and return code of
 b64_pton from BSD.
 It should return an int (or ssize_t) instead of size_t, and return -1 on
 errors. It should also be able to skip whitespaces.

I've chaned API as requested but there is no easy way of adding support
for whitespaces current b64decode() function. So if you really want
support for whitespaces as well as the same capabilities and return
codes I am proposing that we take in function from BSD instead of this
one. Please let me know.

  +static const uint8_t b64encode_tbl[] =
  +   ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/;
  +
  +size_t b64encode(void *out, const void *in, size_t len)
  +{
  +   uint8_t *o = (uint8_t *) out;
  +   const uint8_t *data = (const uint8_t *) in;
  +   size_t lenout, pad, i;
  +   uint32_t cv;
  +
  +   lenout = b64_encode_size(len);
  +   if (!lenout)
  +   return 0;
 Why call b64_encode_size instead of just setting *o = 0 at the end of
 the function?

Fixed in v5 which I've sent few moments ago.

Luka
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH][RFC] ramips:Add support for HiWiFi HC5761.

2015-04-18 Thread 郭传鈜
Sorry...The EEPROM script is not working correctly because I forgot to
include /lib/functions/system.sh...
But I still want some suggestions about the script:-)

2015-04-19 0:02 GMT+08:00 郭传鈜 gch981...@gmail.com:
 Hi,all!
   I'm trying to add support for HiWiFi HC5761 router,This patch works 
 fine.Because the mac address is not saved in factory partition and I think my 
 way to deal with this problem is not so good,I hope I could get some 
 suggestions for this patch.
   HiWiFi HC5761 is a dual band router with mt7620a SoC.It has 3 network 
 interface,SD card and USB.
 There is an MT7610E for 5G wireless but there is no open-source driver to 
 support this.I enabled the PCI-E interface so that I could use the 
 proprietary driver from MTK.
 MAC address is not in factory partition.It is defined in bdinfo partition in 
 ascii format.
 With 'strings' command we could see such a line:Vfac_mac = XX:XX:XX:XX:XX:XX
 There is a space between 'Vfac_mac' and '=' so 'mtd_get_mac_ascii' function 
 in /lib/functions/system.sh doesn't work.I copied the function and added a 
 space in the sed command.
 Because of the mac address,the calibration data for wireless should't be read 
 from mtd partition directly.I used the hotplug script to generate the 
 calibration data for the wireless driver.
 I think I added too much code for the MAC address:-( I wonder if there is a 
 better way to do this.
 Best regards.
 Guo Chuanhong

 Signed-off-by: 郭传鈜 gch981...@gmail.com
 ---
  target/linux/ramips/base-files/etc/board.d/01_leds |   5 +
  .../linux/ramips/base-files/etc/board.d/02_network |  20 +++
  target/linux/ramips/base-files/etc/diag.sh |   3 +
  .../etc/hotplug.d/firmware/10-rt2x00-eeprom|  39 +-
  target/linux/ramips/base-files/lib/ramips.sh   |   3 +
  .../ramips/base-files/lib/upgrade/platform.sh  |   1 +
  target/linux/ramips/dts/HiWiFi-HC5761.dts  | 155 
 +
  target/linux/ramips/image/Makefile |   3 +
  8 files changed, 228 insertions(+), 1 deletion(-)
  create mode 100644 target/linux/ramips/dts/HiWiFi-HC5761.dts

 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 56ba3b7..e20732d 100755
 --- a/target/linux/ramips/base-files/etc/board.d/01_leds
 +++ b/target/linux/ramips/base-files/etc/board.d/01_leds
 @@ -222,6 +222,11 @@ case $board in
 set_usb_led wr8305rt:usb
 set_wifi_led wr8305rt:wifi
 ;;
 +   hiwifi-hc5761)
 +   ucidef_set_led_default system system hiwifi:blue:system 
 1
 +   ucidef_set_led_netdev internet internet 
 hiwifi:blue:internet eth0.2
 +   set_wifi_led hiwifi:blue:wlan-2p4
 +   ;;
 wt1520)
 set_wifi_led rt2800pci-phy0::radio
 ;;
 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 24e1ba8..615baa4 100755
 --- a/target/linux/ramips/base-files/etc/board.d/02_network
 +++ b/target/linux/ramips/base-files/etc/board.d/02_network
 @@ -223,6 +223,7 @@ ramips_setup_interfaces()
 ucidef_add_switch_vlan switch0 2 4 6t
 ;;

 +   hiwifi-hc5761 | \
 y1s)
 ucidef_set_interfaces_lan_wan eth0.1 eth0.2
 ucidef_add_switch switch0 1 1
 @@ -288,6 +289,25 @@ ramips_setup_macs()
 wan_mac=$(macaddr_add $lan_mac 4)
 ;;

 +   hiwifi-hc5761)
 +   local part
 +   local mac_dirty
 +
 +   part=$(find_mtd_part bdinfo)
 +   if [ -z $part ]; then
 +   echo hiwifi_get_mac: partition bdinfo not found! 2
 +   return
 +   fi
 +
 +   mac_dirty=$(strings $part | sed -n 's/^'Vfac_mac '=//p')
 +
 +   # canonicalize mac
 +   [ -n $mac_dirty ]  {
 +   lan_mac=$(macaddr_canonicalize $mac_dirty)
 +   }
 +   wan_mac=$(macaddr_add $lan_mac 1)
 +   ;;
 +
 m3 |\
 m4 |\
 x5 |\
 diff --git a/target/linux/ramips/base-files/etc/diag.sh 
 b/target/linux/ramips/base-files/etc/diag.sh
 index 5301593..e66336f 100644
 --- a/target/linux/ramips/base-files/etc/diag.sh
 +++ b/target/linux/ramips/base-files/etc/diag.sh
 @@ -220,6 +220,9 @@ get_status_led() {
 na930)
 status_led=na930:blue:power
 ;;
 +   hiwifi-hc5761)
 +   status_led=hiwifi:blue:system
 +   ;;
 y1 | \
 y1s)
 status_led=lenovo:blue:power
 diff --git 
 a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom 
 b/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
 index 0cd95a5..ce7171c 100644
 --- a/target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom