OpenWrt for D-Link DNS320 A1 - v25.12.4

USB recovery...

This needs to be used responsibly, as leaving a USB plugged in the device with the right files will cause NAND to be flashed on every boot. The NAS won't last long if that happens, and impossible to estimate as there is no way to know how battered the NAND may be after so many years of dlink or alt-f use.

Release v24.10.5-r1 only. This has been baked into the default environment of u-boot, and is also configured in the env.bin file of that release.

To flash from USB, a formatted USB drive (any type) with a (preferably single) 1st partition formatted as ext4 is required.

A folder named dns320a-to-flash is needed at root level.
Inside that folder, an optional file named env-contents.bin will be flashed if present to the u-boot env.
Another optional file by the name ubi-filesystem.bin will be flashed if present to the UBI partition.
If both files are present, both partitions will be flashed.

/dns320a-to-flash
     - env-contents.bin
     - ubi-filesystem.bin

If no USB is present, or partition is not of ext4 type, or either/both files are not present, NAND will not be touched and device will boot normally. Only side effect is a 4s delay.

This will allow recovery from a bad environment, corrupt firmware installation, or failed install without disassembly (as long as u-boot was flashed OK).

Console logs

This is what a UBI flash looks like in the console:

=> boot
resetting USB...
Bus ehci@50000: USB EHCI 1.00
scanning bus ehci@50000 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
11010048 bytes read in 566 ms (18.6 MiB/s)
flashing ubi a80000 bytes...

NAND erase.part: device 0 offset 0x100000, size 0x7f00000
Erasing at 0x7fe0000 -- 100% complete.
OK

NAND write: device 0 offset 0x100000, size 0xa80000
 11010048 bytes written: OK
ubi0: attaching mtd3
ubi0: scanning is finished
ubi0: volume 2 ("rootfs_data") re-sized from 9 to 910 LEBs
ubi0: attached mtd3 (name "ubi", size 127 MiB)

An env flash:

=> boot
resetting USB...
Bus ehci@50000: USB EHCI 1.00
scanning bus ehci@50000 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
131072 bytes read in 13 ms (9.6 MiB/s)
flashing env 20000 bytes...

NAND erase.part: device 0 offset 0xe0000, size 0x20000
Erasing at 0xe0000 -- 100% complete.
OK

NAND write: device 0 offset 0xe0000, size 0x20000
 131072 bytes written: OK
ubi0: attaching mtd3
ubi0: scanning is finished
ubi0: attached mtd3 (name "ubi", size 127 MiB)

And this is what it looks like when neither file is present:

> boot
resetting USB...
Bus ehci@50000: USB EHCI 1.00
scanning bus ehci@50000 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
ubi0: attaching mtd3
ubi0: scanning is finished
ubi0: attached mtd3 (name "ubi", size 127 MiB)