@dheerajdake I haven’t used the EEPROM yet although I will try to take a stab at a solution.
Referring to: https://github.com/m-mcgowan/spark-flashee-eeprom
384 pages @ 4096 bytes each are available in the EEPROM. That’s 1,048,576 bytes.
Two pieces of information to consider from the readme:
- The spark external flash has 384 pages, each 4096 bytes in size and is managed as the device provided via the Devices::userFlash() method. Rather than hard-code these page count and page size constants, you can make the code more flexible for future changes by using: Devices::userFlash().pageSize() and Devices::userFlash().pageCount()
- At present, the maximum contiguous area that the Wear Leveling and Address Erase schemes can occupy is 1MB (256 pages). This is to keep runtime memory overhead to a minimum.
A workaround is to create 2 devices as shown below in separate regions.
FlashDevice* eeprom = Devices::createAddressErase(0, 256*4096);
CircularBuffer* logBuffer = Devices::createCircularBuffer(256*4096, 384*4096);
My thinking is that the reason you are getting that error is because your read/write may fall along a page boundary when you create your device.
Each page can store 4096 bytes/2 bytes = 2048 short ints.
The following creates a buffer between page 256 and 384 (~0.5 MB). Its just for demonstration but expand it for your own application.
CircularBuffer* buffer = Devices::createCircularBuffer(4096256, 4096384);
When you read and write, use pointers and increment/decrement the address. Something like below:
ptr = &data;
bool success = buffer->write(ptr++, sizeof(data));
I’ll edit the post later to make it more clear.