ivmarkov / rust-esp32-std-demo

Rust on ESP32 STD demo app. A demo STD binary crate for the ESP32[XX] and ESP-IDF, which connects to WiFi, Ethernet, drives a small HTTP server and draws on a LED screen.
Apache License 2.0
785 stars 105 forks source link

ESP_IDF master - struct `esp_idf_sys::eth_dm9051_config_t` has no field named `spi_hdl` #131

Closed 3d-t closed 1 year ago

3d-t commented 1 year ago

Trying to install demo with ESP_IDF master:

install-rust-toolchain.sh -s master
 ./export-esp.sh
cargo build

config.toml

[build]
# Uncomment the relevant target for your chip here (ESP32, ESP32-S2, ESP32-S3 or ESP32-C3)
target = "xtensa-esp32-espidf"
#target = "xtensa-esp32s2-espidf"
#target = "xtensa-esp32s3-espidf"
#target = "riscv32imc-esp-espidf"

[target.xtensa-esp32-espidf]
linker = "ldproxy"
# Uncomment for ESP-IDF 5 and later
rustflags = ["--cfg", "espidf_time64"]

[target.xtensa-esp32s2-espidf]
linker = "ldproxy"
# Uncomment for ESP-IDF 5 and later
#rustflags = ["--cfg", "espidf_time64"]

[target.xtensa-esp32s3-espidf]
linker = "ldproxy"
# Uncomment for ESP-IDF 5 and later
#rustflags = ["--cfg", "espidf_time64"]

[target.riscv32imc-esp-espidf]
linker = "ldproxy"
# Uncomment for ESP-IDF 5 and later
#rustflags = ["--cfg", "espidf_time64", "-C", "default-linker-libraries"]
# Future - necessary for the experimental "native build" of esp-idf-sys with ESP32C3
# See also https://github.com/ivmarkov/embuild/issues/16
rustflags = ["-C", "default-linker-libraries"]

[unstable]
build-std = ["std", "panic_abort"]
#build-std-features = ["panic_immediate_abort"] # Only necessary if building against ESP-IDF tag `v4.3.2` (the minimum supported version)

[env]
# Uncomment this and use the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF 5.0 (master)
ESP_IDF_VERSION = { value = "master" }

# Comment out this when using the PlatformIO build (it only supports `v4.3.2`)
#ESP_IDF_VERSION = { value = "release/v4.4" }

# These configurations will pick up your custom "sdkconfig.release", "sdkconfig.debug" or "sdkconfig.defaults[.*]" files
# that you might put in the root of the project
# The easiest way to generate a full "sdkconfig" configuration (as opposed to manually enabling only the necessary flags via "sdkconfig.defaults[.*]"
# is by running "cargo pio espidf menuconfig" (that is, if using the pio builder)
#ESP_IDF_SDKCONFIG = { value = "sdkconfig.release;sdkconfig.debug" }
ESP_IDF_SDKCONFIG_DEFAULTS = { value = "sdkconfig.defaults;sdkconfig.defaults.esp32;sdkconfig.defaults.esp32s2" }

Error message

Compiling mipidsi v0.5.0
   Compiling esp-idf-hal v0.39.1
   Compiling esp-idf-svc v0.43.1
error[E0560]: struct `esp_idf_sys::eth_dm9051_config_t` has no field named `spi_hdl`
   --> /Users/maarten/.cargo/registry/src/github.com-1ecc6299db9ec823/esp-idf-svc-0.43.1/src/eth.rs:357:21
    |
357 |                     spi_hdl: spi_handle as *mut _,
    |                     ^^^^^^^ `esp_idf_sys::eth_dm9051_config_t` does not have this field
    |
    = note: available fields are: `spi_host_id`, `spi_devcfg`, `int_gpio_num`

error[E0560]: struct `esp_idf_sys::eth_w5500_config_t` has no field named `spi_hdl`
   --> /Users/maarten/.cargo/registry/src/github.com-1ecc6299db9ec823/esp-idf-svc-0.43.1/src/eth.rs:371:21
    |
371 |                     spi_hdl: spi_handle as *mut _,
    |                     ^^^^^^^ `esp_idf_sys::eth_w5500_config_t` does not have this field
    |
    = note: available fields are: `spi_host_id`, `spi_devcfg`, `int_gpio_num`
ivmarkov commented 1 year ago

OK, so indeed I have missed the incompatible change to the eth SPI drivers in ESP IDF 5. What is worse, the change is not so small, in that in 4.4, the API expects the user to configure an SPI device and then hand it off to the eth layer. In 5.0, the eth API configures the device itself, and expects from the user only to pass the bus (SPI driver) and a minimal configuration.

I'll try to fix it in the next days (or over the weekend), but if you really want to use an eth SPI device driver, you need to stick to 4.4 in the meantime.

3d-t commented 1 year ago

OK. I need SPI for SD card. But I have problems installing 4.4 as well.

ivmarkov commented 1 year ago

OK. I need SPI for SD card. But I have problems installing 4.4 as well.

Installing the stable version should be much easier than installing the master version. The master version will have all the issues of the stable version plus more. So please do not go in that direction. (I guess I'm repeating myself.)

ivmarkov commented 1 year ago

OK. I need SPI for SD card. But I have problems installing 4.4 as well.

Just to mention that SPI is something (much) simpler than eth on SPI. Regardless, you can use both on ESP IDF 4.4. The latter would be fixed for ESP IDF 5 soon.

ivmarkov commented 1 year ago

Fixed with https://github.com/esp-rs/esp-idf-svc/commit/e20c313f574ee5eacf6ddbc6c2827e961f002d1b