XIAO store data in QSPI flash memory

Hi everyone,

I’m trying to save the IMU data I get from my XIAO BLE Sense into its flash memory, until it can be sent via bluetooth, and don’t understand how to do it. Any help?

Thanks!
Dersim

I have not done it yet, but this may help you get started:

There are two versions of the programming environments (board files) in Arduino IDE for this board. Version 1.0 is using Adafruit (RTOS) and libraries and version 2.6.1 using Arduino on top of Mbed. Cannot use both at the same time. Have to uninstall one in order to load up the other.

Here are some examples that Seeed says can be adapted to QSPI from SD:

There is an example already in the Arduino IDE under named “Adafruit Internal File System on Bluefruit nrf52” => “Internal_ReadWrite” that works. It’s a very simple program that allows you to name a file and some text that you want inside that file and it will write it. Then when you reboot/restart the board you can read back that text from that file.

Careful not to place any write functions inside the “main loop” or it could wear out your memory. I assume its true for QSPI also.

The example does not work standalone - I tried the entire root, which is not a valid structure to be included as a library. Trying to load all dependencies turned out beyond my capabilities.
I am coming to the conclusion that I should stay away from the Seeed XIAO.

In order to make sure the new library works, make sure that the file structure inside the library folder you are adding to your Arduino IDE master library looks similar to this. May need to go several layers deep in the folder until you see similar to this:

Then either drop in the new folder (unzipped) in the Arduino master library (restart Arduino IDE); or import it with the ZIP function from the IDE menu (make sure it is zipped).

This library depends on other libraries and certain files in the “cores” directory. While each library has this structure and I can include it, the dependencies across multiple directories are beyond my programming skills.

This one worked for me (using BLE Sense board version 1.0 ). What are the problems you are running into?

  1. I cloned the git Adafruit_nRF52_Arduino, which is not valid library to be loaded
  2. I unzipped and zipped the libraries Adafruit_LittleFS and InternalFileSystem from within (those cannot be cloned individually)
    2a) I was able to add both libraries to my sketch
  3. I tried to add the library [Adafruit_TinyUSB_Arduino @ e58ed11] in the same way
    ==> Error: The library “Adafruit_TinyUSB_Arduino-e58ed11de15e2cfbd71f1a79cf84a2372ba27e08” cannot be used.
    Library names must contain only basic letters and numbers.
    (ASCII only and no spaces, and it cannot start with a number)
  4. I added Adafruit_TinyUSB via the library manager
  5. Compilation error:
    …/Arduino/libraries/InternalFileSytem/src/InternalFileSystem.cpp:26:0:
    …/Arduino/libraries/InternalFileSytem/src/flash/flash_nrf5x.h:28:10: fatal error: common_inc.h: No such file or directory
    #include “common_inc.h”
    ^~~~~~~~~~~~~~
    compilation terminated.
    exit status 1

If you installed SEED’s version 1.0 of the XIAO BLE Sense then you should be seeing this “example” file-tree. This comes with all the required libraries. If you do not have this file-tree showing under examples, then uninstall and reinstall version 1.0 (Adafruit) of the SEEED XIAO BLE Sense and check again.

Version 2.6.1 (Mbed) of the XIAO BLE Sense surely has a different structure and library.

1 Like

Anyone know how i can download the files to my computer from the flash directly through a cable? Thanks!

Hi,
I struggled for hours to find out how to write data to the flash memory. The subject itself is not well documented, there are several libraries its not clear which one to use. Some of them seem to write in the MCU internal flash…
Finally I get some success with Adafruit_SPIFlash.

I reworked their sample flash_speedtest and adapt it to this board. Here is a link to my gitlab repository.

You’ll see that it’s not so complicated, it’s mostly a lack of documentation.

@user1203 I think that your question is out of the scope of that thread.

Hi, have you tried to mount a filesystem to the qspi blockdevice? Thanks.

Please check my post about how to use the qspi on the seeed xiao ble sense. The qspi works.

But the littlefs does not work with that block device. I need help. Thanks.

Well,

How did you succeed in using the QSPI block device?
I tried to rebuild mbed including the patches 91 and 92 as described here. It took me a day to figure out how to do this. Including QSPIFBlockDevice.h still does not work.

Well… This board bored me a lot…

If others are thinking it, I’ll say it.
There is NO clear example that’s NOT a “HACK JOB” for SEEED on using the QSPI sure it works , If you want to buy a bridge I own one in Jersey I can Sell you.
No SEEED Engineers ever post definitive info.

Anyone have it working like a normal Flash memory with code ? , ie.You can read and write and erase , with out the need to wave a chicken over it and spin around 3.5 times and howl at the moon twice to get this stuff working?
C’mon SEEED, Adafruit is eating your lunch on this stuff…
–Soap box–OFF—
HTH
GL :slight_smile:

Hi,
Thank you @yangx30 for the hint, but… well, I know about this commit, it has been integrated in the master branch since more than a year. I checked the branch and didn’t found a “rollback” at least in the commit messages. So it is supposed to work out of box, even in the 2.9.1 release.

I tried the latest commit of that repository, it still doesn’t work. So there is probably a regression somewhere.
@yangx30 Actually, you opened this issue and closed it right after. But in my case I still have the same compilation errors as you had.

So, for now, I’m stuck with mbed, but I have some succes with the other … OS/solution/whatever?

Hi, that commit has NOT integrated in the master. Just modified the files and replace the local .a file with the provided .a file. It works.

Well,
according to what I see in git gui it is, but it has been reverted for some weird reason by this commit:

b659b54325c23ba69fdf3c252c5875436f52dc90 (for some reason I cannot make link to the repository like you did)

I cherry-picked that commit and indeed, QSPIF works. It would be nice to integrate it back. Maybe worth a merge request…

I don’t like when things are too… straight forward. But here… it’s a maze. I don’t like it too much either.

Hi there, Wonder if anyone has a working 2.9.1 board files QSPI flash that works, R,W,Erase…?
Seems this is TOO difficult for the SEEED (marketers) a.k.a engineering to provide a working example of this Smoke and Mirror Xiao line.
I beginning to wonder if they have any Xiao boards that actually do ALL they claim ?? Hmmm? also appears they CAN’t do Products on there own Software bases… Always need to poach other hardware platforms Gits… Hmmm.
GL :slight_smile:
PJ

Hello, the qspi flash does work with 2.9.1. Check this out:
Xiao BLE Sense using Mbed LittleFS on QSPI blockdevice - Products & Technology - Seeed Forum (seeedstudio.com)
For the erase, you need to erase at least 4kb (4096), which is the return value of bd.get_erase_size(0). In addition, you need to pre-erase the flash before read/write. Otherwise it is unstable. Good luck.