This complements the work you've been doing on moving the constant arrays in the encryption routines to PMEM.
Constant text strings actually take up SRAM space on the ESP8266 because the .RODATA segment must be copied to the top of RAM at startup since FLASH isn't byte-accessible but all string(char) functions (like ets_printf, Serial., etc.) need this. There are a lot of string literals in the axtls code for certificate debugging, and that eats up nearly 10% of the free RAM in any project w/SSL.
This patch moves the constant format strings in axtls' printf completely into FLASH and add a wrapper to copy it into a local stack-allocated space when needed, freeing up about 3100 bytes of RAM for use. This doesn't make FLASH usage any higher, either, since those strings were already being stored there (but never used after the power-on startup code).
Minor edits required in some of the output/debug/tracing functions, but no logic changed.
Constant strings do NOT show up in the symbol table, so they aren't easily visible by many tools like READELF. One easy way to check what string literals are eating up RAM in RODATA is to use the command:
objdump -s -j .rodata /tmp/arduino_build_89991/*.elf
where the number will vary depending on the Arduino PID, etc.
This complements the work you've been doing on moving the constant arrays in the encryption routines to PMEM.
Constant text strings actually take up SRAM space on the ESP8266 because the .RODATA segment must be copied to the top of RAM at startup since FLASH isn't byte-accessible but all string(char) functions (like ets_printf, Serial., etc.) need this. There are a lot of string literals in the axtls code for certificate debugging, and that eats up nearly 10% of the free RAM in any project w/SSL.
This patch moves the constant format strings in axtls' printf completely into FLASH and add a wrapper to copy it into a local stack-allocated space when needed, freeing up about 3100 bytes of RAM for use. This doesn't make FLASH usage any higher, either, since those strings were already being stored there (but never used after the power-on startup code).
Minor edits required in some of the output/debug/tracing functions, but no logic changed.
Constant strings do NOT show up in the symbol table, so they aren't easily visible by many tools like READELF. One easy way to check what string literals are eating up RAM in RODATA is to use the command:
objdump
-s -j .rodata /tmp/arduino_build_89991/*.elf where the number will vary depending on the Arduino PID, etc.