Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By ewaldc
#87624 This small program compiles without warnings, but crashes immediately.
I understand that accessing non-32 bit aligned data (e.g. a[6]) requires the use of special_P functions, but simply the definition of c[3] causes the program not to start.
Since &a is a (const char *) pointer, it would normally be 32 bit aligned, but it looks like the code crashes at initialization time. When declared in RAM there are no issues (array b[]).

Code: Select allconst char* a PROGMEM = "Alpha\0Bravo\0Charlie";
const char* b[3] = {&a[0], &a[6], &a[12]}; //OK
const char* c[3] PROGMEM = {&a[0], &a[6], &a[12]}; // declaration causes ESP12E to crash at (re)start

void setup() {
  Serial.begin(115200);
  while (!Serial) continue;
  Serial.println();
  Serial.printf_P(PSTR("PROGMEM Array %s %s %s\n"), &a[0], &a[6], &a[12]); // OK
  Serial.printf_P(PSTR("PROGMEM Array %s %s %s\n"), b[0], b[1], b[2]); // OK
  //Serial.printf_P(PSTR("PROGMEM Array %s %s %s\n"), c[0], c[1], c[2]);
}

void loop() {}


09:10:39.978 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
09:10:39.978 ->
09:10:39.978 -> load 0x4010f000, len 3456, room 16
09:10:39.978 -> tail 0
09:10:39.978 -> chksum 0x84
09:10:39.978 -> csum 0x84
09:10:39.978 -> va5432625
09:10:39.978 -> ~ld


[i]Environment
: Arduino IDE 1.8.12, nodemcu 1.0, Arduino ESP8266 2.7.1