QSPI Erase and reboot does not keep the changes for me

Hello,

I am currently creating a save section on the QSPI Flash using qspi.Erase, qspi.Write, and memory reads.

Here is a simple repro:

  1. Create an app that is using the BOOT_TYPE=SRAM
  2. Add globals:
typedef struct _testing
{
    uint32_t    many[100];
} testing;

DSY_QSPI_BSS testing testqspi;
  1. in main make:
    hw.Init(true);

    const uint32_t EraseSize4K = 4096;
    uint32_t eraseme = (sizeof(_testing) % EraseSize4K) + sizeof(_testing);

    hw.seed.qspi.Erase((uint32_t)&testqspi, (uint32_t)&testqspi + eraseme);

  1. Set a breakpoint at the Erase line.
  2. Run the code to the break point
  3. Check the values in memory, my first few showed values of:
0: 0x20020000
1: 0x20020000
  1. Step past the break point after the qspi is erased
  2. Check the values in memory, my first few showed values of:
0: 0xffffffff
1: 0xffffffff
  1. Now restart the app.
  2. Run to the breakpoint
  3. Check the values in testingqspi. Here is what I am observing:
0: 0x20020000
1: 0x24000689

I would have expected the values pointing to the qspi memory to be 0xffffffff.

Any thoughts on what I may be doing incorrectly here?

Thank you for your time and help with this,
Brett

Hey Brett! I’m sorry for the delay in response. I appreciated your waiting.

We took a look at the code and it looks like it should probably work.
What we might suggest is using the PersistentStorage class to handle this instead rather than doing it manually. That approach might be less error prone.

Here’s the documentation for that class: libDaisy: daisy::PersistentStorage< SettingStruct > Class Template Reference