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

Moderator: igrr

User avatar
By brutzler
#29208 Hi,
just struggling with this: The concurrent use of PROGMEM with String-objects and the F-Macro causes a compile error on ESP8266-boards
This:
Code: Select allconst char html_page2[] PROGMEM = "Teststring";

void setup() {
  // Open serial communications:
  Serial.begin(115200);
  Serial.println(F("Programmstart"));
}

void loop() {
}
is working on using ESP8266-board and Arduino UNO

This:
Code: Select allconst String html_page2 PROGMEM = "Teststring";

void setup() {
  // Open serial communications:
  Serial.begin(115200);
  Serial.println(F("Programmstart"));
}

void loop() {
}
is only compiling with an UNO-Board selected.
With an ESP-Board it causes an
Arduino: 1.6.5 (Windows 7), Platine: "Generic ESP8266 Module (Autoflash), Serial, 80 MHz, 40MHz, DIO, 115200, 1M (512K SPIFFS)"

sketch_sep17a:1: error: html_page2 causes a section type conflict with __c
In file included from C:\Users\brutzler\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\cores\esp8266/Arduino.h:245:0,
from sketch_sep17a.ino:1:
C:\Users\brutzler\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\cores\esp8266/pgmspace.h:18:51: note: '__c' was declared here
#define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
^
C:\Users\brutzler\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\cores\esp8266/WString.h:38:76: note: in definition of macro 'FPSTR'
#define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
^
C:\Users\brutzler\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\cores\esp8266/WString.h:39:34: note: in expansion of macro 'PSTR'
#define F(string_literal) (FPSTR(PSTR(string_literal)))
^
sketch_sep17a.ino:6:18: note: in expansion of macro 'F'
html_page2 causes a section type conflict with __c


And even eliminating the F-Macro of the Seriel.println, it is compiling, but causing continously restarts of the ESP after flashing
User avatar
By martinayotte
#29242 Unfortunately, we can't use PROGMEM with println() directly on ESPs.
Why it is working on AVR ? simply because the Flash is directly accessible in the memory map of the AVR, which is not the case of ESPs since the Flash is external and connected by SPI bus, Flash content is accessible by cache mechanism.

If you really wish to use PROGMEM, you will need to write a println_P() wrapper function which would be similar to the send_P() or sendContent_P() from ESP8266WebServer which use a memccpy_P() to copy PROGMEM into a RAM buffer with limited buffer size and looping until the end of string.
User avatar
By brutzler
#29252 Hi Martin,
perhaps we talk past each other? Or I wrote the thread-header for missunderstood.
Sorry for this, but english is not my native.

The
Code: Select allSerial.println(F("Programmstart"));
is working for itself.

Problem is following:
I can define a char-array with PROGMEM. sketch is compiling and working.
But I can not define a string-object with PROGMEM.
Two issues
- In combination with the 'Serial.println(F("Programmstart"));' it is not compiling.
- And using it alone, the sketch is compiling, but always running into a restart.

Reading your statement, a cha-rarray-string could not be stored in flash with PROGMEM too, or?
But this is working.
User avatar
By martinayotte
#29254 Don't worry about your english, me too it is not my native language ... ;)

I means that if you try some thing like :

Code: Select allconst char huge_progmem[] PROGMEM = R"=====(...blablabla...)=====";
Serial.println(huge_progmem);


It will crash !

You will need to do some wrapper like (although code here is not formatted as a wrapper) :

Code: Select all    const char huge_progmem[] PROGMEM = R"=====(...blablabla...)=====";
    char chunkUnit[1001];
    chunkUnit[1000] = '\0'; 
    size_t remaining_size = sizeof(huge_progmem);
    PGM_P buf = huge_progmem;
    while (buf != NULL && remaining_size > 0) {
      size_t chunkUnitLen = 1000;
      if (remaining_size < 1000) chunkUnitLen = remaining_size;
      memcpy_P((void*)chunkUnit, (PGM_VOID_P)buf, chunkUnitLen);
      buf += chunkUnitLen;
      remaining_size -= chunkUnitLen;
      Serial.write((const char*)chunkUnit, chunkUnitLen);
    }


This will not crash ... ;)