[OpenWrt-Devel] [PATCH v1 0/7] Add custom TRX header option

2015-02-09 Thread Will Sheppard
Patchset to essentially add custom TRX header to all firmware produced.

This is most useful for the Belkin routers from my experience. I'm not
how other trx based firmwares modify the header for their own purposes.

This is applied across the board so that the kernel, trx tools and mtd 
tools are all compiled with the specified header.

I have modified the kernel specifically for the brcm47xx based boards to
ensure the mtd parser looks for the correct magic. NOTE: This function will, 
for other boards, fail.

Will Sheppard (7):
  config: Add option to specify custom TRX header
  mtd: Add custom trx magic option to mtd tool
  mtd: Fix: Use TRX_MAGIC define not hard-coded number
  trx: Add custom TRX option to trx firmware tool
  mtd: Add debug showing header magic in use
  kernel: bcm47xx: Add custom TRX header option to kernel
  mtd: Fix makefile to work with quilt as per wiki

 config/Config-images.in| 15 ++
 package/system/mtd/Makefile|  9 +-
 package/system/mtd/src/trx.c   | 10 +--
 .../patches-3.14/162-Belkin_custom_trx_magic.patch | 35 ++
 tools/firmware-utils/Makefile  |  4 +++
 tools/firmware-utils/src/trx.c | 10 ++-
 6 files changed, 79 insertions(+), 4 deletions(-)
 create mode 100644 
target/linux/brcm47xx/patches-3.14/162-Belkin_custom_trx_magic.patch

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


[OpenWrt-Devel] [PATCH v1 7/7] mtd: Fix makefile to work with quilt as per wiki

2015-02-09 Thread Will Sheppard
Signed-off-by: Will Sheppard wshepp...@embedded-bits.co.uk
---
 package/system/mtd/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/system/mtd/Makefile b/package/system/mtd/Makefile
index 91c4fac..5da27d1 100644
--- a/package/system/mtd/Makefile
+++ b/package/system/mtd/Makefile
@@ -34,6 +34,7 @@ endef
 define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
+   $(call Build/Prepare/Default)
 endef
 
 target=$(firstword $(subst -, ,$(BOARD)))
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v1 4/7] trx: Add custom TRX option to trx firmware tool

2015-02-09 Thread Will Sheppard
Signed-off-by: Will Sheppard wshepp...@embedded-bits.co.uk
---
 tools/firmware-utils/Makefile  |  4 
 tools/firmware-utils/src/trx.c | 10 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index 83c51d7..9c9a6a5 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -18,7 +18,11 @@ endef
 define Host/Compile
mkdir -p $(HOST_BUILD_DIR)/bin
$(call cc,addpattern)
+ifeq ($(CONFIG_KERNEL_TRX_MAGIC_OVERRIDE),y)
+   $(call cc,trx,-DCONFIG_KERNEL_TRX_MAGIC_OVERRIDE 
-DCONFIG_KERNEL_TRX_MAGIC=$(CONFIG_KERNEL_TRX_MAGIC) )
+else
$(call cc,trx)
+endif
$(call cc,motorola-bin)
$(call cc,dgfirmware)
$(call cc,mksenaofw md5)
diff --git a/tools/firmware-utils/src/trx.c b/tools/firmware-utils/src/trx.c
index aa1f5be..848d67b 100644
--- a/tools/firmware-utils/src/trx.c
+++ b/tools/firmware-utils/src/trx.c
@@ -66,7 +66,15 @@ uint32_t crc32buf(char *buf, size_t len);
 /**/
 /* from trxhdr.h */
 
-#define TRX_MAGIC  0x30524448  /* HDR0 */
+
+#ifndef CONFIG_KERNEL_TRX_MAGIC_OVERRIDE
+#warning  Using default TRX MAGIC
+#define TRX_MAGIC   0x30524448  /* HDR0 */
+#else
+#warning TRX firmware tool is using overridden TRX_MAGIC
+#define TRX_MAGIC (CONFIG_KERNEL_TRX_MAGIC)
+#endif
+
 #define TRX_MAX_LEN0x72
 #define TRX_NO_HEADER  1   /* Do not write TRX header */
 
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v1 1/7] config: Add option to specify custom TRX header

2015-02-09 Thread Will Sheppard
Signed-off-by: Will Sheppard wshepp...@embedded-bits.co.uk
---
 config/Config-images.in | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/config/Config-images.in b/config/Config-images.in
index 5c2e79e..e4e4804 100644
--- a/config/Config-images.in
+++ b/config/Config-images.in
@@ -6,6 +6,21 @@
 
 menu Target Images
 
+
+   config KERNEL_TRX_MAGIC_OVERRIDE
+   bool Override TRX magic number
+   default n
+   help
+   Select to override default TRX_MAGIC value of HDR0
+
+   config KERNEL_TRX_MAGIC
+   hex TRX_MAGIC
+   default 0x12345678
+   depends on KERNEL_TRX_MAGIC_OVERRIDE
+   help
+   Enter magic
+
+
menuconfig TARGET_ROOTFS_INITRAMFS
bool ramdisk
default y if USES_INITRAMFS
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v1 5/7] mtd: Add debug showing header magic in use

2015-02-09 Thread Will Sheppard
Signed-off-by: Will Sheppard wshepp...@embedded-bits.co.uk
---
 package/system/mtd/src/trx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/system/mtd/src/trx.c b/package/system/mtd/src/trx.c
index 1722cf2..776cb82 100644
--- a/package/system/mtd/src/trx.c
+++ b/package/system/mtd/src/trx.c
@@ -160,7 +160,7 @@ mtd_fixtrx(const char *mtd, size_t offset)
size_t block_offset;
 
if (quiet  2)
-   fprintf(stderr, Trying to fix trx header in %s at 0x%x...\n, 
mtd, offset);
+   fprintf(stderr, Trying to fix trx header in %s at 0x%x... 
Magic 0x%08X\n, mtd, offset, TRX_MAGIC);
 
fd = mtd_check_open(mtd);
if(fd  0) {
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v1 6/7] kernel: bcm47xx: Add custom TRX header option to kernel

2015-02-09 Thread Will Sheppard
Signed-off-by: Will Sheppard wshepp...@embedded-bits.co.uk
---
 .../patches-3.14/162-Belkin_custom_trx_magic.patch | 35 ++
 1 file changed, 35 insertions(+)
 create mode 100644 
target/linux/brcm47xx/patches-3.14/162-Belkin_custom_trx_magic.patch

diff --git 
a/target/linux/brcm47xx/patches-3.14/162-Belkin_custom_trx_magic.patch 
b/target/linux/brcm47xx/patches-3.14/162-Belkin_custom_trx_magic.patch
new file mode 100644
index 000..eea7716
--- /dev/null
+++ b/target/linux/brcm47xx/patches-3.14/162-Belkin_custom_trx_magic.patch
@@ -0,0 +1,35 @@
+--- a/drivers/mtd/bcm47xxpart.c
 b/drivers/mtd/bcm47xxpart.c
+@@ -42,7 +42,14 @@
+ #define T_METER_MAGIC 0x4D54  /* MT */
+ #define ML_MAGIC1 0x39685a42
+ #define ML_MAGIC2 0x26594131
++
++
++#ifdef CONFIG_TRX_MAGIC_OVERRIDE
++#define TRX_MAGIC (CONFIG_TRX_MAGIC)
++#else
+ #define TRX_MAGIC 0x30524448
++#endif
++
+ #define SHSQ_MAGIC0x71736873  /* shsq (weird ZTE 
H218N endianness) */
+ #define UBI_EC_MAGIC  0x23494255  /* UBI# */
+ 
+--- a/drivers/mtd/Kconfig
 b/drivers/mtd/Kconfig
+@@ -14,6 +14,15 @@ if MTD
+ 
+ menu OpenWrt specific MTD options
+ 
++config TRX_MAGIC_OVERRIDE
++  bool Override trx magic
++  default n
++
++config TRX_MAGIC
++  hex Enter the magic...
++  depends on TRX_MAGIC_OVERRIDE
++  default 0x12345678
++
+ config MTD_ROOTFS_ROOT_DEV
+   bool Automatically set 'rootfs' partition to be root filesystem
+   default y
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v1 3/7] mtd: Fix: Use TRX_MAGIC define not hard-coded number

2015-02-09 Thread Will Sheppard
Signed-off-by: Will Sheppard wshepp...@embedded-bits.co.uk
---
 package/system/mtd/src/trx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/system/mtd/src/trx.c b/package/system/mtd/src/trx.c
index 5d0f364..1722cf2 100644
--- a/package/system/mtd/src/trx.c
+++ b/package/system/mtd/src/trx.c
@@ -189,7 +189,7 @@ mtd_fixtrx(const char *mtd, size_t offset)
}
 
trx = (struct trx_header *) (buf + offset);
-   if (trx-magic != STORE32_LE(0x30524448)) {
+   if (trx-magic != STORE32_LE(TRX_MAGIC)) {
fprintf(stderr, No trx magic found\n);
exit(1);
}
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v1 2/7] mtd: Add custom trx magic option to mtd tool

2015-02-09 Thread Will Sheppard
Signed-off-by: Will Sheppard wshepp...@embedded-bits.co.uk
---
 package/system/mtd/Makefile  | 8 +++-
 package/system/mtd/src/trx.c | 6 ++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/package/system/mtd/Makefile b/package/system/mtd/Makefile
index 8d7bb44..91c4fac 100644
--- a/package/system/mtd/Makefile
+++ b/package/system/mtd/Makefile
@@ -39,7 +39,13 @@ endef
 target=$(firstword $(subst -, ,$(BOARD)))
 
 MAKE_FLAGS += TARGET=$(target)
-TARGET_CFLAGS := $(TARGET_CFLAGS) -Dtarget_$(target)=1 -Wall
+
+
+TARGET_CFLAGS := $(TARGET_CFLAGS) -Dtarget_$(target)=1 -Wall 
+
+ifdef CONFIG_KERNEL_TRX_MAGIC_OVERRIDE
+  TARGET_CFLAGS += -DCONFIG_KERNEL_TRX_MAGIC_OVERRIDE 
-DCONFIG_KERNEL_TRX_MAGIC=$(CONFIG_KERNEL_TRX_MAGIC)
+endif
 
 ifdef CONFIG_MTD_REDBOOT_PARTS
   MAKE_FLAGS += FIS_SUPPORT=1
diff --git a/package/system/mtd/src/trx.c b/package/system/mtd/src/trx.c
index 089d1ac..5d0f364 100644
--- a/package/system/mtd/src/trx.c
+++ b/package/system/mtd/src/trx.c
@@ -34,7 +34,13 @@
 #include mtd.h
 #include crc32.h
 
+#ifndef CONFIG_KERNEL_TRX_MAGIC_OVERRIDE
+#warning  Using default TRX MAGIC
 #define TRX_MAGIC   0x30524448  /* HDR0 */
+#else
+#warning mtd is using overridden TRX_MAGIC
+#define TRX_MAGIC (CONFIG_KERNEL_TRX_MAGIC)
+#endif
 struct trx_header {
uint32_t magic; /* HDR0 */
uint32_t len;   /* Length of file including header */
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v1 0/7] Add custom TRX header option

2015-02-09 Thread Will Sheppard
Hi - thanks for review; reply inline

On 9 February 2015 at 20:52, Florian Fainelli flor...@openwrt.org wrote:

 On 09/02/15 08:29, Will Sheppard wrote:
  Patchset to essentially add custom TRX header to all firmware produced.
 
  This is most useful for the Belkin routers from my experience. I'm not
  how other trx based firmwares modify the header for their own purposes.
 
  This is applied across the board so that the kernel, trx tools and mtd
  tools are all compiled with the specified header.
 
  I have modified the kernel specifically for the brcm47xx based boards to
  ensure the mtd parser looks for the correct magic. NOTE: This function
 will,
  for other boards, fail.

 I don't think this is desirable at all to have, for many reasons:

 - how can an use figure out the proper TRX_MAGIC value he/she should use?


There's simply no hard-and-fast rule for this - just looking at a factory
binary might not help - it worked for me.


 - this is extremely error prone and can result, as you mention in
 failing to work with existing devices with well-defined TRX headers


Error prone inasmuch as it could be the wrong value and thus brick the
router? ( I guess I'm always thinking from a have a serial port
perspective )


 - how can we get some level of reproducibility for both the kernel and
 firmware tools builds?

 I would really encourage you to extend the existing code to take an
 arbitrary list of TRX magics, such that you can have maybe a single file
 to modify and both mtd and the kernel can use that list of magic
 values accordingly.


I agree. As the mtd utility looks for this value though, it would have to
know what router it was being used on - i'm not sure that is available as a
value in user-space is it?


 Out of curiosity, how many different TRX magic values should we have to
 support with or without your patches?


I know that Belkin seem to use different magics i.e. not HDR0, I'm not sure
about other manufacturers. But presumably these values could be added as
they become known.


 
  Will Sheppard (7):
config: Add option to specify custom TRX header
mtd: Add custom trx magic option to mtd tool
mtd: Fix: Use TRX_MAGIC define not hard-coded number
trx: Add custom TRX option to trx firmware tool
mtd: Add debug showing header magic in use
kernel: bcm47xx: Add custom TRX header option to kernel
mtd: Fix makefile to work with quilt as per wiki
 
   config/Config-images.in| 15 ++
   package/system/mtd/Makefile|  9 +-
   package/system/mtd/src/trx.c   | 10 +--
   .../patches-3.14/162-Belkin_custom_trx_magic.patch | 35
 ++
   tools/firmware-utils/Makefile  |  4 +++
   tools/firmware-utils/src/trx.c | 10 ++-
   6 files changed, 79 insertions(+), 4 deletions(-)
   create mode 100644
 target/linux/brcm47xx/patches-3.14/162-Belkin_custom_trx_magic.patch
 


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


Re: [OpenWrt-Devel] Ethernet performance for transfers between VLANs (bcm47xx)

2014-03-06 Thread Will Sheppard
Hi,

Did you manage to get any further with this?

I have a seeming limit of 50Mbs with VLAN routed traffic on Download -
ksoftirqd uses a lot of CPU.

(Where the stock firmware was happy at 100Mbs and more. - router is F6D6230)

Interestingly, Upload at 10Mbs, whilst less, shows no ksoftirqd at all.

I wonder, is there reason that the downoad/upload might have differently
demanding routing requirements in software?

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