I've been trying to find a simple way to store key=value parameters between power cycles.
Using EEPROM or SD cards won't work with OPTA
I was directed by support to Portenta's tutorial.
when trying the full copy of the sketch FlashKeyValue.ino with the helper .h file
I get
/Users/bradkuhns/Library/Arduino15/packages/arduino/hardware/mbed_opta/4.0.10/cores/arduino/main.cpp:47: undefined reference to `loop'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Opta.
When I try the other examples it overwrites the WiFi partition.
I can fix WIFI using the example files to repartition but isn't there a simple example for OPTA NOT PORTENTA that could be published?
Hi @bkuhnsarduino.
I didn't find any sketch named "FlashKeyValue.ino" on the tutorial you linked. The sketch on the linked page is named "FlashStorage.ino".
I did find another tutorial with a sketch named "FlashKeyValue.ino":
Which tutorial are you using?
If you are using the "Creating a Flash-Optimized Key-Value Store" tutorial, did you piece together a sketch yourself from the snippets provided in the tutorial, or did you open the complete sketch from the File > Examples > Arduino_Pro_Tutorials > Creating a Flash-Optimized Key-Value Store > FlashKeyValue menu in Arduino IDE as mentioned by the tutorial? Note there is a typo in the sketch name in the tutorial, which I have now submitted a fix for.
The error you got has nothing to do with the Opta board. The problem is simply that every Arduino sketch must contain a loop
function and the sketch you are compiling does not contain a function of that name.
I compiled the "FlashStorage.ino" sketch provided in the tutorial and also the "FlashKeyValue.ino" sketch from the "Arduino_Pro_Tutorials" library as mentioned in the "Creating a Flash-Optimized Key-Value Store" tutorial. Both of them contain a loop
function and both of them compile without any problems for the Opta.
Thank you.
The missing void loop(){} was indeed the problem with the FlashKeyValue.ino demo.
I made an error in the sketch name with the link because I had copied the QSPI in section 5 of the link I posted into the alternate sketch name just to test it. My error I'm sorry.
However the link I posted originally, when run on OPTA 485 model, disables WIFI due to erasing WIFI partitions and has to be restored by reflashing the WIFIFirmwareUpdater. You may want to warn of that on the demo page.
example tryiing the demo then trying my working code after it (just replicated it)
Failed to mount the filesystem containing the WiFi firmware.
Usually that means that the WiFi firmware has not been installed yet or was overwritten with another firmware.
Further the example always produces a random number of 45 because it seeds by analog read of a likely zero value every time.
Random number: 45
Done.
QSPI Block Device Test
Partitioning block device...
Block device size: 4 KB
Readable block size: 1 bytes
Programmable block size: 1 bytes
Erasable block size: 4 KB
Reading previous message...
Random number: 45
Writing new message...
Random number: 45
I think the simple keyvalue pair would be worthy of having a demo perhaps with a bit more use case examples for OPTA users on the OPTA demo pages. It's not on the downloaded examples for OPTA just portenta.
Thank you, I should have it from here.