XIAO Sense nRF52840 LittleFS on QSPI Flash with FreeRTOS

I wasn’t able to figure out how to write to the 2 MB QSPI Flash and would still love to find out how, but I was able to figure out writing to the on-chip flash (with the help of @PJ_Glasso, of course!). Here’s the link to the GitHub repo with the InternalFS library. It acts as a wrapper for the AdafruitLittleFS library and writes to the 1 MB flash. Formatting doesn’t format the bootloader partition, but be mindful of the size of data you write to the memory. I’m not exactly sure if it can overwrite it, but it doesn’t sound fun finding out.

I’m pretty sure the on-chip flash has ~100,000 write cycles, but don’t put any formatting or writing functions in loop because it’ll wear it out pretty fast. I don’t think reading functions are included since it’s NOR flash.

In general the error messages are quite cryptic. From my experience with the library, when I would get an error message, the problem would usually be one of the following things.:

  • The file is open when you’re formatting
  • You’re trying to write when reading or read when writing
  • The file isn’t closed

If you use it with the SD library you’ll have to explicitly say where the File functions come from (since they both have a File class)

// Prefix with Adafruit_LittleFS_Namespace::
File.open(FILENAME, Adafruit_LittleFS_Namespace::FILE_O_READ);

They have some examples on the GitHub already, but if you can explain your use case I can try to create an example for you as well.

Let me know if you have any questions and good luck!