Skip to content

Unable to reference MBEDTLS_ERR_NET_SEND_FAILED and MBEDTLS_ERR_NET_RECV_FAILED after upgrade to ESP-IDF v5.3.2 / esp-idf-svc 0.50.1 #361

Description

@acmorrow

Bug description

I'm attempting to update an esp-rs based project which is currently using ESP-IDF v4.4.8 / esp-idf-svc 0.48.1 / esp-idf-sys 0.34.1 to ESP-IDF v5.3.2 / esp-idf-svc 0.50.1 / esp-idf-sys 0.36.0.

Things are mostly building, but I've found that references to esp_idf_svc::sys::MBEDTLS_ERR_NET_SEND_FAILED and esp_idf_svc::sys::MBEDTLS_ERR_NET_RECV_FAILED no longer work.

The symbols do still seem to be part of mbedtls as bundled in ESP-IDF v5.3.2:

esp-idf/v5.3.2/components/mbedtls/mbedtls/include/mbedtls/net_sockets.h
50:#define MBEDTLS_ERR_NET_SEND_FAILED                       -0x004E
esp-idf/v5.3.2/components/mbedtls/mbedtls/include/mbedtls/net_sockets.h
48:#define MBEDTLS_ERR_NET_RECV_FAILED                       -0x004C

But when I look for these symbols in bindings.rs generated with ESP-IDF v5.3.2 / esp-idf-svc 0.50.1 I don't get any matches:

$ grep -c MBEDTLS_ERR_NET `find . -name bindings.rs`
0

However, after reverting to an ESP-IDF v4.4.8 / esp-idf-svc 0.48.1 build I can see those symbols are generated into bindings.rs:

$ grep MBEDTLS_ERR_NET `find . -name bindings.rs`
pub const MBEDTLS_ERR_NET_SOCKET_FAILED: i32 = -66;
pub const MBEDTLS_ERR_NET_CONNECT_FAILED: i32 = -68;
pub const MBEDTLS_ERR_NET_BIND_FAILED: i32 = -70;
pub const MBEDTLS_ERR_NET_LISTEN_FAILED: i32 = -72;
pub const MBEDTLS_ERR_NET_ACCEPT_FAILED: i32 = -74;
pub const MBEDTLS_ERR_NET_RECV_FAILED: i32 = -76;
pub const MBEDTLS_ERR_NET_SEND_FAILED: i32 = -78;
  • Would you like to work on a fix?

Sure, if it is a real issue and I haven't messed something up, I'd be happy to work on a fix with some guidance if that would be helpful.

To Reproduce

Check out acmorrow/micro-rdk@0c7c2aa and run make build-esp32-bin, and you should see errors like:

error[E0432]: unresolved imports `crate::esp32::esp_idf_svc::sys::MBEDTLS_ERR_NET_RECV_FAILED`, `crate::esp32::esp_idf_svc::sys::MBEDTLS_ERR_NET_SEND_FAILED`
  --> micro-rdk/src/esp32/dtls.rs:32:56
   |
32 |     mbedtls_x509_crt_init, mbedtls_x509_crt_parse_der, MBEDTLS_ERR_NET_RECV_FAILED,
   |                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `MBEDTLS_ERR_NET_RECV_FAILED` in `sys`
33 |     MBEDTLS_ERR_NET_SEND_FAILED, MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY, MBEDTLS_ERR_SSL_TIMEOUT,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `MBEDTLS_ERR_NET_SEND_FAILED` in `sys`
   |
help: a similar name exists in the module
   |
32 |     mbedtls_x509_crt_init, mbedtls_x509_crt_parse_der, MBEDTLS_ERR_RSA_RNG_FAILED,
   |                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~
help: a similar name exists in the module
   |
33 |     MBEDTLS_ERR_RSA_RNG_FAILED, MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY, MBEDTLS_ERR_SSL_TIMEOUT,
   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~

Note that there are some other errors in there that I haven't investigated yet.

Expected behavior

Unless these symbols have been removed from mbedtls (doesn't seem like it) or purposely withdrawn from visibility as part of esp-idf / esp-idf-sys, I'd expect to be able to continue to use them. I looked but didn't see any sort of release note that seemed to hint at that. Also possible i'm missing some new kconfig option or esp-idf-[sys,svc] feature?

Environment

  • Crate (esp-idf-sys) version: 0.36.0
  • ESP-IDF branch or tag: v5.3.2
  • Target device (MCU): esp32
  • OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions