Skip to content

esp_vfs_cdcacm.h is incorrectly included with IDF v5.3 and above #397

Description

@tom-a-wagner

Bug description

Related: esp-rs/esp-idf-template#262

The esp_vfs_cdcacm.h is included whenever ESP_IDF_COMP_VFS_ENABLED is set :
https://github.com/esp-rs/esp-idf-sys/blob/a97dd46f4bfdfcd79650c52cb9fe5be3511b1b78/src/include/esp-idf/bindings.h#L209C10-L209C11

However, in IDF v5.3 and above, this file has moved to the esp_vfs_console component.
Paths from two IDF versions:

./v5.3/components/esp_vfs_console/include/esp_vfs_cdcacm.h
./v5.2.4/components/vfs/include/esp_vfs_cdcacm.h

esp_vfs_console is a private requirement of the vfs component, so another component that
depends on vfs does not get include paths for esp_vfs_console.
If esp_vfs_console is not a requirement of the component esp-idf-sys is built in,
such as in the esp-idf-template cmake template,
this causes esp-idf-sys to fail when running bindgen:

error: failed to run custom build command for `esp-idf-sys v0.36.1`

Caused by:
  process didn't exit successfully: `/home/tomwagner/Projects/foo/build/esp-idf/rust-foo/target/release/build/esp-idf-sys-36861e3a0ec2f2cf/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=/home/tomwagner/.local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/esp-idf-sys-0.36.1/src/include/esp-idf/bindings.h
  cargo:rustc-env=EMBUILD_GENERATED_BINDINGS_FILE=/home/tomwagner/Projects/foo/build/esp-idf/rust-foo/target/xtensa-esp32-espidf/release/build/esp-idf-sys-f316917e7990708f/out/bindings.rs

  --- stderr
  /home/tomwagner/.local/sdks/esp-idf/v5.3/components/freertos/esp_additions/include/freertos/task_snapshot.h:8:2: warning: freertos/task_snapshot.h header is no longer used, and will be removed in future versions. [-W#warnings]
  /home/tomwagner/.local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/esp-idf-sys-0.36.1/src/include/esp-idf/bindings.h:186:10: fatal error: 'esp_vfs_cdcacm.h' file not found
  clang diag: /home/tomwagner/.local/sdks/esp-idf/v5.3/components/freertos/esp_additions/include/freertos/task_snapshot.h:8:2: warning: freertos/task_snapshot.h header is no longer used, and will be removed in future versions. [-W#warnings]
  Error: failed to generate bindings in file '/home/tomwagner/Projects/foo/build/esp-idf/rust-foo/target/xtensa-esp32-espidf/release/build/esp-idf-sys-f316917e7990708f/out/bindings.rs'

  Caused by:
      clang diagnosed error: /home/tomwagner/.local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/esp-idf-sys-0.36.1/src/include/esp-idf/bindings.h:186:10: fatal error: 'esp_vfs_cdcacm.h' file not found

Note that adding an explicit requirement for the component fixes the error above,
but then leads to the linker errors mentioned in esp-rs/esp-idf-template#262,
which I haven't looked into further yet.

  • Would you like to work on a fix?

Yes.

I'm not sure yet how the ESP_IDF_COMP_VFS_ENABLED vars are set.
Would the correct fix would be to move the include into the
#ifdef ESP_IDF_COMP_VFS_CONSOLE_ENABLED for v5.3 and above?

Also need to look at if the linker errors are related.

To Reproduce

  1. Create a project using the esp-idf-template cmake template
  2. Try to build using ESP-IDF >= v5.3

The bug also appears if using esp-idf-sys master branch.

Expected behavior

The build should succeed, the file should not be included unless the component esp-idf-sys is compiled in explicitely depends on the esp_vfs_console component.

Environment

  • Crate (esp-idf-sys) version: master
  • ESP-IDF branch or tag: release/v5.3 and above
  • Target device (MCU): ESP32, ESP32S3, ESP32C6 tested
  • OS: Ubuntu 24.04

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