0

EEPROM support in the Feather M0 would be really nice.
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

EEPROM support in the Feather M0 would be really nice.

by pocketmoon on Thu Jan 21, 2016 3:33 pm

the chip supports EEPROM through 'emulation' and it would be cool if that could happen.

It sucks having no on-board eeprom - especially after spending an afternoon trying to get an external SPI eeprom chip to work with no luck whatsoever.

pocketmoon
 
Posts: 78
Joined: Fri Dec 27, 2013 8:21 pm

Re: EEPROM support in the Feather M0 would be really nice.

by adafruit2 on Fri Jan 22, 2016 11:27 am

yah its the one sad thing about cortex m0 - but note that the eeprom would get erased during program!

try https://github.com/cmaglie/FlashStorage ?

adafruit2
Site Admin
 
Posts: 18711
Joined: Fri Mar 11, 2005 7:36 pm

Re: EEPROM support in the Feather M0 would be really nice.

by cbxbiker61 on Fri Jan 22, 2016 6:20 pm

The I2C or SPI Frams are good choices for new work. I've tested both of those out.

Interestingly enough the I2C Fram can be used as a drop-in replacement for the "normal" I2C EEPROMs, i.e. the EEPROM libraries work with it and it uses the same I2C address. An optimized Fram library can drive it a bit faster than the standard EEPROM libs though. I have libs for all of those scenarios.

cbxbiker61
 
Posts: 79
Joined: Wed Feb 04, 2015 7:16 pm

Re: EEPROM support in the Feather M0 would be really nice.

by pocketmoon on Mon Jan 25, 2016 11:03 am

adafruit2 wrote:yah its the one sad thing about cortex m0 - but note that the eeprom would get erased during program!

try https://github.com/cmaglie/FlashStorage ?



Hmm.. Datasheet suggest that EEPROM is available 'via emulation' which uses a section of flash that's protected from being erased. That sounds ideal. I'm surprised Arduino don't have an official EEPROM library for the similar Zero board.

pocketmoon
 
Posts: 78
Joined: Fri Dec 27, 2013 8:21 pm

Re: EEPROM support in the Feather M0 would be really nice.

by georgeklinger on Mon Jan 25, 2016 1:03 pm

Thanks. The lack of EEPROM made me dismiss M0-based boards, but this is a great solution. I was wondering whether PROGMEM macros might help, but this solution will work for me. I need to store some sensor calibration data and PID autotune data, and it doesn't matter much to me that it is lost during reprogramming. This is a nice solution!

georgeklinger
 
Posts: 37
Joined: Fri May 25, 2012 7:11 pm

Re: EEPROM support in the Feather M0 would be really nice.

by adafruit2 on Mon Jan 25, 2016 1:25 pm

great! its really the only thing that is missing...you could also use an M0 datalogger and store config in a file

adafruit2
Site Admin
 
Posts: 18711
Joined: Fri Mar 11, 2005 7:36 pm

Re: EEPROM support in the Feather M0 would be really nice.

by georgeklinger on Mon Jan 25, 2016 1:55 pm

great! its really the only thing that is missing...you could also use an M0 datalogger and store config in a file

I could, but in my case the end-user's data is stored there, and they could pull it out and insert a blank SD card...

georgeklinger
 
Posts: 37
Joined: Fri May 25, 2012 7:11 pm

Re: EEPROM support in the Feather M0 would be really nice.

by richdrich on Wed May 04, 2016 6:11 pm

I too need EEPROM (to store the WiFi credentials, without doing that any IOT device would be fairly useless...)

- Some ATSAMD21 devices have built in RWW emulated EEPROM, but the ATSAMD21G18 doesn't.

- It ought still be possible to write (and read) a section of Flash from a program

- However, the bootloader's X command which is used before programming erases all memory above a start address, so any flash data stored in high memory will get deleted on reprogram

Some ideas:
- Adafruit could change the bootloader to allow memory to be reserved (this would only help newly shipped devices and developers who own a programmer).

- We could (maybe) move the start of the (application) program up and have some memory below it that doesn't get erased.

- The ATWINC has also got Flash memory and there is a (low level) API to access this. It may be possible to store data on this - e.g. in the rollback image area (which would be invalidated only by a WiFi firmware upgrade).

- Finally, "bossac" could be changed (or just scripted) to save the Flash data area before an erase/programming operation and re-write it afterwards.

richdrich
 
Posts: 4
Joined: Thu Apr 28, 2016 6:49 pm

Re: EEPROM support in the Feather M0 would be really nice.

by adafruit2 on Wed May 04, 2016 6:36 pm

yah basically it would require a new bootloader that would not erase the whole chip during upload. this is just one of those sad things about arm cortex chips, they rarely have eeprom.
there's no ETA for adding this, its a lot of work and has a lot of potential to break other things!

