Skip to content

SPI LAN crash #604

@joyhope

Description

@joyhope

Bug description

using eth_spi_async code on ESP32S3 board. Crashed when lan driver dropped.

I (1493) esp_idf_svc::eth: Driver initialized
I (1493) esp_idf_svc::eth: Attached MAC address: [2, 0, 0, 18, 52, 86]
I (1493) esp_idf_svc::eth: Initialization complete
I (1493) esp_idf_svc::eth: Stopping
E (1493) esp_eth: esp_eth_stop(309): driver not started yet
I (1501) esp_idf_svc::eth: Stop requested
I (1509) esp_eth.netif.netif_glue: 02:00:00:12:34:56
I (1509) esp_eth.netif.netif_glue: ethernet attached to netif
I (1517) esp32test::eth_spi_async: Starting eth...
I (1525) esp_idf_svc::eth: Start requested
I (1525) esp32test::eth_spi_async: Waiting for DHCP lease...
I (4541) esp_netif_handlers: eth ip: 192.168.9.186, mask: 255.255.255.0, gw: 192.168.9.1
I (4541) esp32test::eth_spi_async: Eth DHCP info: IpInfo { ip: 192.168.9.186, subnet: Subnet { gateway: 192.168.9.1, mask: Mask(24) }, dns: Some(192.168.9.1), secondary_dns: Some(0.0.0.0) }
I (4549) esp32test::eth_spi_async: About to do some pings for 192.168.9.1
I (4557) esp_idf_svc::ping: About to run a summary ping 192.168.9.1 with configuration Configuration { count: 5, interval: 1s, timeout: 1s, data_size: 56, tos: 0 }
I (4573) esp_idf_svc::ping: Ping session established, got handle 0x3fcba7f8
I (4581) esp_idf_svc::ping: Ping session started
I (4581) esp_idf_svc::ping: Ping success callback invoked
I (4589) esp_idf_svc::ping: Waiting for the ping session to complete
I (4597) esp_idf_svc::ping: From 1.9.168.192 icmp_seq=1 ttl=64 time=3ms bytes=56
I (5581) esp_idf_svc::ping: Ping success callback invoked
I (5581) esp_idf_svc::ping: From 1.9.168.192 icmp_seq=2 ttl=64 time=1ms bytes=56
I (6581) esp_idf_svc::ping: Ping success callback invoked
I (6581) esp_idf_svc::ping: From 1.9.168.192 icmp_seq=3 ttl=64 time=1ms bytes=56
I (7581) esp_idf_svc::ping: Ping success callback invoked
I (7581) esp_idf_svc::ping: From 1.9.168.192 icmp_seq=4 ttl=64 time=1ms bytes=56
I (8581) esp_idf_svc::ping: Ping success callback invoked
I (8581) esp_idf_svc::ping: From 1.9.168.192 icmp_seq=5 ttl=64 time=1ms bytes=56
I (9581) esp_idf_svc::ping: Ping end callback invoked
I (9581) esp_idf_svc::ping: 5 packets transmitted, 5 received, time 7ms
I (9581) esp_idf_svc::ping: Ping session stopped
I (9581) esp_idf_svc::ping: Ping session 0x3fcba7f8 removed
I (9589) esp32test::eth_spi_async: Pinging done
I (9589) esp_idf_svc::eth: Stopping
I (9597) esp_idf_svc::eth: Stop requested
I (9597) esp_idf_svc::eth: EspEth dropped
I (9605) esp_idf_svc::netif: Dropped
I (9605) esp_idf_svc::eth: Stopping
E (9605) esp_eth: esp_eth_stop(309): driver not started yet
I (9613) esp_idf_svc::eth: Stop requested
I (9621) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (9629) esp_idf_svc::eth: Driver deinitialized
I (9629) esp_idf_svc::eth: EthDriver dropped
E (9637) spi_master: spi_master_deinit_driver(355): not all CSses freed

thread 'main' panicked at /home/redux/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/esp-idf-hal-0.45.2/src/spi.rs:616:52:
called `Result::unwrap()` on an `Err` value: ESP_ERR_INVALID_STATE (error code 259)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • Would you like to work on a fix? no

To Reproduce

Just run the sample code.

Expected behavior

Do not crash.

The init will display error, i think this state is not correct, so it causes a crash.

I (1493) esp_idf_svc::eth: Initialization complete
I (1493) esp_idf_svc::eth: Stopping
E (1493) esp_eth: esp_eth_stop(309): driver not started yet
I (1501) esp_idf_svc::eth: Stop requested
I (1509) esp_eth.netif.netif_glue: 02:00:00:12:34:56

Environment

I use idf-esp 5.4.2

   Compiling embuild v0.33.1
   Compiling esp-idf-sys v0.36.1
   Compiling esp-idf-hal v0.45.2
   Compiling esp-idf-svc v0.51.0

running on ubunutu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions