diff mbox series

bcm53xx: add nand subtarget

Message ID 20230819150904.742961-1-arinc.unal@arinc9.com
State New
Headers show
Series bcm53xx: add nand subtarget | expand

Commit Message

Arınç ÜNAL Aug. 19, 2023, 3:09 p.m. UTC
The NVMEM_BRCM_NVRAM driver won't work properly with NVRAM in NAND. It
causes the devices with NVRAM in NAND to bootloop. Create a subtarget for
NAND devices and disable the driver on it.

Disable NVMEM too as the bgmac_bcma driver will hang trying to retrieve the
MAC address without NVMEM_BRCM_NVRAM enabled.

Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
---
 target/linux/bcm53xx/Makefile            |   8 +-
 target/linux/bcm53xx/generic/target.mk   |   4 +
 target/linux/bcm53xx/image/Makefile      | 338 +----------------------
 target/linux/bcm53xx/image/generic.mk    |  43 +++
 target/linux/bcm53xx/image/nand.mk       | 293 ++++++++++++++++++++
 target/linux/bcm53xx/nand/config-default |   3 +
 target/linux/bcm53xx/nand/target.mk      |   6 +
 7 files changed, 352 insertions(+), 343 deletions(-)
 create mode 100644 target/linux/bcm53xx/image/generic.mk
 create mode 100644 target/linux/bcm53xx/image/nand.mk
 create mode 100644 target/linux/bcm53xx/nand/config-default
 create mode 100644 target/linux/bcm53xx/nand/target.mk

Comments

Rafał Miłecki Aug. 20, 2023, 2:15 p.m. UTC | #1
sob., 19 sie 2023 o 17:12 Arınç ÜNAL <arinc.unal@arinc9.com> napisał(a):
> The NVMEM_BRCM_NVRAM driver won't work properly with NVRAM in NAND. It
> causes the devices with NVRAM in NAND to bootloop. Create a subtarget for
> NAND devices and disable the driver on it.
>
> Disable NVMEM too as the bgmac_bcma driver will hang trying to retrieve the
> MAC address without NVMEM_BRCM_NVRAM enabled.

Adding a new subtarget just because one driver doesn't work correctly
is an overkill.

I'll handle that in some simple solution after holidays.
Arınç ÜNAL Aug. 20, 2023, 6:50 p.m. UTC | #2
On 20 August 2023 17:15:51 GMT+03:00, "Rafał Miłecki" <zajec5@gmail.com> wrote:
>sob., 19 sie 2023 o 17:12 Arınç ÜNAL <arinc.unal@arinc9.com> napisał(a):
>> The NVMEM_BRCM_NVRAM driver won't work properly with NVRAM in NAND. It
>> causes the devices with NVRAM in NAND to bootloop. Create a subtarget for
>> NAND devices and disable the driver on it.
>>
>> Disable NVMEM too as the bgmac_bcma driver will hang trying to retrieve the
>> MAC address without NVMEM_BRCM_NVRAM enabled.
>
>Adding a new subtarget just because one driver doesn't work correctly
>is an overkill.
>
>I'll handle that in some simple solution after holidays.

Rafał, you've been aware of this problem and reportedly working on at least diagnosing it for the last 6 months. You did not come up with anything yet. Forgive me if I find it hard to believe that you will come up with a solution in a short amount of time, if that's what you mean by after holidays as I don't know what holidays you're referring to.

In the meantime, there is a good amount of users unable to use the newer OpenWrt versions on the affected devices because of a driver that provides a rather trivial feature. I would like these devices to work again as soon as possible as we've already lost a lot of time.

To have these devices work again, I see these solutions:

- First and the most obvious, fix the driver. I do not know the NVMEM subsystem well enough to do it and am currently not interested to spend time studying it.

- Prevent the driver to read from the flash if NAND flash is detected. Once the underlying cause is fixed, this can then be reverted. Like I stated above, I lack the knowledge to do this.

- This patch. It can be easily reverted in the future when or should the issue be fixed.

- My other patch submitted here that disables the driver for the whole target. Currently, only four devices do not have NAND flash and two of these devices are not set to be compiled anyway. I'd rather prefer this than convoluting OpenWrt with another subtarget. I'd much rather prefer two devices not benefiting the future provided by this driver compared to a lot more devices being unable to boot.

I feel like writing this mail has been a waste of time as lately I've never seen you reply or in any way acknowledge that you've read any of my responses, yet I've done it anyway, at least for the mailing list.

