[OpenWrt-Devel] [RESEND PATCH v2 1/3] sysupgrade: let force be more forceful with multiple --force/-F options

2014-05-11 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 package/base-files/files/sbin/sysupgrade | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index cd224c6..c17e2a1 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -33,7 +33,7 @@ while [ -n $1 ]; do
-r|--restore-backup) export CONF_RESTORE=$2 NEED_IMAGE=1; 
shift;;
-l|--list-backup) export CONF_BACKUP_LIST=1; break;;
-f) export CONF_IMAGE=$2; shift;;
-   -F|--force) export FORCE=1;;
+   -F|--force) export FORCE=$(($FORCE + 1));;
-T|--test) export TEST=1;;
-h|--help) export HELP=1; break;;
-*)
@@ -174,7 +174,7 @@ type platform_check_image /dev/null 2/dev/null || {
 
 for check in $sysupgrade_image_check; do
( eval $check \\$ARGV\ ) || {
-   if [ $FORCE -eq 1 ]; then
+   if [ $FORCE -gt 0 ]; then
echo Image check '$check' failed but --force given - 
will update anyway!
break
else
-- 
1.9.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [RESEND PATCH v2 2/3] upgrade/common: force mtd when sysupgrade gets -F -F (2 forces)

2014-05-11 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 package/base-files/files/lib/upgrade/common.sh | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/upgrade/common.sh 
b/package/base-files/files/lib/upgrade/common.sh
index ecf1a98..7b3554b 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -198,10 +198,15 @@ jffs2_copy_config() {
 
 default_do_upgrade() {
sync
+   local f_arg=
+   if [ $FORCE -gt 1 ]; then
+   f_arg=-f
+   fi
+
if [ $SAVE_CONFIG -eq 1 ]; then
-   get_image $1 | mtd $MTD_CONFIG_ARGS -j $CONF_TAR write - 
${PART_NAME:-image}
+   get_image $1 | mtd $f_arg $MTD_CONFIG_ARGS -j $CONF_TAR 
write - ${PART_NAME:-image}
else
-   get_image $1 | mtd write - ${PART_NAME:-image}
+   get_image $1 | mtd $f_arg write - ${PART_NAME:-image}
fi
 }
 
-- 
1.9.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 1/3] sysupgrade: let force be more forceful with multiple --force/-F options

2013-12-15 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 package/base-files/files/sbin/sysupgrade | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 56e9a92..033bd35 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -32,7 +32,7 @@ while [ -n $1 ]; do
-r|--restore-backup) export CONF_RESTORE=$2 NEED_IMAGE=1; 
shift;;
-l|--list-backup) export CONF_BACKUP_LIST=1; break;;
-f) export CONF_IMAGE=$2; shift;;
-   -F|--force) export FORCE=1;;
+   -F|--force) export FORCE=$(($FORCE + 1));;
-T|--test) export TEST=1;;
-h|--help) export HELP=1; break;;
-*)
@@ -173,7 +173,7 @@ type platform_check_image /dev/null 2/dev/null || {
 
 for check in $sysupgrade_image_check; do
( eval $check \\$ARGV\ ) || {
-   if [ $FORCE -eq 1 ]; then
+   if [ $FORCE -gt 0 ]; then
echo Image check '$check' failed but --force given - 
will update anyway!
break
else
-- 
1.8.5.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 0/8] Improve Belkin F7Dxxxx support

2013-12-15 Thread Cody P Schafer
Anyone have any opinions on this? Anything need changing? Any recomendations?
A related question:
- I'd like to move all the trx handling logic into a common header. 1)
is there anything obvious that would prevent this? 2) where should I
put the header?


On Thu, Dec 5, 2013 at 2:45 AM, Cody P Schafer de...@codyps.com wrote:
 - fixup board detection with some new boards
 - cleanup broadcom-diag usage
 - teach lzmaloader, brcm47xxpart, mtd, and brcm47xx's upgrade/platform.sh 
 about
   the Belkin trx magic
 - build some Belkin F7D images

 As noted in a previous email, we need to recognize all of the
 various trx magic because the Belkin web interface doesn't like the
 0x12345678 (QA) trx magic that works on all of these routers.



 Cody P Schafer (8):
   linux/brcm47xx : tweak Belkin F7D board detection
   broadcom-diag: tweak Belkin F7D, share 1 led/button layout
   brcm47xx/lzmaloader: add Belkin F7D support
   brcm47xx/mtd-partition: recognize Belkin F7D TRX headers
   mtd: recognize belkin trx magic
   brcm47xx/upgrade: add workarounds for Belkin .trx headers
   brcm47xx/image: build Belkin F7D images
   brcm47xx: add brcmsmac + bgmac profile

  package/kernel/broadcom-diag/src/diag.c| 36 --
  package/system/mtd/src/trx.c   | 29 +--
  .../brcm47xx/base-files/lib/upgrade/platform.sh| 58 
 +++---
  target/linux/brcm47xx/image/Makefile   | 25 ++
  .../brcm47xx/image/lzma-loader/src/decompress.c| 27 +-
  ...PS-BCM47XX-fix-detection-of-some-boards-2.patch | 28 +--
  .../077-MIPS-BCM47XX-mtd-partition-belkin.patch| 49 ++
  .../profiles/226-Broadcom-bgmac-brcsmac.mk | 20 
  8 files changed, 228 insertions(+), 44 deletions(-)
  create mode 100644 
 target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch
  create mode 100644 
 target/linux/brcm47xx/profiles/226-Broadcom-bgmac-brcsmac.mk

 --
 1.8.4.2

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


Re: [OpenWrt-Devel] WRT610n v2 support

2013-12-13 Thread Cody P Schafer
I run current trunk on a wrt610n v2 without applying any patches, and
without observing any of the issues mentioned. Also, that kernel is
ancient (Was this email stalled for 2 years somewhere in the depths of
the web?).

