-->
Page 1 of 1

ESP12E crash when using PROGMEM

PostPosted: Wed Sep 14, 2016 9:50 am
by Pedro Albuquerque
I've been exploring the ESP8266 having previous experience using Moteino (arduino based board from LowPower labs).

In this approach i was inspired and based my projects on Andreas Spiess video tutorials (thank so much for this enlightening videos) and and code.

My platform is a ESP12E board, and using Arduino IDE 1.6.9 with board version 2.3.0.
All compilation done choosing board NodeMCU 1.0 (ESP12E) with 4M (3M SPIFFS).

I started by creating a template on which I would base my several projects, one that would include OTA, and Web config page that would save configuration on EEPROM.
Code can be found here -> https://github.com/Pedroalbuquerque/template

The original source used the PROGMEM modifier on all static string like html page definition like
"//
// HTML PAGE
//

const char PAGE_AdminMainPage[] PROGMEM= R"=====(
<meta name="viewport" content="width=device-width, initial-scale=1" />
<strong>Administration</strong>
<hr>
<a"..

with this declaration every time I access one from a browser the processor resets.

Changing it to

"//
// HTML PAGE
//

const char PAGE_AdminMainPage[] = R"=====(
<meta name="viewport" content="width=device-width, initial-scale=1" />
<strong>Administration</strong>
<hr>
<a"...

solves the problem.

Couldn't find out why so far.

With isolated PROGRAM var declaration on a basic sketch with just one var, this seems to work, but not on a more complex sketch with several declarations.
Could that be a bug in the ESP8266WebServer object in the server.on ( "/", []() ...) method something related to the size of the string pointer the method is expecting being diferente when there is a PROGMEM string var or regular string var ?

Did any one had this problem ?
problem can be seen on the video(.mov) also available on github.

Re: ESP12E crash when using PROGRAM

PostPosted: Wed Sep 14, 2016 12:48 pm
by martinayotte
PROGMEM need to be read by code in a special way since it is coming directly from Flash.
Every places you are using server.send() needs to be replace by its PROGMEM variant server.send_P() to avoid crashes.

Re: ESP12E crash when using PROGRAM

PostPosted: Wed Sep 14, 2016 1:22 pm
by Pedro Albuquerque
martinayotte wrote:PROGMEM need to be read by code in a special way since it is coming directly from Flash.
Every places you are using server.send() needs to be replace by its PROGMEM variant server.send_P() to avoid crashes.


Hello Martinayotte, thank you so much for your explanation, i would never guess, and already tested and confirmed - it WORKS!!! no more resets.

I wonder were I can find information about available methods and purpose, or do I have to dig into the library code ?

thanks once again
Pedro

Re: ESP12E crash when using PROGMEM

PostPosted: Wed Sep 14, 2016 3:09 pm
by martinayotte
For ESP8266WebServer, there is only send_P() and sendContent_P().
For low core files, they are defined in pgmspace.h, such as memcpy_P(), strlen_P(), strcpy_P(), strcmp_P(), printf_P(), etc ...