Closed janoist1 closed 5 years ago
I am getting the same issues. undefined reference to `_binary_index_html_end'
I'm getting this issue as well. Are there any ideas on this @tonyp7?
Hi, I had the same issue, but adding the files as build param as mentioned in http://docs.platformio.org/en/latest/platforms/espressif32.html#embedding-binary-data fixes the linker problems. Still having issues that the jquery doesn't seem to get loaded in the page (all very static without the list of AP's).
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = espidf
build_flags =
-DCOMPONENT_EMBED_TXTFILES=src/index.html:src/jquery.gz:src/code.js:src/style.css
@ictcorebiz have you looked at the "Content-Type" and "Content-Encoding" header in your webpage response? Confirm you see the "Content-Type" as "application/json" and the "Content-Encoding" is "gzip."
Another suggestion to try would be to unzip jquery.gz into the respective jquery.js file and serve that instead of the compressed version.
It turned out that the library sent 1 byte too many (\u0), hence code.js gave an error. I added a -1 to the size and it worked perfectly. Thanks for helping.
Hi.
Sorry, but I still have the problem not able to load the external references:
.pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0x8): undefined reference to _binary_index_html_end' .pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0xc): undefined reference to
_binary_index_html_start'
.pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0x18): undefined reference to _binary_jquery_gz_end' .pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0x1c): undefined reference to
_binary_jquery_gz_start'
.pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0x28): undefined reference to _binary_code_js_end' .pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0x2c): undefined reference to
_binary_code_js_start'
.pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0x48): undefined reference to _binary_style_css_end' .pioenvs/esp32dev/src/http_server.o:(.literal.http_server_netconn_serve+0x4c): undefined reference to
_binary_style_css_start'
collect2: error: ld returned 1 exit status
*** [.pioenvs/esp32dev/firmware.elf] Error 1
Although I put in the external load in the .ini file: [env:esp32dev] platform = espressif32 board = esp32dev framework = espidf
build_flags = -DCOMPONENT_EMBED_TXTFILES=src/index.html:src/jquery.gz:src/code.js:src/style.css
Is there still some magic left I need to know?
found the problem, missing src in the asm definition: extern const uint8_t style_css_start[] asm("_binary_src_style_css_start");
Now I'm getting the same static behavior as ictcorebiz. Does someone knows where to add the "-1" in the source code?
The size for the content (javascript, css, web page) is incorrectly calculated in http_server.c:
netconn_write(conn, index_html_start, index_html_end - index_html_start, NETCONN_NOCOPY);
copies one extra byte at the end,
netconn_write(conn, index_html_start, index_html_end - index_html_start - 1, NETCONN_NOCOPY);
is the corrected version. This fix needs to be done for each copy. Patch: https://github.com/tonyp7/esp32-wifi-manager/issues/32
I follow all the instructions above and got the code compiled, but the landing page is rather static as described. I have done the patch but it looks to me the html is still trying to get jquery.js instead of jquery.gz, in which jquery.js is not in the board.
I can’t pin down the problem but I have a feeling more codes need to be modified for the html to use jquery.gz instead of jquery.js (as I go to ‘inspect elements’ of the landing page, it says ‘Failed to load resource: The network connection was lost.’ And ‘failed to load resource: the server response with a status of 400 (bad request)) Am I missing anything?
Hello, the file we embed is jquery.gz because its gzipped version of jquery.js, then in the web server when jsquery.js is requested we just serve the binary data of jquery.gz just like:
const static char http_jquery_gz_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/javascript\nAccept-Ranges: bytes\nContent-Length: 29995\nContent-Encoding: gzip\n\n";
if(strstr(line, "GET /jquery.js ")) { netconn_write(conn, http_jquery_gz_hdr, sizeof(http_jquery_gz_hdr) - 1, NETCONN_NOCOPY); netconn_write(conn, jquery_gz_start, jquery_gz_end - jquery_gz_start, NETCONN_NOCOPY); }
does that make sense?
In case anyone else ever comes here with this problem:
The reason some of the files have an extra byte on the end is the way PlatformIO handles files included with COMPONENT_EMBED_TXTFILES. You would think that it would apply the trailing /0 during the compile but it does not - it appends a /0 to the original source files (see here).
One simple workaround is to replace:
netconn_write(conn, index_html_start, index_html_end - index_html_start, NETCONN_NOCOPY);
with
netconn_write(conn, index_html_start, strlen(index_html_start), NETCONN_NOCOPY);
you would need to do this for index.html, code.js and style.css
Another would be to use COMPONENT_EMBED_FILES
instead of COMPONENT_EMBED_TXTFILES
but I've been unable to make that work correctly.
I ran into the same issue some days ago and I found, that PIO does not handle COMPONENT_EMBED_FILES
at the moment. So I created a PR platformio/platform-espressif32#220 to enable that functionality.
I also fixed the issue with modifying the files which have been embedded using COMPONENT_EMBED_TXTFILES
. The files will be emedded with \0 as string delimiter but the source file wont be altered.
The same issues exist with newer releases of esp32-wifi-manager on Platformio. For anyone else facing the same problem, this is the fix for wifi-manager release v3.3.1 on Platformio v3.0.0.
Add this to your platform.ini:
board_build.embed_txtfiles =
components/esp32-wifi-manager/src/index.html
components/esp32-wifi-manager/src/style.css
components/esp32-wifi-manager/src/code.js
Then modify these 3 lines in http_app.c:
252: httpd_resp_send(req, (char*)index_html_start, index_html_end - index_html_start);
258: httpd_resp_send(req, (char*)code_js_start, code_js_end - code_js_start);
265: httpd_resp_send(req, (char*)style_css_start, style_css_end - style_css_start);
to
httpd_resp_send(req, (char*)index_html_start, strlen((char*)index_html_start));
httpd_resp_send(req, (char*)code_js_start, strlen((char*)code_js_start));
httpd_resp_send(req, (char*)style_css_start, strlen((char*)style_css_start));
Hi,
Thanks for sharing this great work! I've made it run as it is but now I'd like to use it as a library. Is it possible to use it in PlatformIO? I've managed to add it to the project (with
pio lib install <url>
, andlib_deps = esp32-wifi-manager
), but couldn't make it work there. I copied the filemain.c
to mysrc
, and updated the includes inside as follows:I'm now getting error:
What am I doing wrong? It seems to me the assets couldn't be linked. Or it is just not yet capable for library use?