[Submission] Flashee-eeprom library: eeprom storage in external flash


#122

version 1.1.7.9 of flashee was pushed to github and imported to the web IDE - this fixes an error that can occur writing to particular addresses and with specific data access patterns with the address erase scheme.

If you have used flashee before but seen errors, please try with the updated version. I will be updating the unit tests to cover this particular case and similar cases so these types of errors won’t happen again in future.


#123

This library was just what I needed. Thank you so much!


#124

It was working last week until today with these code. The led flash SOS (red)

FlashDevice *record;
struct WEATHER_REPORT report;

record = Devices::createAddressErase( ); // OK

record->write (&report, 430, sizeof(struct WEATHER_REPORT)); --> OK
record->write (&report, 480, sizeof(struct WEATHER_REPORT)); --> ERROR

Size of (struct WEATHER_REPORT) is 56 bytes.
Further test should certain address cause problem. What function should I use to define the range of valid flash-ee to use ?

NOTE : with more test, if I move the start address of all the records. to 1000 instead of 0. Everything is OK. Meaning certain code overlap in the 500 area.


#125

@mdma

Just wondering what the main differences between this library and the existing EEPROM library are? (https://docs.particle.io/reference/firmware/photon/#eeprom)
I assume the above library doesn’t include the wear leveling algorithm etc?
I envisage my users doing about 3-4 writes a day max and would like a decent product lifetime (~10 years).
To save memory I’d prefer to use the (smaller?) EEPROM library instead if wear wasn’t going to be a problem…


#126

Sorry guys for the noob-level question. And I also carry the burden of reviving this thread which was 455 days older. :wink:

So I was able to get the library up and running on CircularBuffer. The data is getting retained and retrieved but after a reset the data is lost like its getting cleared. On reading after reset a variable length of “¥” gets read on every reset.

My purpose of using the library if for storing data without having to use external eeprom. Can someone please tell me if this user flash cannot be used like eeprom to retain data over resets? If it can be used to retain data then what am I doing wrong?


#127

the library does save data persistently, but not the read/write pointers with CircularBuffer. CircularBuffer was made to allow streamed data to be buffered to a larger memory store than RAM - persistence isn’t the primary motivation here.


#128

Thanks a lot @mdma. createWearLevelErase() worked for me!


#129

Hi Guys. Continuing the same thread. I am using flashee for reading from and writing to a struct variable.

Right after flashing the code on photon, I get the red flashes of death right after the read statement (same is happening with write statement) is encountered. Below are parts of my code:

// global declared flash device
FlashDevice* FlashVar = Devices::createAddressErase(0*Devices::userFlash().pageSize(), 60*Devices::userFlash().pageSize());

// my struct - global
struct Mystruct2
{
  uint8_t Var1;
  uint8_t Var2;
  char Var3[9];
  char Var4[9];
  int16_t Var5[6];
  int8_t Var6[6];
};

struct MyStruct
{
  Mystruct2 Struct2Test;
  uint8_t Var1;
  uint8_t Var2;
  uint8_t Var3;
}
StructTest[8];

void setup()
{
  for(uint8_t V_IDX_VAR = 0; V_IDX_VAR < 8; V_IDX_VAR++)
  {
     FlashVar->read(&StructTest[V_IDX_VAR], sizeof(MyStruct), (V_IDX_VAR)*sizeof(MyStruct));
  }
}

void loop()
{
  // do nothing
}

So, I tried to debug the issue a little bit and found that when I hard code the value of V_IDX_VAR to 0 and 1 in flash read command it works fine. But as soon as the value exceeds 2 then photon starts flashing red.

eg. FlashVar->read(&StructTest[V_IDX_VAR], sizeof(MyStruct), (0)*sizeof(MyStruct)); // works fine
FlashVar->read(&StructTest[V_IDX_VAR], sizeof(MyStruct), (1)*sizeof(MyStruct)); // works fine

but

FlashVar->read(&StructTest[V_IDX_VAR], sizeof(MyStruct), (2)*sizeof(MyStruct)); // red flashes

Can someone tell me what is going wrong here? I am sure its related to the address of reading. But I have 04096 to 604096 as the range of device and I also printed the addresses of reading and they are 0(works fine), 232 (works fine), 464 (red flashes onwards),…


#130

Ping @rickkas7


#131

@rickkas7 Can you help with the above problem that I am facing?


#132

I’ll try to run the code tomorrow (Wednesday) and see what happens.


#133

Hey there NS_Blue,

You did a good job of finding some edge cases of when it fails or succeeds! That’s a good start. We need all the details to be able to reproduce the issue.

Writing up a “steps to reproduce” is a good way to find all the details needed, off the top of my head I’m thinking:

  • version of flashee-eeprom used
  • device type
  • version of system firmware on the device

Essentially you are describing the exact sequence of steps that someone else has to take to reproduce the situation you are in. I hope that helps! :slight_smile:


#134

Hi @mdma. Sorry was travelling most past days. So dint get a chance to update the thread. So I got it to work by changing the way the call is made to read and write. Unfortunately the call was incorrectly mentioned in one of the threads or it may have been the way it used to then when the post was made.

The right call to get it working was
FlashVar->write(&StructTest[V_IDX_VAR], (V_IDX_VAR)*sizeof(StructTest), sizeof(StructTest));

instead of
FlashVar->write(&StructTest[V_IDX_VAR], sizeof(MyStruct), (V_IDX_VAR)*sizeof(MyStruct));

Anyways, now that I have it working I am having issue that the at times I have seen wrong values being read like -1 in some of the struct variable.

Do you have any insight as to why this would be happening?

Flashee version 0.1.8
Device type P1
System firmware 0.6.1

So, this has happened thrice in few days I have been using flashee and has been a a bit scary to put it in production. I want to know if I can depend with my life on flashee to read the right values? :worried:

ps. specifically seen wrong data of -1 in signed integer variables.


#135

Any update on this one? @mdma


#136

Can I use this to PHOTON PARTICLE


#137

Sir, I am using PHOTON can I use this library to store data when there is no WiFi connection, please help e in this context.My project is struck here


#138

@Jeevan_Jinnu, you can use the Photon but you will need to provide an external SPI flash chip. The P1, much like the old Core, has a 1MB flash chip onboard.