adafruit2
Site Admin
 
Posts: 18711
Joined: Fri Mar 11, 2005 7:36 pm

Re: EEPROM support in the Feather M0 would be really nice.

by HerrGilbert on Fri Jul 08, 2016 8:02 pm



Basically, I tried that with my Feather M0 Bluefruit LE and the OLED Wing, and I have some weird behaviour: I've defined a struct like that:

Code: Select all | TOGGLE FULL SIZE
typedef struct {
  char username[64];
  char password[64];
  char comment[128];
} LoginEntry;

typedef struct {
  LoginEntry entries[32];
} LoginEntryStorage;


I then do the initialization like that:

Code: Select all | TOGGLE FULL SIZE
FlashStorage(mySecureStorage, LoginEntryStorage);


It happens that after uploading the sketch, the OLED stays black and the Feather is not recognized by the IDE for automatic sketch upload. After doublepressing the reset button, I can upload the Blink sketch and everything works like a charme. So I'm afraid that the library is overwriting "something", or does any other weird stuff.

Any idea what could cause this? The datasheet just blows my mind, and I don't want to break anything in terms of the bootloader.

HerrGilbert
 
Posts: 2
Joined: Sat Jul 11, 2015 5:38 am

Re: EEPROM support in the Feather M0 would be really nice.

by richdrich on Fri Jul 08, 2016 8:29 pm

Does the basic example: https://github.com/cmaglie/FlashStorage ... trieve.ino
work?

I might be wrong in this, but doesn't using the serial port always kill the bootloader and need a double-click to get back on a Feather? It does on my ATWINC1500.

richdrich
 
Posts: 4
Joined: Thu Apr 28, 2016 6:49 pm

Re: EEPROM support in the Feather M0 would be really nice.

by HerrGilbert on Sat Jul 09, 2016 7:18 am

Hi richdrich,

thanks for your reply!

Yes, the basic example works. I adapted it a bit like that:

Code: Select all | TOGGLE FULL SIZE
void setup() {
  SERIAL_PORT_MONITOR.begin(115200);
  while (!SERIAL_PORT_MONITOR) { }
 
  int number;


I did this for better debugging. So after pressing "Reset", I can see the counter on the serial monitor counting up.

Now I changed the example to include my struct:

Code: Select all | TOGGLE FULL SIZE
/*
  Store and retrieve an integer value in Flash memory.
  The value is increased each time the board is restarted.

  This example code is in the public domain.

  Written 30 Apr 2015 by Cristian Maglie
*/

#include <FlashStorage.h>

typedef struct {
  char username[64];
  char password[64];
  char comment[128];
} LoginEntry;

typedef struct {
  LoginEntry entries[128];
} LoginEntryStorage;

// Reserve a portion of flash memory to store an "int" variable
// and call it "my_flash_store".
//FlashStorage(my_flash_store, int);

FlashStorage(mySecureStorage, LoginEntryStorage);

// Note: the area of flash memory reserved for the variable is
// lost every time the sketch is uploaded on the board.

void setup() {
  SERIAL_PORT_MONITOR.begin(115200);
  while (!SERIAL_PORT_MONITOR) { }
  SERIAL_PORT_MONITOR.println("Hi! :)");
 
  LoginEntryStorage storage = mySecureStorage.read();

  // Print the current number on the serial monitor
  SERIAL_PORT_MONITOR.println("passed");
}

void loop() {
  // Do nothing...
}


I experimented a bit with the size of the "entries" array. Too bad you cannot embed tables here.^^

FYI: I'm closing the serial monitor between each step.

Elements: 1
Compiled Sketch Size (CSS): 8944 Bytes (3 %)
Behaviour: I can see the serial output, reset the board, see the serial output again. I can also re-upload the sketch automatically.

Elements: 16
CSS: 12.784 Bytes (4%)
Behaviour: Same as above.

Elements: 64
CSS: 25.072 Bytes (9%)
Behaviour: Same as above.

Elements: 128
CSS: 41.456 Bytes (15%)
Behaviour: I can see the serial output, reset the board, see the serial output again. But then the device is gone, it cannot be found on COM3! I can then double click "Reset" and upload a smaller sketch by switching to COM4. Then the board works again, and I have to switch back to COM3.

Now, in my "real" code, this error happens earlier, at 32 elements. But the sketch itself is bigger. My guess is that with the technique the library is using, "something" is overwritten, which the bootloader needs. It's just an educated guess, I don't really know it.

HerrGilbert
 
Posts: 2
Joined: Sat Jul 11, 2015 5:38 am

Please be positive and constructive with your questions and comments.