-->
Page 1 of 1

ESP8266 and PROGMEM

PostPosted: Thu Jun 07, 2018 6:52 am
by gatoruss
I know there must be something I am missing, but how does the code described at the following link use String to copy char array from flash?

https://circuits4you.com/2016/12/16/esp8266-web-server-html/

Whtyaren't the special attributed and function at the following link required?

https://github.com/esp8266/Arduino/blob/master/doc/PROGMEM.rst

Re: ESP8266 and PROGMEM

PostPosted: Sun Jun 10, 2018 3:40 pm
by gatoruss
It seems that PROGMEM is not necessary with respecr to the ESP8266 - If "Constant Data" is automatically saved in flash, and can be read directly from flash without first being read into RAM. See https://www.esp32.com/viewtopic.php?t=2737

Re: ESP8266 and PROGMEM

PostPosted: Sun Jun 10, 2018 4:13 pm
by btidey
I didn't think that was the case for the esp8266.
See http://arduino-esp8266.readthedocs.io/e ... OGMEM.html

Re: ESP8266 and PROGMEM

PostPosted: Sun Jun 10, 2018 6:06 pm
by McChubby007
btidey wrote:I didn't think that was the case for the esp8266.
See http://arduino-esp8266.readthedocs.io/e ... OGMEM.html

I agree. Must use PROGMEM. Same with Atmel328 (Uno etc).
I've made mistakes in the past with a table of pointers to strings, with the pointers going in PROGMEM and the strings in RAM.
Arduino Due on the other hand doesn't need PROGMEM and will happily put const strings in flash.
I would say in any case, for the sake on compatibility it is better to always use PROGMEM no matter what. The architectural settings can then decide whether to ignore or use PROGMEM (for instance a lot of my code is developed and runs on Linux as well as esp8266, so I just redefine PROGMEM on the linux compile).