Re: [OpenWrt-Devel] [RFC PATCH] ar71xx: Support Antminer S1/S3

2015-05-10 Thread Felix Fietkau
On 2015-05-02 05:08, James Hilliard wrote:
 I did my best to separate this device out, below is my current patch,
 comments appreciated. I'm having trouble figuring out how to
 differentiate the hwid which seems to be the same as the tp-link
 wr743nd-v2. 0x07430002 Is the hardware ID that both seem to have, is
 there any other ID's that I may be able to use?
 
There are a lot of seemingly bogus unrelated changes, especially the
ones to the generic code. The patch is completely misformatted, so it
won't ever apply.
Many of the changes do not make sense, so please make an effort to
reduce the patch to the smallest amount of change to support the platform.

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


Re: [OpenWrt-Devel] [RFC PATCH] ar71xx: Support Antminer S1/S3

2015-05-10 Thread James Hilliard
The generic changes I had intended to remove before a final
submission. I'm also wondering what the best way to handle devices
with 1 ethernet port is, should that be a WAN or a LAN port(right now
it seems to be WAN with some things on the firewall opened up), it
also has a rarely used wireless header that is configured as a LAN
port. For the moment I'm a little stuck on separating it out fully
from the tp-link device specifically in relation to
tplink_board_detect() and the conflicting ID, would you have any
suggestions for how to fix that? I'll work on making the patch as
small as possible as well. I created the patch using a git diff and it
seemed to apply when I used git apply, did my mail client mess up the
formatting?

On Sun, May 10, 2015 at 5:23 AM, Felix Fietkau n...@openwrt.org wrote:
 On 2015-05-02 05:08, James Hilliard wrote:
 I did my best to separate this device out, below is my current patch,
 comments appreciated. I'm having trouble figuring out how to
 differentiate the hwid which seems to be the same as the tp-link
 wr743nd-v2. 0x07430002 Is the hardware ID that both seem to have, is
 there any other ID's that I may be able to use?

 There are a lot of seemingly bogus unrelated changes, especially the
 ones to the generic code. The patch is completely misformatted, so it
 won't ever apply.
 Many of the changes do not make sense, so please make an effort to
 reduce the patch to the smallest amount of change to support the platform.

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


Re: [OpenWrt-Devel] [RFC PATCH] ar71xx: Support Antminer S1/S3

2015-05-01 Thread James Hilliard
I did my best to separate this device out, below is my current patch,
comments appreciated. I'm having trouble figuring out how to
differentiate the hwid which seems to be the same as the tp-link
wr743nd-v2. 0x07430002 Is the hardware ID that both seem to have, is
there any other ID's that I may be able to use?

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh
b/package/base-files/files/lib/functions/uci-defaults.sh
index 5a8809d..363c016 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -8,7 +8,11 @@ ucidef_set_led_netdev() {
  local name=$2
  local sysfs=$3
  local dev=$4
+ local mode=link tx rx

+ if [ -n $5 ]; then
+ mode=$5
+ fi
  uci -q get system.$cfg  return 0

  uci batch EOF
@@ -17,7 +21,7 @@ set system.$cfg.name='$name'
 set system.$cfg.sysfs='$sysfs'
 set system.$cfg.trigger='netdev'
 set system.$cfg.dev='$dev'
-set system.$cfg.mode='link tx rx'
+set system.$cfg.mode='$mode'
 EOF
  UCIDEF_LEDS_CHANGED=1
 }
diff --git a/package/network/config/firewall/files/firewall.config
b/package/network/config/firewall/files/firewall.config
index d149e77..00d6021 100644
--- a/package/network/config/firewall/files/firewall.config
+++ b/package/network/config/firewall/files/firewall.config
@@ -1,177 +1,118 @@
-config defaults
- option syn_flood 1
- option input ACCEPT
- option output ACCEPT
- option forward REJECT
-# Uncomment this line to disable ipv6 rules
-# option disable_ipv6 1