On Sat, Dec 18, 2010 at 2:19 AM, Nathan Hintz nlhi...@hotmail.com wrote:
 The patches being referred to can be found in this thread
 (https://lists.openwrt.org/pipermail/openwrt-devel/2010-May/007049.html).  I
 have applied them with modifications to a recent version of trunk and the
 2.6.37-rc6 kernel; and modified the build to produce a bootable image for a
 Linksys E3000 (same H/W as WRT610Nv2).  The modifications include changes
 for the WRT610Nv2, but I have not tested that image to see if it loads (no
 H/W to test on).



 The image  has  the same problems as mentioned previously (no Ethernet, no
 wireless, no USB,  no switch support); you need to have serial access to do
 anything with it.  There are also issues with reading from NVRAM (some work,
 some don’t) that I looked into a little but didn’t figure out; so the board
 detection (in broadcom-diag) doesn’t work.   The broadcom-wl driver loads
 (w/ a small patch) and creates an interface; but when the interface is
 brought up, it causes a kernel oops followed by a reboot.



 The patches from the link above disable support for the PCI-E core.  I
 suspect this needs to be fixed, before we will get very far.  This was what
 I was going to look at next, but it will be slow going since I have to
 educate myself before I can make sense of it.  If someone knows how this all
 works, I could really use some help with this or some pointers to send me in
 the right direction so I’m not wasting effort.



 Nathan


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

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


Re: [OpenWrt-Devel] [PATCH 0/2] let sysupgrade's --force also trigger mtd --force

2013-12-11 Thread Cody P Schafer
On Wed, Dec 11, 2013 at 4:49 AM, Yousong Zhou yszhou4t...@gmail.com wrote:
 Hi,

 On 5 December 2013 18:42, Cody P Schafer de...@codyps.com wrote:
 Normal force (one -F flag) is unchanged in behavior and only overrides the
 sysupgrade checks.  Force with two or more flags also passes --force to mtd,
 overriding some of it's checks.

 This was useful in testing of the belkin f7d patches, and seems like a 
 good idea.

 Cody P Schafer (2):
   sysupgrade: let force be more forceful with multiple --force/-F
 options

 Interesting. But the behavior of multiple --force should be at least
 documented in the usage output?

I very good point. I'll add that.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] quilt: avoid copying backup files.

2013-12-05 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 include/quilt.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/quilt.mk b/include/quilt.mk
index 925b7a7..4e68f1b 100644
--- a/include/quilt.mk
+++ b/include/quilt.mk
@@ -31,7 +31,7 @@ define PatchDir/Quilt
mkdir -p $(1)/patches/$(3); \
cp $(2)/series $(1)/patches/$(3); \
fi
-   @for patch in ( (cd $(2)  if [ -f series ]; then $(call 
filter_series,series); else ls | sort; fi; ) 2/dev/null ); do ( \
+   @for patch in ( (cd $(2)  if [ -f series ]; then $(call 
filter_series,series); else ls | sort | grep -v '^.*~'; fi; ) 2/dev/null 
); do ( \
cp $(2)/patch $(1)/patches/$(3); \
echo $(3)patch  $(1)/patches/series; \
); done
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/2] upgrade/common: force mtd when sysupgrade gets -F -F (2 forces)

2013-12-05 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 package/base-files/files/lib/upgrade/common.sh | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/upgrade/common.sh 
b/package/base-files/files/lib/upgrade/common.sh
index 6122ae7..cad6d72 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -187,10 +187,15 @@ jffs2_copy_config() {
 
 default_do_upgrade() {
sync
+   local f_arg=
+   if [ $FORCE -gt 1 ]; then
+   f_arg=-f
+   fi
+
if [ $SAVE_CONFIG -eq 1 ]; then
-   get_image $1 | mtd $MTD_CONFIG_ARGS -j $CONF_TAR write - 
${PART_NAME:-image}
+   get_image $1 | mtd $f_arg $MTD_CONFIG_ARGS -j $CONF_TAR 
write - ${PART_NAME:-image}
else
-   get_image $1 | mtd write - ${PART_NAME:-image}
+   get_image $1 | mtd $f_arg write - ${PART_NAME:-image}
fi
 }
 
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 0/2] let sysupgrade's --force also trigger mtd --force

2013-12-05 Thread Cody P Schafer
Normal force (one -F flag) is unchanged in behavior and only overrides the
sysupgrade checks.  Force with two or more flags also passes --force to mtd,
overriding some of it's checks.

This was useful in testing of the belkin f7d patches, and seems like a good 
idea.

Cody P Schafer (2):
  sysupgrade: let force be more forceful with multiple --force/-F
options
  upgrade/common: force mtd when sysupgrade gets -F -F (2 forces)

 package/base-files/files/lib/upgrade/common.sh | 9 +++--
 package/base-files/files/sbin/sysupgrade   | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

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


[OpenWrt-Devel] [PATCH 1/8] linux/brcm47xx : tweak Belkin F7Dxxxx board detection

2013-12-05 Thread Cody P Schafer
Add a few Belkin F7D entries, with F7D4401 sourced from online
documentation and the F7D7302 being observed. F7D3301, F7D3302, and
F7D4302 are reasonable guesses which are unlikely to cause
mis-detection.

It also appears that at least the F7D3302, F7D3301, F7D7301, and F7D7302
have a shared boardtype and boardrev, so use that as a fallback to a
generic F7D board.
---
 ...PS-BCM47XX-fix-detection-of-some-boards-2.patch | 28 ++
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git 
a/target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch
 
b/target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch
index f330669..d0c838c 100644
--- 
a/target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch
+++ 
b/target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch
@@ -1,14 +1,27 @@
 --- a/arch/mips/bcm47xx/board.c
 +++ b/arch/mips/bcm47xx/board.c
-@@ -180,6 +180,7 @@ struct bcm47xx_board_type_list3 bcm47xx_
+@@ -69,7 +69,12 @@ struct bcm47xx_board_type_list1 bcm47xx_
+   {{BCM47XX_BOARD_ASUS_WL500W, Asus WL500W}, WL500gW-},
+   {{BCM47XX_BOARD_ASUS_WL520GC, Asus WL520GC}, WL520GC-},
+   {{BCM47XX_BOARD_ASUS_WL520GU, Asus WL520GU}, WL520GU-},
++  {{BCM47XX_BOARD_BELKIN_F7D3301, Belkin F7D3301}, F7D3301},
++  {{BCM47XX_BOARD_BELKIN_F7D3302, Belkin F7D3302}, F7D3302},
++  {{BCM47XX_BOARD_BELKIN_F7D3302, Belkin F7D7302}, F7D7302 v1},
+   {{BCM47XX_BOARD_BELKIN_F7D4301, Belkin F7D4301}, F7D4301},
++  {{BCM47XX_BOARD_BELKIN_F7D4302, Belkin F7D4302}, F7D4302},
++  {{BCM47XX_BOARD_BELKIN_F7D4401, Belkin F7D4401}, F7D4401},
+   { {0}, 0},
+ };
+ 
+@@ -180,6 +185,7 @@ struct bcm47xx_board_type_list3 bcm47xx_
{{BCM47XX_BOARD_ZTE_H218N, ZTE H218N}, 0x053d, 1234, 0x1305},
{{BCM47XX_BOARD_NETGEAR_WNR3500L, Netgear WNR3500L}, 0x04CF, 
3500, 02},
{{BCM47XX_BOARD_LINKSYS_WRT54GSV1, Linksys WRT54GS V1}, 0x0101, 
42, 0x10},
-+  {{BCM47XX_BOARD_BELKIN_F7D330X, Belkin F7D330X}, 0xa4cf, NULL, 
0x1102 },
++  {{BCM47XX_BOARD_BELKIN_F7D, Belkin F7D}, 0xa4cf, NULL, 
0x1102},
{ {0}, 0},
  };
  
-@@ -270,9 +271,9 @@ static __init const struct bcm47xx_board
+@@ -270,9 +276,9 @@ static __init const struct bcm47xx_board
bcm47xx_nvram_getenv(boardnum, buf2, sizeof(buf2)) = 0 
bcm47xx_nvram_getenv(boardrev, buf3, sizeof(buf3)) = 0) {
for (e3 = bcm47xx_board_list_board; e3-value1; e3++) {
@@ -23,11 +36,16 @@
}
 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
-@@ -28,6 +28,7 @@ enum bcm47xx_board {
+@@ -27,7 +27,12 @@ enum bcm47xx_board {
+   BCM47XX_BOARD_ASUS_WL700GE,
BCM47XX_BOARD_ASUS_WLHDD,
  
++  BCM47XX_BOARD_BELKIN_F7D,
++  BCM47XX_BOARD_BELKIN_F7D3301,
++  BCM47XX_BOARD_BELKIN_F7D3302,
BCM47XX_BOARD_BELKIN_F7D4301,
-+  BCM47XX_BOARD_BELKIN_F7D330X,
++  BCM47XX_BOARD_BELKIN_F7D4302,
++  BCM47XX_BOARD_BELKIN_F7D4401,
  
BCM47XX_BOARD_BUFFALO_WBR2_G54,
BCM47XX_BOARD_BUFFALO_WHR2_A54G54,
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/8] broadcom-diag: tweak Belkin F7Dxxxx, share 1 led/button layout

2013-12-05 Thread Cody P Schafer
While marked and marketed as different boards, the F7D series is
(so far) largely the same in what matters for broadcom-diag: all the
buttons and leds are assigned to the same gpios.

The only difference that may need to be noted: some models lack a usb1
led (as they lack usb1). Given that it is relatively easy to populate
that led, I see no point in disabling access to it. Additionally, this
does mean that /proc/diag/model will only show the non-specific model.
As /proc/cpuinfo's machine: entry still shows the detailed board
type, we don't loose anything overall.

Signed-off-by: Cody P Schafer de...@codyps.com
---
 package/kernel/broadcom-diag/src/diag.c | 36 +
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/package/kernel/broadcom-diag/src/diag.c 
b/package/kernel/broadcom-diag/src/diag.c
index fccc219..3feb746 100644
--- a/package/kernel/broadcom-diag/src/diag.c
+++ b/package/kernel/broadcom-diag/src/diag.c
@@ -145,8 +145,7 @@ enum {
 
/* Belkin */
BELKIN_UNKNOWN,
-   BELKIN_F7D330X, /* covers F7D7302,F7D3302,F7D3301, and F7D7301 */
-   BELKIN_F7D4301,
+   BELKIN_F7D,
 
/* Netgear */
WGT634U,
@@ -967,28 +966,8 @@ static struct platform_t __initdata platforms[] = {
{ .name = connected,  .gpio = 1  0, .polarity = 
NORMAL },
},
},
-   [BELKIN_F7D330X] = {
-   .name   = Belkin F7D330X,
-   .buttons= {
-   { .name = reset,  .gpio = 1  6 },
-   { .name = wps,.gpio = 1  8 },
-   },
-   .leds   = {
-   /* green */
-   { .name = power,  .gpio = 1  10, .polarity = 
REVERSE },
-   /* orange power */
-   { .name = warn,   .gpio = 1  11, .polarity = 
REVERSE },
-   /* green */
-   { .name = wps,.gpio = 1  12, .polarity = 
REVERSE },
-   /* orange wps */
-   { .name = wlan,   .gpio = 1  13, .polarity = 
REVERSE },
-   { .name = usb0,   .gpio = 1  14, .polarity = 
REVERSE },
-   /* shipped unconnected in the F7D3302 */
-   { .name = usb1,   .gpio = 1  15, .polarity = 
REVERSE },
-   },
-   },
-   [BELKIN_F7D4301] = {
-   .name   = Belkin PlayMax F7D4301,
+   [BELKIN_F7D] = {
+   .name   = Belkin F7D,
.buttons= {
{ .name = reset,  .gpio = 1  6 },
{ .name = wps,.gpio = 1  8 },
@@ -1399,10 +1378,13 @@ static struct platform_t __init *platform_detect(void)
return platforms[WL700GE];
case BCM47XX_BOARD_ASUS_WLHDD:
return platforms[WLHDD];
+   case BCM47XX_BOARD_BELKIN_F7D:
+   case BCM47XX_BOARD_BELKIN_F7D3301:
+   case BCM47XX_BOARD_BELKIN_F7D3302:
case BCM47XX_BOARD_BELKIN_F7D4301:
-   return platforms[BELKIN_F7D4301];
-   case BCM47XX_BOARD_BELKIN_F7D330X:
-   return platforms[BELKIN_F7D330X];
+   case BCM47XX_BOARD_BELKIN_F7D4302:
+   case BCM47XX_BOARD_BELKIN_F7D4401:
+   return platforms[BELKIN_F7D];
case BCM47XX_BOARD_BUFFALO_WBR2_G54:
return platforms[WBR2_G54];
case BCM47XX_BOARD_BUFFALO_WHR2_A54G54:
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 4/8] brcm47xx/mtd-partition: recognize Belkin F7Dxxxx TRX headers

2013-12-05 Thread Cody P Schafer
F7D3301/F7D7301, F7D3302/F7D7302, and F7D4301 replace the HDR0 with a
custom byte sequence (which appears to be a date). Also, they all
appear to support a single QA byte sequence.

Just support the QA byte sequence, we don't need the others.

Signed-off-by: Cody P Schafer de...@codyps.com
---
 .../077-MIPS-BCM47XX-mtd-partition-belkin.patch| 49 ++
 1 file changed, 49 insertions(+)
 create mode 100644 
target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch

diff --git 
a/target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch
 
b/target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch
new file mode 100644
index 000..2bba2fe
--- /dev/null
+++ 
b/target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch
@@ -0,0 +1,49 @@
+Index: linux-3.10.18/drivers/mtd/bcm47xxpart.c
+===
+--- linux-3.10.18.orig/drivers/mtd/bcm47xxpart.c
 linux-3.10.18/drivers/mtd/bcm47xxpart.c
+@@ -33,7 +33,12 @@
+ #define POT_MAGIC20x504f  /* OP */
+ #define ML_MAGIC1 0x39685a42
+ #define ML_MAGIC2 0x26594131
+-#define TRX_MAGIC 0x30524448
++#define TRX_MAGIC 0x30524448  /* HDR0 */
++#define BELKIN_F7D3301_MAGIC  0x20100322
++#define BELKIN_F7D3302_MAGIC  0x20090928
++#define BELKIN_F7D4302_MAGIC  0x20101006
++#define BELKIN_F7D4401_MAGIC  0x00018517
++#define BELKIN_F7D_QA_MAGIC   0x12345678
+ #define SQSH_MAGIC0x71736873  /* shsq */
+ 
+ struct trx_header {
+@@ -45,6 +50,21 @@ struct trx_header {
+   uint32_t offset[3];
+ } __packed;
+ 
++static bool is_trx_magic(uint32_t magic)
++{
++  switch (magic) {
++  case TRX_MAGIC:
++  case BELKIN_F7D_QA_MAGIC:
++  case BELKIN_F7D3301_MAGIC:
++  case BELKIN_F7D3302_MAGIC:
++  case BELKIN_F7D4302_MAGIC:
++  case BELKIN_F7D4401_MAGIC:
++  return true;
++  default:
++  return false;
++  }
++}
++
+ static void bcm47xxpart_add_part(struct mtd_partition *part, char *name,
+u64 offset, uint32_t mask_flags)
+ {
+@@ -139,7 +159,7 @@ static int bcm47xxpart_parse(struct mtd_
+   }
+ 
+   /* TRX */
+-  if (buf[0x000 / 4] == TRX_MAGIC) {
++  if (is_trx_magic(buf[0x000 / 4])) {
+   trx = (struct trx_header *)buf;
+ 
+   trx_part = curr_part;
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/8] brcm47xx/lzmaloader: add Belkin F7Dxxxx support

2013-12-05 Thread Cody P Schafer
F7D3301/F7D7301, F7D3302/F7D7302, F7D4302, and F7D4401 all have
replacements for the TRX magic (HDR0), and all those models also
appear to support a single QA TRX magic.

Only bother supporting the QA (0x12345678) TRX magic, no need for
board specific ones.

Signed-off-by: Cody P Schafer de...@codyps.com
---
 .../brcm47xx/image/lzma-loader/src/decompress.c| 27 --
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/target/linux/brcm47xx/image/lzma-loader/src/decompress.c 
b/target/linux/brcm47xx/image/lzma-loader/src/decompress.c
index 05681b1..5d623c0 100644
--- a/target/linux/brcm47xx/image/lzma-loader/src/decompress.c
+++ b/target/linux/brcm47xx/image/lzma-loader/src/decompress.c
@@ -90,6 +90,12 @@ struct trx_header {
 #define EDIMAX_PS_HEADER_MAGIC 0x36315350 /*  PS16  */
 #define EDIMAX_PS_HEADER_LEN   0xc /* 12 bytes long for edimax header */
 
+#define BELKIN_F7D3301_MAGIC   0x20100322 /* a date of some sort */
+#define BELKIN_F7D3302_MAGIC   0x20090928
+#define BELKIN_F7D4302_MAGIC   0x20101006
+#define BELKIN_F7D4401_MAGIC   0x00018517
+#define BELKIN_F7D_QA_MAGIC0x12345678
+
 /* beyound the image end, size not known in advance */
 extern unsigned char workspace[];
 
@@ -121,6 +127,24 @@ static __inline__ unsigned char get_byte(void)
return read_byte(0, buffer, fake), *buffer;
 }
 
+static int has_header_magic(unsigned char *data)
+{
+   UInt32 magic = ((struct trx_header *)data)-magic;
+
+   switch (magic) {
+   case TRX_MAGIC:
+   case BELKIN_F7D3301_MAGIC:
+   case BELKIN_F7D3302_MAGIC:
+   case BELKIN_F7D4302_MAGIC:
+   case BELKIN_F7D4401_MAGIC:
+   case EDIMAX_PS_HEADER_MAGIC:
+   case BELKIN_F7D_QA_MAGIC:
+   return 1;
+   default:
+   return 0;
+   }
+}
+
 /* should be the first function */
 void entry(unsigned long icache_size, unsigned long icache_lsize, 
unsigned long dcache_size, unsigned long dcache_lsize,
@@ -138,8 +162,7 @@ void entry(unsigned long icache_size, unsigned long 
icache_lsize,
 
/* look for trx header, 32-bit data access */
for (data = ((unsigned char *) KSEG1ADDR(BCM4710_FLASH));
-   ((struct trx_header *)data)-magic != TRX_MAGIC 
-   ((struct trx_header *)data)-magic != EDIMAX_PS_HEADER_MAGIC;
+!has_header_magic(data);
 data += 65536);
 
if (((struct trx_header *)data)-magic == EDIMAX_PS_HEADER_MAGIC)
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 0/8] Improve Belkin F7Dxxxx support

2013-12-05 Thread Cody P Schafer
- fixup board detection with some new boards
- cleanup broadcom-diag usage
- teach lzmaloader, brcm47xxpart, mtd, and brcm47xx's upgrade/platform.sh about
  the Belkin trx magic
- build some Belkin F7D images

As noted in a previous email, we need to recognize all of the
various trx magic because the Belkin web interface doesn't like the
0x12345678 (QA) trx magic that works on all of these routers.



Cody P Schafer (8):
  linux/brcm47xx : tweak Belkin F7D board detection
  broadcom-diag: tweak Belkin F7D, share 1 led/button layout
  brcm47xx/lzmaloader: add Belkin F7D support
  brcm47xx/mtd-partition: recognize Belkin F7D TRX headers
  mtd: recognize belkin trx magic
  brcm47xx/upgrade: add workarounds for Belkin .trx headers
  brcm47xx/image: build Belkin F7D images
  brcm47xx: add brcmsmac + bgmac profile

 package/kernel/broadcom-diag/src/diag.c| 36 --
 package/system/mtd/src/trx.c   | 29 +--
 .../brcm47xx/base-files/lib/upgrade/platform.sh| 58 +++---
 target/linux/brcm47xx/image/Makefile   | 25 ++
 .../brcm47xx/image/lzma-loader/src/decompress.c| 27 +-
 ...PS-BCM47XX-fix-detection-of-some-boards-2.patch | 28 +--
 .../077-MIPS-BCM47XX-mtd-partition-belkin.patch| 49 ++
 .../profiles/226-Broadcom-bgmac-brcsmac.mk | 20 
 8 files changed, 228 insertions(+), 44 deletions(-)
 create mode 100644 
target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch
 create mode 100644 target/linux/brcm47xx/profiles/226-Broadcom-bgmac-brcsmac.mk

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


[OpenWrt-Devel] [PATCH 7/8] brcm47xx/image: build Belkin F7Dxxxx images

2013-12-05 Thread Cody P Schafer
F7D3302/F7D7302, F7D3301/F7D7301, F7D4302/F7D8302, and F7D4401

Same story as the lzmaloader changeset which proceeds this.

Signed-off-by: Cody P Schafer de...@codyps.com
---
 target/linux/brcm47xx/image/Makefile | 25 +
 1 file changed, 25 insertions(+)

diff --git a/target/linux/brcm47xx/image/Makefile 
b/target/linux/brcm47xx/image/Makefile
index eca09a8..56a7f86 100644
--- a/target/linux/brcm47xx/image/Makefile
+++ b/target/linux/brcm47xx/image/Makefile
@@ -60,6 +60,24 @@ define Image/Build/Edi
$(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx 
$(BIN_DIR)/openwrt-$(2)-$(3).bin
 endef
 
+
+# 1: trx input
+# 2: bin output
+# 3: 4 magic bytes
+define Image/Build/Belkin_
+   echo -ne $(3)  $(2).head
+   dd if=$(1) of=/dev/stdout bs=4 skip=1  $(2).tail
+   cat $(2).head $(2).tail  $(2)
+   rm -f $(2).head $(2).tail
+endef
+
+# $(1) : fs type (squashfs)
+# $(2) : device name
+# $(3) : encoded printf string to use in place of the trx's HDR\0
+define Image/Build/Belkin
+   $(call 
Image/Build/Belkin_,$(BIN_DIR)/$(IMG_PREFIX)-$(1).trx,$(BIN_DIR)/openwrt-$(2)-$(patsubst
 jffs2-%,jffs2,$(1)).bin,$(3))
+endef
+
 define Image/Build/Huawei
dd if=/dev/zero of=$(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin bs=92 count=1
echo -ne 'HDR0\x08\x00\x00\x00'  $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
@@ -118,10 +136,17 @@ define Image/Build/jffs2-64k
$(call Image/Build/CyberTAN,$(1),e3000_v1,61XN,1.0.3,$(patsubst 
jffs2-%,jffs2,$(1)))
$(call Image/Build/CyberTAN,$(1),e3200_v1,3200,1.0.1,$(patsubst 
jffs2-%,jffs2,$(1)))
$(call Image/Build/CyberTAN,$(1),e4200_v1,4200,1.0.5,$(patsubst 
jffs2-%,jffs2,$(1)))
+
$(call Image/Build/Motorola,$(1),wa840g,2,$(patsubst 
jffs2-%,jffs2,$(1)))
$(call Image/Build/Motorola,$(1),we800g,3,$(patsubst 
jffs2-%,jffs2,$(1)))
$(call Image/Build/Edi,$(1),ps1208mfg,$(patsubst jffs2-%,jffs2,$(1)))
$(call Image/Build/dwl3150,$(1),$(patsubst jffs2-%,jffs2,$(1)))
+
+   $(call Image/Build/Belkin,$(1),f7d,'\x78\x56\x34\x12')
+   $(call Image/Build/Belkin,$(1),f7d3301,'\x22\x03\x10\x20')
+   $(call Image/Build/Belkin,$(1),f7d3302,'\x28\x09\x09\x20')
+   $(call Image/Build/Belkin,$(1),f7d4302,'\x06\x10\x10\x20')
+   $(call Image/Build/Belkin,$(1),f7d4401,'\x17\x85\x01\x00')
 endef
 
 define Image/Build/squashfs
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 0/8] Add Belkin F7Dx30x support

2013-11-20 Thread Cody P Schafer
 You said:
 F7D3301/F7D7301, F7D3302/F7D7302 and F7D4301 all have replacements for
 the TRX magic (HDR0), and all those models also appear to support a
 single QA TRX magic. Add all of this to the lzmaloader's trx
 recognition code.

 Would it work to just generate images with the 0x12345678 header for all
 these devices and they would boot or are these different header necessary?

 That is a very good point. I don't see any reason it wouldn't work to
 generate the single image (removing a bunch of these magic numbers).

Turns out my testing of this wasn't complete: the web interface in the
manuf firmware doesn't let me flash 0x12345678 images to my F7D7302,
and I expect the other F7D routers will have similar issues.

That being the case, I'm going to respin (again) with the extended
image generation for multiple boards.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 0/8] Add Belkin F7Dx30x support

2013-11-11 Thread Cody P Schafer
[Sending again so it actually makes it to the list]

 You said:
 F7D3301/F7D7301, F7D3302/F7D7302 and F7D4301 all have replacements for
 the TRX magic (HDR0), and all those models also appear to support a
 single QA TRX magic. Add all of this to the lzmaloader's trx
 recognition code.

 Would it work to just generate images with the 0x12345678 header for all
 these devices and they would boot or are these different header necessary?

That is a very good point. I don't see any reason it wouldn't work to
generate the single image (removing a bunch of these magic numbers).
The only difference I've noticed so far in using the 0x12345678 magic
is CFE lets me know It's QA Firmware on the serial console prior to
boot.

I'll send out a new patchset with that simplification and some of the
changes that were in my v2 patchset.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 4/8] brcm47xx/lzmaloader: add Belkin F7DXXXX support

2013-11-10 Thread Cody P Schafer
F7D3301/F7D7301, F7D3302/F7D7302 and F7D4301 all have replacements for
the TRX magic (HDR0), and all those models also appear to support a
single QA TRX magic. Add all of this to the lzmaloader's trx
recognition code.

Signed-off-by: Cody P Schafer de...@codyps.com
---
 .../brcm47xx/image/lzma-loader/src/decompress.c| 25 --
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/target/linux/brcm47xx/image/lzma-loader/src/decompress.c 
b/target/linux/brcm47xx/image/lzma-loader/src/decompress.c
index 05681b1..56f4500 100644
--- a/target/linux/brcm47xx/image/lzma-loader/src/decompress.c
+++ b/target/linux/brcm47xx/image/lzma-loader/src/decompress.c
@@ -90,6 +90,11 @@ struct trx_header {
 #define EDIMAX_PS_HEADER_MAGIC 0x36315350 /*  PS16  */
 #define EDIMAX_PS_HEADER_LEN   0xc /* 12 bytes long for edimax header */
 
+#define BELKIN_F7D3301_MAGIC   0x20100322 /* a date of some sort */
+#define BELKIN_F7D3302_MAGIC   0x20090928
+#define BELKIN_F7D4302_MAGIC   0x20101006
+#define BELKIN_F7D_QA_MAGIC0x12345678
+
 /* beyound the image end, size not known in advance */
 extern unsigned char workspace[];
 
@@ -121,6 +126,23 @@ static __inline__ unsigned char get_byte(void)
return read_byte(0, buffer, fake), *buffer;
 }
 
+static int has_trx_magic(unsigned char *data)
+{
+   UInt32 magic = ((struct trx_header *)data)-magic;
+
+   switch (magic) {
+   case TRX_MAGIC:
+   case EDIMAX_PS_HEADER_MAGIC:
+   case BELKIN_F7D3301_MAGIC:
+   case BELKIN_F7D3302_MAGIC:
+   case BELKIN_F7D4302_MAGIC:
+   case BELKIN_F7D_QA_MAGIC:
+   return 1;
+   default:
+   return 0;
+   }
+}
+
 /* should be the first function */
 void entry(unsigned long icache_size, unsigned long icache_lsize, 
unsigned long dcache_size, unsigned long dcache_lsize,
@@ -138,8 +160,7 @@ void entry(unsigned long icache_size, unsigned long 
icache_lsize,
 
/* look for trx header, 32-bit data access */
for (data = ((unsigned char *) KSEG1ADDR(BCM4710_FLASH));
-   ((struct trx_header *)data)-magic != TRX_MAGIC 
-   ((struct trx_header *)data)-magic != EDIMAX_PS_HEADER_MAGIC;
+!has_trx_magic(data);
 data += 65536);
 
if (((struct trx_header *)data)-magic == EDIMAX_PS_HEADER_MAGIC)
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 0/8] Add Belkin F7Dx30x support

2013-11-10 Thread Cody P Schafer
These pathes add (at least) support for the Belkin F7D3302/F7D7302 router
(which I have), and potentially also enable the F7D3301 and F7D4301 routers
(which I don't have and have not tested).


--

Cody P Schafer (8):
  broadcom-diag: add Belkin F7D3302/F7D7302
  linux/brcm47xx : Belkin F7Dx30x board detection
  brcm47xx/image: build Belkin F7D images
  brcm47xx/lzmaloader: add Belkin F7D support
  brcm47xx/mtd-partition: recognize Belkin F7D TRX headers
  brcm47xx: fix netconfig for inverted vlan?ports in nvram
  mtd: recognize belkin trx magic
  brcm47xx/upgrade: add workarounds for Belkin .trx headers

 package/kernel/broadcom-diag/src/diag.c| 31 +--
 package/system/mtd/src/trx.c   | 27 --
 .../linux/brcm47xx/base-files/etc/init.d/netconfig |  6 ++-
 .../brcm47xx/base-files/lib/upgrade/platform.sh| 62 --
 target/linux/brcm47xx/image/Makefile   | 24 +
 .../brcm47xx/image/lzma-loader/src/decompress.c| 25 -
 ...PS-BCM47XX-fix-detection-of-some-boards-2.patch | 37 +
 .../077-MIPS-BCM47XX-mtd-partition-belkin.patch| 42 +++
 8 files changed, 239 insertions(+), 15 deletions(-)
 create mode 100644 
target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch
 create mode 100644 
target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch

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


[OpenWrt-Devel] [PATCH 2/8] linux/brcm47xx : Belkin F7Dx30x board detection

2013-11-10 Thread Cody P Schafer
boardnum is unstable, so allow using NULL to make it unchecked.

A method for differentiating F7D3301 from F7D3302 using nvram is
unknown at this point. Reading the first 32bits of magic from the
linux mtd partition would do the trick, but these 2 are similar
enough that we don't need separate led/button definitions. Not knowing
which one you have is only a usability issue for upgrading the device:
they expect different magic numbers for their trx images.

Signed-off-by: Cody P Schafer de...@codyps.com
---
 ...PS-BCM47XX-fix-detection-of-some-boards-2.patch | 37 ++
 1 file changed, 37 insertions(+)
 create mode 100644 
target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch

diff --git 
a/target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch
 
b/target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch
new file mode 100644
index 000..21eda18
--- /dev/null
+++ 
b/target/linux/brcm47xx/patches-3.10/076-MIPS-BCM47XX-fix-detection-of-some-boards-2.patch
@@ -0,0 +1,37 @@
+Index: linux-3.10.18/arch/mips/bcm47xx/board.c
+===
+--- linux-3.10.18.orig/arch/mips/bcm47xx/board.c
 linux-3.10.18/arch/mips/bcm47xx/board.c
+@@ -180,6 +180,7 @@ struct bcm47xx_board_type_list3 bcm47xx_
+   {{BCM47XX_BOARD_ZTE_H218N, ZTE H218N}, 0x053d, 1234, 0x1305},
+   {{BCM47XX_BOARD_NETGEAR_WNR3500L, Netgear WNR3500L}, 0x04CF, 
3500, 02},
+   {{BCM47XX_BOARD_LINKSYS_WRT54GSV1, Linksys WRT54GS V1}, 0x0101, 
42, 0x10},
++  {{BCM47XX_BOARD_BELKIN_F7D330X, Belkin F7D330X}, 0xa4cf, NULL, 
0x1102 },
+   { {0}, 0},
+ };
+ 
+@@ -270,9 +271,9 @@ static __init const struct bcm47xx_board
+   bcm47xx_nvram_getenv(boardnum, buf2, sizeof(buf2)) = 0 
+   bcm47xx_nvram_getenv(boardrev, buf3, sizeof(buf3)) = 0) {
+   for (e3 = bcm47xx_board_list_board; e3-value1; e3++) {
+-  if (!strcmp(buf1, e3-value1) 
+-  !strcmp(buf2, e3-value2) 
+-  !strcmp(buf3, e3-value3))
++  if ((!e3-value1 || !strcmp(buf1, e3-value1)) 
++  (!e3-value2 || !strcmp(buf2, e3-value2)) 
++  (!e3-value3 || !strcmp(buf3, e3-value3)))
+   return e3-board;
+   }
+   }
+Index: linux-3.10.18/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
+===
+--- linux-3.10.18.orig/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
 linux-3.10.18/arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
+@@ -28,6 +28,7 @@ enum bcm47xx_board {
+   BCM47XX_BOARD_ASUS_WLHDD,
+ 
+   BCM47XX_BOARD_BELKIN_F7D4301,
++  BCM47XX_BOARD_BELKIN_F7D330X,
+ 
+   BCM47XX_BOARD_BUFFALO_WBR2_G54,
+   BCM47XX_BOARD_BUFFALO_WHR2_A54G54,
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/8] broadcom-diag: add Belkin F7D3302/F7D7302

2013-11-10 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 package/kernel/broadcom-diag/src/diag.c | 31 ---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/package/kernel/broadcom-diag/src/diag.c 
b/package/kernel/broadcom-diag/src/diag.c
index e11141e..fccc219 100644
--- a/package/kernel/broadcom-diag/src/diag.c
+++ b/package/kernel/broadcom-diag/src/diag.c
@@ -145,6 +145,7 @@ enum {
 
/* Belkin */
BELKIN_UNKNOWN,
+   BELKIN_F7D330X, /* covers F7D7302,F7D3302,F7D3301, and F7D7301 */
BELKIN_F7D4301,
 
/* Netgear */
@@ -966,6 +967,26 @@ static struct platform_t __initdata platforms[] = {
{ .name = connected,  .gpio = 1  0, .polarity = 
NORMAL },
},
},
+   [BELKIN_F7D330X] = {
+   .name   = Belkin F7D330X,
+   .buttons= {
+   { .name = reset,  .gpio = 1  6 },
+   { .name = wps,.gpio = 1  8 },
+   },
+   .leds   = {
+   /* green */
+   { .name = power,  .gpio = 1  10, .polarity = 
REVERSE },
+   /* orange power */
+   { .name = warn,   .gpio = 1  11, .polarity = 
REVERSE },
+   /* green */
+   { .name = wps,.gpio = 1  12, .polarity = 
REVERSE },
+   /* orange wps */
+   { .name = wlan,   .gpio = 1  13, .polarity = 
REVERSE },
+   { .name = usb0,   .gpio = 1  14, .polarity = 
REVERSE },
+   /* shipped unconnected in the F7D3302 */
+   { .name = usb1,   .gpio = 1  15, .polarity = 
REVERSE },
+   },
+   },
[BELKIN_F7D4301] = {
.name   = Belkin PlayMax F7D4301,
.buttons= {
@@ -973,10 +994,12 @@ static struct platform_t __initdata platforms[] = {
{ .name = wps,.gpio = 1  8 },
},
.leds   = {
-   { .name = power,  .gpio = 1  11, .polarity = 
REVERSE },
+   { .name = power,  .gpio = 1  10, .polarity = 
REVERSE },
+   { .name = warn,   .gpio = 1  11, .polarity = 
REVERSE },
+   { .name = wps,.gpio = 1  12, .polarity = 
REVERSE },
{ .name = wlan,   .gpio = 1  13, .polarity = 
REVERSE },
-   { .name = led0,   .gpio = 1  14, .polarity = 
REVERSE },
-   { .name = led1,   .gpio = 1  15, .polarity = 
REVERSE },
+   { .name = usb0,   .gpio = 1  14, .polarity = 
REVERSE },
+   { .name = usb1,   .gpio = 1  15, .polarity = 
REVERSE },
},
},
/* Netgear */
@@ -1378,6 +1401,8 @@ static struct platform_t __init *platform_detect(void)
return platforms[WLHDD];
case BCM47XX_BOARD_BELKIN_F7D4301:
return platforms[BELKIN_F7D4301];
+   case BCM47XX_BOARD_BELKIN_F7D330X:
+   return platforms[BELKIN_F7D330X];
case BCM47XX_BOARD_BUFFALO_WBR2_G54:
return platforms[WBR2_G54];
case BCM47XX_BOARD_BUFFALO_WHR2_A54G54:
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/8] brcm47xx/image: build Belkin F7DXXXX images

2013-11-10 Thread Cody P Schafer
F7D3302/F7D7302, F7D3301/F7D7301, and F7D4301

Signed-off-by: Cody P Schafer de...@codyps.com
---
 target/linux/brcm47xx/image/Makefile | 24 
 1 file changed, 24 insertions(+)

diff --git a/target/linux/brcm47xx/image/Makefile 
b/target/linux/brcm47xx/image/Makefile
index eca09a8..43403a2 100644
--- a/target/linux/brcm47xx/image/Makefile
+++ b/target/linux/brcm47xx/image/Makefile
@@ -60,6 +60,24 @@ define Image/Build/Edi
$(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx 
$(BIN_DIR)/openwrt-$(2)-$(3).bin
 endef
 
+
+# 1: trx input
+# 2: bin output
+# 3: 4 magic bytes
+define Image/Build/Belkin_
+   echo -ne $(3)  $(2).head
+   dd if=$(1) of=/dev/stdout bs=4 skip=1  $(2).tail
+   cat $(2).head $(2).tail  $(2)
+   rm -f $(2).head $(2).tail
+endef
+
+# $(1) : fs type (squashfs)
+# $(2) : device name
+# $(3) : encoded printf string to use in place of the trx's HDR\0
+define Image/Build/Belkin
+   $(call 
Image/Build/Belkin_,$(BIN_DIR)/$(IMG_PREFIX)-$(1).trx,$(BIN_DIR)/openwrt-$(2)-$(patsubst
 jffs2-%,jffs2,$(1)).bin,$(3))
+endef
+
 define Image/Build/Huawei
dd if=/dev/zero of=$(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin bs=92 count=1
echo -ne 'HDR0\x08\x00\x00\x00'  $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
@@ -118,10 +136,16 @@ define Image/Build/jffs2-64k
$(call Image/Build/CyberTAN,$(1),e3000_v1,61XN,1.0.3,$(patsubst 
jffs2-%,jffs2,$(1)))
$(call Image/Build/CyberTAN,$(1),e3200_v1,3200,1.0.1,$(patsubst 
jffs2-%,jffs2,$(1)))
$(call Image/Build/CyberTAN,$(1),e4200_v1,4200,1.0.5,$(patsubst 
jffs2-%,jffs2,$(1)))
+
$(call Image/Build/Motorola,$(1),wa840g,2,$(patsubst 
jffs2-%,jffs2,$(1)))
$(call Image/Build/Motorola,$(1),we800g,3,$(patsubst 
jffs2-%,jffs2,$(1)))
$(call Image/Build/Edi,$(1),ps1208mfg,$(patsubst jffs2-%,jffs2,$(1)))
$(call Image/Build/dwl3150,$(1),$(patsubst jffs2-%,jffs2,$(1)))
+
+   $(call Image/Build/Belkin,$(1),f7d-qa,'\x78\x56\x34\x12')
+   $(call Image/Build/Belkin,$(1),f7d3301,'\x22\x03\x10\x20')
+   $(call Image/Build/Belkin,$(1),f7d3302,'\x28\x09\x09\x20')
+   $(call Image/Build/Belkin,$(1),f7d4302,'\x06\x10\x10\x20')
 endef
 
 define Image/Build/squashfs
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 7/8] mtd: recognize belkin trx magic

2013-11-10 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 package/system/mtd/src/trx.c | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/package/system/mtd/src/trx.c b/package/system/mtd/src/trx.c
index 65c2440..8d85aaf 100644
--- a/package/system/mtd/src/trx.c
+++ b/package/system/mtd/src/trx.c
@@ -22,6 +22,7 @@
 #include stdio.h
 #include stdlib.h
 #include stddef.h
+#include stdbool.h
 #include unistd.h
 #include fcntl.h
 #include sys/mman.h
@@ -35,6 +36,11 @@
 #include crc32.h
 
 #define TRX_MAGIC   0x30524448  /* HDR0 */
+#define BELKIN_F7D3301_MAGIC   0x20100322 /* a date of some sort */
+#define BELKIN_F7D3302_MAGIC   0x20090928
+#define BELKIN_F7D4302_MAGIC   0x20101006
+#define BELKIN_F7D_QA_MAGIC0x12345678
+
 struct trx_header {
uint32_t magic; /* HDR0 */
uint32_t len;   /* Length of file including header */
@@ -54,6 +60,21 @@ struct trx_header {
 ssize_t pread(int fd, void *buf, size_t count, off_t offset);
 ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
 
+static bool is_trx_magic(uint32_t magic)
+{
+   magic = STORE32_LE(magic);
+   switch (magic) {
+   case TRX_MAGIC:
+   case BELKIN_F7D3301_MAGIC:
+   case BELKIN_F7D3302_MAGIC:
+   case BELKIN_F7D4302_MAGIC:
+   case BELKIN_F7D_QA_MAGIC:
+   return true;
+   default:
+   return false;
+   }
+}
+
 int
 trx_fixup(int fd, const char *name)
 {
@@ -82,7 +103,7 @@ trx_fixup(int fd, const char *name)
}
 
trx = ptr;
-   if (trx-magic != TRX_MAGIC) {
+   if (!is_trx_magic(trx-magic)) {
fprintf(stderr, TRX header not found\n);
goto err;
}
@@ -116,7 +137,7 @@ trx_check(int imagefd, const char *mtd, char *buf, int *len)
return 0;
}
 
-   if (trx-magic != TRX_MAGIC || trx-len  sizeof(struct trx_header)) {
+   if (!is_trx_magic(trx-magic) || trx-len  sizeof(struct trx_header)) {
if (quiet  2) {
fprintf(stderr, Bad trx header\n);
fprintf(stderr, This is not the correct file format; 
refusing to flash.\n
@@ -181,7 +202,7 @@ mtd_fixtrx(const char *mtd, size_t offset)
}
 
trx = (struct trx_header *) (buf + offset);
-   if (trx-magic != STORE32_LE(0x30524448)) {
+   if (!is_trx_magic(trx-magic)) {
fprintf(stderr, No trx magic found\n);
exit(1);
}
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 8/8] brcm47xx/upgrade: add workarounds for Belkin .trx headers

2013-11-10 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 .../brcm47xx/base-files/lib/upgrade/platform.sh| 62 --
 1 file changed, 57 insertions(+), 5 deletions(-)

diff --git a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh 
b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
index 9921cf5..5aad6c0 100644
--- a/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/brcm47xx/base-files/lib/upgrade/platform.sh
@@ -1,14 +1,66 @@
 PART_NAME=linux
 
+get_fw_mtd () {
+   grep \$PART_NAME\  /proc/mtd | cut -d':' -f1
+}
+
+get_current_magic_long () {
+   dd bs=4 count=1 2/dev/null  /dev/$(get_fw_mtd) | hexdump -v -n 4 -e 
'1/1 %02x'
+}
+
 platform_check_image() {
[ $ARGC -gt 1 ]  return 1
 
-   case $(get_magic_word $1) in
-   # .trx files
-   4844) return 0;;
-   *)
-   echo Invalid image type. Please use only .trx files
+   magic=$(get_magic_long $1)
+   # For Belkin support, check on magic in current image.
+   cmagic=$(get_current_magic_long)
+
+   case $cmagic in
+   48445230) # HDR0
+   case $magic in
+   # .trx files
+   48445230) return 0;;
+   *)
+   echo Invalid image type. Please use only .trx 
files
+   return 1
+   ;;
+   esac
+   ;;
+   22031020) # F7D3301
+   if [ $magic = 22031020 ] || [ $magic = 78563412 ]; then
+   return 0
+   else
+   echo Invalid image for this router.
+   echo Either f7d3301 or f7d-qa .bin files required.
+   return 1
+   fi
+   ;;
+   28090920) # F7D3302
+   if [ $magic = 28090920 ] || [ $magic = 78563412 ]; then
+   return 0
+   else
+   echo Invalid image for this router.
+   echo Either f7d3302 or f7d-qa .bin files required.
+   return 1
+   fi
+   ;;
+   06101020) # F7D4302
+   if [ $magic = 06101020 ] || [ $magic = 78563412 ]; then
+   return 0
+   else
+   echo Invalid image for this router.
+   echo Either f7d4302 or f7d-qa .bin files required.
+   return 1
+   fi
+   ;;
+   78563412) # Belkin F7Dx30x QA Firmware
+   if [ $magic = 78563412 ] ; then
+   return 0
+   else
+   echo Potentially invalid image for this router.
+   echo Please use a f7d-qa .bin file (or force)
return 1
+   fi
;;
esac
 }
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 5/8] brcm47xx/mtd-partition: recognize Belkin F7DXXXX TRX headers

2013-11-10 Thread Cody P Schafer
F7D3301/F7D7301, F7D3302/F7D7302, and F7D4301 replace the HDR0 with a
custom byte sequence (which appears to be a date). Also, they all
appear to support a single QA byte sequence. Add all of these to the
partition detection.

Signed-off-by: Cody P Schafer de...@codyps.com
---
 .../077-MIPS-BCM47XX-mtd-partition-belkin.patch| 42 ++
 1 file changed, 42 insertions(+)
 create mode 100644 
target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch

diff --git 
a/target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch
 
b/target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch
new file mode 100644
index 000..18c3117
--- /dev/null
+++ 
b/target/linux/brcm47xx/patches-3.10/077-MIPS-BCM47XX-mtd-partition-belkin.patch
@@ -0,0 +1,42 @@
+Index: linux-3.10.17/drivers/mtd/bcm47xxpart.c
+===
+--- linux-3.10.17.orig/drivers/mtd/bcm47xxpart.c
 linux-3.10.17/drivers/mtd/bcm47xxpart.c
+@@ -33,7 +33,11 @@
+ #define POT_MAGIC20x504f  /* OP */
+ #define ML_MAGIC1 0x39685a42
+ #define ML_MAGIC2 0x26594131
+-#define TRX_MAGIC 0x30524448
++#define TRX_MAGIC 0x30524448  /* HDR0 */
++#define BELKIN_F7D3301_MAGIC  0x20100322
++#define BELKIN_F7D3302_MAGIC  0x20090928
++#define BELKIN_F7D4302_MAGIC  0x20101006
++#define BELKIN_F7D_QA_MAGIC   0x12345678
+ #define SQSH_MAGIC0x71736873  /* shsq */
+ 
+ struct trx_header {
+@@ -45,6 +48,15 @@ struct trx_header {
+   uint32_t offset[3];
+ } __packed;
+ 
++static bool is_trx_magic(uint32_t magic)
++{
++  return (magic == TRX_MAGIC) ||
++   (magic == BELKIN_F7D_QA_MAGIC) ||
++  (magic == BELKIN_F7D3301_MAGIC) ||
++  (magic == BELKIN_F7D3302_MAGIC) ||
++  (magic == BELKIN_F7D4302_MAGIC);
++}
++
+ static void bcm47xxpart_add_part(struct mtd_partition *part, char *name,
+u64 offset, uint32_t mask_flags)
+ {
+@@ -139,7 +150,7 @@ static int bcm47xxpart_parse(struct mtd_
+   }
+ 
+   /* TRX */
+-  if (buf[0x000 / 4] == TRX_MAGIC) {
++  if (is_trx_magic(buf[0x000 / 4])) {
+   trx = (struct trx_header *)buf;
+ 
+   trx_part = curr_part;
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] quilt: avoid copying backup files.

2013-11-10 Thread Cody P Schafer
Signed-off-by: Cody P Schafer de...@codyps.com
---
 include/quilt.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/quilt.mk b/include/quilt.mk
index 925b7a7..e256489 100644
--- a/include/quilt.mk
+++ b/include/quilt.mk
@@ -22,7 +22,7 @@ endif
 QUILT_CMD:=quilt --quiltrc=-
 
 define filter_series
-sed -e s,\\\#.*,, $(1) | grep -E \[a-zA-Z0-9\]
+sed -e s,\\\#.*,, $(1) | grep -E \[a-zA-Z0-9\] | grep -v '^.*~'
 endef
 
 define PatchDir/Quilt
@@ -31,7 +31,7 @@ define PatchDir/Quilt
mkdir -p $(1)/patches/$(3); \
cp $(2)/series $(1)/patches/$(3); \
fi
-   @for patch in ( (cd $(2)  if [ -f series ]; then $(call 
filter_series,series); else ls | sort; fi; ) 2/dev/null ); do ( \
+   @for patch in ( (cd $(2)  if [ -f series ]; then $(call 
filter_series,series); else ls | sort | grep -v '^.*~'; fi; ) 2/dev/null 
); do ( \
cp $(2)/patch $(1)/patches/$(3); \
echo $(3)patch  $(1)/patches/series; \
); done
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 6/8] brcm47xx: fix netconfig for inverted vlan?ports in nvram

2013-11-10 Thread Cody P Schafer
This was observed on the Belkin Share F7D7302.

Signed-off-by: Cody P Schafer de...@codyps.com
---
 target/linux/brcm47xx/base-files/etc/init.d/netconfig | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/target/linux/brcm47xx/base-files/etc/init.d/netconfig 
b/target/linux/brcm47xx/base-files/etc/init.d/netconfig
index 1bf9487..d0ce9d3 100755
--- a/target/linux/brcm47xx/base-files/etc/init.d/netconfig
+++ b/target/linux/brcm47xx/base-files/etc/init.d/netconfig
@@ -93,12 +93,14 @@ start() {
 
END {
if (((nvram[vlan0ports] ~ /^0 1 2 3 8/ )  
(nvram[vlan1ports] ~ /^4 8/  (cpuport == 8))) || \
-   ((nvram[vlan1ports] ~ /^0 1 2 3 8/ )  
(nvram[vlan2ports] ~ /^4 8/  (cpuport == 8 {
+   ((nvram[vlan1ports] ~ /^0 1 2 3 8/ )  
(nvram[vlan2ports] ~ /^4 8/  (cpuport == 8))) || \
+   ((nvram[vlan2ports] ~ /^0 1 2 3 8/ )  
(nvram[vlan1ports] ~ /^4 8/  (cpuport == 8 {
c[vlan1ports] = 0 1 2 3 8t
c[vlan2ports] = 4 8t
}
if (((nvram[vlan0ports] ~ /^0 1 2 3 5/ )  
(nvram[vlan1ports] ~ /^4 5/  (cpuport == 5))) || \
-   ((nvram[vlan1ports] ~ /^0 1 2 3 5/ )  
(nvram[vlan2ports] ~ /^4 5/  (cpuport == 5 {
+   ((nvram[vlan1ports] ~ /^0 1 2 3 5/ )  
(nvram[vlan2ports] ~ /^4 5/  (cpuport == 5))) || \
+   ((nvram[vlan2ports] ~ /^0 1 2 3 5/ )  
(nvram[vlan1ports] ~ /^4 5/  (cpuport == 5 {
c[vlan1ports] = 0 1 2 3 5t
c[vlan2ports] = 4 5t
}
-- 
1.8.4.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel