Porting WNDR4300 to ath79

Iā€™m guessing this is some SoC-specific NAND driver, as nothing has happened of consequence in months on

(That PR also solves many sysupgrade problems with ar71xx and ath79 related to NAND.)

Yes, this is SoC-specific driver, WNDR4300 has flash memory attached to this subsystem instead of usual SPI solution.

1 Like

@realmicu

Would you be able to test your WNDR4300 build using the changes in PR 2184, or at least examine the kernel config?

In that PR, I've cleaned up the cruft from the long-stale kernel config and just rebased to include

CONFIG_MTD_NAND_AR934X=y

Much of what was in that config I found to be either deprecated, obsolete, or unnecessary. However, I can't confirm what is needed for the NAND driver for the AR934x (as I don't know if it is using software ECC), such as

CONFIG_BCH=y
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_BCH=y
CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_NAND_ECC_BCH=y

Clearly obsolete, as not supported by the upstream SPI-NAND framework present in Linux 4.19 and later (which is required for OpenWrt acceptance of support for SPI NAND).

CONFIG_MTD_SPINAND_MT29F=y
CONFIG_MTD_SPINAND_ONDIEECC=y

While it wouldn't surprise me that

CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_ECC=y

are required, I don't know enough about the driver to make an informed decision on those, or the BCH-related ones.



Edit:

I do see in target/linux/ath79/dts/ar934x.dtsi

nand-ecc-mode = "hw";

so I suspect that the BCH code is not necessary at this time.



Current local, based on reading the driver and kconfig:

--- a/target/linux/ath79/nand/config-default
+++ b/target/linux/ath79/nand/config-default
@@ -1,7 +1,9 @@
 CONFIG_BLK_MQ_PCI=y
 CONFIG_LEDS_RESET=y
+CONFIG_MTD_NAND=y
 CONFIG_MTD_NAND_AR934X=y
 CONFIG_MTD_NAND_CORE=y
+CONFIG_MTD_NAND_ECC=y
 CONFIG_MTD_SPI_NAND=y
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_BLOCK=y

yielding

$ cat target/linux/ath79/nand/config-default 
CONFIG_BLK_MQ_PCI=y
CONFIG_LEDS_RESET=y
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_AR934X=y
CONFIG_MTD_NAND_CORE=y
CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_SPI_NAND=y
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_BLOCK=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_LIMIT=20
# CONFIG_MTD_UBI_FASTMAP is not set
# CONFIG_MTD_UBI_GLUEBI is not set
CONFIG_OF_ADDRESS_PCI=y
CONFIG_OF_PCI=y
CONFIG_OF_PCI_IRQ=y
CONFIG_PCI=y
# CONFIG_PCI_AR71XX is not set
CONFIG_PCI_AR724X=y
CONFIG_PCI_DISABLE_COMMON_QUIRKS=y
CONFIG_PCI_DOMAINS=y
# CONFIG_PHY_AR7100_USB is not set
CONFIG_PHY_AR7200_USB=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_UBIFS_FS=y
CONFIG_UBIFS_FS_ADVANCED_COMPR=y
CONFIG_UBIFS_FS_LZO=y
CONFIG_UBIFS_FS_ZLIB=y

PR comment added at https://github.com/openwrt/openwrt/pull/2184#pullrequestreview-304748885

Hello Jeff,

WNDR4300 works best with ECC set to HW.
I was curious enough to change ECC from hardware (default) to software but for either of supported SW mode (BCH or Hamming) there were ECC errors logged during boot process. Therefore, even though driver defaults to HW, I explicitly set this also in DTS as a hint.

Here's my config (pushed to openwrt-devel as a part of WNDR4300 patchset):

CONFIG_BCH=y
# CONFIG_MTD_CFI is not set
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_AR934X=y
CONFIG_MTD_NAND_BCH=y
CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_NAND_ECC_BCH=y
CONFIG_MTD_SPINAND_MT29F=y
CONFIG_MTD_SPINAND_ONDIEECC=y
# CONFIG_MTD_SPLIT_SEAMA_FW is not set
# CONFIG_MTD_SPLIT_TPLINK_FW is not set
# CONFIG_MTD_TPLINK_PARTS is not set
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_BEB_LIMIT=20
CONFIG_MTD_UBI_BLOCK=y
# CONFIG_MTD_UBI_FASTMAP is not set
# CONFIG_MTD_UBI_GLUEBI is not set
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_UBIFS_FS=y
# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
CONFIG_UBIFS_FS_LZO=y
CONFIG_UBIFS_FS_ZLIB=y
CONFIG_LZO_COMPRESS=y
CONFIG_LZO_DECOMPRESS=y
CONFIG_ZLIB_DEFLATE=y
CONFIG_ZLIB_INFLATE=y
# CONFIG_IP17XX_PHY is not set
# CONFIG_RTL8306_PHY is not set
# CONFIG_RTL8366_SMI is not set
CONFIG_BLK_MQ_PCI=y
CONFIG_PCI=y
CONFIG_PCI_DISABLE_COMMON_QUIRKS=y
CONFIG_PCI_DOMAINS=y
CONFIG_PCI_AR724X=y
# CONFIG_PCI_AR71XX is not set
# CONFIG_CAN_C_CAN_PCI is not set
# CONFIG_KSZ884X_PCI is not set
# CONFIG_NE2K_PCI is not set
# CONFIG_MISDN_HFCPCI is not set
# CONFIG_SERIAL_8250_PCI is not set
# CONFIG_SND_PCI is not set

("not set" PHY, SMI and PCI settings from above config are for keeping LZMA-compressed kernel size under 2 Megabytes)

I will test your config on my router, just please clarify that you want to include CONFIG_PHY_AR7200_USB directly in the kernel, as for now system builds it as part of kmod package.

Regards
Michal

1 Like

Thanks, removing it seems reasonable. It looks like they are all disabled in the "top-level" config on master at this time

target/linux/ath79/config-4.19

# CONFIG_PHY_AR7100_USB is not set
# CONFIG_PHY_AR7200_USB is not set
# CONFIG_PHY_ATH79_USB is not set

I'll remove from my config and test a build on the GL-AR300M and GL-AR750S when I'm back with the devices in hand and determine how best to manage the USB on the NAND variants, consistent with the existing "generic" builds.

Edit:

I didn't think I was losing my mind. They appear to be built into the "generic" target, but not the "tiny" target.

target/linux/ath79/generic/config-default

CONFIG_PHY_AR7100_USB=y
CONFIG_PHY_AR7200_USB=y

Fresh builds, remembering to remove ./tmp/ this time

1,959,688 from "my" config
1,948,137 removing "unneeded" kernel config
11,551 savings

2 MB = 2,097,152

I agree that there is going to be a problem in the not-too-distant future with devices that only permit a 2 MB kernel. 137,464 bytes (6.5%) isn't a lot of headroom and 149,015 isn't much better.

For reference, prior to the raw-NAND support, my NAND-aware kernel was running 1,920,760 bytes.

    ath79: NAND: disable some kernel options as per realmicu suggestions
    
    Did not remove CONFIG_UBIFS_FS_ADVANCED_COMPR=y
    
    Removed:
    
     # CONFIG_MTD_CFI is not set
     # CONFIG_MTD_SPLIT_SEAMA_FW is not set
     # CONFIG_MTD_SPLIT_TPLINK_FW is not set
     # CONFIG_MTD_TPLINK_PARTS is not set
     # CONFIG_IP17XX_PHY is not set
     # CONFIG_RTL8306_PHY is not set
     # CONFIG_RTL8366_SMI is not set
     # CONFIG_PCI_AR71XX is not set
     # CONFIG_CAN_C_CAN_PCI is not set
     # CONFIG_KSZ884X_PCI is not set
     # CONFIG_NE2K_PCI is not set
     # CONFIG_MISDN_HFCPCI is not set
     # CONFIG_SERIAL_8250_PCI is not set
     # CONFIG_SND_PCI is not set

Hi Jeff,

Tomorrow I will try to compile system with combined kernel config (changes yours and mine) minus software ECC.

I agree that there is going to be a problem in the not-too-distant future with devices that only permit a 2 MB kernel. 137,464 bytes (6.5%) isn't a lot of headroom and 149,015 isn't much better.

That's correct, for WNDR4300 I use Netgear GPL u-boot sources as reference. Apparently it does not limit compressed kernel (+fake rootfs) to 2 MB but I will test it anyway - one day it surely will grow over this number, especially when more NAND devices appear in ath79.

Cheers
Michal

1 Like

Hello Jeff,

My WNDR4300 works OK with following kernel config:

target/linux/ath79/nand/config-default:

CONFIG_LEDS_RESET=y
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_AR934X=y
CONFIG_MTD_NAND_CORE=y
CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_SPI_NAND=y
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_BEB_LIMIT=20
CONFIG_MTD_UBI_BLOCK=y
# CONFIG_MTD_UBI_FASTMAP is not set
# CONFIG_MTD_UBI_GLUEBI is not set
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_UBIFS_FS=y
CONFIG_UBIFS_FS_LZO=y
CONFIG_UBIFS_FS_ZLIB=y
CONFIG_UBIFS_FS_ADVANCED_COMPR=y
CONFIG_BLK_MQ_PCI=y
CONFIG_OF_ADDRESS_PCI=y
CONFIG_OF_PCI=y
CONFIG_OF_PCI_IRQ=y
CONFIG_PCI=y
CONFIG_PCI_DISABLE_COMMON_QUIRKS=y
CONFIG_PCI_DOMAINS=y
CONFIG_PCI_AR724X=y
# CONFIG_PCI_AR71XX is not set
# CONFIG_PHY_AR7100_USB is not set
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y

Amazingly, kernel is still under 2 MB so no need to change default partition layout in dts (probably recently upgraded toolchain helped a little).

Regards
Michal

2 Likes

Please submit patch thz

Hello,

It's already in master branch so you can use it without any further patching.

Regards
Michal

1 Like

Hello. I'm using ATH79 and it works great. Is there any information about the introduction to the stable version of 19.07?

Recently added devices probably won't be added to 19.07, which was branched six months ago. I still haven't read anything definitive about "20.01", but my guess is that the project isn't going to be anywhere close to their stated goal of releases every six months.

Yesterday I ported my old .config to the new ath79 target and now I'm successfully running a smooth master build. Thank you!

Once thing (I think) I noticed: There's not USB/uhci support in the default config? Or did it just get disabled with the oldconfig merging / target selection? I had to explicitly enable it to get the port working. If not-a-bug: sorry for the spam. :wink:

Anyways, great success, guys!

Hello!

Glad you enjoying this software!
On my WNDR4300 I hadn't any problems with USB - and AFAIK UHCI is for USB v1 on Intel chips only, not Atheros. USB support should come automatically with kmod-usb2 package in default install. Which config option exactly have you enabled to get your USB working ?

Regards
Micu

is it possible to add wndr4300sw to the list of profiles? the wndr4300sw is exactly the same hardware as the wndr4300v1 except for the board id. thank you and best regards.

Hi wrtboy,

Sure it is.

It is mentioned here Netgear WNDR4300 "SW" branded that this device has board id set to WNDR4300SW and that is the only difference. If you want to test original WNDR4300 build, you can set identification string to 'WNDR4300' from u-boot command line via 'board_hw_id_set' command:

board_model_id_set WNDR4300

Of course you can set it back to original value using the same method. Changing board id will let you upload WNDR4300 OpenWRT image via tftp.

Best regards!

hi realmicu,

i know a wndr4300 image works for the wndr4300sw because i had successfully tftp-ed a wndr4300 image with a modified header and checksum to a wndr4300. i thought perhaps it would be easier for other wndr4300sw owners for the sw variant to get its profile because many don't know how to modify the header and checksum. the thread Netgear WNDR4300 "SW" branded contains wrong information about burnboardid because i had telnet-ed into the original wndr4300sw firmware and the burnboardid command does not exist in the oem custom kamikaze wndr4300sw firmware. there is a 'set' command in the oem wndr4300sw firmware but the board id for the wndr4300sw is already set to wndr4300 and yet still it will not accept a wndr4300 image. i also think many users may not mess with serial cable to execute u-boot commands hence i think it would be easier to suggest wndr4300sw to get its own profile similar to wndr3800sw. wndr3800sw has its own profile in openwrt. just my 2 cents.

I have a wndr4300sw and somehow I managed to change it to a plain wndr4300 and now it accepts normal non-SW images. I don't know what I did, I tried many things in frustration and something did the trick! I want to say the most likely thing was to take the very first stock Netgear image for the non-SW version, I modified it by changing the signature and flashed it then I think I tried some of the set commands but not sure which. All of a sudden my device turned into a plain WNDR4300 which I'm happy about but I wish I could tell others how to do it too :frowning:
Indeed burnboardid does not exist.

i know mine remains a wndr4300sw even when i can update the firmware using a regular wndr4300 sysupgrade tar file. the modified header and checksum is only needed for the initial tftp to openwrt. i just thought it would be nice to include wndr4300sw to ath79 to save others the challenges. i look forward to having the wndr4300 added to the ath79.

@wrtboy Can you apply the patch below if you can compile your own master build? Would you be able to confirm if that works for you then?

Let me know if the BOARD_ID is a lowercase or uppercase SW suffix, that isn't totally clear to me.

diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index 3ccd19914f..9814815ff1 100644
--- a/target/linux/ath79/image/nand.mk
+++ b/target/linux/ath79/image/nand.mk
@@ -172,6 +172,18 @@ define Device/netgear_wndr4300
 endef
 TARGET_DEVICES += netgear_wndr4300
 
+define Device/netgear_wndr4300sw
+  SOC := ar9344
+  DEVICE_MODEL := WNDR4300
+  DEVICE_VARIANT := SW
+  NETGEAR_KERNEL_MAGIC := 0x33373033
+  NETGEAR_BOARD_ID := WNDR4300SW
+  NETGEAR_HW_ID := 29763948+0+128+128+2x2+3x3
+  $(Device/netgear_ath79_nand)
+endef
+TARGET_DEVICES += netgear_wndr4300sw
+
+
 define Device/netgear_wndr4300-v2
   SOC := qca9563
   DEVICE_MODEL := WNDR4300

If it does then I can file it for inclusion.