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

login
register
Submitter Mathias Adam
Date 2012-10-14 20:13:48
Message ID <20121014201348.GA16431@alpha.inft.de>
Download mbox | patch
Permalink /patch/2749/
State Superseded
Delegated to: Hauke Mehrtens
Headers show

Comments

Mathias Adam - 2012-10-14 20:13:48
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 <m.adam--openwrt@adamis.de>

---

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
Rafał Miłecki - 2012-10-15 15:57:35
2012/10/14 Mathias Adam <m.adam--openwrt@adamis.de>:
> 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.
Mathias Adam - 2012-10-15 16:41:05
Am Mo, 15.10.2012, 17:57 schrieb Rafał Miłecki:
> 2012/10/14 Mathias Adam <m.adam--openwrt@adamis.de>:
>> 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
Rafał Miłecki - 2012-10-15 17:17:26
2012/10/15 Mathias Adam <m.adam--openwrt@adamis.de>:
> Am Mo, 15.10.2012, 17:57 schrieb Rafał Miłecki:
>> 2012/10/14 Mathias Adam <m.adam--openwrt@adamis.de>:
>>> 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).

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
Mathias Adam - 2012-11-11 20:38:44
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 <m.adam--openwrt@adamis.de>
>
> ---
>
> 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 0x20000 -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 0000000..2d83d24
> --- /dev/null
> +++ b/target/linux/brcm47xx/patches-3.3/830-huawei_e970_support.patch
> @@ -0,0 +1,120 @@
> +--- a/arch/mips/bcm47xx/time.c
> ++++ b/arch/mips/bcm47xx/time.c
> +@@ -25,9 +25,75 @@
> +
> + #include <linux/init.h>
> + #include <linux/ssb/ssb.h>
> ++#include <linux/gpio.h>
> + #include <asm/time.h>
> ++#include <asm/mach-bcm47xx/nvram.h>
> + #include <bcm47xx.h>
> +
> ++#define ROUTER_HUAWEI_E970		1
> ++
> ++#define E970_GPIO_WDT_INTERVAL		HZ
> ++#define E970_GPIO_WDT_PIN		7
> ++
> ++
> ++static struct bcm47xx_gpiowdt {
> ++	struct timer_list timer;
> ++	unsigned long interval;
> ++	unsigned gpio;
> ++	int gstate;
> ++} bcm47xx_gpiowdt;
> ++
> ++
> ++static void bcm47xx_gpiowdt_timer_tick(unsigned long unused)
> ++{
> ++	bcm47xx_gpiowdt.gstate = !bcm47xx_gpiowdt.gstate;
> ++	gpio_set_value(bcm47xx_gpiowdt.gpio, bcm47xx_gpiowdt.gstate);
> ++
> ++	mod_timer(&bcm47xx_gpiowdt.timer, jiffies + bcm47xx_gpiowdt.interval);
> ++}
> ++
> ++static void bcm47xx_gpiowdt_setup(unsigned long interval, unsigned gpio)
> ++{
> ++	int ret;
> ++
> ++	bcm47xx_gpiowdt.interval = interval;
> ++	bcm47xx_gpiowdt.gpio = gpio;
> ++	bcm47xx_gpiowdt.gstate = 1;
> ++
> ++	ret = gpio_request(bcm47xx_gpiowdt.gpio, "bcm47xx-gpio-wdt");
> ++	if (ret < 0) {
> ++		printk(KERN_INFO "bcm47xx: failed to request gpio\n");
> ++		return;
> ++	}
> ++	ret = gpio_direction_output(bcm47xx_gpiowdt.gpio,
> bcm47xx_gpiowdt.gstate);
> ++	if (ret < 0) {
> ++		printk(KERN_INFO "bcm47xx: failed to set gpio as output\n");
> ++		return;
> ++	}
> ++
> ++	setup_timer(&bcm47xx_gpiowdt.timer, bcm47xx_gpiowdt_timer_tick, 0L);
> ++	bcm47xx_gpiowdt_timer_tick(0);
> ++}
> ++
> ++static int get_router(void)
> ++{
> ++	char buf[20];
> ++	u32 boardnum = 0;
> ++	u16 boardtype = 0;
> ++
> ++	if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
> ++		boardnum = simple_strtoul(buf, NULL, 0);
> ++	if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
> ++		boardtype = simple_strtoul(buf, NULL, 0);
> ++
> ++	if (boardnum == 0x5347 && boardtype == 0x048e) {
> ++		/* Huawei E970 */
> ++                return ROUTER_HUAWEI_E970;
> ++	}
> ++
> ++	return 0;
> ++}
> ++
> + void __init plat_time_init(void)
> + {
> + 	unsigned long hz = 0;
> +@@ -57,4 +123,11 @@ void __init plat_time_init(void)
> +
> + 	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
> + 	mips_hpt_frequency = hz;
> ++
> ++	/* device-specific initializations */
> ++	switch (get_router()) {
> ++	case ROUTER_HUAWEI_E970:
> ++		printk(KERN_INFO "bcm47xx: detected Huawei E970, starting gpio
> watchdog pet timer\n");
> ++		bcm47xx_gpiowdt_setup(E970_GPIO_WDT_INTERVAL, E970_GPIO_WDT_PIN);
> ++	}
> + }
> +--- a/drivers/mtd/bcm47xxpart.c
> ++++ b/drivers/mtd/bcm47xxpart.c
> +@@ -84,6 +84,7 @@ struct trx_header {
> + #define ROUTER_NETGEAR_WNR3500L		4
> + #define ROUTER_SIMPLETECH_SIMPLESHARE	5
> + #define ROUTER_NETGEAR_WNDR3400		6
> ++#define ROUTER_HUAWEI_E970		7
> +
> + static int
> + find_cfe_size(struct mtd_info *mtd)
> +@@ -405,6 +406,11 @@ static int get_router(void)
> + 		return ROUTER_SIMPLETECH_SIMPLESHARE;
> + 	}
> +
> ++	if (boardnum == 0x5347 && boardtype == 0x048e) {
> ++		/* Huawei E970 */
> ++                return ROUTER_HUAWEI_E970;
> ++	}
> ++
> + 	return 0;
> + }
> +
> +@@ -446,6 +452,7 @@ static int parse_bcm47xx_partitions(stru
> + 		case ROUTER_NETGEAR_WNDR3300:
> + 		case ROUTER_NETGEAR_WNR3500L:
> + 		case ROUTER_NETGEAR_WNDR3400:
> ++		case ROUTER_HUAWEI_E970:
> + 			/* Netgear: checksum is @ 0x003AFFF8 for 4M flash or checksum
> + 			 * is @ 0x007AFFF8 for 8M flash
> + 			 */
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>
>
Hauke Mehrtens - 2012-12-13 19:45:39
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 <m.adam--openwrt@adamis.de>
>>
>> ---
>>
>> 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?

Hauke
Hauke Mehrtens - 2012-12-13 19:55:24
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.
>>
>>  		!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.

Hauke
Florian Fainelli - 2012-12-13 19:59:22
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
Hauke Mehrtens - 2012-12-13 21:49:19
On 12/13/2012 08:59 PM, Florian Fainelli wrote:
> 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
Hi Mathias,

is it possible to deactivate the watchdog for e.g. 30 seconds?
where do I find the GPL source code for the original firmware of the
Huawei E970?

Hauke
Mathias Adam - 2012-12-17 14:10:20
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
<https://lists.openwrt.org/pipermail/openwrt-devel/2011-December/013159.html>)

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
Mathias Adam - 2012-12-17 21:05:10
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

Patch

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 0x20000 -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 0000000..2d83d24
--- /dev/null
+++ b/target/linux/brcm47xx/patches-3.3/830-huawei_e970_support.patch
@@ -0,0 +1,120 @@ 
+--- a/arch/mips/bcm47xx/time.c
++++ b/arch/mips/bcm47xx/time.c
+@@ -25,9 +25,75 @@
+ 
+ #include <linux/init.h>
+ #include <linux/ssb/ssb.h>
++#include <linux/gpio.h>
+ #include <asm/time.h>
++#include <asm/mach-bcm47xx/nvram.h>
+ #include <bcm47xx.h>
+ 
++#define ROUTER_HUAWEI_E970		1
++
++#define E970_GPIO_WDT_INTERVAL		HZ
++#define E970_GPIO_WDT_PIN		7
++
++
++static struct bcm47xx_gpiowdt {
++	struct timer_list timer;
++	unsigned long interval;
++	unsigned gpio;
++	int gstate;
++} bcm47xx_gpiowdt;
++
++
++static void bcm47xx_gpiowdt_timer_tick(unsigned long unused)
++{
++	bcm47xx_gpiowdt.gstate = !bcm47xx_gpiowdt.gstate;
++	gpio_set_value(bcm47xx_gpiowdt.gpio, bcm47xx_gpiowdt.gstate);
++
++	mod_timer(&bcm47xx_gpiowdt.timer, jiffies + bcm47xx_gpiowdt.interval);
++}
++
++static void bcm47xx_gpiowdt_setup(unsigned long interval, unsigned gpio)
++{
++	int ret;
++
++	bcm47xx_gpiowdt.interval = interval;
++	bcm47xx_gpiowdt.gpio = gpio;
++	bcm47xx_gpiowdt.gstate = 1;
++
++	ret = gpio_request(bcm47xx_gpiowdt.gpio, "bcm47xx-gpio-wdt");
++	if (ret < 0) {
++		printk(KERN_INFO "bcm47xx: failed to request gpio\n");
++		return;
++	}
++	ret = gpio_direction_output(bcm47xx_gpiowdt.gpio, bcm47xx_gpiowdt.gstate);
++	if (ret < 0) {
++		printk(KERN_INFO "bcm47xx: failed to set gpio as output\n");
++		return;
++	}
++
++	setup_timer(&bcm47xx_gpiowdt.timer, bcm47xx_gpiowdt_timer_tick, 0L);
++	bcm47xx_gpiowdt_timer_tick(0);
++}
++
++static int get_router(void)
++{
++	char buf[20];
++	u32 boardnum = 0;
++	u16 boardtype = 0;
++
++	if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
++		boardnum = simple_strtoul(buf, NULL, 0);
++	if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
++		boardtype = simple_strtoul(buf, NULL, 0);
++
++	if (boardnum == 0x5347 && boardtype == 0x048e) {
++		/* Huawei E970 */
++                return ROUTER_HUAWEI_E970;
++	}
++
++	return 0;
++}
++
+ void __init plat_time_init(void)
+ {
+ 	unsigned long hz = 0;
+@@ -57,4 +123,11 @@ void __init plat_time_init(void)
+ 
+ 	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
+ 	mips_hpt_frequency = hz;
++
++	/* device-specific initializations */
++	switch (get_router()) {
++	case ROUTER_HUAWEI_E970:
++		printk(KERN_INFO "bcm47xx: detected Huawei E970, starting gpio watchdog pet timer\n");
++		bcm47xx_gpiowdt_setup(E970_GPIO_WDT_INTERVAL, E970_GPIO_WDT_PIN);
++	}
+ }
+--- a/drivers/mtd/bcm47xxpart.c
++++ b/drivers/mtd/bcm47xxpart.c
+@@ -84,6 +84,7 @@ struct trx_header {
+ #define ROUTER_NETGEAR_WNR3500L		4
+ #define ROUTER_SIMPLETECH_SIMPLESHARE	5
+ #define ROUTER_NETGEAR_WNDR3400		6
++#define ROUTER_HUAWEI_E970		7
+ 
+ static int
+ find_cfe_size(struct mtd_info *mtd)
+@@ -405,6 +406,11 @@ static int get_router(void)
+ 		return ROUTER_SIMPLETECH_SIMPLESHARE;
+ 	}
+ 
++	if (boardnum == 0x5347 && boardtype == 0x048e) {
++		/* Huawei E970 */
++                return ROUTER_HUAWEI_E970;
++	}
++
+ 	return 0;
+ }
+ 
+@@ -446,6 +452,7 @@ static int parse_bcm47xx_partitions(stru
+ 		case ROUTER_NETGEAR_WNDR3300:
+ 		case ROUTER_NETGEAR_WNR3500L:
+ 		case ROUTER_NETGEAR_WNDR3400:
++		case ROUTER_HUAWEI_E970:
+ 			/* Netgear: checksum is @ 0x003AFFF8 for 4M flash or checksum
+ 			 * is @ 0x007AFFF8 for 8M flash
+ 			 */