Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By wpfundstein
#20868 Hi

Vars

Code: Select allstruct _settings {
  int id;
  int wlan_mode;
};

_settings settings;



function readSettings

Code: Select all
void readSettings() {
 
  int i = 0;
  byte e[4096];
  unsigned long size = 0;
  Serial.println("read 4096 bytes");
  for (i = 0; i < 4096; i++) {
    e[i] = EEPROM.read(i);
  }

  Serial.println("copy data to settings");
  size = sizeof(_settings);
  memcpy(&settings,e,size);
  Serial.println("done");
 
}



Setup

Code: Select allvoid setup() {

  // put your setup code here, to run once:
  Serial.begin(9600, SERIAL_8N1);
  Serial.println("");
  Serial.println("Init");

  Serial.println("Init");

  WiFi.mode(WIFI_OFF);

  EEPROM.begin(4096);

  readSettings();
 
  Serial.println("Ready");
 
}


Main

Code: Select all
void loop() {
 
  while(1) {
    delay(10);
  }

}


i call the function readSettings and got the message "done" on Serial. then the module resets.

if i comment out the line with memcpy i got no reset. i also used os_memcpy to test. same result: reset

Any idea?
User avatar
By gustav1971
#62263 Hello
Same problem here.
os_memcpy makes module reset writing the fields of a struct declared into a function.
If I copy the fields one by one (they are char arrays) with single byte assignments, no problems.
If I create a memcpy of my own, same issue.
Any ideas?
Thank you
Marco