undefined reference to `esp_aes_init'

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

undefined reference to `esp_aes_init'

Postby permal » Fri Aug 16, 2019 6:55 pm

I'm following the "rename main" component instructions in the documentation, but have gotten stuck on the following errors:

Code: Select all

: && /home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++  -mlongcalls -Wno-frame-address  -nostdlib CMakeFiles/smooth_test.elf.dir/project_elf_src.c.obj  -o smooth_test.elf  esp-idf/esp_ringbuf/libesp_ringbuf.a esp-idf/driver/libdriver.a esp-idf/wpa_supplicant/libwpa_supplicant.a esp-idf/efuse/libefuse.a esp-idf/bootloader_support/libbootloader_support.a esp-idf/app_update/libapp_update.a esp-idf/spi_flash/libspi_flash.a esp-idf/nvs_flash/libnvs_flash.a esp-idf/smartconfig_ack/libsmartconfig_ack.a esp-idf/esp_wifi/libesp_wifi.a esp-idf/esp_eth/libesp_eth.a esp-idf/lwip/liblwip.a esp-idf/tcpip_adapter/libtcpip_adapter.a esp-idf/esp_event/libesp_event.a esp-idf/pthread/libpthread.a esp-idf/espcoredump/libespcoredump.a esp-idf/esp32/libesp32.a esp-idf/xtensa/libxtensa.a esp-idf/esp_common/libesp_common.a esp-idf/esp_rom/libesp_rom.a esp-idf/soc/libsoc.a esp-idf/log/liblog.a esp-idf/heap/libheap.a esp-idf/freertos/libfreertos.a esp-idf/vfs/libvfs.a esp-idf/newlib/libnewlib.a esp-idf/cxx/libcxx.a esp-idf/app_trace/libapp_trace.a esp-idf/asio/libasio.a esp-idf/coap/libcoap.a esp-idf/console/libconsole.a esp-idf/nghttp/libnghttp.a esp-idf/esp-tls/libesp-tls.a esp-idf/esp_adc_cal/libesp_adc_cal.a esp-idf/esp_gdbstub/libesp_gdbstub.a esp-idf/tcp_transport/libtcp_transport.a esp-idf/esp_http_client/libesp_http_client.a esp-idf/esp_http_server/libesp_http_server.a esp-idf/esp_https_ota/libesp_https_ota.a esp-idf/protobuf-c/libprotobuf-c.a esp-idf/protocomm/libprotocomm.a esp-idf/mdns/libmdns.a esp-idf/esp_local_ctrl/libesp_local_ctrl.a esp-idf/esp_websocket_client/libesp_websocket_client.a esp-idf/expat/libexpat.a esp-idf/wear_levelling/libwear_levelling.a esp-idf/sdmmc/libsdmmc.a esp-idf/fatfs/libfatfs.a esp-idf/freemodbus/libfreemodbus.a esp-idf/jsmn/libjsmn.a esp-idf/json/libjson.a esp-idf/libsodium/liblibsodium.a esp-idf/mqtt/libmqtt.a esp-idf/openssl/libopenssl.a esp-idf/spiffs/libspiffs.a esp-idf/ulp/libulp.a esp-idf/unity/libunity.a esp-idf/wifi_provisioning/libwifi_provisioning.a esp-idf/smooth_component/libsmooth_component.a esp-idf/destructing_event_queues/libdestructing_event_queues.a -Wl,--cref -Wl,--Map=/home/permal/electronics/IO-Card-G3/software/externals/smooth/build/smooth_test.map esp-idf/esp_http_client/libesp_http_client.a esp-idf/tcp_transport/libtcp_transport.a esp-idf/esp-tls/libesp-tls.a esp-idf/protocomm/libprotocomm.a esp-idf/esp_http_server/libesp_http_server.a esp-idf/nghttp/libnghttp.a esp-idf/protobuf-c/libprotobuf-c.a esp-idf/mdns/libmdns.a esp-idf/console/libconsole.a esp-idf/smooth_component/libsmooth_component.a esp-idf/json/libjson.a esp-idf/fatfs/libfatfs.a esp-idf/wear_levelling/libwear_levelling.a esp-idf/sdmmc/libsdmmc.a esp-idf/libsodium/liblibsodium.a esp-idf/cxx/libcxx.a esp-idf/newlib/libnewlib.a esp-idf/freertos/libfreertos.a esp-idf/heap/libheap.a esp-idf/log/liblog.a esp-idf/soc/libsoc.a esp-idf/esp_rom/libesp_rom.a esp-idf/esp_common/libesp_common.a esp-idf/xtensa/libxtensa.a esp-idf/esp32/libesp32.a esp-idf/esp_ringbuf/libesp_ringbuf.a esp-idf/lwip/liblwip.a esp-idf/mbedtls/mbedtls/library/libmbedtls.a esp-idf/mbedtls/mbedtls/library/libmbedcrypto.a esp-idf/mbedtls/mbedtls/library/libmbedx509.a esp-idf/bootloader_support/libbootloader_support.a esp-idf/spi_flash/libspi_flash.a esp-idf/efuse/libefuse.a esp-idf/app_update/libapp_update.a esp-idf/tcpip_adapter/libtcpip_adapter.a esp-idf/wpa_supplicant/libwpa_supplicant.a esp-idf/nvs_flash/libnvs_flash.a esp-idf/smartconfig_ack/libsmartconfig_ack.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libcoexist.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libcore.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libespnow.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libmesh.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libnet80211.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libphy.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libpp.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/librtc.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libsmartconfig.a esp-idf/esp_event/libesp_event.a esp-idf/driver/libdriver.a esp-idf/vfs/libvfs.a esp-idf/esp_wifi/libesp_wifi.a esp-idf/esp_eth/libesp_eth.a esp-idf/app_trace/libapp_trace.a esp-idf/pthread/libpthread.a esp-idf/espcoredump/libespcoredump.a esp-idf/cxx/libcxx.a esp-idf/newlib/libnewlib.a esp-idf/freertos/libfreertos.a esp-idf/heap/libheap.a esp-idf/log/liblog.a esp-idf/soc/libsoc.a esp-idf/esp_rom/libesp_rom.a esp-idf/esp_common/libesp_common.a esp-idf/xtensa/libxtensa.a esp-idf/esp32/libesp32.a esp-idf/esp_ringbuf/libesp_ringbuf.a esp-idf/lwip/liblwip.a esp-idf/mbedtls/mbedtls/library/libmbedtls.a esp-idf/mbedtls/mbedtls/library/libmbedcrypto.a esp-idf/mbedtls/mbedtls/library/libmbedx509.a esp-idf/bootloader_support/libbootloader_support.a esp-idf/spi_flash/libspi_flash.a esp-idf/efuse/libefuse.a esp-idf/app_update/libapp_update.a esp-idf/tcpip_adapter/libtcpip_adapter.a esp-idf/wpa_supplicant/libwpa_supplicant.a esp-idf/nvs_flash/libnvs_flash.a esp-idf/smartconfig_ack/libsmartconfig_ack.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libcoexist.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libcore.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libespnow.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libmesh.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libnet80211.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libphy.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libpp.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/librtc.a /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32/libsmartconfig.a esp-idf/esp_event/libesp_event.a esp-idf/driver/libdriver.a esp-idf/vfs/libvfs.a esp-idf/esp_wifi/libesp_wifi.a esp-idf/esp_eth/libesp_eth.a esp-idf/app_trace/libapp_trace.a esp-idf/pthread/libpthread.a esp-idf/espcoredump/libespcoredump.a -lstdc++ -u __cxa_guard_dummy esp-idf/newlib/libnewlib.a -u newlib_include_locks_impl -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -Wl,--undefined=uxTopUsedPriority -L /home/permal/esp/esp-idf/components/esp_rom/esp32/ld -T esp32.rom.ld -T esp32.rom.libgcc.ld -T esp32.rom.syscalls.ld -T esp32.rom.newlib-data.ld -Wl,--gc-sections /home/permal/esp/esp-idf/components/xtensa/esp32/libhal.a -L /home/permal/electronics/IO-Card-G3/software/externals/smooth/build/esp-idf/esp32 -T esp32_out.ld -u app_main -L /home/permal/electronics/IO-Card-G3/software/externals/smooth/build/esp-idf/esp32/ld -T esp32.project.ld -L /home/permal/esp/esp-idf/components/esp32/ld -T esp32.peripherals.ld -u call_user_start_cpu0 -u ld_include_panic_highint_hdl -mfix-esp32-psram-cache-issue -u esp_app_desc -u vfs_include_syscalls_impl -L /home/permal/esp/esp-idf/components/esp_wifi/lib_esp32 -lgcov -lc -lm -lgcc && :
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/wpa_supplicant/libwpa_supplicant.a(aes-unwrap.c.obj):(.literal.aes_unwrap+0x0): undefined reference to `esp_aes_init'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/wpa_supplicant/libwpa_supplicant.a(aes-unwrap.c.obj):(.literal.aes_unwrap+0x4): undefined reference to `esp_aes_setkey'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/wpa_supplicant/libwpa_supplicant.a(aes-unwrap.c.obj):(.literal.aes_unwrap+0x8): undefined reference to `esp_aes_free'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/wpa_supplicant/libwpa_supplicant.a(aes-unwrap.c.obj):(.literal.aes_unwrap+0xc): undefined reference to `esp_internal_aes_decrypt'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/wpa_supplicant/libwpa_supplicant.a(aes-unwrap.c.obj): in function `aes_unwrap':
/home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-unwrap.c:68: undefined reference to `esp_aes_init'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-unwrap.c:69: undefined reference to `esp_aes_setkey'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-unwrap.c:71: undefined reference to `esp_aes_free'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-unwrap.c:95: undefined reference to `esp_internal_aes_decrypt'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-unwrap.c:105: undefined reference to `esp_aes_free'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/wpa_supplicant/libwpa_supplicant.a(aes-wrap.c.obj):(.literal.aes_wrap+0x0): undefined reference to `esp_internal_aes_encrypt'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: esp-idf/wpa_supplicant/libwpa_supplicant.a(aes-wrap.c.obj): in function `aes_wrap':
/home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-wrap.c:62: undefined reference to `esp_aes_init'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-wrap.c:63: undefined reference to `esp_aes_setkey'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-wrap.c:65: undefined reference to `esp_aes_free'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-wrap.c:87: undefined reference to `esp_internal_aes_encrypt'
/home/permal/.espressif/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/permal/esp/esp-idf/components/wpa_supplicant/src/crypto/aes-wrap.c:100: undefined reference to `esp_aes_free'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

What am I missing that causes the linker to emit these errors? I have included idf::mbedtls as per below component registration.

Code: Select all

idf_component_register(SRCS ${SOURCES}
                       INCLUDE_DIRS ${SMOOTH_LIB_ROOT}/smooth/include
                                    $ENV{IDF_PATH}/components
                                    ${CMAKE_CURRENT_LIST_DIR}/../lib/smooth/include
                        REQUIRES
                            idf::mbedtls
                            idf::cxx
                            idf::newlib
                            idf::freertos
                            idf::esp_wifi
                            idf::esp32
                            idf::freertos
                            idf::esptool_py
                            idf::fatfs
                            idf::sdmmc
                            idf::spi_flash
                            idf::nvs_flash
                            idf::wear_levelling
                            idf::lwip
                            idf::json
                            idf::xtensa
                            idf::pthread
                            idf::libsodium
                            idf::json
                        )

User avatar
rudi ;-)
Posts: 1728
Joined: Fri Nov 13, 2015 3:25 pm

Re: undefined reference to `esp_aes_init'

Postby rudi ;-) » Fri Aug 16, 2019 11:52 pm

perhabs it helps:

https://esp32.com/viewtopic.php?f=2&t=3080&start=10

-> esp_aes_init
-> esp32/aes.h
-> mbedtls/aes.h
( https://github.com/espressif/mbedtls/bl ... aes.h#L103
void mbedtls_aes_init( mbedtls_aes_context *ctx );
)

Code: Select all

..
#include "mbedtls/aes.h" // void mbedtls_aes_init( mbedtls_aes_context *ctx );
#include "esp32/aes.h" // void esp_aes_init( esp_aes_context *ctx )
..
your missing


btw:
did you check menuconfig "USE_MBEDTLS_CRYPTO" ?

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: undefined reference to `esp_aes_init'

Postby permal » Sat Aug 17, 2019 7:58 am

I do have WPA_MBEDTLS_CRYPTO, which presumably enables USE_MBEDTLS_CRYPTO

Disabling WPA_MBEDTLS_CRYPTO allows the project to compile, but that's not what I want.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: undefined reference to `esp_aes_init'

Postby ESP_Angus » Mon Aug 19, 2019 12:11 am

Hi Permal,

Exactly which version of IDF do you have ("get describe --tags")? Could you please post the full output from a CMake run? (Either running CMake directly or running "idf.py reconfigure" in your project.)

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: undefined reference to `esp_aes_init'

Postby permal » Mon Aug 19, 2019 4:27 am

v4.0-dev-1443-g39f090a4f
tensa-esp32-elf-gcc (crosstool-NG esp32-2019r1) 8.2.0

CMake output attached.
Attachments
output.txt
(6.19 KiB) Downloaded 720 times

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: undefined reference to `esp_aes_init'

