Calling String::reserve() causes a crash if String object was in invalidated state. Per the comment on the method's declaration in ESP_SSD1306.h, This method was supposed to recover invalidated strings. This change fixes the edge case bug in String::changeBuffer() which is the root cause of the crash exposed from String::reserve().
Following test code was used to reproduce the problem and also to validate the fix:
String result;
while(true){
char c = 'A';
result += c; // the loop will cause malloc() to fail at some point.
if (result.c_str()==0)
{
Serial.println("String INVALIDATED!!!!!");
result.reserve(0); // before fix, this would crash.
Serial.println("Trying to empty....");
result="";
Serial.println("Emptied!!!!");
break;
}
}
PSTR() and F() macros correctly place string into flash memory relying
on PROGMEM
PROGMEM uses ICACHE_RODATA_ATTR
Print and String classes fixed up
str* classes fixed up
This includes empty stubs for most core Arduino functions.
Need to actually implement all those digital reads writes whatever.
Need to prebuild toolchains (xtensa-elf-lx106) for 3 platforms and put them on some download server.
Need to do the same with esptool.
Need to fix 0x40000 binary generation and add correct upload commands.
Maybe even implement uploads over WiFi.