ESP_igrr wrote: ↑Tue Feb 26, 2019 10:05 am
The way you are doing this now seems to be the correct one. I don't think there is any better option when using just COMPONENT_EMBED_FILES without any extra logic.
(extra logic would be: determine size of the file at Make run time, store it as a variable, add -DMY_FILE_LEN=$(length_var) to CPPFLAGS...)
I was digging through a compiled MAP output (trying to find the actual handles the compiler used for the embedded files), and noticed that there appears to be a "size" attribute also provided. See below...
Code: Select all
_binary_web_index_htm_end .pio/build/esp32dev/index.htm.txt.o
.pio/build/esp32dev/src/wifi.cpp.o
_binary_web_index_htm_size .pio/build/esp32dev/index.htm.txt.o
_binary_web_index_htm_start .pio/build/esp32dev/index.htm.txt.o
.pio/build/esp32dev/src/wifi.cpp.o
_binary_web_script_js_end .pio/build/esp32dev/script.js.txt.o
.pio/build/esp32dev/src/wifi.cpp.o
_binary_web_script_js_size .pio/build/esp32dev/script.js.txt.o
_binary_web_script_js_start .pio/build/esp32dev/script.js.txt.o
.pio/build/esp32dev/src/wifi.cpp.o
_binary_web_style_css_end .pio/build/esp32dev/style.css.txt.o
.pio/build/esp32dev/src/wifi.cpp.o
_binary_web_style_css_size .pio/build/esp32dev/style.css.txt.o
_binary_web_style_css_start .pio/build/esp32dev/style.css.txt.o
.pio/build/esp32dev/src/wifi.cpp.o
I'm not well versed in the binutils, i.e. trying to figure out if that symbol is actually mapped to a memory address, what size the symbol is (assuming 32-bit?), and what value it is. Tried defining an "asm("")" to reference the corresponding "*_size" entry to a size_t, but it just crashes the ESP32 every time I try to access it.
I mean, doing "end - start" is one way to get the length--but heck, if there's a better way...what's the trick?