-
Notifications
You must be signed in to change notification settings - Fork 889
Description
Version/revision of the library used
2.7.20
Describe the bug
Currently used definition const PROGMEM char* X = "...stuff..."; is a no-op and simply refers to the string literal pool loaded in the RAM, it should be explicitly declared as const char X[] PROGMEM = "...stuff..." in the .cpp if the idea is to store things both in the flash and bound to a single object file
Lines 12 to 13 in 10706fc
| // Constant text to be shared across all object files. | |
| // This means there is only one copy of the character/string/text etc. |
IRremoteESP8266/src/IRtext.cpp
Line 195 in 10706fc
| const PROGMEM char *kAllProtocolNamesStr = |
Although, extern const char X[]; in the header does not work with arrays as the size is not known at compilation time and const char* X can't be used instead b/c it is a different type. One alternative is redirecting through a functionk, e.g. const char* protocols() { return &kAllProotoclNamesStr[0]; }, but one needs to be aware that this is a PSTR and only pgm_... reads work.
To Reproduce / example code
Running on the current esp8266 Core
#include <Arduino.h>
#include <IRtext.h>
const char teststring[] PROGMEM = "test\x00test\x00test";
void setup() {
Serial.begin(115200);
Serial.printf("%p\n", kAllProtocolNamesStr);
Serial.printf("%p\n", &teststring[0]);
}
void loop() {
}Will print 0x3ffxxxxx instead of something in the 0x402xxxxx range of the teststring[] var, where the flash strings are usually stored with the esp8266
Using something like gdb will also show the location when the -g option is set in the build flags line
(gdb.exe can be found with the gcc.exe and the rest of the toolchain, platformio.ini env modified build_flags = -g)
$ xtensa-lx106-elf-gdb.exe .\.pio\build\test\firmware.elf
(gdb) p /a kAllProtocolNamesStr
$1 = 0x3ffe8817
(gdb) p /a teststring
$2 = {0x74, 0x65, 0x73, 0x74, 0x0, 0x74, 0x65, 0x73, 0x74, 0x0, 0x74, 0x65, 0x73, 0x74, 0x0}
(gdb) p /a &teststring[0]
$3 = 0x4027a6e5 <_ZL10teststring>
(gdb)