Confused on how to embed files and what directory to place them

RollingRocker
Posts: 16
Joined: Tue Feb 09, 2021 10:45 pm

Confused on how to embed files and what directory to place them

Postby RollingRocker » Tue Sep 28, 2021 8:48 pm

I am working on the ESP-IDF with the ESP-AT command set.
I have an existing project (modified set of AT commands) that works/compiles and flashes fine.

I now want to embed 2 files into
\esp-idf\esp-at\main\interface\uart\at_uart_task.c

These 2 files are an SSL file (.pem) and a binary file .hex.
the names are ca_certs.pem and firmware.hex

I have tried various ways of putting the files via COMPONENT_EMBED_TXTFILES and EMBED_FILES into CMAKELISTS.txt and component.mk TO NO AVAIL.

I can't get the project to compile because presumably it's not finding the 2 files above (or I am putting them in the wrong location).

Where do I place these two files in the directory structure and what code do I put in the CMAKELISTS.txt or COMPONENT.MK to make these load and compile?

I have tried multiple ways of doing this such as:
idf_component_register(SRCS ${app_sources} EMBED_FILES "ca_cert.pem" "firmware.hex") (cmakelists.txt)
and
COMPONENT_EMBED_TXTFILES := ca_cert.pem
COMPONENT_EMBED_TXTFILES += firmware.hex


but each time I compile I get these errors and it won't compile.

c:/users/zzz/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(at_uart_task.c.obj):(.literal.fw_test1+0x24): undefined reference to `_binary_ca_cert_pem_start'
c:/users/zzz/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(at_uart_task.c.obj):(.literal.fw_test1+0x28): undefined reference to `firmware_hex_length'



Thanks in advance!


jdoubleu
Posts: 8
Joined: Wed Sep 29, 2021 3:58 pm

Re: Confused on how to embed files and what directory to place them

Postby jdoubleu » Thu Sep 30, 2021 9:52 am

First of all, you don't need to use component.mk if you're using the CMake build system.

You can find the documentation about embedding files here: https://docs.espressif.com/projects/esp ... inary-data

Make sure you following the naming rules/convention from the documentation and that you're resolving the symbols through the asm keyword:

Code: Select all

extern const uint8_t firmware_start[] asm("_binary_firmware_hex_start");
If your files are to be found in a subdirectory, still only their names get converted.

When adding the files to embed in your CMakeLists.txt, the paths are resolved relative to that file.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 80 guests