Arınç
Rafał Miłecki Aug. 20, 2023, 8:54 p.m. UTC | #3
niedz., 20 sie 2023 o 20:50 Arınç ÜNAL <arinc.unal@arinc9.com> napisał(a):
> On 20 August 2023 17:15:51 GMT+03:00, "Rafał Miłecki" <zajec5@gmail.com> wrote:
> >sob., 19 sie 2023 o 17:12 Arınç ÜNAL <arinc.unal@arinc9.com> napisał(a):
> >> The NVMEM_BRCM_NVRAM driver won't work properly with NVRAM in NAND. It
> >> causes the devices with NVRAM in NAND to bootloop. Create a subtarget for
> >> NAND devices and disable the driver on it.
> >>
> >> Disable NVMEM too as the bgmac_bcma driver will hang trying to retrieve the
> >> MAC address without NVMEM_BRCM_NVRAM enabled.
> >
> >Adding a new subtarget just because one driver doesn't work correctly
> >is an overkill.
> >
> >I'll handle that in some simple solution after holidays.
>
> Rafał, you've been aware of this problem and reportedly working on at least diagnosing it for the last 6 months. You did not come up with anything yet. Forgive me if I find it hard to believe that you will come up with a solution in a short amount of time, if that's what you mean by after holidays as I don't know what holidays you're referring to.
>
> In the meantime, there is a good amount of users unable to use the newer OpenWrt versions on the affected devices because of a driver that provides a rather trivial feature. I would like these devices to work again as soon as possible as we've already lost a lot of time.
>
> To have these devices work again, I see these solutions:
>
> - First and the most obvious, fix the driver. I do not know the NVMEM subsystem well enough to do it and am currently not interested to spend time studying it.
>
> - Prevent the driver to read from the flash if NAND flash is detected. Once the underlying cause is fixed, this can then be reverted. Like I stated above, I lack the knowledge to do this.
>
> - This patch. It can be easily reverted in the future when or should the issue be fixed.
>
> - My other patch submitted here that disables the driver for the whole target. Currently, only four devices do not have NAND flash and two of these devices are not set to be compiled anyway. I'd rather prefer this than convoluting OpenWrt with another subtarget. I'd much rather prefer two devices not benefiting the future provided by this driver compared to a lot more devices being unable to boot.
>
> I feel like writing this mail has been a waste of time as lately I've never seen you reply or in any way acknowledge that you've read any of my responses, yet I've done it anyway, at least for the mailing list.

I'm not going to argue I handled it properly. It looked at it once
then forgot it. My maintenance time is very limited and I'm not
denying this.

I assumed holidays end for most people with the end of August. I'm on
a 1-week holiday family trip and I don't have time for development or
hardware for testing.

In my very personal opinion I prefer to leave support for those
devices broken for another week (given it has been 6 months now)
rather than push a (in my opinion) pretty hacky workaround.
Arınç ÜNAL Aug. 20, 2023, 10:18 p.m. UTC | #4
On 20.08.2023 23:54, Rafał Miłecki wrote:
> niedz., 20 sie 2023 o 20:50 Arınç ÜNAL <arinc.unal@arinc9.com> napisał(a):
>> On 20 August 2023 17:15:51 GMT+03:00, "Rafał Miłecki" <zajec5@gmail.com> wrote:
>>> sob., 19 sie 2023 o 17:12 Arınç ÜNAL <arinc.unal@arinc9.com> napisał(a):
>>>> The NVMEM_BRCM_NVRAM driver won't work properly with NVRAM in NAND. It
>>>> causes the devices with NVRAM in NAND to bootloop. Create a subtarget for
>>>> NAND devices and disable the driver on it.
>>>>
>>>> Disable NVMEM too as the bgmac_bcma driver will hang trying to retrieve the
>>>> MAC address without NVMEM_BRCM_NVRAM enabled.
>>>
>>> Adding a new subtarget just because one driver doesn't work correctly
>>> is an overkill.
>>>
>>> I'll handle that in some simple solution after holidays.
>>
>> Rafał, you've been aware of this problem and reportedly working on at least diagnosing it for the last 6 months. You did not come up with anything yet. Forgive me if I find it hard to believe that you will come up with a solution in a short amount of time, if that's what you mean by after holidays as I don't know what holidays you're referring to.
>>
>> In the meantime, there is a good amount of users unable to use the newer OpenWrt versions on the affected devices because of a driver that provides a rather trivial feature. I would like these devices to work again as soon as possible as we've already lost a lot of time.
>>
>> To have these devices work again, I see these solutions:
>>
>> - First and the most obvious, fix the driver. I do not know the NVMEM subsystem well enough to do it and am currently not interested to spend time studying it.
>>
>> - Prevent the driver to read from the flash if NAND flash is detected. Once the underlying cause is fixed, this can then be reverted. Like I stated above, I lack the knowledge to do this.
>>
>> - This patch. It can be easily reverted in the future when or should the issue be fixed.
>>
>> - My other patch submitted here that disables the driver for the whole target. Currently, only four devices do not have NAND flash and two of these devices are not set to be compiled anyway. I'd rather prefer this than convoluting OpenWrt with another subtarget. I'd much rather prefer two devices not benefiting the future provided by this driver compared to a lot more devices being unable to boot.
>>
>> I feel like writing this mail has been a waste of time as lately I've never seen you reply or in any way acknowledge that you've read any of my responses, yet I've done it anyway, at least for the mailing list.
> 
> I'm not going to argue I handled it properly. It looked at it once
> then forgot it. My maintenance time is very limited and I'm not
> denying this.
> 
> I assumed holidays end for most people with the end of August. I'm on
> a 1-week holiday family trip and I don't have time for development or
> hardware for testing.
> 
> In my very personal opinion I prefer to leave support for those
> devices broken for another week (given it has been 6 months now)
> rather than push a (in my opinion) pretty hacky workaround.

I agree.

Arınç
diff mbox series

Patch

