esp-rs / esp-idf-svc

Type-Safe Rust Wrappers for various ESP-IDF services (WiFi, Network, Httpd, Logging, etc.)
https://docs.esp-rs.org/esp-idf-svc/
Apache License 2.0
285 stars 161 forks source link

Use of embassy primitives fails with linking errors to missing embassy symbols #417

Closed cdaringe closed 2 months ago

cdaringe commented 2 months ago

Problem statement

Attempting to build with an embassy-executor & timing tasks fails with missing symbols.

Research

cargo run yields:

= note: [ldproxy] Running ldproxy
          Error: Linker /home/cdaringe/src/gimbal-motion/.embuild/espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc failed: exit status: 1
          STDERR OUTPUT:
          /home/cdaringe/src/gimbal-motion/.embuild/espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/12.2.0/../../../../xtensa-esp32s3-elf/bin/ld: /home/cdaringe/src/gimbal-motion/target/xtensa-esp32s3-espidf/debug/deps/libembassy_executor-8ab9f3880deba396.rlib(embassy_executor-8ab9f3880deba396.embassy_executor.739ad4c05c33a474-cgu.0.rcgu.o):(.literal._ZN16embassy_executor3raw12SyncExecutor5spawn17h150b9fb71c094c9bE+0x0): undefined reference to `__pender'
          /home/cdaringe/src/gimbal-motion/.embuild/espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/12.2.0/../../../../xtensa-esp32s3-elf/bin/ld: /home/cdaringe/src/gimbal-motion/target/xtensa-esp32s3-espidf/debug/deps/libembassy_time_queue_driver-0e1460ccf284f7bb.rlib(embassy_time_queue_driver-0e1460ccf284f7bb.embassy_time_queue_driver.d97ccd9d01cbeca7-cgu.0.rcgu.o):(.literal._ZN25embassy_time_queue_driver13schedule_wake17hd48deb6fcbe97cc1E+0x0): undefined reference to `_embassy_time_schedule_wake'
          collect2: error: ld returned 1 exit status
          collect2: error: ld returned 1 exit status

          Stack backtrace:
             0: anyhow::error::<impl anyhow::Error>::msg
             1: ldproxy::main
             2: std::sys_common::backtrace::__rust_begin_short_backtrace
             3: std::rt::lang_start::{{closure}}
            ...snip
            16: _start

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified

Key observations:

ivmarkov commented 2 months ago
ivmarkov commented 2 months ago

Update: generic-queue might not be necessary, as you are using embassy-executor after all, which has its own timer queue. Try first without it.

With that said, I find using embassy-executor in a STD environment a bit controversial, as the code underneath your app does have support for the alloc crate and is using heap allocs a lot anyway. Perhaps you are better off with async-executor or edge-executor. But that's just my opinion. In that case though you DO need generic-queue as embassy-executor and its embedded timer queue will not be around.

Also cannot recall right now if embassy-executor did allow the instantiation of multiple "thread-mode" executors. If it doesn't (easily) it would be a pitty to pass on the option to have multiple (thread-local) executors, each with its own priority, which is very easy with async-executor and edge-executor.