R strings - save in flash

Is there any way to store R strings in flash. I realize it can be done with char * "arrays", but have found no documentation on C strings.

Thanks

const String html_1 = R"=====(
<!DOCTYPE html>
<html lang="en">
  <head>

  <meta name='viewport' content='width=device-width, initial-scale=1.0'/>
  <meta charset='utf-8'>
.
.
.
.
)=====";

ESP Arduino Store "R" strings in flash - Search (bing.com)

That link mostly showed char arrays stored in flash, but I did not see any working examples of String arrays stored in flash.

In any case - I will move all the Strings into char *, and work with those for these strings.

Well, you did ask about storing C strings rather than C++ Strings

That's true, sorry

There is only one option to have strings sitting in flash: they are defined as const and linker script places these to flash ROM space.
When you flash now image (bootloader) - these const variables come from Flash ROM.

But no way to update, to write, during runtime: it would need a function to erase the flash, to write a segment etc.

For my understanding: all what is defined as const can sit in ROM, as available there during startup. But writing to ROM during is not possible, except you would reprogram the Flash ROM with a special procedure (like the bootloader does).

You can use the MAP file generated in order to check where such a const variable is located. Or define a const variable and check the address (via UART print).

It is not a compiler and language feature: the linker will organize where the variables end up. There not really a keyword in C language to specify it should be in ROM flash.
You can use attribute(()) or relay on: const goes to flash ROM.
A keyword R in front of a string might just define as "const" and therefore it goes to ROM. But the linker is in charge to assign global variables to memory regions, even ROM flash. Not any keyword available on source code level to control (memory management is not a feature of a compiler).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.