diff --git a/target/linux/bcm53xx/Makefile b/target/linux/bcm53xx/Makefile
index 84f08f1f80..6bf8ebbd18 100644
--- a/target/linux/bcm53xx/Makefile
+++ b/target/linux/bcm53xx/Makefile
@@ -7,17 +7,13 @@  include $(TOPDIR)/rules.mk
 ARCH:=arm
 BOARD:=bcm53xx
 BOARDNAME:=Broadcom BCM47xx/53xx (ARM)
-FEATURES:=squashfs nand usb pci pcie gpio pwm
+FEATURES:=squashfs usb pci pcie gpio pwm
 CPU_TYPE:=cortex-a9
-SUBTARGETS:=generic
+SUBTARGETS:=generic nand
 
 KERNEL_PATCHVER:=5.15
 KERNEL_TESTING_PATCHVER:=6.1
 
-define Target/Description
-	Build firmware images for Broadcom based BCM47xx/53xx routers with ARM CPU, *not* MIPS.
-endef
-
 include $(INCLUDE_DIR)/target.mk
 
 KERNELNAME:=zImage dtbs
diff --git a/target/linux/bcm53xx/generic/target.mk b/target/linux/bcm53xx/generic/target.mk
index f5cb1fb19b..2b55583077 100644
--- a/target/linux/bcm53xx/generic/target.mk
+++ b/target/linux/bcm53xx/generic/target.mk
@@ -1 +1,5 @@ 
 BOARDNAME:=Generic
+
+define Target/Description
+	Build firmware images for Broadcom based BCM47xx/53xx routers with ARM CPU, *not* MIPS.
+endef
diff --git a/target/linux/bcm53xx/image/Makefile b/target/linux/bcm53xx/image/Makefile
index 5158b432b3..4af12d0222 100644
--- a/target/linux/bcm53xx/image/Makefile
+++ b/target/linux/bcm53xx/image/Makefile
@@ -105,22 +105,6 @@  define Build/seama-nand
 		-i $@.entity
 endef
 
-define Build/dwl8610ap-image
-	mkdir -p $@.tmptar
-	# The DWL8610AP pretends to be a Broadcom reference design
-	echo "bcm953012er" > $@.tmptar/board
-	echo "LVL7" > $@.tmptar/model
-	# Something high beyond what D-Link has put out
-	echo "5.0.0.0" > $@.tmptar/version
-	# Create rootfs.bin, this is just a NAND image including everything
-	cp $@ $@.tmptar/rootfs.bin
-	# Hash the rootfs.bin
-	cat $@.tmptar/rootfs.bin | md5sum > $@.tmptar/rootfs.md5
-	cd $@.tmptar && tar -c -f $@.new *
-	rm -rf $@.tmptar
-	mv $@.new $@
-endef
-
 DEVICE_VARS += ASUS_PRODUCTID
 DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR
 DEVICE_VARS += SIGNATURE
@@ -159,54 +143,6 @@  define Device/asus
   IMAGE/trx := append-ubi | trx-nand | asus-trx
 endef
 
-define Device/asus_rt-ac3100
-  $(call Device/asus)
-  DEVICE_MODEL := RT-AC3100
-  DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
-  ASUS_PRODUCTID := RT-AC3100
-endef
-TARGET_DEVICES += asus_rt-ac3100
-
-define Device/asus_rt-ac56u
-  $(call Device/asus)
-  DEVICE_MODEL := RT-AC56U
-  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
-  ASUS_PRODUCTID := RT-AC56U
-endef
-TARGET_DEVICES += asus_rt-ac56u
-
-define Device/asus_rt-ac68u
-  $(call Device/asus)
-  DEVICE_MODEL := RT-AC68U
-  DEVICE_PACKAGES := $(USB3_PACKAGES)
-  ASUS_PRODUCTID := RT-AC68U
-endef
-TARGET_DEVICES += asus_rt-ac68u
-
-define Device/asus_rt-ac87u
-  $(call Device/asus)
-  DEVICE_MODEL := RT-AC87U
-  DEVICE_PACKAGES := $(USB3_PACKAGES)
-  ASUS_PRODUCTID := RT-AC87U
-endef
-TARGET_DEVICES += asus_rt-ac87u
-
-define Device/asus_rt-ac88u
-  $(call Device/asus)
-  DEVICE_MODEL := RT-AC88U
-  DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
-  ASUS_PRODUCTID := RT-AC88U
-endef
-TARGET_DEVICES += asus_rt-ac88u
-
-define Device/asus_rt-n18u
-  $(call Device/asus)
-  DEVICE_MODEL := RT-N18U
-  DEVICE_PACKAGES := $(USB3_PACKAGES)
-  ASUS_PRODUCTID := RT-N18U
-endef
-TARGET_DEVICES += asus_rt-n18u
-
 # Buffalo devices have TFTP recovery mode which can work nicely with initramfs
 # kernels.
 # We should have two initramfs images for Buffalo: plain initramfs kernel and
@@ -218,186 +154,18 @@  define Device/buffalo/Default
   KERNEL_INITRAMFS = $$(KERNEL)
 endef
 
-define Device/buffalo_wxr-1900dhp
-  $(call Device/buffalo/Default)
-  DEVICE_MODEL := WXR-1900DHP
-  DEVICE_PACKAGES := $(USB3_PACKAGES)
-endef
-TARGET_DEVICES += buffalo_wxr-1900dhp
-
-define Device/buffalo_wzr-600dhp2
-  $(call Device/buffalo/Default)
-  DEVICE_MODEL := WZR-600DHP2
-  DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
-endef
-TARGET_DEVICES += buffalo_wzr-600dhp2
-
-define Device/buffalo_wzr-900dhp
-  $(call Device/buffalo/Default)
-  DEVICE_MODEL := WZR-900DHP
-  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
-  BUFFALO_TAG_PLATFORM := bcm
-  BUFFALO_TAG_VERSION := 9.99
-  BUFFALO_TAG_MINOR := 9.99
-  IMAGES += factory-DHP-EU.bin factory-DHP2-JP.bin
-  IMAGE/factory-DHP-EU.bin := \
-	append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP EU | \
-	buffalo-enc WZR-900DHP $$(BUFFALO_TAG_VERSION) | \
-	buffalo-tag-dhp WZR-900DHP EU mlang20 | buffalo-enc-tag | \
-	buffalo-dhp-image
-  IMAGE/factory-DHP2-JP.bin := \
-	append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP2 JP | \
-	buffalo-enc WZR-900DHP2 $$(BUFFALO_TAG_VERSION) | \
-	buffalo-tag-dhp WZR-900DHP2 JP jp | buffalo-enc-tag | \
-	buffalo-dhp-image
-endef
-TARGET_DEVICES += buffalo_wzr-900dhp
-
-define Device/buffalo_wzr-1750dhp
-  $(call Device/buffalo/Default)
-  DEVICE_MODEL := WZR-1750DHP
-  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
-endef
-TARGET_DEVICES += buffalo_wzr-1750dhp
-
 define Device/dlink
   DEVICE_VENDOR := D-Link
   IMAGES := bin
   IMAGE/bin := append-ubi | seama-nand
 endef
 
-define Device/dlink_dir-885l
-  DEVICE_MODEL := DIR-885L
-  DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
-  $(Device/dlink)
-  SIGNATURE := wrgac42_dlink.2015_dir885l
-endef
-TARGET_DEVICES += dlink_dir-885l
-
-define Device/dlink_dwl-8610ap
-  DEVICE_VENDOR := D-Link
-  DEVICE_MODEL := DWL-8610AP
-  DEVICE_PACKAGES := $(B43)
-  IMAGES := factory.tar
-  IMAGE/factory.tar := append-ubi | trx-nand | dwl8610ap-image
-endef
-TARGET_DEVICES += dlink_dwl-8610ap
-
-define Device/linksys_ea6300-v1
-  DEVICE_VENDOR := Linksys
-  DEVICE_MODEL := EA6300
-  DEVICE_VARIANT := v1
-  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
-endef
-TARGET_DEVICES += linksys_ea6300-v1
-
-define Device/linksys_ea6500-v2
-  DEVICE_VENDOR := Linksys
-  DEVICE_MODEL := EA6500
-  DEVICE_VARIANT := v2
-  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
-endef
-TARGET_DEVICES += linksys_ea6500-v2
-
-define Device/linksys_ea9200
-  DEVICE_VENDOR := Linksys
-  DEVICE_MODEL := EA9200
-  DEVICE_VARIANT := v1
-  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
-endef
-TARGET_DEVICES += linksys_ea9200
-
-define Device/linksys_ea9500
-  DEVICE_VENDOR := Linksys
-  DEVICE_MODEL := EA9500
-  DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
-  DEVICE_DTS := bcm47094-linksys-panamera
-endef
-TARGET_DEVICES += linksys_ea9500
-
 define Device/luxul
   DEVICE_VENDOR := Luxul
   IMAGES := lxl
   IMAGE/lxl := append-ubi | trx-nand | luxul-lxl
 endef
 
