This hack is derived from this mail by Paul Fertser on openwrt-devel.
- When using 32M flash, the SPI bus needs to be reconfigured to use 4-byte addressing mode, instead of the usual (?) 3-byte mode.
- Issueing a soft reset without this patch leaves the bus in 4-byte mode, which then crashes the system because the SoC tries (and fails) to communicate in 3-byte addressing mode.
- Writing the opcodes brings the SPI back into 3-byte addressing mode, so the SoC can continue communicating after issueing a soft reset.
What I'm not sure about is, whether this causes any issues on boards with 16M flash or less. Leaving the 32bit addressing mode twice doesn't seem to cause any harm.
It is tested on both a ZBT-WG3526 (16M) and Digineo AC1200 Pro (32M), using LEDE master (8459d85). While it fixes the reboot on the AC1200 Pro, it doesn't break the WG3526.
Ideally I'd like to detect the current mode and execute the spi_write
s
conditionally. Also, JESD216B implies in 6.4.19 (JEDEC Basic Flash
Parameter Table) for bits 13:8 (Soft Reset and Rescue Sequence Support),
that the reset sequence used here may not be available (i.e. bit 12 == 0).
(Obviously this needs some cleanup before it can be used anywhere.)
Follow ups: