Re: [OpenWrt-Devel] Increase default squashfs blocksize for devices with small flash?

2014-09-10 Thread Mathias Adam
Hi again Felix,

Am Di, 9.09.2014, 22:20 schrieb Mathias Adam:
> Hi Felix,
>
> Am Di, 9.09.2014, 21:32 schrieb Felix Fietkau:
>> On 2014-09-09 21:21, Mathias Adam wrote:
>>> Hi,
>>>
>>> just noticed that the pre-built image for Huawei E970 (brcm47xx-legacy,
>>> openwrt-e970-squashfs-gz.bin) is too large for its 4MiB flash.
>>> This is true for both BB-rc3 and trunk snapshots.
>>>
>>> Apparently Imagebuilder creates squashfs with 64kiB blocksize. However
>>> I
>>> usually used 256kiB or even 1MiB on this device, which in my experience
>>> saves some 100kiB.
>>>
>>> Up to now I mostly used trunk builds; now I was able to create working
>>> images with ImageBuilder as well after manually changing .config.
>>>
>>> What is the recommended way to deal with this?
>>> E.g. is it possible to set squashfs blocksize in a profile?
>> It's not possible to set it in a profile. You can change it via make
>> menuconfig, but keep in mind that increasing the block size will
>> significantly increase RAM usage. That's the main reason why
>> brcm47xx-legacy uses a smaller block size than other targets.
>
> I see. I assumed squashfs needs some more RAM with larger blocks size, but
> didn't actually measure it so far. Though I haven't experienced short RAM
> issues so far on E970, at least it has 32M. Flash size was always my
> biggest concern on that device. (I stopped using a WRT54 some time before
> because of constant hassle with its only 16M RAM...)
>
> So maybe it would make sense to move it to generic?
> However that would include more variants in b43 -- or is it possible to
> remove unnecessary b43 PHY variants in a profile?

ImageBuilder seems not to have make target menuconfig... is there another
official way to configure it on ImageBuilder?

Regarding subtarget: is there a rule on specific device properties whether
a device fits generic, or legacy?


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


Re: [OpenWrt-Devel] Increase default squashfs blocksize for devices with small flash?

2014-09-09 Thread Mathias Adam
Hi Felix,

Am Di, 9.09.2014, 21:32 schrieb Felix Fietkau:
> On 2014-09-09 21:21, Mathias Adam wrote:
>> Hi,
>>
>> just noticed that the pre-built image for Huawei E970 (brcm47xx-legacy,
>> openwrt-e970-squashfs-gz.bin) is too large for its 4MiB flash.
>> This is true for both BB-rc3 and trunk snapshots.
>>
>> Apparently Imagebuilder creates squashfs with 64kiB blocksize. However I
>> usually used 256kiB or even 1MiB on this device, which in my experience
>> saves some 100kiB.
>>
>> Up to now I mostly used trunk builds; now I was able to create working
>> images with ImageBuilder as well after manually changing .config.
>>
>> What is the recommended way to deal with this?
>> E.g. is it possible to set squashfs blocksize in a profile?
> It's not possible to set it in a profile. You can change it via make
> menuconfig, but keep in mind that increasing the block size will
> significantly increase RAM usage. That's the main reason why
> brcm47xx-legacy uses a smaller block size than other targets.

I see. I assumed squashfs needs some more RAM with larger blocks size, but
didn't actually measure it so far. Though I haven't experienced short RAM
issues so far on E970, at least it has 32M. Flash size was always my
biggest concern on that device. (I stopped using a WRT54 some time before
because of constant hassle with its only 16M RAM...)

So maybe it would make sense to move it to generic?
However that would include more variants in b43 -- or is it possible to
remove unnecessary b43 PHY variants in a profile?


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


[OpenWrt-Devel] Increase default squashfs blocksize for devices with small flash?

2014-09-09 Thread Mathias Adam
Hi,

just noticed that the pre-built image for Huawei E970 (brcm47xx-legacy,
openwrt-e970-squashfs-gz.bin) is too large for its 4MiB flash.
This is true for both BB-rc3 and trunk snapshots.

Apparently Imagebuilder creates squashfs with 64kiB blocksize. However I
usually used 256kiB or even 1MiB on this device, which in my experience
saves some 100kiB.

Up to now I mostly used trunk builds; now I was able to create working
images with ImageBuilder as well after manually changing .config.

What is the recommended way to deal with this?
E.g. is it possible to set squashfs blocksize in a profile?


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


[OpenWrt-Devel] [PATCH] mtd: Fix trx check after partition rename ("linux" to "firmware")

2014-09-02 Thread Mathias Adam
On brcm47xx (Huawei E970), I noticed that sysupgrade now tries to flash trx 
images which don't fit into the flash, resulting in non-booting system.

I found that mtd does trx size checking only when flashing to a partition 
called "linux". This patch changes this to be "firmware".

This matches the following patch which changed partition name in bcm47xxpart.c 
driver to "firmware":

commit 86b4d5ef68ca77ff6724ebb9bddd6b93239c87fc
Author: hauke 
Date:   Sun Dec 1 16:32:32 2013 +

brcm47xx: use "firmware" partition name
...
Signed-off-by: Rafał Miłecki 

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38973 
3c298f89-4303-0410-b956-a3cf2f4a3e73


Signed-off-by: Mathias Adam 
---
 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 65c2440..86d62fc 100644
--- a/package/system/mtd/src/trx.c
+++ b/package/system/mtd/src/trx.c
@@ -107,7 +107,7 @@ trx_check(int imagefd, const char *mtd, char *buf, int *len)
const struct trx_header *trx = (const struct trx_header *) buf;
int fd;
 
-   if (strcmp(mtd, "linux") != 0)
+   if (strcmp(mtd, "firmware") != 0)
return 1;
 
*len = read(imagefd, buf, 32);
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] brcm47xx: image: build alternative TRX using less optimized LZMA

2014-08-26 Thread Mathias Adam
Hi Stephen,

do you still have the old working trx, or better, remember how you created
it?

That might help debugging the "Starting program" hang...

Mathias


Am Di, 26.08.2014, 04:34 schrieb Stephen Parry:
> No sorry - I did not explain carefully enough:
> 1. About 9 months ago I built a trx using trunk that flashed and worked
> OK.
> 2. Two weeks ago I built a new image. This loaded and tested fine as ELF
> via tftp boot so I flashed the trx using MTD command. the resulting image
> hung after "starting program at 8001000" just as you described.
> 3. I incorrectly thought the problem was that I had flashed incorrectly so
> tried CFE flash command instead.
> 4. I got parameters of flash command wrong and overwrote CFE.
> 5. I saw your patch and kicked myself for not having seen it sooner.
>
> I was supporting (seconding) your patch by trying to explain that had I
> seen it 15 minutes earlier it would have saved me from a dead router.
>
> Rafa? Mi?ecki  wrote:
>>First of all, I really don't think this patch itself may cause any
>> problem with MTD/partitions/bricking.
>
>> I don't understand much of your report. > It was working previously? But
>> then you say it was hanging? Then you > mention some MTD command
>> failing...? What did you do in CFE? Which firmware did you try to
>> install at all? What was the log of firmware booting & destroying your
>> CFE?
>> This "report" says nothing
>> :(___
> 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] brcm47xx: image: build alternative TRX using less optimized LZMA

2014-08-25 Thread Mathias Adam
Hi Rafal,

just gave it a try on a Huawei E970: it didn't work, unfortunately (see
below).

Originally, this device ran into a reboot loop after "Starting program at
0x80001000" with lzma-loader. The device has a hardware watchdog set to
about 1 or 2 seconds, so I thought it may as well be the hang you're
reporting.

When adding support for E970 I had introduced the -gz image variant with
gzipped kernel and no lzma-loader. Still it would be nicer to get rid of
the extra image variant, additional to the fact that .gz is considerably
larger than .lzma image.


This is what I get:

CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date:   2 13 14:50:54 CST 2008
(w114501@localhost.localdomain)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.
[...]
Loader:raw Filesys:raw Dev:flash0.os File: Options:(null)
Loading: . 0 bytes read
Failed.
Could not load flash0.os:: Error
CFE clear reboot_number: reboot_flag0 = 0x12345678, reboot_flag1 =
0x0,reboot_flag2 = 0x,reboot_number = 0x0
web info: Waiting for connection on socket 0.
CFE>

Loading manually gives some more detail but still doesn't work:

