2025-04-08 12:56 AM
Hi all,
I am trying to understand how the OctoSPI and QuadSPI peripherals work in single-spi mode, specifically as to how they treat the IO2/nWP line.
When the attached spi device (in my case, a NOR flash memory) operates in singlespi mode, i.e. after reset or power cycle, the line used for IO2 becomes nWP (active LOW write protect input to the memory chip).
According to the reference manual (sect 19.4.4 of RM0432) and AN4760:
Single-SPI mode (from RM0432):
The legacy SPI mode allows just a single bit to be sent/received serially. In this mode, the
data is sent to the external device over the SO signal (whose I/Os are shared with IO0). The
data received from the external device arrives via SI (whose I/Os are shared with IO1).
The different phases can each be configured separately to use this Single-bit mode by
setting to 001 the IMODE, ADMODE, ABMODE, and DMODE fields in OCTOSPI_CCR and
OCTOSPI_WCCR.
In each phase configured in Single-SPI mode:
• IO0 (SO) is in output mode.
• IO1 (SI) is in input mode (high impedance).
• IO2 is in output mode and forced to 0 (to deactivate the “write protect” function).
• IO3 is in output mode and forced to 1 (to deactivate the “hold” function).
• IO4 to IO7 are in output mode and forced to 0.
This is the case even for the dummy phase if DMODE[2:0] = 001.
My first read of this was WTH?? Low Activates the WP function, it doesn't deactivate it!
Write protect on all spi/qspi/octospi nor flash chips I have looked at is active low.
The diagram in AN4760 even shows the wp input on the attached memory device as active low (nWP), while simultaneously saying that low deactivates the memory device's write protect!
So, as I read this, the default operating mode of the QuadSPI and OctoSPI STM32 Peripherals, when set to operate in Single-SPI mode, is that it will drive the memory device's IO2 (now repurposed as nWP) pin LOW, thus ENABLING the chip's Write Protect function!
This can cause all kinds of grief, as the IO2 signal does not appear to be alterable, and in some cases, quad or octo mode cannot be entered when WP is active! This can happen on the Macronix MX25L25645G part, and several others as well. All it takes is for the status register SRWD bit to be set, and then the memory device is stuck in singlespi mode, and effectively read only, possibly "bricking" the product.
Can anyone confirm if the IO2 signal does actually operate in this way (and for ST designers, What were you thinking)?
If it does indeed operate in this way, I am thinking that while in singlespi mode, I might have to override the IO2 signal by reconfiguring it as a gpio output, and set it high. Then, when entering quad or octo mode, releasing the gpio pin back to the quad or octo spi peripheral's alternate function (as IO2)..
Very interested in what others have found with this (I am hoping it is a typo, and not real behaviour).
If the IO2 pin is actually driven high by the octospi (and quadspi) peripheral, instead of low as the documentation says, then ST folks, PLEASE fix this error in all the documents where it occurs!
Cheers,
Pete
2025-04-09 4:20 AM - edited 2025-04-09 4:22 AM
Hello @PeteG and welcome to the community;
Thank you for bringing this issue to our attention.
I reported this issue internally for checking.
Write protect on all spi/qspi/octospi nor flash chips I have looked at is active low.
If you can share your used memories datasheets to confirm this.
Internal ticket number: 207179 (This is an internal tracking number and is not accessible or usable by customers).
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-04-09 4:55 AM
Not sure I've looked a the pin state, but have gotten several reports of certain Winbond W25Q64 (die or settings, based on age, part suffix, and factory configuration) that get into a unworkable/unhelpful state.
I ended up making a 1-bit / 2-bit loader that initializes the D2 / D3 as GPIO with the state I want to present to the device, and work from there.
Seen many Micron's get locked out with the Macronix QE setting (0x40) which sets a BPB locking bit in the larger devices (512Mb ?), precluding some erase, write and mass erase functionality and similarly for Winbond's, so something I walk the devices out of if spotted.