OpenWrt Forum Archive

Topic: WNDR3700 exploration

The content of this topic has been archived between 1 Oct 2014 and 7 May 2018. Unfortunately there are posts – most likely complete pages – missing.

whiskas wrote:

@all:
Does nobody else have this router? There is absolutely NO BRICKING RISK since we're only running ramdisk-images (if i not specifically interrupt the bootup, the router loads the netgear firmware). Also if you do not solder or rampage inside your router, you STILL HAVE WARRANTY. The serial-cable is easily built with a connector for the serial header, the screws are right under the rubber feet. Even the environment-args in uboot are not saved until one specifically calls 'saveenv'.

I don't, unfortunately. I'm still running on 802.11g hardware for the moment and I have other financial priorities than upgrading my WLAN, as much as I'd love to.

I get my unit this afternoon, so I will definitely do some poking around. Have to make an impromptu serial cable tonight!

UPDATE

@whiskas

I'm currently at the point you've lead up to so far. My homemade serial logic-level converter works well, using a nice two-transistor design. I have a base ramdisk image running and more experimentation is pending...

(Last edited by vexingviking on 1 Nov 2009, 02:56)

Another success! I got one of the LAN-ports working!

I'll sort out the settings and files needed and post them here soon.

Edit:

--- trunk/target/linux/ar71xx/base-files/lib/ar71xx.sh~    2009-10-08 11:54:10.000000000 +0200
+++ trunk/target/linux/ar71xx/base-files/lib/ar71xx.sh    2009-11-03 12:11:35.000000000 +0100
@@ -70,6 +70,9 @@
     *WRT160NL)
         name="wrt160nl"
         ;;
+    *WNDR3700)
+        name="wndr3700"
+        ;;
     *WRT400N)
         name="wrt400n"
         ;;
--- trunk/target/linux/ar71xx/config-2.6.30~    2009-11-03 17:44:01.000000000 +0100
+++ trunk/target/linux/ar71xx/config-2.6.30    2009-11-03 18:11:12.000000000 +0100
@@ -19,6 +19,7 @@
 CONFIG_AR71XX_MACH_WNR2000=y
 CONFIG_AR71XX_MACH_WP543=y
 CONFIG_AR71XX_MACH_WRT160NL=y
+CONFIG_AR71XX_MACH_WNDR3700=y
 CONFIG_AR71XX_MACH_WRT400N=y
 CONFIG_AR71XX_WDT=y
 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
--- trunk/target/linux/ar71xx/config-2.6.31~    2009-11-03 17:44:01.000000000 +0100
+++ trunk/target/linux/ar71xx/config-2.6.31    2009-11-03 18:11:36.000000000 +0100
@@ -21,6 +21,7 @@
 CONFIG_AR71XX_MACH_WNR2000=y
 CONFIG_AR71XX_MACH_WP543=y
 CONFIG_AR71XX_MACH_WRT160NL=y
+CONFIG_AR71XX_MACH_WNDR3700=y
 CONFIG_AR71XX_MACH_WRT400N=y
 CONFIG_AR71XX_WDT=y
 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
--- trunk/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig~    2009-11-03 17:44:00.000000000 +0100
+++ trunk/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig    2009-11-03 18:12:16.000000000 +0100
@@ -35,6 +35,10 @@
     bool "Linksys WRT160NL board support"
     default y
 
+config AR71XX_MACH_WNDR3700
+    bool "Netgear WNDR3700 board support"
+    default y
+
 config AR71XX_MACH_WRT400N
     bool "Linksys WRT400N board support"
     default y
--- trunk/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile~    2009-11-03 17:44:00.000000000 +0100
+++ trunk/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile    2009-11-03 18:12:38.000000000 +0100
@@ -29,4 +29,5 @@
 obj-$(CONFIG_AR71XX_MACH_WNR2000)    += mach-wnr2000.o
 obj-$(CONFIG_AR71XX_MACH_WP543)        += mach-wp543.o
 obj-$(CONFIG_AR71XX_MACH_WRT160NL)    += mach-wrt160nl.o
+obj-$(CONFIG_AR71XX_MACH_WNDR3700)    += mach-wndr3700.o
 obj-$(CONFIG_AR71XX_MACH_WRT400N)    += mach-wrt400n.o
--- trunk/target/linux/ar71xx/files/arch/mips/ar71xx/prom.c~    2009-11-03 18:06:57.000000000 +0100
+++ trunk/target/linux/ar71xx/files/arch/mips/ar71xx/prom.c    2009-11-03 18:13:31.000000000 +0100
@@ -92,6 +92,9 @@
         .name        = "WRT160NL",
         .mach_type    = AR71XX_MACH_WRT160NL,
     }, {
+        .name        = "WNDR3700",
+        .mach_type    = AR71XX_MACH_WNDR3700,
+    }, {
         .name        = "WP543",
         .mach_type    = AR71XX_MACH_WP543,
     }, {
--- trunk/target/linux/ar71xx/files/arch/mips/include/asm/mach-ar71xx/ar71xx.h~    2009-11-03 17:44:00.000000000 +0100
+++ trunk/target/linux/ar71xx/files/arch/mips/include/asm/mach-ar71xx/ar71xx.h    2009-11-03 18:14:05.000000000 +0100
@@ -144,6 +144,7 @@
     AR71XX_MACH_WNR2000,    /* NETGEAR WNR2000 */
     AR71XX_MACH_WP543,    /* Compex WP543 */
     AR71XX_MACH_WRT160NL,    /* Linksys WRT160NL */
+    AR71XX_MACH_WNDR3700,    /* Netgear WNDR3700 */
     AR71XX_MACH_WRT400N,    /* Linksys WRT400N */
 };

This was basically what juhosg changed to introduce the wrt160nl here.

Now two new files: trunk/target/linux/ar71xx/profiles/netgear.mk

#
# Copyright (C) 2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

define Profile/WNDR3700
    NAME:=Netgear WNDR3700
    PACKAGES:=kmod-ath9k hostapd-mini kmod-usb-core kmod-usb-ohci kmod-usb2 swconfig
endef

define Profile/WNDR3700/Description
    Package set optimized for the Netgear WNDR3700.
endef

$(eval $(call Profile,WNDR3700))

trunk/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c

/*
 *  Netgear WNDR3700 board support
 *
 *  Copyright (C) 2009 Marco Porsch
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License version 2 as published
 *  by the Free Software Foundation.
 */

#include <linux/platform_device.h>
//#include <linux/mtd/mtd.h>
//#include <linux/mtd/partitions.h>
//#include <linux/spi/spi.h>
//#include <linux/spi/flash.h>
#include <linux/input.h>

#include <asm/mips_machine.h>
#include <asm/mach-ar71xx/ar71xx.h>

#include "devices.h"

static void __init wndr3700_setup(void)
{
    ar71xx_add_device_mdio(0x0);

    ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
    ar71xx_eth0_data.phy_mask = 0xf;
    ar71xx_eth0_data.speed = SPEED_1000;
    ar71xx_eth0_data.duplex = DUPLEX_FULL;

    ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
    ar71xx_eth1_data.phy_mask = 0x10;

    ar71xx_add_device_eth(0);
    ar71xx_add_device_eth(1);

    //ar71xx_add_device_usb();
    //ar91xx_add_device_wmac();
}

MIPS_MACHINE(AR71XX_MACH_WNDR3700, "Netgear WNDR3700", wndr3700_setup);

After this, the WNDR3700 target should show up in menuconfig and should be recognized with the correct bootarg.

(Last edited by whiskas on 3 Nov 2009, 19:43)

whiskas wrote:

Another success! I got one of the LAN-ports working!

Excellent news!

I applied your patch and now have eth0, eth1, and br-lan interfaces. Is this actually for one of the LAN ports, or is it the one WAN port? I expected the LAN ports would all depend on a driver for the rtl8366sr switch. I would like to help in getting the rtl8366sr hardware working, but I need more familiarity with OpenWRT. Could it just be a matter of adapting the OpenWRT build system for the U-Boot rtl8366sr driver included in some vendor firmware packages such as Belkin's F5D8235v2-2.01.07-GPL.tar.gz?

I think, that every network device has a kind of general interface, by which it can be used for a network boot or other simple functions. Another thing will be the network switching and throughput for LAN-WAN. This is what a driver is needed for. For this driver a skilled programmer will know how to use the various sources included in the vendor packages.
For now i'm quiet fine with the basic functions of the LAN. I'm curious, if it will also be this easy to activate the pci-devices. Once recognized, these should be supported by the ath9k-driver. At least i hope so wink

By playing around with ping, it seemed to me, that only the LAN-port works; don't know, what is needed for the WAN.

