Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embassy Executor Linking Issue #61

Closed
mawoka-myblock opened this issue Feb 1, 2025 · 11 comments
Closed

Embassy Executor Linking Issue #61

mawoka-myblock opened this issue Feb 1, 2025 · 11 comments

Comments

@mawoka-myblock
Copy link

Hi,

I'm trying to get a websocket server working with edge-ws, but when I want to compile, I get the following error:

  = note: [ldproxy] Running ldproxy
          Error: Linker /var/home/mawoka/projects/td-free/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/riscv32-esp-elf-gcc failed: exit status: 1
          STDERR OUTPUT:
          /var/home/mawoka/projects/td-free/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /var/home/mawoka/projects/td-free/target/riscv32imc-esp-espidf/debug/deps/libembassy_executor-8ecf0055e554e2a8.rlib(embassy_executor-8ecf0055e554e2a8.embassy_executor.d4ab2539f0bbacfd-cgu.0.rcgu.o): in function `embassy_executor::raw::Pender::pend':
          /home/mawoka/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embassy-executor-0.7.0/src/raw/mod.rs:373:(.text._ZN16embassy_executor3raw9wake_task17h5eb5b418fd484295E+0x52): undefined reference to `__pender'
          collect2: error: ld returned 1 exit status

I want to use std with esp-rs on an ESP32C3. My dependency-section from the Cargo.toml looks like that:

log = { version = "0.4", default-features = false }
esp-idf-svc = { version = "0.49", default-features = false, features= ["experimental"] }
embedded-hal = "1"
heapless = "0.8"
edge-http = {version = "0.5", features = ["embedded-svc"]}
embedded-io-async = { version = "0.6", default-features = false }
edge-nal-std = "0.5"
edge-nal = "0.5"
edge-ws = "0.4"
futures-lite = "2.6"
anyhow = "1"
url = "2.5"
esp-ota = { git= "https://github.com/KevinBeckers/esp-ota.git", rev = "d6b572f1df6b68135666d6802f8c9b273ef03f17", optional = true}
veml7700 = "0.2.0"
ws2812-esp32-rmt-driver = { version = "0.9", features = ["smart-leds-trait"] }
smart-leds = "0.4"
embassy-time = { version = "0.4.0", features = ["log", "std"] }
embassy-executor = { version = "0.7.0", features = ["arch-std"] }
@MabezDev
Copy link

MabezDev commented Feb 1, 2025

Enable generic-queue-8 feature on embassy-time.

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Feb 1, 2025

Awesome, thanks! But now that it compiles, I get a panic:

I (564) main_task: Started on CPU0
I (564) main_task: Calling app_main()
Guru Meditation Error: Core  0 panic'ed (Stack protection fault). 

Detected in task "main" at 0x42003a54
0x42003a54 - td_free_rs::main
    at /var/home/mawoka/projects/td-free/src/main.rs:43
Stack pointer: 0x3fc92b00
0x3fc92b00 - TxRxCxt
    at ??:??
Stack bounds: 0x3fc9ade8 - 0x3fc9ea70


Core  0 register dump:
MEPC    : 0x42003a58  RA      : 0x4200499c  SP      : 0x3fc92b00  GP      : 0x3fc92600  
0x42003a58 - td_free_rs::main
    at /var/home/mawoka/projects/td-free/src/main.rs:46
0x4200499c - core::hint::black_box
    at ??:??
0x3fc92b00 - TxRxCxt
    at ??:??
0x3fc92600 - __global_pointer$
    at ??:??
TP      : 0x3fc4c8a8  T0      : 0x42047522  T1      : 0x4203ce36  T2      : 0xffffffff  
0x42047522 - std::thread::Thread::new_main
    at /var/home/mawoka/.rustup/toolchains/nightly-2024-12-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:1420
0x4203ce36 - std::sys::thread_local::os::LocalPointer::set
    at /var/home/mawoka/.rustup/toolchains/nightly-2024-12-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/thread_local/os.rs:174
S0/FP   : 0x3fc9e9f0  S1      : 0x3fc9ea28  A0      : 0x0000bdb0  A1      : 0x4200b440  
0x4200b440 - std::rt::lang_start::{{closure}}
    at /var/home/mawoka/.rustup/toolchains/nightly-2024-12-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:195
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x3fc9f4e0  A5      : 0x00000000  
A6      : 0xa0000000  A7      : 0x0000000a  S2      : 0x00000000  S3      : 0x00000000  
S4      : 0x00000000  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x00000000  T4      : 0x00000000  T5      : 0x00000000  T6      : 0x00000000  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x0000001b  MTVAL   : 0x00006509  
0x40380001 - _vector_table
    at ??:??
MHARTID : 0x00000000  

Stack memory:
3fc92b00: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92b20: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92b40: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92b60: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92b80: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92ba0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92bc0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92be0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92c00: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92c20: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92c40: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92c60: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92c80: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92ca0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92cc0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92ce0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92d00: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92d20: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92d40: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92d60: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92d80: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92da0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92dc0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92de0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92e00: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92e20: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92e40: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fc92e60: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000640 0x00000000 0x00000000
3fc92e80: 0x420dadda 0x00000001 0x420f4002 0x00000002 0x420dadc8 0x00000003 0x420dadb6 0x00000004
0x420dadda - pp_timer_dream
    at ??:??
0x420f4002 - pp_timer_tbtt
    at ??:??
0x420dadc8 - pp_timer_active
    at ??:??
0x420dadb6 - pp_timer_coex_slice
    at ??:??
3fc92ea0: 0x420dada4 0x00000005 0x420dad92 0x00000006 0x420dad80 0x00000007 0x420dad6e 0x00000008
0x420dada4 - pp_timer_sleep_delay
    at ??:??
0x420dad92 - pp_timer_disconnected_sleep_delay
    at ??:??
0x420dad80 - pp_timer_connectionless_wake_interval
    at ??:??
0x420dad6e - pp_timer_connectionless_wake_window
    at ??:??
3fc92ec0: 0x420dad5c 0x00000009 0x420dad46 0x0000000a 0x420dad30 0x00000000 0x00000000 0x020b020b
0x420dad5c - pp_timer_beacon_monitor
    at ??:??
0x420dad46 - pp_timer_beacon_monitor_tbtt
    at ??:??
0x420dad30 - pp_timer_beacon_monitor_tbtt
    at ??:??
3fc92ee0: 0x1900030b 0x00000020 0x02060207 0x19060306 0x00004020 0x02060206 0x19060306 0x00003920



ELF file SHA256: 000000000

Rebooting...

And here's my code:

#![feature(iter_intersperse)]

use edge_http::io::server::{DefaultServer, Handler};
use edge_nal::TcpBind;
use edge_ws::{FrameHeader, FrameType};
use esp_idf_svc::hal::task::block_on;
use edge_http::ws::MAX_BASE64_KEY_RESPONSE_LEN;
use esp_idf_svc::io::vfs;
use edge_http::io::Error as EdgeError;
use edge_http::Method as EdgeMethod;

use esp_idf_svc::nvs::EspDefaultNvsPartition;
use esp_idf_svc::timer::EspTaskTimerService;
use esp_idf_svc::wifi::{AsyncWifi, EspWifi};
use esp_idf_svc::{
    eventloop::EspSystemEventLoop,
    hal::peripherals::Peripherals,
};
use std::sync::{Arc, Mutex};
use wifi::WifiEnum;
use core::fmt::{Debug, Display};

use edge_http::io::server::Connection;

use embedded_io_async::{Read, Write};
// use wifi::get;
use ws2812_esp32_rmt_driver::{driver::color::LedPixelColorGrb24, LedPixelEsp32Rmt, RGB8};
// mod dns;
mod helpers;
mod led;
// mod routes;
mod wifi;


static BUILD_TIMESTAMP: &str = env!("VERGEN_BUILD_TIMESTAMP");
static RUSTC_VERSION: &str = env!("VERGEN_RUSTC_SEMVER");
static GIT_COMMIT_HASH: &str = env!("VERGEN_GIT_SHA");
static GIT_DESCRIBE: &str = env!("VERGEN_GIT_DESCRIBE");
static GIT_COMMIT_TIMESTAMP: &str = env!("VERGEN_GIT_COMMIT_TIMESTAMP");
static GIT_COMMIT_AUTHOR_NAME: &str = env!("VERGEN_GIT_COMMIT_AUTHOR_NAME");

pub type LedType<'a> = LedPixelEsp32Rmt<'static, RGB8, LedPixelColorGrb24>;
fn main() -> Result<(), ()> {
    // It is necessary to call this function once. Otherwise some patches to the runtime
    // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
    esp_idf_svc::sys::link_patches();

    // Bind the log crate to the ESP Logging facilities
    esp_idf_svc::log::EspLogger::initialize_default();
    log::info!(
        "Basic init done. Built on {} with Rustc {} from Commit {}, described as \"{}\" and commited on {} by {}.",
        &BUILD_TIMESTAMP,
        &RUSTC_VERSION,
        &GIT_COMMIT_HASH,
        &GIT_DESCRIBE,
        &GIT_COMMIT_TIMESTAMP,
        &GIT_COMMIT_AUTHOR_NAME
    );

    let peripherals = Peripherals::take().unwrap();
    let rgb_led_pin = peripherals.pins.gpio21;


    let rgb_led_channel = peripherals.rmt.channel0;
    let ws2812: Arc<
        Mutex<
            LedPixelEsp32Rmt<
                '_,
                smart_leds::RGB<u8>,
                ws2812_esp32_rmt_driver::driver::color::LedPixelColorImpl<3, 1, 0, 2, 255>,
            >,
        >,
    > = Arc::new(Mutex::new(
        LedType::new(rgb_led_channel, rgb_led_pin).unwrap(),
    ));
    let pixels = std::iter::repeat(RGB8::new(255, 255, 0)).take(1);
    ws2812.lock().unwrap().write_nocopy(pixels).unwrap();

    let sysloop = EspSystemEventLoop::take().unwrap();

    vfs::initialize_eventfd(5).unwrap();

    let nvs = EspDefaultNvsPartition::take().unwrap();
    let timer_service = EspTaskTimerService::new().unwrap();
    let driver = EspWifi::new(peripherals.modem, sysloop.clone(), Some(nvs.clone())).unwrap();
    let mut wifi = AsyncWifi::wrap(driver, sysloop, timer_service).unwrap();
    let wifi_status: Arc<Mutex<WifiEnum>> = Arc::new(Mutex::new(WifiEnum::Working));

    block_on(wifi::wifi_setup(
        &mut wifi,
        nvs.clone(),
        ws2812.clone(),
        wifi_status.clone(),
    ))
    .unwrap();
    log::info!("WiFi Started");
   
    let mut server = DefaultServer::new();

    block_on(run(&mut server)).unwrap();
    Ok(())
}

pub async fn run(server: &mut DefaultServer) -> Result<(), anyhow::Error> {
    let addr = "0.0.0.0:8881";

    log::info!("Running HTTP server on {addr}");

    let acceptor = edge_nal_std::Stack::new()
        .bind(addr.parse().unwrap())
        .await?;

    server.run(None, acceptor, WsHandler).await.unwrap();

    Ok(())
}

#[derive(Debug)]
enum WsHandlerError<C, W> {
    Connection(C),
    Ws(W),
}

impl<C, W> From<C> for WsHandlerError<C, W> {
    fn from(e: C) -> Self {
        Self::Connection(e)
    }
}

struct WsHandler;

impl Handler for WsHandler {
    type Error<E>
        = WsHandlerError<EdgeError<E>, edge_ws::Error<E>>
    where
        E: Debug;

    async fn handle<T, const N: usize>(
        &self,
        _task_id: impl Display + Clone,
        conn: &mut Connection<'_, T, N>,
    ) -> Result<(), Self::Error<T::Error>>
    where
        T: Read + Write,
    {
        let headers = conn.headers()?;

        if headers.method != EdgeMethod::Get {
            conn.initiate_response(405, Some("Method Not Allowed"), &[])
                .await?;
        } else if headers.path != "/" {
            conn.initiate_response(404, Some("Not Found"), &[]).await?;
        } else if !conn.is_ws_upgrade_request()? {
            conn.initiate_response(200, Some("OK"), &[("Content-Type", "text/plain")])
                .await?;

            conn.write_all(b"Initiate WS Upgrade request to switch this connection to WS")
                .await?;
        } else {
            let mut buf = [0_u8; MAX_BASE64_KEY_RESPONSE_LEN];
            conn.initiate_ws_upgrade_response(&mut buf).await?;

            conn.complete().await?;

            log::info!("Connection upgraded to WS, starting a simple WS echo server now");

            // Now we have the TCP socket in a state where it can be operated as a WS connection
            // Run a simple WS echo server here

            let mut socket = conn.unbind()?;

            let mut buf = [0_u8; 8192];

            loop {
                let mut header = FrameHeader::recv(&mut socket)
                    .await
                    .map_err(WsHandlerError::Ws)?;
                let payload = header
                    .recv_payload(&mut socket, &mut buf)
                    .await
                    .map_err(WsHandlerError::Ws)?;

                match header.frame_type {
                    FrameType::Text(_) => {
                        log::info!(
                            "Got {header}, with payload \"{}\"",
                            core::str::from_utf8(payload).unwrap()
                        );
                    }
                    FrameType::Binary(_) => {
                        log::info!("Got {header}, with payload {payload:?}");
                    }
                    FrameType::Close => {
                        log::info!("Got {header}, client closed the connection cleanly");
                        break;
                    }
                    _ => {
                        log::info!("Got {header}");
                    }
                }

                // Echo it back now

                header.mask_key = None; // Servers never mask the payload

                if matches!(header.frame_type, FrameType::Ping) {
                    header.frame_type = FrameType::Pong;
                }

                log::info!("Echoing back as {header}");

                header.send(&mut socket).await.map_err(WsHandlerError::Ws)?;
                header
                    .send_payload(&mut socket, payload)
                    .await
                    .map_err(WsHandlerError::Ws)?;
            }
        }

        Ok(())
    }
}

@ivmarkov
Copy link
Owner

ivmarkov commented Feb 1, 2025

"Stack protection fault" means you are running with a too small stack - likely for the main task. You have to increase it in sdkconfig.defaults.

@mawoka-myblock
Copy link
Author

I did increase it even further now:

# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
CONFIG_ESP_MAIN_TASK_STACK_SIZE=30000
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=15000
CONFIG_HTTPD_WS_SUPPORT=y
CONFIG_LWIP_LOCAL_HOSTNAME=tdfree

# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default).
# This allows to use 1 ms granularity for thread sleeps (10 ms by default).
#CONFIG_FREERTOS_HZ=1000

# Workaround for https://github.com/espressif/esp-idf/issues/7631
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n

Still same error.

@ivmarkov
Copy link
Owner

ivmarkov commented Feb 1, 2025

Pretty sure that's the problem, so most likely you are placing the sdkconfig.defaults in the wrong location (it should be in the crate root except for a workspace setup) OR you are overriding its location in .cargo/config.toml

Also you are enabling other parameters which do not make sense. You should only do this if you really need it. For example, the pthread one, or the httpd ws support one (you are not really using the esp idf http server).

@ivmarkov
Copy link
Owner

ivmarkov commented Feb 1, 2025

One more thing that will help lowering the stack usage: use async-io-mini, not async-io as a feature of edge-nal-std.

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Feb 1, 2025

Okay, that worked, but a new error occurs, but now the ESP just resets once it reaches the block_on call. It then just resets without any stack trace or anything.

I (15829) td_free_rs: Server created
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380000
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd5820,len:0x1714
load:0x403cc710,len:0x968
load:0x403ce710,len:0x2f9c
entry 0x403cc710

Here's the updated snippet:

    let mut server = DefaultServer::new();
    log::info!("Server created");

    match block_on(run(&mut server)) {
        Ok(_) => (),
        Err(e) => log::error!("block_on: {:?}", e),
    };

It's the same with futures-lite's block_on and esp-idf-svc's block_on. I also replaced every unwrap with a match and a logging in the run function.

@ivmarkov
Copy link
Owner

ivmarkov commented Feb 1, 2025

There are still issues in your app that have nothing to do with edge-ws/edge-http:

  • your esp-idf-svc version is not even compatible with the embassy-time version you are using. You should be using 0.51 with e-t 0.4
  • you are depending on embassy-executor yet you are not using it at all, but rather - using block_on. Either one or the other but not both

I suggest you remove embassy-executor from the project. Then the project will likely fail to compile as you don't have an embassy-time driver then, which you should enable with feature embassy-time on esp-idf-svc.

Or the other way around: forget about block-on and use embassy-executor to schedule your async tasks.

@mawoka-myblock
Copy link
Author

Thanks for the tip, but unfortunately that didn't help. I now removed the embassy-executor and upgraded esp-idf-svc to 0.51. It then compiles and the error is the same as before. But when I add the "embassy-time-driver" feature, I get another linking error:

  = note: [ldproxy] Running ldproxy
          Error: Linker /var/home/mawoka/projects/td-free/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/riscv32-esp-elf-gcc failed: exit status: 1
          STDERR OUTPUT:
          /var/home/mawoka/projects/td-free/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /var/home/mawoka/projects/td-free/target/riscv32imc-esp-espidf/debug/deps/libembassy_time-48d166ee8fd16f35.rlib(embassy_time-48d166ee8fd16f35.embassy_time.55e4585bfaebdfec-cgu.0.rcgu.o): in function `_embassy_time_now':
          /home/mawoka/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embassy-time-driver-0.2.0/src/lib.rs:161: multiple definition of `_embassy_time_now'; /var/home/mawoka/projects/td-free/target/riscv32imc-esp-espidf/debug/deps/libesp_idf_svc-e4cb55224dab9b4e.rlib(esp_idf_svc-e4cb55224dab9b4e.esp_idf_svc.ac93784b4ec61dea-cgu.08.rcgu.o):/home/mawoka/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-idf-svc-0.51.0/src/timer.rs:405: first defined here
          /var/home/mawoka/projects/td-free/.embuild/espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/../lib/gcc/riscv32-esp-elf/13.2.0/../../../../riscv32-esp-elf/bin/ld: /var/home/mawoka/projects/td-free/target/riscv32imc-esp-espidf/debug/deps/libembassy_time-48d166ee8fd16f35.rlib(embassy_time-48d166ee8fd16f35.embassy_time.55e4585bfaebdfec-cgu.0.rcgu.o): in function `_embassy_time_schedule_wake':
          /home/mawoka/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embassy-time-driver-0.2.0/src/lib.rs:166: multiple definition of `_embassy_time_schedule_wake'; /var/home/mawoka/projects/td-free/target/riscv32imc-esp-espidf/debug/deps/libesp_idf_svc-e4cb55224dab9b4e.rlib(esp_idf_svc-e4cb55224dab9b4e.esp_idf_svc.ac93784b4ec61dea-cgu.08.rcgu.o):/home/mawoka/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embassy-time-driver-0.2.0/src/lib.rs:166: first defined here


But please keep in mind, block_on works as that's how the wifi is getting initialized successfully.

@ivmarkov
Copy link
Owner

ivmarkov commented Feb 1, 2025

Thanks for the tip, but unfortunately that didn't help. I now removed the embassy-executor and upgraded esp-idf-svc to 0.51. It then compiles and the error is the same as before. But when I add the "embassy-time-driver" feature, I get another linking error:

(
Digression:

I think you are in general taking too big steps whereas you might have had an easier life if you've started simple and only when you have something working add an extra dependency and try to do the next thing.

BTW: If you want a faster turnaround from me, just upload your project and I'll take the time over the weekend to clean it up for you (though again, this has nothing to do with edge-http but rather bootstrapping basics, but np).

Also - maybe you want to join the ESP-RS Matrix chat and get help that way rather than via a GH issue.
)

Anyway, perhaps it is now easier if we just finish the process instead of you starting simple. So another problem:
esp-ota

Why is this thing there? esp-idf-svc has a built-in OTA update mechanism, so you don't need it. Furthermore, it depends on an ancient esp-idf-svc so you are ending up with two such in your cargo tree and there is no way how that would work. And you don't need this for the WS demo you are trying to achieve. At least not immediately.

So remove it.

You have to start removing dependencies that you absolutely don't need on your first step until you get a clean error-free link. Perhaps, rather than generating an empty project with esp-idf-template, you took something from somewhere and then added stuff on top of it?

But please keep in mind, block_on works as that's how the wifi is getting initialized successfully.

I keep that in mind. (esp_idf_svc::hal::task::block_on was implemented by me BTW). The problem is not with it. The problem is with embassy-time which has a very steep setup curve, especially at the beginning when one is not yet aware about the subtle ways it interacts with both embassy-executor and other crates. If you set it up improperly, you can get any of:

  • Missing link symbols
  • Duplicate link symbols (your current case)
  • Interrupt watchdog reset due to the main task likely busylooping with a disable-all-interrupts critical section taken (your "TG1WDT_SYS_RST" from before)

So yeah, you are now on the right track, but you need to remove a few more dependencies until embassy-time is happy.

@mawoka-myblock
Copy link
Author

Thank you for the offer to look over it. Here's the repo: https://github.com/mawoka-myblock/td-free/ and that's the edge-http branch: https://github.com/mawoka-myblock/td-free/tree/edge-http-test

So, the thing is that I had an existing codebase around esp-idf-svc, but the fact that the DNS/DHCP server in SoftAP mode don't seem customizable and a very basic WebSocket implementation made my try edge-http because of its more advanced approach. If you'd take the time to check that, I'd be super grateful and please give me an option to donate to you! Feel free to change the communication channel to any of the ones listed on the website: https://mawoka.eu/contact

@mawoka-myblock mawoka-myblock closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants