Configure QuadSpi in Single/Dual Mode to communicate with external flash device


Hello Everyone, I am attempting to integrate with a NOR based external flash storage with mbed os. I am using an STM32F446RC that is attatched to the external flash on the QSPI bus, but should be configured to use either single or dual spi, (4 wires instead of 6).

The Problem

I am having trouble initializing a QSPIFBlockDevice, I am currently passing in the 4 pins I am using and NC for IO2 and IO3. The program halts when trying to map the pins for the device.

QSPIName qspi_data_first = (QSPIName)pinmap_merge(qspiio0name, qspiio1name);
QSPIName qspi_data_second = (QSPIName)pinmap_merge(qspiio2name, qspiio3name);
QSPIName qspi_data_third = (QSPIName)pinmap_merge(qspiclkname, qspisselname);

if (qspi_data_first != qspi_data_second || qspi_data_second != qspi_data_third ||
          qspi_data_first != qspi_data_third) {

In my case, qspi_data_second = -1 due to the two NC pins causing initialization to halt. You cannot set these to random pins either because the pinmap for my device only contains mappings to NC.

My takeaway from this was that the QSPI requires 4 distinct data pins, but my device only supports two so the object doesn’t get initialized.

Essentially I am asking, what is the workaround for this problem? Am I missing extra configuration in my mbed_app.json ? Do I need to directly modify the api or hal files? Am I just missing something extremely simple?

What I’ve Tried

So far I have

  1. attempted creating a regular SPIF but run into the same pin mapping issue with the QSPIF.
  2. Modifying qspi_api.c to ignore the NC checks.
    • This succeeded in initialization but failed later down the line when trying to read or write from the block device
  3. I have also tried the route discussed in 2 but without the block device class and attempting to do raw read and writes.
    • Nothing has crashed here but I have been unable to get any useful data off of the chip
QSPI qspi(PC_9, PC_10, NC, NC, PB_2, PB_6);
 char buf[30];
 size_t size = 30;
 qspi.write(0x9F, buf, &size); << 1, buf, &size);