(Last edited by whiskas on 4 Nov 2009, 11:11)

I found something interesting here. This seems to be the sourcecode of one of the modules used in the stock firmware: ag7100-mod.ko. Dunno what it is used for though..

Edit: there is a thread on this topic. I guess the code is now included in the ar71xx-tree.

(Last edited by whiskas on 4 Nov 2009, 16:46)

Weird.. after appying the following patch, i get pci-devices..

--- trunk/build_dir/linux-ar71xx/linux-2.6.30.9/arch/mips/ar71xx/mach-wndr3700.c    2009-11-05 13:08:53.000000000 +0100
+++ trunk/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c    2009-11-05 13:08:25.000000000 +0100
@@ -14,12 +14,25 @@
 //#include <linux/spi/spi.h>
 //#include <linux/spi/flash.h>
 #include <linux/input.h>
+#include <asm/mach-ar71xx/pci.h>
 
 #include <asm/mips_machine.h>
 #include <asm/mach-ar71xx/ar71xx.h>
 
 #include "devices.h"
 
+static struct ar71xx_pci_irq wndr3700_pci_irqs[] __initdata = {
+    {
+        .slot    = 0,
+        .pin    = 1,
+        .irq    = AR71XX_PCI_IRQ_DEV0,
+    }, {
+        .slot    = 1,
+        .pin    = 1,
+        .irq    = AR71XX_PCI_IRQ_DEV1,
+    }
+};
+
 static void __init wndr3700_setup(void)
 {
     ar71xx_add_device_mdio(0x0);
@@ -37,6 +50,8 @@
 
     ar71xx_add_device_usb();
     //ar91xx_add_device_wmac();
+
+    ar71xx_pci_init(ARRAY_SIZE(wndr3700_pci_irqs), wndr3700_pci_irqs);
 }
 
 MIPS_MACHINE(AR71XX_MACH_WNDR3700, "Netgear WNDR3700", wndr3700_setup);

But the devices are:

root@OpenWrt:/# cat proc/bus/pci/devices 
0000    07001107        0                      8                       1                       0                       0    0
0088    168cff1d        31              10000000                       0                       0                       0    0
0090    168cff1d        0               10010000                       0                       0                       0    0


root@OpenWrt:/# lspci 
00:00.0 Non-VGA unclassified device: Device 0700:1107 (rev 01)
00:11.0 Ethernet controller: Atheros Communications Inc. AR5008 Wireless Network Adapter (rev 01)
00:12.0 Ethernet controller: Atheros Communications Inc. AR5008 Wireless Network Adapter (rev 01)

Should be some AR9xxx with pci-id 168c:0029?! Whats wrong here?

dmesg says:

MIPS: machine is Netgear WNDR3700
registering PCI controller with io_map_base unsetpin
bio: create slab <bio-0> at 0
pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot
pci 0000:00:00.0: PME# disabled
PCI: mapping irq 48 to pin1@0000:00:11.0
PCI: mapping irq 50 to pin1@0000:00:12.0

I get the IRQs only with these settings, but the two AR5008s appear no matter whatever slot or pin i use.

(Last edited by whiskas on 5 Nov 2009, 19:25)

whiskas wrote:
root@OpenWrt:/# lspci 
00:00.0 Non-VGA unclassified device: Device 0700:1107 (rev 01)
00:11.0 Ethernet controller: Atheros Communications Inc. AR5008 Wireless Network Adapter (rev 01)
00:12.0 Ethernet controller: Atheros Communications Inc. AR5008 Wireless Network Adapter (rev 01)

Should be some AR9xxx with pci-id 168c:0029?! Whats wrong here?

I get the IRQs only with these settings, but the two AR5008s appear no matter whatever slot or pin i use.

Are you sure you're supposed to be getting AR9xxx? Check out this link: http://www.atheros.com/pt/AR5008Bulletins.htm

From some quick (5 minute) googling it looks like the AR9xxx series and the AR5008 are related.

Links:
http://www.atheros.com/pt/AR9002Bulletins.htm
http://www.atheros.com/pt/AR9001Bulletins.htm

Apparently the 9 series are the successors to the 5 series. Maybe the chips are announcing themselves as the preceding iteration? Is there any way to verify that the chip on the board is actually a 9 series? Or more exactly, to confirm that the PCI report for a 9 series isn't the same as what you're getting?

If I'm totally missing something then feel free to correct me. Thanks for all the work you're doing, it's great to see it coming along nicely!

entee wrote:

Are you sure you're supposed to be getting AR9xxx?

According to this, that PCI device ID, 168c:0029, should show up as "AR922X Wireless Network Adapter."

(Last edited by vexingviking on 8 Nov 2009, 22:25)

I just wrote a small C program to make an image with a patched header from a freshly built image.
Compile with gcc -o wndr3700 wndr3700.c
Basic usage is ./wndr3700 orig_file patched_file

Get it here : http://aorlinsk2.free.fr/openwrt/wndr3700/

It should be easy to integrate it in the toolchain and generate "ready to load in uboot via tftp" images (it looks like images to flash have a different header...)

aorlinsk wrote:

I just wrote a small C program to make an image with a patched header from a freshly built image.
Compile with gcc -o wndr3700 wndr3700.c
Basic usage is ./wndr3700 orig_file patched_file

Get it here : http://aorlinsk2.free.fr/openwrt/wndr3700/

It should be easy to integrate it in the toolchain and generate "ready to load in uboot via tftp" images (it looks like images to flash have a different header...)

I'm not clear on your program, does it achieve step 3.2 to 3.4 in post #11 automatically?

ratbug wrote:
aorlinsk wrote:

I just wrote a small C program to make an image with a patched header from a freshly built image.
Compile with gcc -o wndr3700 wndr3700.c
Basic usage is ./wndr3700 orig_file patched_file

Get it here : http://aorlinsk2.free.fr/openwrt/wndr3700/

It should be easy to integrate it in the toolchain and generate "ready to load in uboot via tftp" images (it looks like images to flash have a different header...)

I'm not clear on your program, does it achieve step 3.2 to 3.4 in post #11 automatically?

Yes, steps 3.1 to 3.4.
Basic usage is ./wndr3700 openwrt-ar71xx-uImage-lzma.bin openwrt-ar71xx-uImage-lzma-wndr3700.bin

@ entee & vexingviking:
To be absolutely sure we would need to see some photos of the hardware with the antenna foils removed (FCC photos or something alike). But since smallnetbuilder and the stock firmware relate to a 92xx chipset, i am quiet sure it should not be the 5008. You are right, the 5008 is the predecessor of the 9xxx chipsets. The 5008 was the first atheros draft-n chipset. But the pci-id 168c:0029 should really give "AR922X Wireless Network Adapter", but the stock firmware said 9280. Strange..

@ aorlinsk:
Thanks! Works great! I've grown tired of typing the number and checksum by hand, but was too lazy/stupid to write a script myself wink


Right now i have edited the first lines of "linux-2.6.xx.x/drivers/net/wireless/ath9k/pci.c" to accept the ID "ff1d". But the OS hangs without any output as soon as i insert the ath9k-module.

So is there a problem with ath9k or the PCI connection? Is there a way to test the function of a pci-device? Or some outputs of "lspci -vvvvxxx" that make it clear that the device is working?

(Last edited by whiskas on 9 Nov 2009, 12:04)

whiskas wrote:

So is there a problem with ath9k or the PCI connection? Is there a way to test the function of a pci-device? Or some outputs of "lspci -vvvvxxx" that make it clear that the device is working?

Maybe the system uses an AHB bus... an alternate to PCI. See this topic for more details : https://forum.openwrt.org/viewtopic.php?id=18113


For the rtl8366sr switch I went through various GPL distributions, and I am quite confident to get a full switch support :
- As seen in a previous post, in the linksys Uboot archive there is a file board/ar7100/wndr3700u/rtl8366s_phy.c. It looks like not to be the switch driver itself, but the driver to make the leds blink when there is activity on the network / show amber/green color on 1Gbps/100Mbps connections...
it can be useful though.

- In the Asus RT-N15 GPL archives, it looks like there is switch driver for linux kernel 2.4 (includes + src) : relevant files seems to be rtl8366s_api.c, rtl8366s_asicdrv.c ...  In the 2.4 kernel the switch is implemented as a char device. There is also a tool (and c source) called rtl8366 that seems to setup the switch through the char interface.

- In the Belkin F5D8235-4 GPL archive, the Uboot SDK provides the switch driver in Uboot_SDK_3200/drivers/rtl8366SR. The files have the same names of the ones found in the asus archives. I will have a closer look to this implementation, because Uboot seems to include lots of linux headers, and it could happen that the uboot driver being just the same as a linux one (see references to linux 2.6 in rmain.c).


I will have a try tonight of making kernel modules from those files...

I'm now quiet sure the problem is the pci system. I've tried both madwifi and ath9k with modified sources to accept the 5008. Both crashed:

PCI: Enabling device 0000:00:11.0 (0000 -> 0002)
ath9k 0000:00:11.0: failed to initialize device
ath9k: probe of 0000:00:11.0 failed with error -122
PCI: Enabling device 0000:00:12.0 (0000 -> 0002)
ath9k 0000:00:12.0: failed to initialize device
ath9k: probe of 0000:00:12.0 failed with error -122


ath_pci: trunk
PCI: Enabling device 0000:00:11.0 (0000 -> 0002)
Atheros HAL provided by OpenWrt, DD-WRT and MakSat Technologies
wifi0: unable to attach hardware: 'Hardware didn't respond as expected' (HAL status 3)
ath_pci: ath_attach failed: 6
PCI: Enabling device 0000:00:12.0 (0000 -> 0002)
Atheros HAL provided by OpenWrt, DD-WRT and MakSat Technologies
wifi0: unable to attach hardware: 'Hardware didn't respond as expected' (HAL status 3)
ath_pci: ath_attach failed: 6

But about the pci-thing i'm quiet out of ideas.. By the way, the WRT400N, which is the same hardware with different switch, suffers the same problem.

whiskas wrote:

To be absolutely sure we would need to see some photos of the hardware with the antenna foils removed (FCC photos or something alike).

Unfortunately, it looks like the FCC photos won't be too helpful. The photos are low resolution and the Atheros chip under the small black heatsink is too scuffed up to read, while the chips under the RF shielding are still covered.

(Last edited by vexingviking on 9 Nov 2009, 19:22)

I contacted Realtek regarding programming documentation for the gigabit switch chipset. Unfortunately, Realtek requires developers to sign non-disclosure agreements in exchange for any information. Since non-disclosure agreements are invariably harmful to the open-source community, this seems like a poor route. Let's hope the code from Belkin's UBoot SDK will be enough...

It seems u-boot has initialized the PCI, so kernel does not need to initialize it again.

I removed the PCI init code, and WNDR3700 PCI seems work normally.

diff --git a/target/linux/ar71xx/files/arch/mips/pci/pci-ar71xx.c b/target/linux/ar71xx/files/arch/mips/pci/pci-ar71xx.
index b2d36ca..4f63335 100644
--- a/target/linux/ar71xx/files/arch/mips/pci/pci-ar71xx.c
+++ b/target/linux/ar71xx/files/arch/mips/pci/pci-ar71xx.c
@@ -38,7 +38,7 @@
 
 static void __iomem *ar71xx_pcicfg_base;
 static DEFINE_SPINLOCK(ar71xx_pci_lock);