Postby ESP_Angus » Mon Aug 19, 2019 5:49 am

Hi permal,

Thanks for those details.

I forgot that your project is a CMake project that integrates IDF as an external library. My guess is that this is why something is not building properly.

Is there a branch of your project that I can check out to reproduce this error?

Angus

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: undefined reference to `esp_aes_init'

Postby permal » Mon Aug 19, 2019 6:46 am

Angus,

That's the ting - it's not any longer. I've spent the weekend redoing my build system so that it follows IDF's component-based variant when building for the ESP (too much hassle using IDF as a lib when it is removed two steps from the main app). The only thing I'm doing differently is that I don't have a "main" folder so I'm following the instructions on how to build without a "main"-folder.

So, you can checkout the latest master (https://github.com/PerMalmberg/Smooth), run menuconfig to enable the Wifi supplicant to use mbedtls and just compile it as you would any other IDF-project. It'll compile the SNTP test project out-of-the-box.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: undefined reference to `esp_aes_init'

Postby ESP_Angus » Tue Aug 20, 2019 6:03 am

With commit 329bdf56881e113d3d1715255b1c83926b9e7843 and no config changes I get the following :

Code: Select all

../test/sntp/generated_test_smooth_sntp.cpp:20:17: error: 'sntp' is not a namespace-name
 using namespace sntp;
                 ^~~~
../test/sntp/generated_test_smooth_sntp.cpp:20:21: error: expected namespace-name before ';' token
 using namespace sntp;
                     ^
../test/sntp/generated_test_smooth_sntp.cpp: In function 'void app_main()':
../test/sntp/generated_test_smooth_sntp.cpp:27:5: error: 'App' was not declared in this scope
     App app{};
     ^~~
../test/sntp/generated_test_smooth_sntp.cpp:28:5: error: 'app' was not declared in this scope
     app.start();
     ^~~
I did just realise that a fix was committed internally which might address this problem (commit 6875080b9bcb65e435c23017286fb1a7480b4c41), and hasn't pushed to GitHub master branch yet due to a CI problem but should appear the next time master branch updates, hopefully in the next day or so.)

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: undefined reference to `esp_aes_init'

Postby permal » Tue Aug 20, 2019 9:09 am

Hm, that's odd. I'm sure I tested the sntp test before posting my reply. :\ Will check if I get the same in a completely fresh clone.

Looking forward to the next sync :)

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: undefined reference to `esp_aes_init'

Postby ESP_Angus » Wed Aug 21, 2019 2:02 am

Github master has updated, so if you can then please try again with latest master (commit 02c7c38)

Who is online

Users browsing this forum: Google [Bot] and 166 guests