Code Monkey home page Code Monkey logo

esp_eeprom's People

Contributors

jwrw avatar raichea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

esp_eeprom's Issues

put() versus write() and get() versus read()

Sorry to ask a (perhaps) stupid question. I see the keywords include write and read, but the examples use put and get. Can someone please clarify which to use and when?

Thank you,
John

Allow instantiating multiple instances

The current implementation of this class deliberately hides the EEPROMClass constructor that takes in a specific sector, with the sector being hardcoded as:

((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE

While this specific sector is reserved for EEPROM emulation via flash memory, as far as I can tell there are other sectors that can be safely used, in which case having multiple instances of this library can be useful.

For my specific use case, I need to store some large certificates to flash (~3KB) as well as some other state. Storing this data in the same sector defeats the purpose of this library since the sector needs to be erased each time. However, I've had success using the next sector after the default, as well as instantiating two instances of this class (I'm also using #define NO_GLOBAL_EEPROM). I didn't notice any unpredictability as this comment describes:

* There should not be any reason for creating a second instance of the ESP_EEPROM class
* and as the library assumes there is only one instance and only one EEPROM sector
* results may be 'unpredictable'.

As a start, the constructor with the sector could be promoted to public visibility. To make it easier to use, another approach could be to have a constructor with a sector offset, which would avoid having to hardcode the address above in user code.

commit() should not report error if data not changed

It seems that if commit() is called, and the data in the internal buffer has not changed since the last commit, then commit() reports an error (returns false). Thus we have no way of determining that the error is caused by bad data, bad flash memory, or that the data simply did not change.

It seems that a better idea would be to always return true from a commit, as long as the data in the buffer is identical to the data in EEPROM. As a programmer and a user, I don't really care if the commit was aborted because the data was changed, only if it failed because of an error.

undefined reference to `_FS_end'

Compiling an example sketch results in this error:
c:/users/.../appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: libraries\ESP_EEPROM\ESP_EEPROM.cpp.o:(.text._ZN11EEPROMClassC2Ev+0x0): undefined reference to _FS_end

Which board do I have to select? WeMos D1 R1 always worked fine for flashing Chinese D1 boards. Do I have to pick another one?

Where does _FS_end, declared in ESP_EEPROM.cpp, refer to?

Having Issue Getting it to Work

I have a ESP8266 WeMos Mini and I'm following the ESP_EEPROM_Simple example. Compiling with Generic ESP8266 Module in Arduino IDE. Here is the relevant code for the EEPROM.

The variables I'm trying to put/get are float.

    #include <ESP_EEPROM.h>

    EEPROM.begin(64);

    EEPROM.put(0, 1.0);   // TavgGain    EEPROM Addr 0-3
    EEPROM.put(4, -5.0);  // TavgOffset  EEPROM Addr 4-7
    bool EE_OK = EEPROM.commit();

    Serial.print("EE_OK = ");
    Serial.println(EE_OK);

    EEPROM.get(0, mySensorData.TavgGain);
    EEPROM.get(4, mySensorData.TavgOffset);

    Serial.print("TavgGain = ");
    Serial.println(mySensorData.TavgGain);
    Serial.print("TavgOffset = ");
    Serial.println(mySensorData.TavgOffset);

The Serial Monitor Output...

EE_OK = 1
TavgGain = 0.00
TavgOffset = 0.00

Any idea why it's not working??

ESP_EEPROM_Wipe systematic compilation error

1/ I have installed the Arduino IDE on a Raspbian distrbution on a PI3B+.
2/ I have added the ESP8266 library
3/ I have added the EE_EEPROM library
when I compile the example ESP_EEPROM_Wipe I systematically get this error:

/home/pi/arduino-nightly/libraries/ESP_EEPROM/src/ESP_EEPROM.cpp:90:21: fatal error: c_types.h: No such file or directory compilation terminated. exit status 1 Error compiling for board Arduino/Genuino Uno.

the missing file is under the /home/pi/.arduino15 folder tree

note: the native arduino examples are working fine

could you please give me some light ?

Doubt about flash memory operation

Hi.
I have read that only around 10,000 write cycles are guaranteed for flash memory, although it can be much more. But this question arises: if using this library I write 10,000 times in a sector, would only that sector be damaged, or the entire memory? Because I need to register a variable around 100000 times without risk, and I must do it because where I am going to use my system, the power supply is unpredictable, and, if there is a power outage, I need to be sure what the last value of the variable once the system restarts. I think that I could change the sector every time I approach the limit of 10,000 writes, but I don't know if that would solve this problem. I appreciate your help.

Commit does return an error code

Hi,

Thanks for the great work to this library !

I make use of the library in an Arduino (v1.8.13) script for the wemos mini D1 Pro.
Whatever I try, I keep on getting a returncode 'false' from the EEPROM.commit() and the values are not written to EEPROM. I'm using ESP_EEPROM version 2.1.1 with standard Arduino library management.

The put and get functions seem to work flawless as the get does return the expected values after the put. The problem is its not written to EEPROM with EEPROM.commit().

This is the code I use:

String RfDeviceID[] = {"xx", "74"};
const int RfDeviceIdCount = 2;
int eeAddress;
...
void setup() {
...
EEPROM.begin(RfDeviceIdCount * 10); //Initialize EEPROM
String initCode;
char arrayFromStore[10];
eeAddress=0;
EEPROM.get(eeAddress, arrayFromStore);
initCode = arrayFromStore;
Serial.println();
Serial.print("\nInitCode from EEPROM: ");
Serial.println(arrayFromStore);
if (initCode != RfDeviceID[0]) {
writeInitEEPROM();
}
for (int i=0; i<RfDeviceIdCount; i++ ) {
eeAddress=i10;
EEPROM.get(eeAddress, arrayFromStore);
RfDeviceID[i] = arrayFromStore;
Serial.print("init ");
Serial.print(i);
Serial.print(" read from EEPROM: ");
Serial.println(arrayFromStore);
}
}
...
void writeInitEEPROM() {
char arrayToStore[10];
for (int i=0; i<RfDeviceIdCount; i++ )
{
RfDeviceID[i].toCharArray(arrayToStore, RfDeviceID[i].length()+1);
Serial.print("write init ");
Serial.print(i);
Serial.print(" to EEPROM: ");
Serial.println(arrayToStore);
eeAddress=i
10;
EEPROM.put(eeAddress, arrayToStore);
}
boolean ok=EEPROM.commit(); //Store data to EEPROM
Serial.print((ok) ? "EEProm commit OK: " : "*** EEProm commit failed !!! ");
Serial.println(ok);
}

Example of the output:
13:03:57.000 -> InitCode from EEPROM: ⸮�
13:03:57.000 -> write init 0 to EEPROM: xx
13:03:57.000 -> write init 1 to EEPROM: 74
13:03:57.000 -> *** EEProm commit failed !!! 0
13:03:57.000 -> init 0 read from EEPROM: xx
13:03:57.000 -> init 1 read from EEPROM: 74

Char array inside struct does not terminate correctly

Problem: I've been trying to save a char array inside a struct (only the array for now but used a struct to support features later) and while it appeared to save correctly it did not retrieve the array correctly.

Soltion: If I add another variable to the struct everything works.

struct EEPROM_struct {
    char uid[36];
    uint8_t temp = 0x33;
}eepromVal;

VSCode incompatibility

Not an issue with this library - just a warning to others:
If you try to run the examples from VSCode using the VSCode serial monitor you will get no output, which might leave you wondering what's wrong with the code. It's not the code, it's the serial monitor. There's something going on with the monitor that is breaking output in certain conditions. Use a different monitor/terminal emulator.

Port to ESP32?

Hi there,

Trying to make this library work on an ESP32 and running in to the issue. Here is the error:

/Users/myusername/Documents/Arduino/libraries/ESP_EEPROM/src/ESP_EEPROM.cpp:90:21: fatal error: c_types.h: No such file or directory

If it helps, the ESP32 I'm specifically using in the Boards menu is "ESP32 Wrover Module".

Has the library been tested with ESP32? Any known ways to fix this error or port the library?

Thank you

ESP_EEPROM-master not compiling with LOLIN32 or WEMOS LOLIN32

Sorry if this is an easy fix but I already have half a day in trying to figure out how to get the ESP_EEPROM library to compile for my ESP32 boards: LOLIN32 or WEMOS LONLIN32

I have downloaded V2 via zip and installed them, removing other ESP_EEPROM libraries from my system.

This is the compile-time error I get:

C:\Users\Pete\Documents\Arduino\libraries\ESP_EEPROM-master\src\ESP_EEPROM.cpp:90:21: fatal error: c_types.h: No such file or directory

compilation terminated.

the file ESP_EEPROM.cpp is definitely in this directory and it is a good file.

suggestions are appreciated. stuck until I solve this.
Thanks!

Reference to SPIFFS file system which is now deprecated

The EEPROMClass constructor uses _SPIFFS_END to calculate the sector number for the EEPROM. SPIFFS is now deprecated with the move to LittleFS and so this reference will break in the future. Need to us _FS_END instead

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.