-define Device/luxul_abr-4500
-  $(Device/luxul)
-  DEVICE_MODEL := ABR-4500
-  DEVICE_PACKAGES := $(USB3_PACKAGES)
-  LUXUL_BOARD := ABR-4500
-endef
-TARGET_DEVICES += luxul_abr-4500
-
-define Device/luxul_xap-1610
-  $(Device/luxul)
-  DEVICE_MODEL := XAP-1610
-  DEVICE_PACKAGES := $(BRCMFMAC_4366C0)
-  IMAGE/lxl := append-rootfs | trx-serial | luxul-lxl
-  LUXUL_BOARD := XAP-1610
-endef
-TARGET_DEVICES += luxul_xap-1610
-
-define Device/luxul_xbr-4500
-  $(Device/luxul)
-  DEVICE_MODEL := XBR-4500
-  DEVICE_PACKAGES := $(USB3_PACKAGES)
-  LUXUL_BOARD := XBR-4500
-endef
-TARGET_DEVICES += luxul_xbr-4500
-
-define Device/luxul_xwr-3150
-  $(Device/luxul)
-  DEVICE_MODEL := XWR-3150
-  DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
-  DEVICE_DTS := bcm47094-luxul-xwr-3150-v1
-  LUXUL_BOARD := XWR-3150
-endef
-TARGET_DEVICES += luxul_xwr-3150
-
-define Device/meraki_mr26
-  DEVICE_VENDOR := Meraki
-  DEVICE_MODEL := MR26
-  DEVICE_PACKAGES := $(B43) kmod-i2c-bcm-iproc kmod-eeprom-at24 \
-	kmod-hwmon-ina2xx kmod-leds-uleds nu801
-  DEVICE_DTS := bcm53015-meraki-mr26
-# resize the initramfs to fit the size of the existing part.safe.
-  KERNEL_LOADADDR := 0x00008000
-  KERNEL_INITRAMFS_SUFFIX := .bin
-  KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip | pad-to 9310208
-# LZMA is not supported by the uboot
-  KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
-  IMAGES += sysupgrade.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-endef
-TARGET_DEVICES += meraki_mr26
-
-define Device/meraki_mr32
-  DEVICE_VENDOR := Meraki
-  DEVICE_MODEL := MR32
-  DEVICE_PACKAGES := $(B43) kmod-i2c-bcm-iproc kmod-eeprom-at24 \
-	kmod-leds-pwm kmod-hwmon-ina2xx kmod-bluetooth
-  DEVICE_DTS := bcm53016-meraki-mr32
-# Meraki FW r23 tries to resize the part.safe partition before it will
-# flash the image. This is a bit of a problem, since resizing will fail
-# if the partition is smaller than the old one.
-  KERNEL_LOADADDR := 0x00008000
-  KERNEL_INITRAMFS_SUFFIX := .bin
-  DEVICE_DTS_DELIMITER := @
-  DEVICE_DTS_CONFIG := config@1
-  KERNEL_INITRAMFS := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb | \
-	pad-to 10362880
-  KERNEL := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb
-  IMAGES += sysupgrade.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-
-# The loader is specifically looking for fdt@2:
-# [    3.190000] find_itb_subimage: error finding fdt@2: FDT_ERR_NOTFOUND
-# The image won't boot, if it isn't found. :(
-  DEVICE_FDT_NUM := 2
-endef
-TARGET_DEVICES += meraki_mr32
-
 define Device/netgear
   DEVICE_VENDOR := NETGEAR
   IMAGES := chk
@@ -405,110 +173,6 @@  define Device/netgear
   NETGEAR_REGION := 1
 endef
 
-define Device/netgear_r6250
-  DEVICE_MODEL := R6250
-  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
-  $(Device/netgear)
-  NETGEAR_BOARD_ID := U12H245T00_NETGEAR
-endef
-TARGET_DEVICES += netgear_r6250
-
-define Device/netgear_r6300-v2
-  DEVICE_MODEL := R6300
-  DEVICE_VARIANT := v2
-  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
-  $(Device/netgear)
-  NETGEAR_BOARD_ID := U12H240T00_NETGEAR
-endef
-TARGET_DEVICES += netgear_r6300-v2
-
-define Device/netgear_r7000
-  DEVICE_MODEL := R7000
-  DEVICE_PACKAGES := $(USB3_PACKAGES)
-  $(Device/netgear)
-  NETGEAR_BOARD_ID := U12H270T00_NETGEAR
-endef
-TARGET_DEVICES += netgear_r7000
-
-define Device/netgear_r7900
-  DEVICE_MODEL := R7900
-  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
-  $(Device/netgear)
-  NETGEAR_BOARD_ID := U12H315T30_NETGEAR
-endef
-TARGET_DEVICES += netgear_r7900
-
-define Device/netgear_r8000
-  DEVICE_MODEL := R8000
-  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
-  $(Device/netgear)
-  NETGEAR_BOARD_ID := U12H315T00_NETGEAR
-endef
-TARGET_DEVICES += netgear_r8000
-
-define Device/netgear_r8500
-  DEVICE_MODEL := R8500
-  DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
-  $(Device/netgear)
-  NETGEAR_BOARD_ID := U12H334T00_NETGEAR
-  DEFAULT := n
-endef
-TARGET_DEVICES += netgear_r8500
-
-define Device/smartrg_sr400ac
-  DEVICE_VENDOR := SmartRG
-  DEVICE_MODEL := SR400ac
-  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
-  IMAGES := trx
-  IMAGE/trx := append-rootfs | trx-serial
-  KERNEL_INITRAMFS_SUFFIX := .bin
-  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16
-endef
-TARGET_DEVICES += smartrg_sr400ac
-
-define Device/phicomm_k3
-  DEVICE_VENDOR := PHICOMM
-  DEVICE_MODEL := K3
-  DEVICE_ALT0_VENDOR := Wavlink
-  DEVICE_ALT0_MODEL := QUANTUM DAX
-  DEVICE_ALT1_VENDOR := Wavlink
-  DEVICE_ALT1_MODEL := WL-WN538A8
-  DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
-  IMAGES := trx
-endef
-TARGET_DEVICES += phicomm_k3
-
-define Device/tenda_ac9
-  DEVICE_VENDOR := Tenda
-  DEVICE_MODEL := AC9
-  DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
-  IMAGES := trx
-  IMAGE/trx := append-rootfs | trx-serial
-endef
-TARGET_DEVICES += tenda_ac9
-
-define Device/tplink_archer-c5-v2
-  DEVICE_VENDOR := TP-Link
-  DEVICE_MODEL := Archer C5
-  DEVICE_VARIANT := v2
-  DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
-  IMAGES := bin
-  IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
-  TPLINK_BOARD := ARCHER-C5-V2
-  BROKEN := y
-endef
-#TARGET_DEVICES += tplink_archer-c5-v2
-
-define Device/tplink_archer-c9-v1
-  DEVICE_VENDOR := TP-Link
-  DEVICE_MODEL := Archer C9
-  DEVICE_VARIANT := v1
-  DEVICE_PACKAGES := $(USB3_PACKAGES)
-  IMAGES := bin
-  IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
-  TPLINK_BOARD := ARCHERC9
-  BROKEN := y
-endef
-#TARGET_DEVICES += tplink_archer-c9-v1
+include $(SUBTARGET).mk
 
 $(eval $(call BuildImage))
diff --git a/target/linux/bcm53xx/image/generic.mk b/target/linux/bcm53xx/image/generic.mk
new file mode 100644
index 0000000000..7c66dd2d93
--- /dev/null
+++ b/target/linux/bcm53xx/image/generic.mk
@@ -0,0 +1,43 @@ 
+define Device/smartrg_sr400ac
+  DEVICE_VENDOR := SmartRG
+  DEVICE_MODEL := SR400ac
+  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
+  IMAGES := trx
+  IMAGE/trx := append-rootfs | trx-serial
+  KERNEL_INITRAMFS_SUFFIX := .bin
+  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16
+endef
+TARGET_DEVICES += smartrg_sr400ac
+
+define Device/tenda_ac9
+  DEVICE_VENDOR := Tenda
+  DEVICE_MODEL := AC9
+  DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
+  IMAGES := trx
+  IMAGE/trx := append-rootfs | trx-serial
+endef
+TARGET_DEVICES += tenda_ac9
+
+define Device/tplink_archer-c5-v2
+  DEVICE_VENDOR := TP-Link
+  DEVICE_MODEL := Archer C5
+  DEVICE_VARIANT := v2
+  DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
+  IMAGES := bin
+  IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
+  TPLINK_BOARD := ARCHER-C5-V2
+  BROKEN := y
+endef
+#TARGET_DEVICES += tplink_archer-c5-v2
+
+define Device/tplink_archer-c9-v1
+  DEVICE_VENDOR := TP-Link
+  DEVICE_MODEL := Archer C9
+  DEVICE_VARIANT := v1
+  DEVICE_PACKAGES := $(USB3_PACKAGES)
+  IMAGES := bin
+  IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
+  TPLINK_BOARD := ARCHERC9
+  BROKEN := y
+endef
+#TARGET_DEVICES += tplink_archer-c9-v1
diff --git a/target/linux/bcm53xx/image/nand.mk b/target/linux/bcm53xx/image/nand.mk
new file mode 100644
index 0000000000..813c34470b
--- /dev/null
+++ b/target/linux/bcm53xx/image/nand.mk
@@ -0,0 +1,293 @@ 
+define Build/dwl8610ap-image
+	mkdir -p $@.tmptar
+	# The DWL8610AP pretends to be a Broadcom reference design
+	echo "bcm953012er" > $@.tmptar/board
+	echo "LVL7" > $@.tmptar/model
+	# Something high beyond what D-Link has put out
+	echo "5.0.0.0" > $@.tmptar/version
+	# Create rootfs.bin, this is just a NAND image including everything
+	cp $@ $@.tmptar/rootfs.bin
+	# Hash the rootfs.bin
+	cat $@.tmptar/rootfs.bin | md5sum > $@.tmptar/rootfs.md5
+	cd $@.tmptar && tar -c -f $@.new *
+	rm -rf $@.tmptar
+	mv $@.new $@
+endef
+
+define Device/asus_rt-ac3100
+  $(call Device/asus)
+  DEVICE_MODEL := RT-AC3100
+  DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
+  ASUS_PRODUCTID := RT-AC3100
+endef
+TARGET_DEVICES += asus_rt-ac3100
+
+define Device/asus_rt-ac56u
+  $(call Device/asus)
+  DEVICE_MODEL := RT-AC56U
+  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
+  ASUS_PRODUCTID := RT-AC56U
+endef
+TARGET_DEVICES += asus_rt-ac56u
+
+define Device/asus_rt-ac68u
+  $(call Device/asus)
+  DEVICE_MODEL := RT-AC68U
+  DEVICE_PACKAGES := $(USB3_PACKAGES)
+  ASUS_PRODUCTID := RT-AC68U
+endef
+TARGET_DEVICES += asus_rt-ac68u
+
+define Device/asus_rt-ac87u
+  $(call Device/asus)
+  DEVICE_MODEL := RT-AC87U
+  DEVICE_PACKAGES := $(USB3_PACKAGES)
+  ASUS_PRODUCTID := RT-AC87U
+endef
+TARGET_DEVICES += asus_rt-ac87u
+
+define Device/asus_rt-ac88u
+  $(call Device/asus)
+  DEVICE_MODEL := RT-AC88U
+  DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
+  ASUS_PRODUCTID := RT-AC88U
+endef
+TARGET_DEVICES += asus_rt-ac88u
+
+define Device/asus_rt-n18u
+  $(call Device/asus)
+  DEVICE_MODEL := RT-N18U
+  DEVICE_PACKAGES := $(USB3_PACKAGES)
+  ASUS_PRODUCTID := RT-N18U
+endef
+TARGET_DEVICES += asus_rt-n18u
+
+define Device/buffalo_wxr-1900dhp
+  $(call Device/buffalo/Default)
+  DEVICE_MODEL := WXR-1900DHP
+  DEVICE_PACKAGES := $(USB3_PACKAGES)
+endef
+TARGET_DEVICES += buffalo_wxr-1900dhp
+
+define Device/buffalo_wzr-600dhp2
+  $(call Device/buffalo/Default)
+  DEVICE_MODEL := WZR-600DHP2
+  DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
+endef
+TARGET_DEVICES += buffalo_wzr-600dhp2
+
+define Device/buffalo_wzr-900dhp
+  $(call Device/buffalo/Default)
+  DEVICE_MODEL := WZR-900DHP
+  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
+  BUFFALO_TAG_PLATFORM := bcm
+  BUFFALO_TAG_VERSION := 9.99
+  BUFFALO_TAG_MINOR := 9.99
+  IMAGES += factory-DHP-EU.bin factory-DHP2-JP.bin
+  IMAGE/factory-DHP-EU.bin := \
+	append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP EU | \
+	buffalo-enc WZR-900DHP $$(BUFFALO_TAG_VERSION) | \
+	buffalo-tag-dhp WZR-900DHP EU mlang20 | buffalo-enc-tag | \
+	buffalo-dhp-image
+  IMAGE/factory-DHP2-JP.bin := \
+	append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP2 JP | \
+	buffalo-enc WZR-900DHP2 $$(BUFFALO_TAG_VERSION) | \
+	buffalo-tag-dhp WZR-900DHP2 JP jp | buffalo-enc-tag | \
+	buffalo-dhp-image
+endef
+TARGET_DEVICES += buffalo_wzr-900dhp
+
+define Device/buffalo_wzr-1750dhp
+  $(call Device/buffalo/Default)
+  DEVICE_MODEL := WZR-1750DHP
+  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
+endef
+TARGET_DEVICES += buffalo_wzr-1750dhp
+
+define Device/dlink_dir-885l
+  DEVICE_MODEL := DIR-885L
+  DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
+  $(Device/dlink)
+  SIGNATURE := wrgac42_dlink.2015_dir885l
+endef
+TARGET_DEVICES += dlink_dir-885l
+
+define Device/dlink_dwl-8610ap
+  DEVICE_VENDOR := D-Link
+  DEVICE_MODEL := DWL-8610AP
+  DEVICE_PACKAGES := $(B43)
+  IMAGES := factory.tar
+  IMAGE/factory.tar := append-ubi | trx-nand | dwl8610ap-image
+endef
+TARGET_DEVICES += dlink_dwl-8610ap
+
+define Device/linksys_ea6300-v1
+  DEVICE_VENDOR := Linksys
+  DEVICE_MODEL := EA6300
+  DEVICE_VARIANT := v1
+  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
+endef
+TARGET_DEVICES += linksys_ea6300-v1
+
+define Device/linksys_ea6500-v2
+  DEVICE_VENDOR := Linksys
+  DEVICE_MODEL := EA6500
+  DEVICE_VARIANT := v2
+  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
+endef
+TARGET_DEVICES += linksys_ea6500-v2
+
+define Device/linksys_ea9200
+  DEVICE_VENDOR := Linksys
+  DEVICE_MODEL := EA9200
+  DEVICE_VARIANT := v1
+  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
+endef
+TARGET_DEVICES += linksys_ea9200
+
+define Device/linksys_ea9500
+  DEVICE_VENDOR := Linksys
+  DEVICE_MODEL := EA9500
+  DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
+  DEVICE_DTS := bcm47094-linksys-panamera
+endef
+TARGET_DEVICES += linksys_ea9500
+
+define Device/luxul_abr-4500
+  $(Device/luxul)
+  DEVICE_MODEL := ABR-4500
+  DEVICE_PACKAGES := $(USB3_PACKAGES)
+  LUXUL_BOARD := ABR-4500
+endef
+TARGET_DEVICES += luxul_abr-4500
+
+define Device/luxul_xap-1610
+  $(Device/luxul)
+  DEVICE_MODEL := XAP-1610
+  DEVICE_PACKAGES := $(BRCMFMAC_4366C0)
+  IMAGE/lxl := append-rootfs | trx-serial | luxul-lxl
+  LUXUL_BOARD := XAP-1610
+endef
+TARGET_DEVICES += luxul_xap-1610
+
+define Device/luxul_xbr-4500
+  $(Device/luxul)
+  DEVICE_MODEL := XBR-4500
+  DEVICE_PACKAGES := $(USB3_PACKAGES)
+  LUXUL_BOARD := XBR-4500
+endef
+TARGET_DEVICES += luxul_xbr-4500
+
+define Device/luxul_xwr-3150
+  $(Device/luxul)
+  DEVICE_MODEL := XWR-3150
+  DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
+  DEVICE_DTS := bcm47094-luxul-xwr-3150-v1
+  LUXUL_BOARD := XWR-3150
+endef
+TARGET_DEVICES += luxul_xwr-3150
+
+define Device/meraki_mr26
+  DEVICE_VENDOR := Meraki
+  DEVICE_MODEL := MR26
+  DEVICE_PACKAGES := $(B43) kmod-i2c-bcm-iproc kmod-eeprom-at24 \
+	kmod-hwmon-ina2xx kmod-leds-uleds nu801
+  DEVICE_DTS := bcm53015-meraki-mr26
+# resize the initramfs to fit the size of the existing part.safe.
+  KERNEL_LOADADDR := 0x00008000
+  KERNEL_INITRAMFS_SUFFIX := .bin
+  KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip | pad-to 9310208
+# LZMA is not supported by the uboot
+  KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
+  IMAGES += sysupgrade.bin
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += meraki_mr26
+
+define Device/meraki_mr32
+  DEVICE_VENDOR := Meraki
+  DEVICE_MODEL := MR32
+  DEVICE_PACKAGES := $(B43) kmod-i2c-bcm-iproc kmod-eeprom-at24 \
+	kmod-leds-pwm kmod-hwmon-ina2xx kmod-bluetooth
+  DEVICE_DTS := bcm53016-meraki-mr32
+# Meraki FW r23 tries to resize the part.safe partition before it will
+# flash the image. This is a bit of a problem, since resizing will fail
+# if the partition is smaller than the old one.
+  KERNEL_LOADADDR := 0x00008000
+  KERNEL_INITRAMFS_SUFFIX := .bin
+  DEVICE_DTS_DELIMITER := @
+  DEVICE_DTS_CONFIG := config@1
+  KERNEL_INITRAMFS := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb | \
+	pad-to 10362880
+  KERNEL := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb
+  IMAGES += sysupgrade.bin
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+
+# The loader is specifically looking for fdt@2:
+# [    3.190000] find_itb_subimage: error finding fdt@2: FDT_ERR_NOTFOUND
+# The image won't boot, if it isn't found. :(
+  DEVICE_FDT_NUM := 2
+endef
+TARGET_DEVICES += meraki_mr32
+
+define Device/netgear_r6250
+  DEVICE_MODEL := R6250
+  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
+  $(Device/netgear)
+  NETGEAR_BOARD_ID := U12H245T00_NETGEAR
+endef
+TARGET_DEVICES += netgear_r6250
+
+define Device/netgear_r6300-v2
+  DEVICE_MODEL := R6300
+  DEVICE_VARIANT := v2
+  DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
+  $(Device/netgear)
+  NETGEAR_BOARD_ID := U12H240T00_NETGEAR
+endef
+TARGET_DEVICES += netgear_r6300-v2
+
+define Device/netgear_r7000
+  DEVICE_MODEL := R7000
+  DEVICE_PACKAGES := $(USB3_PACKAGES)
+  $(Device/netgear)
+  NETGEAR_BOARD_ID := U12H270T00_NETGEAR
+endef
+TARGET_DEVICES += netgear_r7000
+
+define Device/netgear_r7900
+  DEVICE_MODEL := R7900
+  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
+  $(Device/netgear)
+  NETGEAR_BOARD_ID := U12H315T30_NETGEAR
+endef
+TARGET_DEVICES += netgear_r7900
+
+define Device/netgear_r8000
+  DEVICE_MODEL := R8000
+  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
+  $(Device/netgear)
+  NETGEAR_BOARD_ID := U12H315T00_NETGEAR
+endef
+TARGET_DEVICES += netgear_r8000
+
+define Device/netgear_r8500
+  DEVICE_MODEL := R8500
+  DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
+  $(Device/netgear)
+  NETGEAR_BOARD_ID := U12H334T00_NETGEAR
+  DEFAULT := n
+endef
+TARGET_DEVICES += netgear_r8500
+
+define Device/phicomm_k3
+  DEVICE_VENDOR := PHICOMM
+  DEVICE_MODEL := K3
+  DEVICE_ALT0_VENDOR := Wavlink
+  DEVICE_ALT0_MODEL := QUANTUM DAX
+  DEVICE_ALT1_VENDOR := Wavlink
+  DEVICE_ALT1_MODEL := WL-WN538A8
+  DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
+  IMAGES := trx
+endef
+TARGET_DEVICES += phicomm_k3
diff --git a/target/linux/bcm53xx/nand/config-default b/target/linux/bcm53xx/nand/config-default
new file mode 100644
index 0000000000..d6ea56ade2
--- /dev/null
+++ b/target/linux/bcm53xx/nand/config-default
@@ -0,0 +1,3 @@ 
+CONFIG_NVMEM=n
+CONFIG_NVMEM_BRCM_NVRAM=n
+CONFIG_NVMEM_SYSFS=n
diff --git a/target/linux/bcm53xx/nand/target.mk b/target/linux/bcm53xx/nand/target.mk
new file mode 100644
index 0000000000..c81b3c6cc6
--- /dev/null
+++ b/target/linux/bcm53xx/nand/target.mk
@@ -0,0 +1,6 @@ 
+BOARDNAME:=Generic devices with NAND flash
+FEATURES+=nand
+
+define Target/Description
+	Build firmware images for generic devices with NAND flash.
+endef