CFE> load -raw flash0.os:
Loader:raw Filesys:raw Dev:flash0.os File: Options:(null)
Loading: Failed.
Could not load flash0.os:: Invalid boot block on disk
*** command status = -31


After reflashing with the -gz image it boots as expected:

Loader:raw Filesys:raw Dev:flash0.os File: Options:(null)
Loading: .. 3356676 bytes read
Entry at 0x80001000
Closing network.
Starting program at 0x80001000
[0.00] Linux version 3.10.12 (fnord@tschunk) (gcc version 4.6.4
(OpenWrt/Linaro GCC 4.6-2013.05 r38170) ) #1 Wed Sep 25 09:54:13 UTC 2013
[0.00] CPU revision is: 00029029 (Broadcom BMIPS3300)


I've read that different versions of lzma behave differently, and using
stdin is different than using file input.

I tried using stdin:
$ cat ... | lzma e -si -so -d16 > ...
--> surprisingly the .lzma is different, but doesn't work as well

I also tried the lzma parameters and dd hack mentioned here, but still no
luck:




To make it short: do you have an idea worth trying? can I check whether
this CFE supports lzma at all? unfortunately the sources I have from
Huawei don't contain CFE...
Thanks!


Mathias



Am Mo, 18.08.2014, 21:44 schrieb Rafał Miłecki:
> There is a group of devices that lzma-loader doesn't work with. They
> simply hang at "Starting program at 0x80001000" which is really hard to
> debug and we didn't find any solution for this for years.
>
> Broadcom doesn't use lzma-loader on these devices anyway. They decided
> to drop lzma-loader and use less optimal LZMA compression that can be
> handled by CFE itself (it doesn't use dictionary).
>
> So support these devices we will need kernel compressed with different
> parameters and trx without a loader.
>
> Signed-off-by: Rafał Miłecki 
> ---
>  target/linux/brcm47xx/image/Makefile | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/target/linux/brcm47xx/image/Makefile
> b/target/linux/brcm47xx/image/Makefile
> index 584bb6c..d19a13e 100644
> --- a/target/linux/brcm47xx/image/Makefile
> +++ b/target/linux/brcm47xx/image/Makefile
> @@ -12,7 +12,12 @@ define Build/Clean
>  endef
>
>  define Image/Prepare
> + # Optimized LZMA compression (with dictionary), handled by lzma-loader.
>   cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1
> -lp2 -pb2 > $(KDIR)/vmlinux.lzma
> +
> + # Less optimal LZMA compression (no dictionary), handled by CFE.
> + $(STAGING_DIR_HOST)/bin/lzma e -so -d16 $(KDIR)/vmlinux >
> $(KDIR)/vmlinux-nodictionary.lzma
> +
>   gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
>  ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
>   cat $(KDIR)/vmlinux-initramfs | $(STAGING_DIR_HOST)/bin/lzma e -si -so
> -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux-initramfs.lzma
> @@ -230,6 +235,9 @@ define Image/Build
>   $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
>   -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
>   $(call trxalign/$(1),$(1))
> + $(STAGING_DIR_HOST)/bin/trx -o
> $(BIN_DIR)/$(IMG_PREFIX)-$(1)-noloader-nodictionary.trx \
> + -f $(KDIR)/vmlinux-nodictionary.lzma \
> + $(call trxalign/$(1),$(1))
>   $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
>   -f $(KDIR)/vmlinux.gz \
>   $(call trxalign/$(1),$(1))
> --
> 1.8.4.5
> ___
> 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


[OpenWrt-Devel] [PATCH] Add generic GPIO watchdog driver gpio_wdt (replaces mtx-1_wdt)

2013-01-16 Thread Mathias Adam
The functionality of mtx-1_wdt could be used on other platforms too.
Huawei E970 being one example (I'll shortly post a patch for it).

drivers/watchdog/mtx-1_wdt.c can be removed after applying the patch.

Signed-off-by: Mathias Adam 

---

Can someone please try it on actual hardware? I've verified that it
builds, but cannot test as I don't have a MTX-1 device available.
Works on my E970 though.



diff --git a/target/linux/au1000/au1500/config-default 
b/target/linux/au1000/au1500/config-default
index 0289d96..98677e6 100644
--- a/target/linux/au1000/au1500/config-default
+++ b/target/linux/au1000/au1500/config-default
@@ -2,4 +2,4 @@ CONFIG_DMA_NONCOHERENT=y
 # CONFIG_MIPS_DB1550 is not set
 CONFIG_MIPS_MTX1=y
 CONFIG_NEED_DMA_MAP_STATE=y
-CONFIG_WDT_MTX1=y
+CONFIG_GPIO_WDT=y
diff --git a/target/linux/generic/patches-3.3/990-gpio_wdt.patch 
b/target/linux/generic/patches-3.3/990-gpio_wdt.patch
new file mode 100644
index 000..b2c73df
--- /dev/null
+++ b/target/linux/generic/patches-3.3/990-gpio_wdt.patch
@@ -0,0 +1,421 @@
+--- a/arch/mips/configs/mtx1_defconfig
 b/arch/mips/configs/mtx1_defconfig
+@@ -499,7 +499,7 @@ CONFIG_SENSORS_W83627HF=m
+ CONFIG_SENSORS_W83627EHF=m
+ CONFIG_WATCHDOG=y
+ CONFIG_WATCHDOG_NOWAYOUT=y
+-CONFIG_WDT_MTX1=y
++CONFIG_GPIO_WDT=y
+ # CONFIG_VGA_ARB is not set
+ # CONFIG_LCD_CLASS_DEVICE is not set
+ CONFIG_BACKLIGHT_CLASS_DEVICE=y
+--- a/drivers/watchdog/Kconfig
 b/drivers/watchdog/Kconfig
+@@ -958,12 +958,14 @@ config JZ4740_WDT
+   help
+ Hardware driver for the built-in watchdog timer on Ingenic jz4740 
SoCs.
+ 
+-config WDT_MTX1
+-  tristate "MTX-1 Hardware Watchdog"
+-  depends on MIPS_MTX1
++config GPIO_WDT
++  tristate "GPIO Hardware Watchdog"
+   help
+-Hardware driver for the MTX-1 boards. This is a watchdog timer that
+-will reboot the machine after a 100 seconds timer expired.
++Hardware driver for GPIO-controlled watchdogs. GPIO pin and
++toggle interval settings are platform-specific. The driver
++will stop toggling the GPIO (i.e. machine reboots) after a
++100 second timer expired and no process has written to
++/dev/watchdog during that time.
+ 
+ config PNX833X_WDT
+   tristate "PNX833x Hardware Watchdog"
+--- a/drivers/watchdog/Makefile
 b/drivers/watchdog/Makefile
+@@ -124,7 +124,7 @@ obj-$(CONFIG_BCM63XX_WDT) += bcm63xx_wdt
+ obj-$(CONFIG_RC32434_WDT) += rc32434_wdt.o
+ obj-$(CONFIG_INDYDOG) += indydog.o
+ obj-$(CONFIG_JZ4740_WDT) += jz4740_wdt.o
+-obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o
++obj-$(CONFIG_GPIO_WDT) += gpio_wdt.o
+ obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o
+ obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o
+ obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
+--- /dev/null
 b/drivers/watchdog/gpio_wdt.c
+@@ -0,0 +1,301 @@
++/*
++ *  Driver for GPIO-controlled Hardware Watchdogs.
++ *
++ *  Copyright (C) 2013 Mathias Adam 
++ *
++ *  Replaces mtx1_wdt (driver for the MTX-1 Watchdog):
++ *
++ *  (C) Copyright 2005 4G Systems ,
++ *  All Rights Reserved.
++ *  http://www.4g-systems.biz
++ *
++ *  (C) Copyright 2007 OpenWrt.org, Florian Fainelli 
++ *
++ *  This program is free software; you can redistribute it and/or
++ *  modify it under the terms of the GNU General Public License
++ *  as published by the Free Software Foundation; either version
++ *  2 of the License, or (at your option) any later version.
++ *
++ *  Neither Michael Stickel nor 4G Systems admit liability nor provide
++ *  warranty for any of this software. This material is provided
++ *  "AS-IS" and at no charge.
++ *
++ *  (c) Copyright 20054G Systems 
++ *
++ *  Release 0.01.
++ *  Author: Michael Stickel  michael.stic...@4g-systems.biz
++ *
++ *  Release 0.02.
++ *  Author: Florian Fainelli flor...@openwrt.org
++ *  use the Linux watchdog/timer APIs
++ *
++ *  Release 0.03.
++ *  Author: Mathias Adam 
++ *  make it a generic gpio watchdog driver
++ *
++ *  The Watchdog is configured to reset the MTX-1
++ *  if it is not triggered for 100 seconds.
++ *  It should not be triggered more often than 1.6 seconds.
++ *
++ *  A timer triggers the watchdog every 5 seconds, until
++ *  it is opened for the first time. After the first open
++ *  it MUST be triggered every 2..95 seconds.
++ */
++
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++
++static int ticks = 100 * HZ;
++
++static struct {
++  struct completion stop;
++  spinlock_t lock;
++  int running;
++  struct timer_list timer;
++  int queue;
++  int default_ticks;
++  unsigned long inuse;
++  unsigned gpio;
++ 

[OpenWrt-Devel] [PATCHv3] Add support for Huawei E970

2013-01-16 Thread Mathias Adam
This patch adds support for Huawei E970 wireless gateway devices.
It has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
E960/B970 should work too, from what I know it's basically the same hardware.

The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.

It uses a hardware watchdog which needs GPIO-7 to be toggled at least
every 1-2 seconds. This patch uses gpio_wdt module (see my previous
patch today) to take care of this.

Tested and works:  3G wan,  wlan+LED,  VLAN config,  failsafe using reset
button,   image to be used for upgrade from OEM firmware's web interface

Link to the wiki page I've created:  <http://wiki.openwrt.org/toh/huawei/e970>

Issue:

* lzma-loader crashes, so gzipped kernel is used. Presumably due to watchdog
  reset during kernel decompress.

Signed-off-by: Mathias Adam 

---

diff --git a/package/broadcom-diag/src/diag.c b/package/broadcom-diag/src/diag.c
index 997fbe8..362cb73 100644
--- a/package/broadcom-diag/src/diag.c
+++ b/package/broadcom-diag/src/diag.c
@@ -150,6 +150,9 @@ enum {
 
/* Edimax */
PS1208MFG,
+
+   /* Huawei */
+   HUAWEI_E970,
 };
 
 static void __init bcm4780_init(void) {
@@ -1036,6 +1039,16 @@ static struct platform_t __initdata platforms[] = {
{ .name = "wlan",   .gpio = 1 << 0, .polarity = 
NORMAL },
},
},
+   /* Huawei */
+   [HUAWEI_E970] = {
+   .name   = "Huawei E970",
+   .buttons= {
+   { .name = "reset",  .gpio = 1 << 6 },
+   },
+   .leds = {
+   { .name = "wlan",   .gpio = 1 << 0, .polarity = 
NORMAL },
+   },
+   },
 };
 
 static struct platform_t __init *platform_detect(void)
@@ -1306,6 +1319,9 @@ static struct platform_t __init *platform_detect(void)
!strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
return &platforms[PS1208MFG];
 
+   if (!strcmp(boardnum, "0x5347") && !strcmp(boardtype, "0x048e"))  /* 
Huawei E970 */
+   return &platforms[HUAWEI_E970];
+
/* not found */
return NULL;
 }
diff --git a/target/linux/brcm47xx/config-3.6 b/target/linux/brcm47xx/config-3.6
index 7f1ea7d..93fdeb9 100644
--- a/target/linux/brcm47xx/config-3.6
+++ b/target/linux/brcm47xx/config-3.6
@@ -143,3 +143,4 @@ CONFIG_USB_ARCH_HAS_XHCI=y
 CONFIG_USB_SUPPORT=y
 CONFIG_WATCHDOG_CORE=y
 CONFIG_ZONE_DMA_FLAG=0
+CONFIG_GPIO_WDT=y
diff --git a/target/linux/brcm47xx/image/Makefile 
b/target/linux/brcm47xx/image/Makefile
index f45fb56..9a716f4 100644
--- a/target/linux/brcm47xx/image/Makefile
+++ b/target/linux/brcm47xx/image/Makefile
@@ -13,6 +13,7 @@ endef
 
 define Image/Prepare
cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 
-lp2 -pb2 > $(KDIR)/vmlinux.lzma
+   gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
rm -f $(KDIR)/loader.gz
$(MAKE) -C lzma-loader \
BUILD_DIR="$(KDIR)" \
@@ -56,6 +57,12 @@ define Image/Build/Edi
$(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx 
$(BIN_DIR)/openwrt-$(2)-$(3).bin
 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
+   cat $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx >> 
$(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
+endef
+
 define trxalign/jffs2-128k
 -a 0x2 -f $(KDIR)/root.$(1)
 endef
@@ -117,9 +124,13 @@ define Image/Build
$(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
-f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
$(call trxalign/$(1),$(1))
+   $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
+   -f $(KDIR)/vmlinux.gz \
+   $(call trxalign/$(1),$(1))
$(call Image/Build/$(1),$(1))
$(call Image/Build/Motorola,$(1),wr850g,1,$(1))
$(call Image/Build/USR,$(1),usr5461,$(1))
+   $(call Image/Build/Huawei,$(1),e970,$(1))
 #  $(call Image/Build/Chk,$(1),wgr614_v8,U12H072T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
 #  $(call Image/Build/Chk,$(1),wgr614_v9,U12H094T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
 #  $(call Image/Build/Chk,$(1),wndr3300,U12H093T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
diff --git a/target/linux/brcm47xx/patches-3.6/830-huawei_e970_support.patch 
b/target/linux/brcm47xx/patches-3.6/830-huawei_e970_support.patch
new file mode 100644
index 000..c6c14d1
--- /dev/null
+++ b/target/linux/brcm47xx/patches-3.6/830-huawei_e970_support.patch
@@ -0,0 +1,174 @@
+--- a/arch/mips/bcm47xx/setup.c
 b/arch/mips/bcm47xx/setup.c
+@@ -33,6 +33,7 @@
+ #inc

Re: [OpenWrt-Devel] [PATCHv2] Add support for Huawei E970

2012-12-17 Thread Mathias Adam
Hi Hauke,

Am Do, 13.12.2012, 20:55 schrieb Hauke Mehrtens:
> On 11/11/2012 09:38 PM, Mathias Adam wrote:
>> ping...
>>
>> Am So, 14.10.2012, 21:13 schrieb Mathias Adam:
>>>
>>> !strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
>>> return &platforms[PS1208MFG];
>>>
>>> +   if (!strcmp(boardnum, "0x5347") && !strcmp(boardtype, "0x048e"))  /*
>>> Huawei E970 */
>>> +   return &platforms[HUAWEI_E970];
>>> +
>
> These two values boardnum and boardtype do not look very device
> specific, could you post the nvram of the device, I hope there are some
> better names in it.

here's nvram dump after a factory reset (serno, il0macaddr, boardno,
et0macaddr are device dependent):

CFE> nvram show
sdram_config=0x0062
sdram_refresh=0
vlan0ports=0 1 2 3 5*
et0mdcport=0
bxa2g=1
vlan1hwname=et0
ag0=2
et0phyaddr=30
serno=KQ7NAB18324.
pa0maxpwr=72
pa0b0=0x125d
pa0b1=0xfb6e
pa0b2=0xfec1
il0macaddr=00:1E:10:10:..:..
wandevs=et0
clkfreq=240
cctl=0
sdram_ncdl=0xffd08
boardnum=0x5347
ccode=0
rssisav2g=2
boardno=020HQG7N830.
rssismc2g=2
rxpo2g=0xfff8
opo=12
aa0=3
pa0itssit=62
sromrev=3
boardtype=0x048e
boardflags=0x750
watchdog=3000
lan_netmask=255.255.255.0
wl0id=0x4318
rssismf2g=0
boardrev=0x11
lan_ipaddr=192.168.1.1
et0macaddr=00:1E:10:10:..:..
et1phyaddr=0x1f
landevs=vlan0 wl0
build_cfe_version=256.11.01.03.102sp02
sdram_init=0x000b
boot_wait=on
tri2g=78
vlan1ports=4 5u
vlan0hwname=et0
xtalfreq=25000
wl0gpio0=11
wl0gpio1=11
wl0gpio2=11
wl0gpio3=11
size: 785 bytes (31983 left)
*** command status = 0


Regards,
Mathias

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


Re: [OpenWrt-Devel] [PATCHv2] Add support for Huawei E970

2012-12-17 Thread Mathias Adam
Hi,

Am Do, 13.12.2012, 20:59 schrieb Florian Fainelli:
> Le 13/12/2012 20:45, Hauke Mehrtens a écrit :
 Changes from previous patch:

 * rebased to svn-rev. 33761
 * b43 wireless now works out of box (no changes were necessary on my
 part)
 * modifications according to comments by Hauke Mehrtens on 2012-04-25
 * header for factory update package now created using dd and echo, no
 need
for binary header template file anymore
>>
>> I just had a closer look at the patch.
>> I do not like the way how this is added, but if you just have 2 seconds
>> time to call the gpio I do not know a better way.
>>
>> How long do you have to send the ping on the gpio after the boot? Do you
>> have a log for me without this patch, so that I can see if there is a
>> better position for this code?
>
> Plus, this should be made a generic gpio-watchdog driver, there is
> nothing specific about such a thing. I already asked for that during the
> first round of the review AFAIR.
> --
> Florian

thanks Florian for the hint, I almost forgot about that discussion -- yet
I even already proposed a "gpio_wdt" module based on the MTX-1 module back
then :-)
(see
)

Hauke: I'll look into reworking this to use arch_initcall() etc. (I guess
that would be something like what you proposed last week?)


Side question: were there any changes to build_dir structure in trunk
recently?
Previously (in October, svn-rev. 33761) kernel sources were under
build_dir/linux-brcm47xx/linux-3.3.8/
I just did an svn update (rev. 34725), and now they seem to be in
build_dir/target-mipsel_uClibc-0.9.33.2/linux-brcm47xx/linux-3.6.10/

Is it supposed to be like this, or has there sth. gone wrong within my
build tree?


Regards,
Mathias

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


Re: [OpenWrt-Devel] [PATCHv2] Add support for Huawei E970

2012-12-14 Thread Mathias Adam
Hi Hauke,

thanks for picking this up!

Am Do, 13.12.2012, 20:45 schrieb Hauke Mehrtens:
> On 11/11/2012 09:38 PM, Mathias Adam wrote:
>> ping...
>> Am So, 14.10.2012, 21:13 schrieb Mathias Adam:
>>> This patch adds support for Huawei E970 wireless gateway devices. It
has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
E960/B970 should work too, from what I know it's basically the same
hardware.
>>> The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem. For
reference, it has already been addressed in this open ticket:
<https://dev.openwrt.org/ticket/2711>
>>> The device has a hardware watchdog which needs GPIO-7 to be toggled at
least
>>> every 1-2 seconds. Therefore a timer is being setup early in the boot
process
>>> in order to take care of this  (see arch/mips/bcm47xx/time.c). Tested
and works:  3G wan,  wlan+LED,  VLAN config,  failsafe using reset
>>> button,   image to be used for upgrade from OEM firmware's web interface
>>> Link to the wiki page I've created:
>>> <http://wiki.openwrt.org/toh/huawei/e970>
>>> Issue:
>>> * lzma-loader crashes, so gzipped kernel is used. Presumably due to
watchdog
>>>   reset during kernel decompress.
>>> Signed-off-by: Mathias Adam 
>>> ---
>>> Changes from previous patch:
>>> * rebased to svn-rev. 33761
>>> * b43 wireless now works out of box (no changes were necessary on my
part)
>>> * modifications according to comments by Hauke Mehrtens on 2012-04-25
* header for factory update package now created using dd and echo, no
need
>>>   for binary header template file anymore
> I just had a closer look at the patch.
> I do not like the way how this is added, but if you just have 2 seconds
time to call the gpio I do not know a better way.
> How long do you have to send the ping on the gpio after the boot? Do you
have a log for me without this patch, so that I can see if there is a
better position for this code?

I'm not completely happy with this solution either. At least it's known to
be working stable so far (I have one of my E970 routers running for nearly
a year now without problems).

I think it doesn't have to be that early in the boot process as it is now.
Two reasons I remember:
1) when trying to get lzma-loader to work I wanted the GPIO toggle as
early as possible within the kernel. But as lzma-loader doesn't work yet
anyway I'd suggest to stay with gzipped kernel for the moment.
2) AFAIR the original firmware does it in a similar way (I'll look for a
download link as you asked later)


