After mcu reset calling nrfx_qspi_init on external flash fails with NRFX_ERROR_TIMEOUT

We are running a custom board with the nrf52840 mcu on the legacy 17.1 nrf sdk.
external flash IC is  AT25FF321A

On a small portion of our boards (maybe 1 - 5%) we are noticing that the external flash init code nrfx_qspi_init is failing with err = NRFX_ERROR_TIMEOUT;
This seems to happen in nrfx_qspi.c function qspi_ready_wait.

This happens when we do a mcu reset or software reset.
However, when we do a power reset (unplug the battery and plug back in) then the qspi init is a success.
We tried increasing the timeout in the qspi ready wait but that didn't work, we also tried clearing all the qspi gpio before hand but that didn't work either.
We also tried slowing down the qspi clock rate to 2 MHz (from 16MHz) but still no luck.
We also called nrfx_qspi_uninit but that failed on assert since 

NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED

Here is a small sample of the code:

#define GPIO_SPI_MISO           6u  // SIO_6  = NVM SPI MISO input pin (QSPI = IO1)
#define GPIO_SPI_CLK            7u  // SIO_7  = NVM SPI CLK output pin
#define GPIO_SPI_MOSI           8u  // SIO_8  = NVM SPI MOSI output pin (QSPI = IO0)
#define GPIO_SPI_IO3            9u  // SIO_9  = NVM SPI IO3 pin
#define GPIO_SPI_IO2            10u // SIO_10 = NVM SPI IO2 pin
#define GPIO_SPI_CS             34u // SIO_34 = NVM SPI CS output pin

nrfx_qspi_config_t nrfx_qspi_config = {.xip_offset = NRFX_QSPI_CONFIG_XIP_OFFSET,
                                       .pins =
                                           {
                                               .sck_pin = GPIO_SPI_CLK,
                                               .csn_pin = GPIO_SPI_CS,
                                               .io0_pin = GPIO_SPI_MOSI,
                                               .io1_pin = GPIO_SPI_MISO,
                                               .io2_pin = GPIO_SPI_IO2,
                                               .io3_pin = GPIO_SPI_IO3,
                                           },
                                       .prot_if =
                                           {
                                               .readoc    = (nrf_qspi_readoc_t)NRFX_QSPI_CONFIG_READOC,
                                               .writeoc   = (nrf_qspi_writeoc_t)NRFX_QSPI_CONFIG_WRITEOC,
                                               .addrmode  = (nrf_qspi_addrmode_t)NRFX_QSPI_CONFIG_ADDRMODE,
                                               .dpmconfig = false,
                                           },
                                       .phy_if =
                                           {
                                               .sck_delay = (uint8_t)NRFX_QSPI_CONFIG_SCK_DELAY,
                                               .dpmen     = false,
                                               .spi_mode  = (nrf_qspi_spi_mode_t)NRFX_QSPI_CONFIG_MODE,
                                               .sck_freq  = (nrf_qspi_frequency_t)NRFX_QSPI_CONFIG_FREQUENCY,
                                           },
                                       .irq_priority = (uint8_t)NRFX_QSPI_CONFIG_IRQ_PRIORITY};
                                       
nrfx_err_t nrf_err = nrfx_qspi_init(&nrfx_qspi_config, m_nrfx_qspi_handler, p_context);
// nrf_err == NRFX_ERROR_TIMEOUT (13)

what is going on and is there a firmware solution?

Parents Reply Children
No Data
Related