-static int ar71xx_pci_fixup_enable;
+static int ar71xx_pci_fixup_enable = 0;
 
 static inline void ar71xx_pci_delay(void)
 {
@@ -302,15 +302,13 @@ static struct pci_controller ar71xx_pci_controller = {
 
 int __init ar71xx_pcibios_init(void)
 {
+#if 0
        ar71xx_device_stop(RESET_MODULE_PCI_BUS | RESET_MODULE_PCI_CORE);
        ar71xx_pci_delay();
 
        ar71xx_device_start(RESET_MODULE_PCI_BUS | RESET_MODULE_PCI_CORE);
        ar71xx_pci_delay();
 
-       ar71xx_pcicfg_base = ioremap_nocache(AR71XX_PCI_CFG_BASE,
-                                               AR71XX_PCI_CFG_SIZE);
-
        ar71xx_ddr_wr(AR71XX_DDR_REG_PCI_WIN0, PCI_WIN0_OFFS);
        ar71xx_ddr_wr(AR71XX_DDR_REG_PCI_WIN1, PCI_WIN1_OFFS);
        ar71xx_ddr_wr(AR71XX_DDR_REG_PCI_WIN2, PCI_WIN2_OFFS);
@@ -326,6 +324,10 @@ int __init ar71xx_pcibios_init(void)
        (void)ar71xx_pci_be_handler(1);
 
        ar71xx_pci_fixup_enable = 1;
+#endif
+       ar71xx_pcicfg_base = ioremap_nocache(AR71XX_PCI_CFG_BASE,
+                                               AR71XX_PCI_CFG_SIZE);
+
        register_pci_controller(&ar71xx_pci_controller);
 
        return 0;

Here is the dump of /proc/bus/pci/devices with above change.

root@OpenWrt:/# cat /proc/bus/pci/devices 
0000    07001107        0           8              1             0             0             0               0             0                10000000             100                0                       0                       0                       0               0
0088    168c0029        30              10000000                       0                       0                      0                0                       0                       0                   10000 
              0                0                       0                       0                       0               0
0090    168c0029        31              10010000                       0                       0                       0                0                       0                       0                   10000 
              0                0                       0                       0                       0 
              0

I know this kind of patch is bad, but I've no idea how to make pci-ar71xx.c support both cases of PCI being initialized and not being initialized.

However, there is still unknown issue to cause ath9k unable to work on WND3700.

cfg80211: Regulatory domain: US
        (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
        (2402000 KHz - 2472000 KHz @ 40000 KHz), (600 mBi, 2700 mBm)
        (5170000 KHz - 5190000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
        (5190000 KHz - 5210000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
        (5210000 KHz - 5230000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
        (5230000 KHz - 5330000 KHz @ 40000 KHz), (600 mBi, 2300 mBm)
        (5735000 KHz - 5835000 KHz @ 40000 KHz), (600 mBi, 3000 mBm)
cfg80211: Calling CRDA for country: US
SCSI subsystem initialized
usbcore: registered new interface driver ar9170usb
ath9k 0000:00:11.0: failed to initialize device
ath9k: probe of 0000:00:11.0 failed with error -22
ath9k 0000:00:12.0: failed to initialize device
ath9k: probe of 0000:00:12.0 failed with error -22

BTW, below provide another way in target/linux/ar71xx/image/Makefile to create WNDR3700 firmware directly.

define Image/Build/WNDR3700
        cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(2)
        $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(2) '$(strip $(3))'
        $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux-$(2) $(KDIR)/vmlinux-$(2).7z
        mkimage -A mips -O linux -T kernel -C lzma -n "Linux Kernel Image" -a 0x80060000 -e $$$$(readelf -a $(KDIR)/vm\
linux.elf |grep "Entry"|cut -d":" -f 2) -d $(KDIR)/vmlinux-$(2).7z $(KDIR)/vmlinux-$(2).7z.uImage.stage1
        dd if=$(KDIR)/vmlinux-$(2).7z.uImage.stage1 of=$(KDIR)/vmlinux-$(2).7z.uImage.head1 bs=1 skip=8 count=56
        echo -n '3700' > $(KDIR)/vmlinux-$(2).7z.uImage.head2
        dd if=/dev/zero bs=4 count=1 >> $(KDIR)/vmlinux-$(2).7z.uImage.head2
        cat $(KDIR)/vmlinux-$(2).7z.uImage.head1 >> $(KDIR)/vmlinux-$(2).7z.uImage.head2
        (cd $(KDIR); rm -rf crca*)
        (cd $(KDIR); crc32 $(KDIR)/vmlinux-$(2).7z.uImage.head2 | split -b 2 - crc)
        echo -n '3700' > $(KDIR)/vmlinux-$(2).7z.uImage.head3
        (export CRCHEX=`cat $(KDIR)/crcaa`; export CRCOCT=`printf "%03o\n" 0x$$$$CRCHEX`; if [ $$$$CRCOCT = "000" ]; t\
hen dd if=/dev/zero bs=1 count=1 >> $(KDIR)/vmlinux-$(2).7z.uImage.head3; else echo -n -e '\0'$$$$CRCOCT >> $(KDIR)/vm\
linux-$(2).7z.uImage.head3; fi)
        (export CRCHEX=`cat $(KDIR)/crcab`; export CRCOCT=`printf "%03o\n" 0x$$$$CRCHEX`; if [ $$$$CRCOCT = "000" ]; t\
hen dd if=/dev/zero bs=1 count=1 >> $(KDIR)/vmlinux-$(2).7z.uImage.head3; else echo -n -e '\0'$$$$CRCOCT >> $(KDIR)/vm\
linux-$(2).7z.uImage.head3; fi)
        (export CRCHEX=`cat $(KDIR)/crcac`; export CRCOCT=`printf "%03o\n" 0x$$$$CRCHEX`; if [ $$$$CRCOCT = "000" ]; t\
hen dd if=/dev/zero bs=1 count=1 >> $(KDIR)/vmlinux-$(2).7z.uImage.head3; else echo -n -e '\0'$$$$CRCOCT >> $(KDIR)/vm\
linux-$(2).7z.uImage.head3; fi)
        (export CRCHEX=`cat $(KDIR)/crcad`; export CRCOCT=`printf "%03o\n" 0x$$$$CRCHEX`; if [ $$$$CRCOCT = "000" ]; t\
hen dd if=/dev/zero bs=1 count=1 >> $(KDIR)/vmlinux-$(2).7z.uImage.head3; else echo -n -e '\0'$$$$CRCOCT >> $(KDIR)/vm\
linux-$(2).7z.uImage.head3; fi)
        cat $(KDIR)/vmlinux-$(2).7z.uImage.head1 >> $(KDIR)/vmlinux-$(2).7z.uImage.head3
        cat $(KDIR)/vmlinux-$(2).7z.uImage.head3 > $(KDIR)/vmlinux-$(2).7z.uImage
        dd if=$(KDIR)/vmlinux-$(2).7z.uImage.stage1 bs=64 skip=1 >> $(KDIR)/vmlinux-$(2).7z.uImage
        cp -f $(KDIR)/vmlinux-$(2).7z.uImage /home/spencer/sshfs/sun/tftpboot/
        ( \                                                                                                            
                dd if=$(KDIR)/vmlinux-$(2).7z.uImage bs=896k conv=sync; \                                              
                dd if=$(KDIR)/root.$(1); \
        ) > $(call imgname,$(1),$(2)).bin;
endef

Thank you yjchang! This is great news! You are my hero of the day smile

Lets get on..
Still neither ath9k nor modified madwifi activate wireless:

ath_pci: trunk
Atheros HAL provided by OpenWrt, DD-WRT and MakSat Technologies
wifi0: unable to attach hardware: 'No hardware present or device not yet supported' (HAL status 1)
ath_pci: ath_attach failed: 6
Atheros HAL provided by OpenWrt, DD-WRT and MakSat Technologies
wifi0: unable to attach hardware: 'No hardware present or device not yet supported' (HAL status 1)
ath_pci: ath_attach failed: 6

However now these lines are missing:

PCI: Enabling device 0000:00:11.0 (0000 -> 0002)

...

PCI: Enabling device 0000:00:12.0 (0000 -> 0002)

I don't know, whether this is normal, or we commented out a bit too much.

If PCI is ok, our next target will be ath9k. We should take a look into their mailing-list or write to them about this.

I have traced the error so far:

trunk/build_dir/linux-ar71xx/compat-wireless-2009-08-20/drivers/net/wireless/ath/ath9k/eeprom.c
in function 'ath9k_hw_eeprom_init' default eeprom is chosen
->
trunk/build_dir/linux-ar71xx/compat-wireless-2009-08-20/drivers/net/wireless/ath/ath9k/eeprom_def.c
in function 'ath9k_hw_def_check_eeprom' a magic number 0x00 is read (instead of 0xA55A or 0x5AA5) which returns error code 22 (invalid)

I've printed out the further 'contents' of the eeprom/nvram but all is just zeros. Same for '4k' and 'AR9287' eeprom profile.

Hm.. does this design have a different eeprom reading procedure, or is the eeprom/nvram just uninitialized/unaccessible due to PCI-problems?

Nice to see some work being done on this, I was hoping that at some point in future would be able to get more uptodate openwrt on as I've got one of these myself, but alas I can't really experiment due to it needing to stay 'up' for rest of family

ath9k seems try to get calibration data from eeprom when the device is connected via PCI.
However, on WNDR3700, the calibration data is saved in flash instead of in eeprom, so ath9k initialize failed on WNDR3700.

I've done some changes on openwrt and ath9k driver to make ath9k get calibration from flash.

in openwrt, base on trunk@18066

diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c
index 90869a8..a009f74 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c
@@ -772,6 +772,26 @@ void __init ar91xx_add_device_wmac(void)
     platform_device_register(&ar91xx_wmac_device);
 }
 
+static struct ath9k_platform_data ar71xx_wmac_data;
+
+static struct platform_device ar71xx_wmac_device = {
+    .name        = "ath9k_flashcalc",
+    .id        = -1,
+    .dev = {
+        .platform_data = &ar71xx_wmac_data,
+    },
+};
+
+void __init ar71xx_add_device_wmac(unsigned int addr)
+{
+    u8 *ee = (u8 *) KSEG1ADDR(addr);
+
+    memcpy(ar71xx_wmac_data.eeprom_data, ee,
+           sizeof(ar71xx_wmac_data.eeprom_data));
+
+    platform_device_register(&ar71xx_wmac_device);
+}
+
 static struct platform_device ar71xx_dsa_switch_device = {
     .name        = "dsa",
     .id        = 0,
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.h b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.h
index 6c72126..23c4985 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.h
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.h
@@ -56,6 +56,8 @@ void ar71xx_add_device_wdt(void) __init;
 
 void ar91xx_add_device_wmac(void) __init;
 
+void ar71xx_add_device_wmac(unsigned int addr) __init;
+
 void ar71xx_add_device_dsa(unsigned int id,
                struct dsa_platform_data *d) __init;
 
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c
index ade34f6..2119d8d 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wndr3700.c
@@ -183,6 +183,8 @@ static void __init wndr3700_setup(void)
     ar71xx_add_device_usb();
 
     ar71xx_pci_init(ARRAY_SIZE(wndr3700_pci_irqs), wndr3700_pci_irqs);
+
+    ar71xx_add_device_wmac(0x1f7f1000);
 }
 
 MIPS_MACHINE(AR71XX_MACH_WNDR3700, "Netgear WNDR3700", wndr3700_setup);

in ath9k, base on compat-wireless-2009-10-09

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 13dd020..0529c8b 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -561,6 +561,7 @@ struct ath_softc {
     struct tasklet_struct bcon_tasklet;
     struct ath_hw *sc_ah;
     void __iomem *mem;
+    u16 *cal_data;
     int irq;
     spinlock_t sc_resetlock;
     spinlock_t sc_serial_rw;
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 63059b6..b751927 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -15,6 +15,8 @@
  */
 
 #include <linux/nl80211.h>
+#include <linux/ath9k_platform.h>
+#include <linux/platform_device.h>
 #include <linux/pci.h>
 #include "ath9k.h"
 
@@ -62,6 +64,12 @@ static void ath_pci_cleanup(struct ath_common *common)
 static bool ath_pci_eeprom_read(struct ath_common *common, u32 off, u16 *data)
 {
     struct ath_hw *ah = (struct ath_hw *) common->ah;
+    struct ath_softc *sc = (struct ath_softc *) common->priv;
+
+    if (sc->cal_data){
+        *data = sc->cal_data[off];
+        return true;
+    }
 
     common->ops->read(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
 
@@ -103,6 +111,22 @@ const static struct ath_bus_ops ath_pci_bus_ops = {
     .bt_coex_prep = ath_pci_bt_coex_prep,
 };
 
+static int ath_set_cal_data(struct ath_softc *sc)
+{
+    struct device *d;
+    struct platform_device *pd;
+    struct ath9k_platform_data *pdata;
+
+    d = bus_find_device_by_name(&platform_bus_type, NULL, "ath9k_flashcalc");
+    if (d){
+        pd = to_platform_device(d);
+        pdata = (struct ath9k_platform_data *) pd->dev.platform_data;
+        sc->cal_data = pdata->eeprom_data;
+    }else{
+        sc->cal_data = NULL;
+    }
+}
+
 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
     void __iomem *mem;
@@ -200,6 +224,7 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
     sc->dev = &pdev->dev;
     sc->mem = mem;
 
+    ath_set_cal_data(sc);
     pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsysid);
     ret = ath_init_device(id->device, sc, subsysid, &ath_pci_bus_ops);
     if (ret) {

whiskas, maybe you will fail on using the patches since our version of openwrt or ath9k driver is not synced. but I think you can get the idea of what I've done.

But, there are still some other issues. I can not make wireless station connect to WNDR3700 even the interfaces are up. sad

(Last edited by yjchang on 12 Nov 2009, 11:38)

By the way do you have some tips to avoid a full kernel rebuild after each code change ?

At the moment I do "make target/linux/clean && make" to use my changes, but this is quite long....
I've seen the targets "target/linux/update" and "target/linux/refresh" but I have no idea how to use them.

Actually, after I modified file in build_dir/linux-ar71xx/linux-2.6.30.8 I do "make" directly, and then only the modified file would be rebuilt.
I am not sure if this is a right way, but at least it works well for me. smile