[ESP8266][Arduino] `F()` macro is unnecessary on ESP chips?

Hey, I’m trying to understand PROGMEM.

How is that it DOES work to use PSTR() strings with “normal” functions, not the dedicated _P versions?

Is it because ESP8266 is NOT harvard architecture, so in fact “normal” function can access the “flash” addresses?

Then, I guess, F() macro is unnecessary on ESP chips, as normal functions can access data stored in FLASH with PSTR()?

According to Guide to PROGMEM on ESP8266 and Arduino IDE — ESP8266 Arduino Core 3.1.1-10-ge25f9e95 documentation passing non-progmem strings into non _P functions is undefined behavior. They also say that with declarations like

const char * xyz = "this is a string" 

the string will be placed in RAM, not Flash.

1 Like

I think you meant progmem strings into non-_P functions.

I do that, maybe it is UB, but it works. My suspicion is because esp8266 is not a harvard architecture – it has one memory address line, for both code and data. I’d like to confirm that.

Yeah, I know.

To store literals in Flash, I do:

const char * foo = PSTR("this is a string");