Chat freely about anything...

User avatar
By Rob.Binet
#79202 Environment
Wemos D1 mini pro (retired)
Arduino IDE 1.8.5
Esp8266 2.4.2 image
memcpy causes the ESP to crash see simple script below:
Code: Select allchar testChar[25];
void setup() {
  Serial.begin (115200);
  Serial.println ("Start mem copy");
result:

  memcpy (testChar,0,25);
}
void loop() {
}


Code: Select all ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld
Start mem copy

Exception (28):
epc1=0x40208774 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3ffffdb0 end: 3fffffd0 offset: 01a0

>>>stack>>>
3fffff50:  3fffdad0 0000000e 3ffee6a0 40202558 
3fffff60:  3fffdad0 00000000 3ffee6a0 402026a1 
3fffff70:  3ffe886f feefeffe 3ffee6a0 402026a1 
3fffff80:  3ffe8860 00000001 3ffee6a0 402026bc 
3fffff90:  0001c200 0000001c 3ffee6a0 402026e0 
3fffffa0:  feefeffe 00000000 3ffee6a0 402024d3 
3fffffb0:  feefeffe feefeffe 3ffee6bc 402028ac 
3fffffc0:  feefeffe feefeffe 3ffe84fc 401000e5 
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)


 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset
User avatar
By QuickFix
#79203 From my memory (but I'm not a C++ expert), memcpy() needs two pointers (a destination and a source) and an integer (length).
You're issuing a constant as source: is this correct? :?

Aren't you confused with memset() (fill your array with 25 zeros)?
User avatar
By quackmore
#79219 by the way

I think the exception 28 (LoadProhibitedCause: A load referenced a page mapped with an attribute that does not permit loads) (according to https://github.com/esp8266/Arduino/blob ... causes.rst)

was caused by memcpy trying to read from a flash memory address (the 0 passed as source address)
void *memcpy(void *str1, const void *str2, size_t n)

cheers