Here's a log snippet from my notes without the watchdog reset:

...
serial8250.0: ttyS0 at MMIO 0xb8000300 (irq = 3) is a U6_16550A
serial8250.0: ttyS1 at MMIO 0xb8000400 (irq = 3) is a U6_16550A
bcm47xx_pflash: flash init: 0x1c00 0x0200
Physically mapped flash: Found 1 x16 devices at 0x0 in 16-bit bank.
Manufacturer ID 0x01 Chip ID 0x001a01
Amd/Fujitsu Extended Query Table at 0x0040
  Amd/Fujitsu Extended Query version 1.3.
Physically mapped flash: Swapping erase regions for top-boot CFI table.
number of CFI chips: 1
bcm47xx_pflash: Flash device: 0x200 at 0xbfc0
bcm47xx_part: bootloader size: 262144
bcm47xx_part: Looking for dual image
bcm47xx_part: TRX offset : 0
bcm47xx_part: Updating TRX offsets and length:
bcm47xx_part: old trx = [0x001c, 0x0012cc00, 0x],
len=0x002e1000 crc32=0x729db7c4
bcm47xx_part: new trx = [0x001c, 0x0012cc00, 0x],
len=0x0012cc00 crc32=0x48f25a83


CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date:   2 13 14:50:54 CST 2008
(w114501@localhost.localdomain)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.