-config zone
- option name lan
- list   network 'lan'
- option input ACCEPT
- option output ACCEPT
- option forward ACCEPT
-
-config zone
- option name wan
- list   network 'wan'
- list   network 'wan6'
- option input REJECT
- option output ACCEPT
- option forward REJECT
- option masq 1
- option mtu_fix 1
-
-config forwarding
- option src lan
- option dest wan
-
-# We need to accept udp packets on port 68,
-# see https://dev.openwrt.org/ticket/4108
-config rule
- option name Allow-DHCP-Renew
- option src wan
- option proto udp
- option dest_port 68
- option target ACCEPT
- option family ipv4
-
-# Allow IPv4 ping
-config rule
- option name Allow-Ping
- option src wan
- option proto icmp
- option icmp_type echo-request
- option family ipv4
- option target ACCEPT
-
-# Allow DHCPv6 replies
-# see https://dev.openwrt.org/ticket/10381
-config rule
- option name Allow-DHCPv6
- option src wan
- option proto udp
- option src_ip fe80::/10
- option src_port 547
- option dest_ip fe80::/10
- option dest_port 546
- option family ipv6
- option target ACCEPT
-
-# Allow essential incoming IPv6 ICMP traffic
-config rule
- option name Allow-ICMPv6-Input
- option src wan
- option proto icmp
- list icmp_type echo-request
- list icmp_type echo-reply
- list icmp_type destination-unreachable
- list icmp_type packet-too-big
- list icmp_type time-exceeded
- list icmp_type bad-header
- list icmp_type unknown-header-type
- list icmp_type router-solicitation
- list icmp_type neighbour-solicitation
- list icmp_type router-advertisement
- list icmp_type neighbour-advertisement
- option limit 1000/sec
- option family ipv6
- option target ACCEPT
-
-# Allow essential forwarded IPv6 ICMP traffic
-config rule
- option name Allow-ICMPv6-Forward
- option src wan
- option dest *
- option proto icmp
- list icmp_type echo-request
- list icmp_type echo-reply
- list icmp_type destination-unreachable
- list icmp_type packet-too-big
- list icmp_type time-exceeded
- list icmp_type bad-header
- list icmp_type unknown-header-type
- option limit 1000/sec
- option family ipv6
- option target ACCEPT
-
-# include a file with users custom iptables rules
-config include
- option path /etc/firewall.user
-
-
-### EXAMPLE CONFIG SECTIONS
-# do not allow a specific ip to access wan
-#config rule
-# option src lan
-# option src_ip 192.168.45.2
-# option dest wan
-# option proto tcp
-# option target REJECT
-
-# block a specific mac on wan
-#config rule
-# option dest wan
-# option src_mac 00:11:22:33:44:66
-# option target REJECT
-
-# block incoming ICMP traffic on a zone
-#config rule
-# option src lan
-# option proto ICMP
-# option target DROP
-
-# port redirect port coming in on wan to lan
-#config redirect
-# option src wan
-# option src_dport 80
-# option dest lan
-# option dest_ip 192.168.16.235
-# option dest_port 80
-# option proto tcp
-
-# port redirect of remapped ssh port (22001) on wan
-#config redirect
-# option src wan
-# option src_dport 22001
-# option dest lan
-# option dest_port 22
-# option proto tcp
-
-# allow IPsec/ESP and ISAKMP passthrough
-#config rule
-# option src wan
-# option dest lan
-# option protocol esp
-# option target ACCEPT
-
-#config rule
-# option src wan
-# option dest lan
-# option src_port 500
-# option dest_port 500
-# option proto udp
-# option target ACCEPT
-
-### FULL CONFIG SECTIONS
-#config rule
-# option src lan
-# option src_ip 192.168.45.2
-# option src_mac 00:11:22:33:44:55
-# option src_port 80
-# option dest wan
-# option dest_ip 

Re: [OpenWrt-Devel] [RFC PATCH] ar71xx: Support Antminer S1/S3

2015-05-01 Thread Dirk Neukirchen

some comments inline

On 30.04.2015 04:08, James Hilliard wrote:
 The Antminer S1 and S3 use a controller with a modified version of
 OpenWRT which has a single ethernet port and a wifi antenna header.
 This is the patch from their GPL source release which appears to break
 support for the tl-wr741nd-v4 in order to support their board. What
 would be the proper way to differentiate this device and add support
 for it?
 

A separate ARCH file because replacing 741ND-v4 will break that unit
This patch contains many different changes so it has to be split up.

 Index: target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
 ===
 --- target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
 (revision 38031)
 +++ target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
 (working copy)

see above - create new file or make changes so it does not break
supported targets

 Index: target/linux/ar71xx/files/drivers/mtd/tplinkpart.c
 ===
 --- target/linux/ar71xx/files/drivers/mtd/tplinkpart.c (revision 38031)
 +++ target/linux/ar71xx/files/drivers/mtd/tplinkpart.c (working copy)
 @@ -149,7 +149,7 @@
   parts[0].name = u-boot;
   parts[0].offset = 0;
   parts[0].size = offset;
 - parts[0].mask_flags = MTD_WRITEABLE;
 + //parts[0].mask_flags = MTD_WRITEABLE;

This seems to remove write protection from u-boot.
This is dangerous and can result in really bad bricks


 Index: target/linux/ar71xx/image/Makefile
 ===
 --- target/linux/ar71xx/image/Makefile (revision 38031)
 +++ target/linux/ar71xx/image/Makefile (working copy)
 @@ -921,7 +921,8 @@
 -$(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR743NV2,tl-wr743nd-v2,TL-WR741ND-v4,ttyATH0,115200,0x07430002,1,4Mlzma))
 +#$(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR743NV2,tl-wr743nd-v2,TL-WR741ND-v4,ttyATH0,115200,0x07430002,1,4Mlzma))
 +$(eval $(call 
 SingleProfile,TPLINK-LZMA,64kraw,TLWR743NV2,tl-wr743nd-v2,TL-WR741ND-v4,ttyATH0,115200,0x07430002,1,8Mlzma))

Same as first comment - this breaks/disables the working images of that router

 --- package/network/services/dropbear/files/dropbear.config (revision 38031)
 +++ package/network/services/dropbear/files/dropbear.config (working copy)
 @@ -2,4 +2,5 @@
   option PasswordAuth 'on'
   option RootPasswordAuth 'on'
   option Port '22'
 +# option Interface 'lan'
  # option BannerFile   '/etc/banner'

dropbear change that affects all other platforms - remove

 Index: package/base-files/files/lib/functions/uci-defaults.sh
 ===
 --- package/base-files/files/lib/functions/uci-defaults.sh (revision 38031)
 +++ package/base-files/files/lib/functions/uci-defaults.sh (working copy)

afaics this is related to LED and probably not needed


 Index: package/base-files/files/etc/rc.button/reset
 ===
 --- package/base-files/files/etc/rc.button/reset (revision 38031)
 +++ package/base-files/files/etc/rc.button/reset (working copy)
 @@ -14,5 +14,5 @@
  elif [ $SEEN -gt 5 ]
  then
   echo FACTORY RESET  /dev/console
 - jffs2reset -y  reboot 
 + jffs2reset -y  reboot -f 

as before this would affect other boards too

  fi
 Index: package/base-files/files/etc/shadow
 ===
 --- package/base-files/files/etc/shadow (revision 38031)
 +++ package/base-files/files/etc/shadow (working copy)
 @@ -1,4 +1,5 @@
 -root:x:0:0:9:7:::
 +root:$1$2zyJL0u3$UjHfNFlkkj9azThzkLaVA0:16013:0:9:7:::
 +admin:*:16013:0:9:7:::

remove (default root password that is antminer device/software specific)
Is admin account needed for all other platforms?
(add it to the software packages that needs it)

 Index: package/base-files/files/etc/profile
 ===
 --- package/base-files/files/etc/profile (revision 38031)
 +++ package/base-files/files/etc/profile (working copy)
 @@ -8,6 +8,7 @@
 
  [ -x /bin/more ] || alias more=less
  [ -x /usr/bin/vim ]  alias vi=vim || alias vim=vi
 +[ -x /bin/ls ]  alias ll=ls -l

while nice this might waste some bytes 

 
  [ -z $KSH_VERSION -o \! -s /etc/mkshrc ] || . /etc/mkshrc
 
 Index: package/base-files/files/etc/config/system
 ===
 --- package/base-files/files/etc/config/system (revision 38031)
 +++ package/base-files/files/etc/config/system (working copy)
 @@ -1,6 +1,8 @@
  config system
 - option hostname OpenWrt
 - option timezone UTC
 + option hostname antMiner
 + #option timezone UTC
 + option zonename 'Asia/Shanghai'
 +option timezone 'CST-8'

remove - antMiner firmware specific settings

 Index: tools/firmware-utils/src/mktplinkfw.c
 

[OpenWrt-Devel] [RFC PATCH] ar71xx: Support Antminer S1/S3

2015-04-29 Thread James Hilliard
The Antminer S1 and S3 use a controller with a modified version of
OpenWRT which has a single ethernet port and a wifi antenna header.
This is the patch from their GPL source release which appears to break
support for the tl-wr741nd-v4 in order to support their board. What
would be the proper way to differentiate this device and add support
for it?

Index: target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
===
--- target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
(revision 38031)
+++ target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr741nd-v4.c
(working copy)
@@ -27,12 +27,13 @@

 #define TL_WR741NDV4_GPIO_LED_WLAN 0
 #define TL_WR741NDV4_GPIO_LED_QSS 1
-#define TL_WR741NDV4_GPIO_LED_WAN 13
-#define TL_WR741NDV4_GPIO_LED_LAN1 14
-#define TL_WR741NDV4_GPIO_LED_LAN2 15
-#define TL_WR741NDV4_GPIO_LED_LAN3 16
-#define TL_WR741NDV4_GPIO_LED_LAN4 17
-#define TL_WR741NDV4_GPIO_LED_SYSTEM 27
+#define TL_WR741NDV4_GPIO_LED_WAN 17
+#define TL_WR741NDV4_GPIO_LED_WANL 22
+#define TL_WR741NDV4_GPIO_LED_LAN1 13
+#define TL_WR741NDV4_GPIO_LED_LAN2 14
+#define TL_WR741NDV4_GPIO_LED_LAN3 15
+#define TL_WR741NDV4_GPIO_LED_LAN4 16
+#define TL_WR741NDV4_GPIO_LED_SYSTEM 23

 #define TL_MR3220V2_GPIO_BTN_WPS 11
 #define TL_MR3220V2_GPIO_BTN_WIFI 24
@@ -68,7 +69,7 @@
  }, {
  .name = tp-link:green:lan4,
  .gpio = TL_WR741NDV4_GPIO_LED_LAN4,
- .active_low = 1,
+ .active_low = 0,
  }, {
  .name = tp-link:green:qss,
  .gpio = TL_WR741NDV4_GPIO_LED_QSS,
@@ -76,12 +77,16 @@
  }, {
  .name = tp-link:green:system,
  .gpio = TL_WR741NDV4_GPIO_LED_SYSTEM,
- .active_low = 1,
+ .active_low = 0,
  }, {
  .name = tp-link:green:wan,
  .gpio = TL_WR741NDV4_GPIO_LED_WAN,
  .active_low = 0,
  }, {
+  .name   = tp-link:green:wan_link,
+  .gpio   = TL_WR741NDV4_GPIO_LED_WANL,
+  .active_low = 0,
+  }, {
  .name = tp-link:green:wlan,
  .gpio = TL_WR741NDV4_GPIO_LED_WLAN,
  .active_low = 0,
@@ -100,7 +105,7 @@
  .code = KEY_RESTART,
  .debounce_interval = TL_WR741NDV4_KEYS_DEBOUNCE_INTERVAL,
  .gpio = TL_WR741NDV4_GPIO_BTN_RESET,
- .active_low = 0,
+ .active_low = 1,
  }, {
  .desc = WPS,
  .type = EV_KEY,
@@ -134,7 +139,20 @@
  u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);

- ath79_setup_ar933x_phy4_switch(true, true);
+ if((mac[0] == 0xff) 
+ (mac[1] == 0xff) 
+ (mac[2] == 0xff) 
+ (mac[3] == 0xff) 
+ (mac[4] == 0xff) 
+ (mac[5] == 0xff))
+ {
+ printk(MAC FF:FF:FF:FF:FF:FF\n);
+ memcpy(mac, ee+2, 6);
+ mac = ee+2;
+ printk(MAC %02x:%02x:%02x:%02x:%02x:%02x, mac[0], mac[1], mac[2],
mac[3], mac[4], mac[5]);
+ }
+ //ath79_setup_ar933x_phy4_switch(true, true);
+ ath79_setup_ar933x_phy4_switch(false, false);

  ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
@@ -156,6 +174,11 @@
 static void __init tl_wr741ndv4_setup(void)
 {
  tl_ap121_setup();
+
+ gpio_request_one(TL_MR3220V2_GPIO_USB_POWER,
+  GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
+  USB power);
+ath79_register_usb();

  ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio) - 1,
  tl_wr741ndv4_leds_gpio);
Index: target/linux/ar71xx/files/drivers/mtd/tplinkpart.c
===
--- target/linux/ar71xx/files/drivers/mtd/tplinkpart.c (revision 38031)
+++ target/linux/ar71xx/files/drivers/mtd/tplinkpart.c (working copy)
@@ -149,7 +149,7 @@
  parts[0].name = u-boot;
  parts[0].offset = 0;
  parts[0].size = offset;
- parts[0].mask_flags = MTD_WRITEABLE;
+ //parts[0].mask_flags = MTD_WRITEABLE;

  parts[1].name = kernel;
  parts[1].offset = offset;
@@ -159,15 +159,24 @@
  parts[2].offset = rootfs_offset;
  parts[2].size = art_offset - rootfs_offset;

+ parts[4].name = art;
+ parts[4].offset = art_offset;
+ parts[4].size = TPLINK_ART_LEN;
+ //part4[3].mask_flags = MTD_WRITEABLE;
+
+ parts[3].name = firmware;
+ parts[3].offset = offset;
+ parts[3].size = art_offset - offset;
+ #if 0
  parts[3].name = art;
  parts[3].offset = art_offset;
  parts[3].size = TPLINK_ART_LEN;
- parts[3].mask_flags = MTD_WRITEABLE;
+ //parts[3].mask_flags = MTD_WRITEABLE;

  parts[4].name = firmware;
  parts[4].offset = offset;
  parts[4].size = art_offset - offset;
-
+ #endif
  vfree(header);

  *pparts = parts;
Index: target/linux/ar71xx/image/Makefile
===
--- target/linux/ar71xx/image/Makefile (revision 38031)
+++ target/linux/ar71xx/image/Makefile (working copy)
@@ -921,7 +921,8 @@
 $(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