This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

QSPI writes of <4 bytes fail

Hello:

I am using the QSPI example on the NRF52840 dev board with the objective of implementing SPIFFS. After a lot of tinkering I believe this is not possible due to the fact that the QSPI seems to fail for reads/writes of less than 4 bytes. I found this forum post https://devzone.nordicsemi.com/f/nordic-q-a/53405/write-1-2-3-bytes-into-serial-flash-by-qspi but I have not been able to find more info.

I wanted to ask, what is the reason behind it? I just want to understand and poissibly to see if it is a HW restriction, SW restriction, has to do something with the DMA, etc. SPIFFS is sadly not word aligned (however I fixed that) and also uses the last two bytes of a page to keep track of a page use (and here is where it is failing! I get failures when SPIFFS tries to update the # of times a page has been erased, and the write never concludes since it sends 2 bytes).

If there is no solution we can try normal SPI, which has worked before. But I wanted to raise the question to understand more. Also, has somebody been able to implement SPIFFS on an NRF52 using QSPI?

Thank you!

  • Hi

    Indeed, the QSPI is only able to read and write full words I.E. in multiples of 4 bytes. This is because the QSPI peripherals READ and WRITE SRC registers have to point to a word-aligned address and only works in 32-bit words, I.E. ending with 0x0, 0x4, 0x8, or 0xC. Please see the documentation for more information. I know this isn't much of a further explanation, but the fact is that the HW peripheral is not able to end at any other values.

    I think you will have to go for using normal SPI unless you're able to edit all messages to end with one of the mentioned values (you might be able to add empty bytes of data at the end of each transmission to make this happen).

    Best regards,

    Simon

  • Thank you, understood. I will implement with SPI. It would be a significant modification to the library to adapt for word use. Thanks again!

Related