Initializing Arena
Initializing Devices.
Boot partition size = 262144(0x4)
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller
CFE reboot flag0 = 0x12345678, flag1 = 0x0,flag2 =
0x,reboot_number = 0x1
CPU type 0x29029: 240MHz
Total memory: 32768 KBytes
...


After that I found the first 64kiB behind CFE being erased, so I guess the
watchdog reset happened during updating the TRX header. As the flash write
usually takes a rather long time, in a second test I manually modified TRX
headers (len and crc) before the first boot so that the kernel doesn't
have to update them:

...
bcm47xx_pflash: Flash device: 0x200 at 0xbfc0
bcm47xx_part: bootloader size: 262144
bcm47xx_part: Looking for dual image
bcm47xx_part: TRX offset : 0
4 bcm47xx partitions found on MTD device Physically mapped flash
Creating 4 MTD partitions on "Physically mapped flash":
0x-0x0004 : "cfe"
0x0004-0x003f : "linux"
0x0016cc00-0x003f : "rootfs"
mtd: partition "rootfs" must either start or end on erase block boundary
or be smal

Re: [OpenWrt-Devel] [PATCHv2] Add support for Huawei E970

2012-11-11 Thread Mathias Adam
ping...

Am So, 14.10.2012, 21:13 schrieb Mathias Adam:
> This patch adds support for Huawei E970 wireless gateway devices.
> It has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
> E960/B970 should work too, from what I know it's basically the same
> hardware.
>
> The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
> For reference, it has already been addressed in this open ticket:
> <https://dev.openwrt.org/ticket/2711>
>
> The device has a hardware watchdog which needs GPIO-7 to be toggled at
> least
> every 1-2 seconds. Therefore a timer is being setup early in the boot
> process
> in order to take care of this  (see arch/mips/bcm47xx/time.c).
>
> Tested and works:  3G wan,  wlan+LED,  VLAN config,  failsafe using reset
> button,   image to be used for upgrade from OEM firmware's web interface
>
> Link to the wiki page I've created:
> <http://wiki.openwrt.org/toh/huawei/e970>
>
> Issue:
>
> * lzma-loader crashes, so gzipped kernel is used. Presumably due to
> watchdog
>   reset during kernel decompress.
>
> Signed-off-by: Mathias Adam 
>
> ---
>
> Changes from previous patch:
>
> * rebased to svn-rev. 33761
> * b43 wireless now works out of box (no changes were necessary on my part)
> * modifications according to comments by Hauke Mehrtens on 2012-04-25
> * header for factory update package now created using dd and echo, no need
>   for binary header template file anymore
>
>
> diff --git a/package/broadcom-diag/src/diag.c
> b/package/broadcom-diag/src/diag.c
> index 7e0ff02..0780f3f 100644
> --- a/package/broadcom-diag/src/diag.c
> +++ b/package/broadcom-diag/src/diag.c
> @@ -149,6 +149,9 @@ enum {
>
>   /* Edimax */
>   PS1208MFG,
> +
> + /* Huawei */
> + HUAWEI_E970,
>  };
>
>  static void __init bcm4780_init(void) {
> @@ -1016,6 +1019,16 @@ static struct platform_t __initdata platforms[] = {
>   { .name = "wlan",   .gpio = 1 << 0, .polarity = 
> NORMAL },
>   },
>   },
> + /* Huawei */
> + [HUAWEI_E970] = {
> + .name   = "Huawei E970",
> + .buttons= {
> + { .name = "reset",  .gpio = 1 << 6 },
> + },
> + .leds = {
> + { .name = "wlan",   .gpio = 1 << 0, .polarity = 
> NORMAL },
> + },
> + },
>  };
>
>  static struct platform_t __init *platform_detect(void)
> @@ -1279,6 +1292,9 @@ static struct platform_t __init
> *platform_detect(void)
>   !strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
>   return &platforms[PS1208MFG];
>
> + if (!strcmp(boardnum, "0x5347") && !strcmp(boardtype, "0x048e"))  /*
> Huawei E970 */
> + return &platforms[HUAWEI_E970];
> +
>   /* not found */
>   return NULL;
>  }
> diff --git a/target/linux/brcm47xx/image/Makefile
> b/target/linux/brcm47xx/image/Makefile
> index 33290ff..7e7c81b 100644
> --- a/target/linux/brcm47xx/image/Makefile
> +++ b/target/linux/brcm47xx/image/Makefile
> @@ -13,6 +13,7 @@ endef
>
>  define Image/Prepare
>   cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1
> -lp2 -pb2 > $(KDIR)/vmlinux.lzma
> + gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
>   rm -f $(KDIR)/loader.gz
>   $(MAKE) -C lzma-loader \
>   BUILD_DIR="$(KDIR)" \
> @@ -51,6 +52,12 @@ define Image/Build/Edi
>   $(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx
> $(BIN_DIR)/openwrt-$(2)-$(3).bin
>  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
> + cat $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx >>
> $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
> +endef
> +
>  define trxalign/jffs2-128k
>  -a 0x2 -f $(KDIR)/root.$(1)
>  endef
> @@ -109,9 +116,13 @@ define Image/Build
>   $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
>   -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
>   $(call trxalign/$(1),$(1))
> + $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
> + -f $(KDIR)/vmlinux.gz \
> + $(call trxalign/$(1),$(1))
>   $(call Image/Build/$(1),$(1))
>   $(call Image/Build/Motorola,$(1),wr850g,1,$(1))
>   $(call Image/Build/USR,$(1),usr5461,$(1))
> +  

Re: [OpenWrt-Devel] [PATCHv2] Add support for Huawei E970

2012-10-20 Thread Mathias Adam
Am Mo, 15.10.2012, 19:17 schrieb Rafał Miłecki:
> 2012/10/15 Mathias Adam :
>> Am Mo, 15.10.2012, 17:57 schrieb Rafał Miłecki:
>>> 2012/10/14 Mathias Adam :
>>>> This patch adds support for Huawei E970 wireless gateway devices. It
has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
E960/B970 should work too, from what I know it's basically the same
hardware.
>>>> The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
For reference, it has already been addressed in this open ticket:
<https://dev.openwrt.org/ticket/2711>
>>> Could you provide dmesg from booting OpenWRT, please? I'd like to see
bcma/b43/mtd logs.
>> sure, rather not dmesg but the bootlog from serial console, see
attachment...
> Thanks! I was surprised to see wiki page [0] saying it contains
> BCM4318 (which is G-PHY type).

what do you mean by G-PHY? the BCM5354 actually is 802.11b/g.


> After seeing log I can tell it's standard BCM5354 with a 80211 core that
has:
> b43-phy0: Found PHY: Analog 6, Type 5 (LP), Revision 0
> There is no separated chipset with just wireless, it's just a mistake on
wiki page :)
> [0] http://wiki.openwrt.org/toh/huawei/e970

I must admit that I haven't done very thorough research when filling in
the hardware table :) merely copied the relevant bits from pages of other
devices with BCM5354. Many of them [*] list wireless to be the 4318, thus
I assumed the one integrated in the 5354 SoC is just compatible to that.

Anyway I just changed the E970 wiki page. Perhaps someone who feels
responsible might change the other pages, in case it's a mistake there
too:

[*] e.g. <http://wiki.openwrt.org/toh/asus/wl500gp#info>,
<http://wiki.openwrt.org/toh/buffalo/whr-g125#hardware>,
<http://wiki.openwrt.org/toh/edimax/ps-1208mfg#info> (this even claims it
to be 11a/b/g...),
and from <http://wiki.openwrt.org/toh/start>: Catch-Tec CW-5354U, D-Link
DIR-320


Regards,
Mathias

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


Re: [OpenWrt-Devel] [PATCHv2] Add support for Huawei E970

2012-10-15 Thread Mathias Adam
Am Mo, 15.10.2012, 17:57 schrieb Rafał Miłecki:
> 2012/10/14 Mathias Adam :
>> This patch adds support for Huawei E970 wireless gateway devices.
>> It has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
>> E960/B970 should work too, from what I know it's basically the same
>> hardware.
>>
>> The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
>> For reference, it has already been addressed in this open ticket:
>> <https://dev.openwrt.org/ticket/2711>
>
> Could you provide dmesg from booting OpenWRT, please? I'd like to see
> bcma/b43/mtd logs.

sure, rather not dmesg but the bootlog from serial console, see attachment...

Regards,
Mathias

bootlog_121014.cap
Description: application/vnd.tcpdump.pcap
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCHv2] Add support for Huawei E970

2012-10-14 Thread Mathias Adam
This patch adds support for Huawei E970 wireless gateway devices.
It has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
E960/B970 should work too, from what I know it's basically the same hardware.

The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
For reference, it has already been addressed in this open ticket:
<https://dev.openwrt.org/ticket/2711>

The device has a hardware watchdog which needs GPIO-7 to be toggled at least
every 1-2 seconds. Therefore a timer is being setup early in the boot process
in order to take care of this  (see arch/mips/bcm47xx/time.c).

Tested and works:  3G wan,  wlan+LED,  VLAN config,  failsafe using reset
button,   image to be used for upgrade from OEM firmware's web interface

Link to the wiki page I've created:  <http://wiki.openwrt.org/toh/huawei/e970>

Issue:

* lzma-loader crashes, so gzipped kernel is used. Presumably due to watchdog
  reset during kernel decompress.

Signed-off-by: Mathias Adam 

---

Changes from previous patch:

* rebased to svn-rev. 33761
* b43 wireless now works out of box (no changes were necessary on my part)
* modifications according to comments by Hauke Mehrtens on 2012-04-25
* header for factory update package now created using dd and echo, no need
  for binary header template file anymore


diff --git a/package/broadcom-diag/src/diag.c b/package/broadcom-diag/src/diag.c
index 7e0ff02..0780f3f 100644
--- a/package/broadcom-diag/src/diag.c
+++ b/package/broadcom-diag/src/diag.c
@@ -149,6 +149,9 @@ enum {
 
/* Edimax */
PS1208MFG,
+
+   /* Huawei */
+   HUAWEI_E970,
 };
 
 static void __init bcm4780_init(void) {
@@ -1016,6 +1019,16 @@ static struct platform_t __initdata platforms[] = {
{ .name = "wlan",   .gpio = 1 << 0, .polarity = 
NORMAL },
},
},
+   /* Huawei */
+   [HUAWEI_E970] = {
+   .name   = "Huawei E970",
+   .buttons= {
+   { .name = "reset",  .gpio = 1 << 6 },
+   },
+   .leds = {
+   { .name = "wlan",   .gpio = 1 << 0, .polarity = 
NORMAL },
+   },
+   },
 };
 
 static struct platform_t __init *platform_detect(void)
@@ -1279,6 +1292,9 @@ static struct platform_t __init *platform_detect(void)
!strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
return &platforms[PS1208MFG];
 
+   if (!strcmp(boardnum, "0x5347") && !strcmp(boardtype, "0x048e"))  /* 
Huawei E970 */
+   return &platforms[HUAWEI_E970];
+
/* not found */
return NULL;
 }
diff --git a/target/linux/brcm47xx/image/Makefile 
b/target/linux/brcm47xx/image/Makefile
index 33290ff..7e7c81b 100644
--- a/target/linux/brcm47xx/image/Makefile
+++ b/target/linux/brcm47xx/image/Makefile
@@ -13,6 +13,7 @@ endef
 
 define Image/Prepare
cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 
-lp2 -pb2 > $(KDIR)/vmlinux.lzma
+   gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
rm -f $(KDIR)/loader.gz
$(MAKE) -C lzma-loader \
BUILD_DIR="$(KDIR)" \
@@ -51,6 +52,12 @@ define Image/Build/Edi
$(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx 
$(BIN_DIR)/openwrt-$(2)-$(3).bin
 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
+   cat $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx >> 
$(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
+endef
+
 define trxalign/jffs2-128k
 -a 0x2 -f $(KDIR)/root.$(1)
 endef
@@ -109,9 +116,13 @@ define Image/Build
$(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
-f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
$(call trxalign/$(1),$(1))
+   $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
+   -f $(KDIR)/vmlinux.gz \
+   $(call trxalign/$(1),$(1))
$(call Image/Build/$(1),$(1))
$(call Image/Build/Motorola,$(1),wr850g,1,$(1))
$(call Image/Build/USR,$(1),usr5461,$(1))
+   $(call Image/Build/Huawei,$(1),e970,$(1))
 #  $(call Image/Build/Chk,$(1),wgr614_v8,U12H072T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
 #  $(call Image/Build/Chk,$(1),wgr614_v9,U12H094T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
 #  $(call Image/Build/Chk,$(1),wndr3300,U12H093T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
diff --git a/target/linux/brcm47xx/patches-3.3/830-huawei_e970_support.patch 
b/target/linux/brcm47xx/patches-3.3/830-huawei_e970_support.patch
new file mode 100644
index 000..2d83d24
--- /dev/null
+++ b/target/linux/b

Re: [OpenWrt-Devel] [PATCH] Add support for Huawei E970

2012-04-26 Thread Mathias Adam

Hi Hauke,

Am 25.04.2012 23:43, schrieb Hauke Mehrtens:

Hi Mathias,

sorry for answering so late. I haven't seen this patch since now.


don't worry. Thanks for picking it up now.


On 12/17/2011 09:46 PM, Mathias Adam wrote:

This patch adds support for Huawei E970 wireless gateway devices.
It has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
E960/B970 should work too, from what I know it's basically the same hardware.

The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
For reference, it has already been addressed in this open ticket:
<https://dev.openwrt.org/ticket/2711>

The device has a hardware watchdog which needs GPIO-7 to be toggled at least
every 1-2 seconds. Therefore a timer is being setup early in the boot process
in order to take care of this  (see arch/mips/bcm47xx/time.c).

Tested and works:  3G wan,  wlan+LED,  VLAN config,  failsafe using reset
button,   image to be used for upgrade from OEM firmware's web interface

Link to the wiki page I've created:<http://wiki.openwrt.org/toh/huawei/e970>

Issues:

* lzma-loader crashes, so gzipped kernel is used. Presumably due to watchdog
   reset during kernel decompress.
* b43 wireless driver crashes after loading firmware, use proprietary module
   (wl) instead. Perhaps due to watchdog, too.


In fact it's not only the driver crashing but the whole system doing an 
immediate reboot.




(kernel patch below)

Signed-off-by: Mathias Adam

---

Index: target/linux/brcm47xx/image/Makefile
===
--- target/linux/brcm47xx/image/Makefile(Revision 29557)
+++ target/linux/brcm47xx/image/Makefile(Arbeitskopie)
@@ -13,6 +13,7 @@

  define Image/Prepare
cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 
-lp2 -pb2>  $(KDIR)/vmlinux.lzma
+   gzip -nc9 $(KDIR)/vmlinux>  $(KDIR)/vmlinux.gz
rm -f $(KDIR)/loader.gz
$(MAKE) -C lzma-loader \
BUILD_DIR="$(KDIR)" \
@@ -51,6 +52,11 @@
$(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx 
$(BIN_DIR)/openwrt-$(2)-$(3).bin
  endef

+define Image/Build/Huawei
+   cp ./huawei-e970-padding $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin

where is huawei-e970-padding ?

cp: cannot stat `./huawei-e970-padding': No such file or directory


my mistake. As it's binary it wasn't included in the patch.
I attach it to this mail. The patch expects it to be in:
target/linux/brcm47xx/image/




+   cat $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx>>  
$(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
+endef
+
  define trxalign/jffs2-128k
  -a 0x2 -f $(KDIR)/root.$(1)
  endef
@@ -107,9 +113,13 @@
$(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
-f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
$(call trxalign/$(1),$(1))
+   $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
+   -f $(KDIR)/vmlinux.gz \
+   $(call trxalign/$(1),$(1))
$(call Image/Build/$(1),$(1))
$(call Image/Build/Motorola,$(1),wr850g,1,$(1))
$(call Image/Build/USR,$(1),usr5461,$(1))
+   $(call Image/Build/Huawei,$(1),e970,$(1))
$(call Image/Build/Chk,$(1),wnr834b_v2,U12H081T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
  # $(call Image/Build/Chk,$(1),wndr3400_v1,U12H155T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
  # $(call Image/Build/Chk,$(1),wgr614_v8,U12H072T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
Index: package/broadcom-diag/src/diag.c
===
--- package/broadcom-diag/src/diag.c(Revision 29557)
+++ package/broadcom-diag/src/diag.c(Arbeitskopie)
@@ -142,6 +142,9 @@

/* Edimax */
PS1208MFG,
+
+   /* Huawei */
+   HUAWEI_E970,
  };

  static void __init bcm4780_init(void) {
@@ -921,6 +924,16 @@
{ .name = "wlan", .gpio = 1<<  0, .polarity = 
NORMAL },
},
},
+   /* Huawei */
+   [HUAWEI_E970] = {
+   .name   = "Huawei E970",
+   .buttons= {
+   { .name = "reset",.gpio = 1<<  6 },
+   },
+   .leds = {
+   { .name = "wlan", .gpio = 1<<  0, .polarity = 
NORMAL },
+   },
+   },
  };

  static struct platform_t __init *platform_detect(void)
@@ -1155,6 +1168,9 @@
!strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
return&platforms[PS1208MFG];

+   if (!strcmp(boardnum, "0x5347")&&  !strcmp(boardtype, "0x048e"))  /* 
Huawei E970 */
+   return&platforms[HUAWEI_E970];
+
/* not found */
return NULL;
  }


--

Re: [OpenWrt-Devel] [PATCH] Add support for Huawei E970

2012-04-10 Thread Mathias Adam
Hi,

I just came across this patch: posted it back in December but didn't get
any feedback, unfortunately.

I'm using it on two of these boxes and know of some others too.
Haven't checked whether it still applies to current trunk, though.

link to patchwork: <http://patchwork.openwrt.org/patch/1689/>

Please give some feedback on whether or how it can be merged into openwrt.

Regards,
Mathias

Am Sa, 17.12.2011, 22:46 schrieb Mathias Adam:
> This patch adds support for Huawei E970 wireless gateway devices.
> It has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
> E960/B970 should work too, from what I know it's basically the same
> hardware.
>
> The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
> For reference, it has already been addressed in this open ticket:
> <https://dev.openwrt.org/ticket/2711>
>
> The device has a hardware watchdog which needs GPIO-7 to be toggled at
> least
> every 1-2 seconds. Therefore a timer is being setup early in the boot
> process
> in order to take care of this  (see arch/mips/bcm47xx/time.c).
>
> Tested and works:  3G wan,  wlan+LED,  VLAN config,  failsafe using reset
> button,   image to be used for upgrade from OEM firmware's web interface
>
> Link to the wiki page I've created:
> <http://wiki.openwrt.org/toh/huawei/e970>
>
> Issues:
>
> * lzma-loader crashes, so gzipped kernel is used. Presumably due to
> watchdog
>   reset during kernel decompress.
> * b43 wireless driver crashes after loading firmware, use proprietary
> module
>   (wl) instead. Perhaps due to watchdog, too.
>
> (kernel patch below)
>
> Signed-off-by: Mathias Adam 
>
> ---
>
> Index: target/linux/brcm47xx/image/Makefile
> ===
> --- target/linux/brcm47xx/image/Makefile  (Revision 29557)
> +++ target/linux/brcm47xx/image/Makefile  (Arbeitskopie)
> @@ -13,6 +13,7 @@
>
>  define Image/Prepare
>   cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1
> -lp2 -pb2 > $(KDIR)/vmlinux.lzma
> + gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
>   rm -f $(KDIR)/loader.gz
>   $(MAKE) -C lzma-loader \
>   BUILD_DIR="$(KDIR)" \
> @@ -51,6 +52,11 @@
>   $(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx
> $(BIN_DIR)/openwrt-$(2)-$(3).bin
>  endef
>
> +define Image/Build/Huawei
> + cp ./huawei-e970-padding $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
> + cat $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx >>
> $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
> +endef
> +
>  define trxalign/jffs2-128k
>  -a 0x2 -f $(KDIR)/root.$(1)
>  endef
> @@ -107,9 +113,13 @@
>   $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
>   -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
>   $(call trxalign/$(1),$(1))
> + $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
> + -f $(KDIR)/vmlinux.gz \
> + $(call trxalign/$(1),$(1))
>   $(call Image/Build/$(1),$(1))
>   $(call Image/Build/Motorola,$(1),wr850g,1,$(1))
>   $(call Image/Build/USR,$(1),usr5461,$(1))
> + $(call Image/Build/Huawei,$(1),e970,$(1))
>   $(call Image/Build/Chk,$(1),wnr834b_v2,U12H081T00_NETGEAR,2,$(patsubst
> jffs2-%,jffs2,$(1)))
>  #$(call Image/Build/Chk,$(1),wndr3400_v1,U12H155T00_NETGEAR,2,$(patsubst
> jffs2-%,jffs2,$(1)))
>  #$(call Image/Build/Chk,$(1),wgr614_v8,U12H072T00_NETGEAR,2,$(patsubst
> jffs2-%,jffs2,$(1)))
> Index: package/broadcom-diag/src/diag.c
> ===
> --- package/broadcom-diag/src/diag.c  (Revision 29557)
> +++ package/broadcom-diag/src/diag.c  (Arbeitskopie)
> @@ -142,6 +142,9 @@
>
>   /* Edimax */
>   PS1208MFG,
> +
> + /* Huawei */
> + HUAWEI_E970,
>  };
>
>  static void __init bcm4780_init(void) {
> @@ -921,6 +924,16 @@
>   { .name = "wlan",   .gpio = 1 << 0, .polarity = 
> NORMAL },
>   },
>   },
> + /* Huawei */
> + [HUAWEI_E970] = {
> + .name   = "Huawei E970",
> + .buttons= {
> + { .name = "reset",  .gpio = 1 << 6 },
> + },
> + .leds = {
> + { .name = "wlan",   .gpio = 1 << 0, .polarity = 
> NORMAL },
> + },
> + },
>  };
>
>  static struct platform_t __init *platform_detect(void)
> @@ -1155,6 +1168,9 @@
>   !strcmp(getvar("status_gpio&qu

Re: [OpenWrt-Devel] which openwrt bin file for huawei E970/E960 for web upgrade?

2012-04-10 Thread Mathias Adam
Hi,

Am So, 8.04.2012, 00:03 schrieb Raymond Looi:
> Hi,
>
> I would like to know which bin file should I get to make my huawei
> E960 support openwrt?
>
> Thank you.
> Ray

as far as I know the E970 support isn't merged into openwrt (yet).

Here you can find the patch, and a .bin I created back in December (from
Openwrt trunk r29557):



Regards,
Mathias

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


[OpenWrt-Devel] [PATCH] Add support for Huawei E970

2011-12-17 Thread Mathias Adam
This patch adds support for Huawei E970 wireless gateway devices.
It has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
E960/B970 should work too, from what I know it's basically the same hardware.

The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
For reference, it has already been addressed in this open ticket:
<https://dev.openwrt.org/ticket/2711>

The device has a hardware watchdog which needs GPIO-7 to be toggled at least
every 1-2 seconds. Therefore a timer is being setup early in the boot process
in order to take care of this  (see arch/mips/bcm47xx/time.c).

Tested and works:  3G wan,  wlan+LED,  VLAN config,  failsafe using reset
button,   image to be used for upgrade from OEM firmware's web interface

Link to the wiki page I've created:  <http://wiki.openwrt.org/toh/huawei/e970>

Issues:

* lzma-loader crashes, so gzipped kernel is used. Presumably due to watchdog
  reset during kernel decompress.
* b43 wireless driver crashes after loading firmware, use proprietary module
  (wl) instead. Perhaps due to watchdog, too.

(kernel patch below)

Signed-off-by: Mathias Adam 

---

Index: target/linux/brcm47xx/image/Makefile
===
--- target/linux/brcm47xx/image/Makefile(Revision 29557)
+++ target/linux/brcm47xx/image/Makefile(Arbeitskopie)
@@ -13,6 +13,7 @@
 
 define Image/Prepare
cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 
-lp2 -pb2 > $(KDIR)/vmlinux.lzma
+   gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
rm -f $(KDIR)/loader.gz
$(MAKE) -C lzma-loader \
BUILD_DIR="$(KDIR)" \
@@ -51,6 +52,11 @@
$(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx 
$(BIN_DIR)/openwrt-$(2)-$(3).bin
 endef
 
+define Image/Build/Huawei
+   cp ./huawei-e970-padding $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
+   cat $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx >> 
$(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
+endef
+
 define trxalign/jffs2-128k
 -a 0x2 -f $(KDIR)/root.$(1)
 endef
@@ -107,9 +113,13 @@
$(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
-f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
$(call trxalign/$(1),$(1))
+   $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
+   -f $(KDIR)/vmlinux.gz \
+   $(call trxalign/$(1),$(1))
$(call Image/Build/$(1),$(1))
$(call Image/Build/Motorola,$(1),wr850g,1,$(1))
$(call Image/Build/USR,$(1),usr5461,$(1))
+   $(call Image/Build/Huawei,$(1),e970,$(1))
$(call Image/Build/Chk,$(1),wnr834b_v2,U12H081T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
 #  $(call Image/Build/Chk,$(1),wndr3400_v1,U12H155T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
 #  $(call Image/Build/Chk,$(1),wgr614_v8,U12H072T00_NETGEAR,2,$(patsubst 
jffs2-%,jffs2,$(1)))
Index: package/broadcom-diag/src/diag.c
===
--- package/broadcom-diag/src/diag.c(Revision 29557)
+++ package/broadcom-diag/src/diag.c(Arbeitskopie)
@@ -142,6 +142,9 @@
 
/* Edimax */
PS1208MFG,
+
+   /* Huawei */
+   HUAWEI_E970,
 };
 
 static void __init bcm4780_init(void) {
@@ -921,6 +924,16 @@
{ .name = "wlan",   .gpio = 1 << 0, .polarity = 
NORMAL },
},
},
+   /* Huawei */
+   [HUAWEI_E970] = {
+   .name   = "Huawei E970",
+   .buttons= {
+   { .name = "reset",  .gpio = 1 << 6 },
+   },
+   .leds = {
+   { .name = "wlan",   .gpio = 1 << 0, .polarity = 
NORMAL },
+   },
+   },
 };
 
 static struct platform_t __init *platform_detect(void)
@@ -1155,6 +1168,9 @@
!strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
return &platforms[PS1208MFG];
 
+   if (!strcmp(boardnum, "0x5347") && !strcmp(boardtype, "0x048e"))  /* 
Huawei E970 */
+   return &platforms[HUAWEI_E970];
+
/* not found */
return NULL;
 }


---

following patch has to be applied to kernel (3.0):


diff -Nur a/arch/mips/bcm47xx/time.c b/arch/mips/bcm47xx/time.c
--- a/arch/mips/bcm47xx/time.c  2011-11-29 16:51:22.0 +0100
+++ b/arch/mips/bcm47xx/time.c  2011-12-17 18:13:32.0 +0100
@@ -25,9 +25,75 @@
 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
+#define ROUTER_HUAWEI_E970 1
+
+#define E970_GPIO_WDT_INTERVAL (HZ / 5)
+#define E970_GPIO_WDT_PIN  7
+
+
+static struct {
+   struct timer_list timer;
+   unsigned long interval;
+   unsigne

Re: [OpenWrt-Devel] Where to place code to reset a watchdog?

2011-12-14 Thread Mathias Adam

Hi,

Am 04.12.2011 18:40, schrieb Florian Fainelli:

Hello Mathias,

Le dimanche 04 décembre 2011 18:16:39, Mathias Adam a écrit :

Hi,

I just got OpenWrt running on a Huawei E970 wireless gateway (in my
case, labelled as T-Mobile web'n'walk Box IV).

The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
For reference, it has already been addressed in this open ticket:
<https://dev.openwrt.org/ticket/2711>

However, the device has a hardware watchdog which needs GPIO7 to be
toggled regularly. Otherwise, the device simply resets after 2-3 secs,
so I wasn't even able to boot into OpenWrt at first.

As a quick fix I put together a small kernel patch which adds a timer to
regularly perform the GPIO toggle. While this does work for me, I think
it could need some cleanup... perhaps, is there already an
infrastructure related to platform-/board-specific watchdogs where this
could be attached to?

Are there other devices already supported by OpenWrt with a similar
watchdog?


The MTX-1 board (AMD Alchemy) is using a similar GPIO-based watchdog:

http://lxr.linux.no/#linux+v3.1.4/drivers/watchdog/mtx-1_wdt.c

such a driver could be made generic by the way.


finally, here's a first working state of such a generic driver. I've 
used mtx-1_wdt.c as a basis for the new gpio_wdt.c.


Unfortunately, the watchdog timeout on the E970 is only 2-3 seconds, so 
that it it already kicks in before all the watchdog drivers are being 
loaded normally. Therefore I moved timer setup from .probe into 
module_init, and modified drivers/Makefile to get the module loaded at 
an earlier time during bootup. However, in order to use it as a generic 
driver, I suspect this should be done in a somewhat cleaner way...


In the original firmware, the watchdog setup is being done in the early 
platform setup code under arch/mips/.  Is it possible to trigger the 
gpio_wdt module to be loaded from the platform setup code? That way the 
driver itself could be generic and be loaded with the watchdog drivers 
on most platforms, while all e970-specific stuff could be done in 
platform setup.


Any other advice appreciated.

Regards,
Mathias Adam


diff -rNU3 
trunk_org//target/linux/brcm47xx/patches-3.0/-huawei_e970.patch 
trunk_e970//target/linux/brcm47xx/patches-3.0/-huawei_e970.patch
--- trunk_org//target/linux/brcm47xx/patches-3.0/-huawei_e970.patch 
1970-01-01 01:00:00.0 +0100
+++ 
trunk_e970//target/linux/brcm47xx/patches-3.0/-huawei_e970.patch 
2011-12-14 00:45:44.0 +0100

@@ -0,0 +1,11 @@
+--- a/drivers/Makefile_org 2011-11-11 19:12:24.0 +0100
 b/drivers/Makefile 2011-12-07 22:12:11.0 +0100
+@@ -5,6 +5,8 @@
+ # Rewritten to use lists instead of if-statements.
+ #
+
++obj-y += watchdog/gpio_wdt.o
++
+ obj-y += gpio/
+ obj-$(CONFIG_PCI) += pci/
+ obj-$(CONFIG_PARISC)  += parisc/


diff -rNU3 
trunk_org//target/linux/brcm47xx/files/drivers/watchdog/gpio_wdt.c 
trunk_e970//target/linux/brcm47xx/files/drivers/watchdog/gpio_wdt.c
--- trunk_org//target/linux/brcm47xx/files/drivers/watchdog/gpio_wdt.c 
1970-01-01 01:00:00.0 +0100
+++ trunk_e970//target/linux/brcm47xx/files/drivers/watchdog/gpio_wdt.c 
2011-12-06 11:06:23.0 +0100

@@ -0,0 +1,284 @@
+/*
+ *  Driver for the MTX-1 Watchdog.
+ *
+ *  (C) Copyright 2005 4G Systems ,
+ * All Rights Reserved.
+ *  http://www.4g-systems.biz
+ *
+ * (C) Copyright 2007 OpenWrt.org, Florian Fainelli 
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version
+ *  2 of the License, or (at your option) any later version.
+ *
+ *  Neither Michael Stickel nor 4G Systems admit liability nor provide
+ *  warranty for any of this software. This material is provided
+ *  "AS-IS" and at no charge.
+ *
+ *  (c) Copyright 20054G Systems 
+ *
+ *  Release 0.01.
+ *  Author: Michael Stickel  michael.stic...@4g-systems.biz
+ *
+ *  Release 0.02.
+ * Author: Florian Fainelli flor...@openwrt.org
+ * use the Linux watchdog/timer APIs
+ *
+ *  The Watchdog is configured to reset the MTX-1
+ *  if it is not triggered for 100 seconds.
+ *  It should not be triggered more often than 1.6 seconds.
+ *
+ *  A timer triggers the watchdog every 5 seconds, until
+ *  it is opened for the first time. After the first open
+ *  it MUST be triggered every 2..95 seconds.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+//#define MTX1_WDT_INTERVAL(5 * HZ)
+#define GPIO_WDT_INTERV

Re: [OpenWrt-Devel] Where to place code to reset a watchdog?

2011-12-04 Thread Mathias Adam

Hello Florian,

Am 04.12.2011 18:40, schrieb Florian Fainelli:

Hello Mathias,

Le dimanche 04 décembre 2011 18:16:39, Mathias Adam a écrit :


However, the device has a hardware watchdog which needs GPIO7 to be
toggled regularly. Otherwise, the device simply resets after 2-3 secs,
so I wasn't even able to boot into OpenWrt at first.

As a quick fix I put together a small kernel patch which adds a timer to
regularly perform the GPIO toggle. While this does work for me, I think
it could need some cleanup... perhaps, is there already an
infrastructure related to platform-/board-specific watchdogs where this
could be attached to?

Are there other devices already supported by OpenWrt with a similar
watchdog?


The MTX-1 board (AMD Alchemy) is using a similar GPIO-based watchdog:

http://lxr.linux.no/#linux+v3.1.4/drivers/watchdog/mtx-1_wdt.c

such a driver could be made generic by the way.


merci!  indeed, from a quick glance it seems very similar to my patch. 
I'll look into making a generic driver as you suggest.


For the moment I attach the patch which works for me:

--- 
trunk/build_dir/linux-brcm47xx/linux-3.0.9/drivers/mtd/maps/bcm47xx-pflash.c 
   2011-11-28 13:40:19.0 +0100
+++ 
trunk_copy111203/build_dir/linux-brcm47xx/linux-3.0.9/drivers/mtd/maps/bcm47xx-pflash.c 
2011-12-03 23:01:37.0 +0100

@@ -48,13 +48,39 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 

 #define WINDOW_ADDR 0x1fc0
 #define WINDOW_SIZE 0x40
 #define BUSWIDTH 2

 static struct mtd_info *bcm47xx_mtd;

+static struct timer_list hwwdt_timer;
+
+static void bcm47xx_hwwdt_timer_tick(unsigned long unused)
+{
+int ret;
+//  printk(KERN_INFO "bcm47xx_timer_tick() called\n");
+
+ret = gpio_request(7, "test");
+//printk(KERN_INFO "gpio_request(7)  ret = %i\n", ret);
+
+ret = gpio_direction_input(7);
+//  printk(KERN_INFO "gpio_direction_input(7)  ret = %i\n", ret);
+ret = gpio_get_value(7);
+//  printk(KERN_INFO "gpio_get_value(7)  ret = %i\n", ret);
+
+ret = gpio_direction_output(7, ret ? 0 : 1);
+//  printk(KERN_INFO "gpio_direction_output(7, !ret)  ret = %i\n", 
ret);

+
+gpio_free(7);
+
+   mod_timer(&hwwdt_timer, jiffies + HZ/5);
+}
+
 static void bcm47xx_map_copy_from(struct map_info *map, void *to, 
unsigned long from, ssize_t len)

 {
if (len == 1) {
@@ -91,6 +117,10 @@
struct mtd_partition *partitions = NULL;
int num_partitions = 0;

+   pr_notice("starting hardware watchdog reset timer (for Huawei 
E970 devices)\n");

+   setup_timer(&hwwdt_timer, bcm47xx_hwwdt_timer_tick, 0L);
+   bcm47xx_hwwdt_timer_tick(0);
+
switch (bcm47xx_bus_type) {
 #ifdef CONFIG_BCM47XX_SSB
case BCM47XX_BUS_TYPE_SSB:
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Where to place code to reset a watchdog?

2011-12-04 Thread Mathias Adam

Hi,

I just got OpenWrt running on a Huawei E970 wireless gateway (in my 
case, labelled as T-Mobile web'n'walk Box IV).


The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
For reference, it has already been addressed in this open ticket:
<https://dev.openwrt.org/ticket/2711>

However, the device has a hardware watchdog which needs GPIO7 to be 
toggled regularly. Otherwise, the device simply resets after 2-3 secs, 
so I wasn't even able to boot into OpenWrt at first.


As a quick fix I put together a small kernel patch which adds a timer to 
regularly perform the GPIO toggle. While this does work for me, I think 
it could need some cleanup... perhaps, is there already an 
infrastructure related to platform-/board-specific watchdogs where this 
could be attached to?


Are there other devices already supported by OpenWrt with a similar 
watchdog?


(I've also posted to the forum: 
<https://forum.openwrt.org/viewtopic.php?pid=150278#p150278> but didn't 
get any answers, hope it's better suited here...)


Regards,
Mathias Adam
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel