Skip to content

Simple Http-Server of std_training fails because of i2c #277

@nsengupta

Description

@nsengupta

I am a newbie in Embedded Rust, trying my hands with the material from std_training.

The Simple HTTP Server compiles (w/o any change yet to be done by me) with an warning and then fails. Here's the relevant portion of the output:

I (396) cpu_start: Unicore app
I (405) cpu_start: Pro cpu start user code
I (405) cpu_start: cpu freq: 160000000 Hz
I (405) app_init: Application information:
I (408) app_init: Project name:     libespidf
I (413) app_init: App version:      1dd9d9c-dirty
I (418) app_init: Compile time:     Nov  2 2025 20:26:27
I (424) app_init: ELF file SHA256:  000000000...
I (429) app_init: ESP-IDF:          v5.3
I (434) efuse_init: Min chip rev:     v0.3
I (439) efuse_init: Max chip rev:     v1.99 
I (444) efuse_init: Chip rev:         v0.4
I (449) heap_init: Initializing. RAM available for dynamic allocation:
I (456) heap_init: At 3FC98EC0 len 00027140 (156 KiB): RAM
I (462) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (469) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (476) heap_init: At 50000200 len 00001DE8 (7 KiB): RTCRAM
I (483) spi_flash: detected chip: generic
I (487) spi_flash: flash io: dio
W (491) i2c: This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h` ### Warning
W (501) timer_group: legacy driver is deprecated, please migrate to `driver/gptimer.h`                                   ### Warning
I (510) sleep: Configure to isolate all GPIO pins in sleep state
I (517) sleep: Enable automatic switching of GPIO sleep configuration
I (524) main_task: Started on CPU0
I (524) main_task: Calling app_main()
I (534) pp: pp rom version: 9387209
I (534) net80211: net80211 rom version: 9387209
I (544) wifi:wifi driver task: 3fca460c, prio:23, stack:6656, core=0
I (544) wifi:wifi firmware version: 0caa81945
I (544) wifi:wifi certification version: v7.0

At runtime it panics, at this line:

temp_sensor
        .lock()
        .unwrap()
        .start_measurement(PowerMode::NormalMode)
        .unwrap();  // <--- panics

Not sure how much of the runt time output will be relevant, but here's a portion:

thread 'main' (1) panicked at src/main.rs:58:10:
called `Result::unwrap()` on an `Err` value: I2c(I2cError { kind: NoAcknowledge(Unknown), cause: ESP_FAIL (error code -1) })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

abort() was called at PC 0x42026407 on core 0
0x42026407 - std::sys::pal::unix::abort_internal
    at /home/nirmalya/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/mod.rs:368
Core  0 register dump:
MEPC    : 0x40381228  RA      : 0x403861a4  SP      : 0x3fc9fb90  GP      : 0x3fc92200  
0x40381228 - panic_abort
    at /home/nirmalya/.espressif/esp-idf/v5.3/components/esp_system/panic.c:463
0x403861a4 - __ubsan_include
    at /home/nirmalya/.espressif/esp-idf/v5.3/components/esp_system/ubsan.c:311
0x3fc92200 - s_stub_table
    at ??:??
....

Cargo.toml has these lines:

[dependencies]
anyhow       = "=1.0.95"
embedded-svc = "=0.28.1"
esp-idf-svc  = "=0.50.1"
#esp-idf-svc  = "=0.51.0"
shtcx        = "=1.0.0"
toml-cfg     = "=0.1.3"
wifi         = { path = "../../common/lib/wifi" }

[build-dependencies]
embuild  = "=0.33.0"
toml-cfg = "=0.1.3"

Could someone please guide me with the exact instructions to resolve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions