UNO R4 and FlashStorage

There is a problem with compiling the examples from the FlashStorage library 1.0.0 with the new UNO R4
The same examples work fine with the SAMD Seeedunino Zero (using this same library not Seeeds own)

c:\Users\Melv\Documents\Arduino\libraries\FlashStorage\src\FlashStorage.cpp: In constructor 'FlashClass::FlashClass(const void*, uint32_t)':
c:\Users\Melv\Documents\Arduino\libraries\FlashStorage\src\FlashStorage.cpp:25:23: error: 'NVMCTRL' was not declared in this scope
PAGE_SIZE(pageSizes[NVMCTRL->PARAM.bit.PSZ]),

Correct me if I am wrong but NVMCTRL is a macro that resolves to something that is not declared when on UNO R4 but is on Seeeduino Zero. However there are thousands of references to NVMCTRL in the files in the 3 Arduinos folders, so I have not managed to trace it.

Anybody have any ideas?

That'll be specific to the SAMDs - the UNO R4 has a completely different processor from a completely different manufacturer.

Does anyone know of any alternative then. Is there any other way to retain some data through a reset, as I assume there is also no EEPROM like the old UNO R3 (AVR).

Hi @Melvb

The Uno R4 (WiFi and Minima) both support the EEPROM library:

The RA4M1 microcontroller doesn't use EEPROM per se, but instead uses 8KB of high endurance "data flash memory" that can withstand 100,000 program/erase cycles.

Oh yes there is:

Sorry @awneil my fault I did not make that clear.

I meant I assume thre was "no" EEPROM on the R4, like there "is" EEPROM on the R3. @MartinL lead me to something I had not yet found, that there is "virtual" EEPROM on the R4, that can be manipulated like the R3 but is actually stored in some of the flash memory on the R4.

Not had chance to try this out yet but it sounds exactly what I need, some persistent memory that survives resets and power downs. The only downside to flash on the SAMD devices over EEPROM on the R3 is that is does not survive a reprogram, and I have to re-initalise it from an SDcard after every reprogram to get the starting settings (which are different for each instance of the device, the main one that needs setting different on each is MAC address). I hope the R4 version of "Flash" EEPROM retains its setting on reprogram, but I haven't found a statement of that yet, will need to test to be sure.

1 Like

For the SAMD, I'm pretty sure there's a fuse setting to change that?

Maybe the tools could be tweaked to allow that?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.