Add (some) support for ESP-IDF v6.0#408
Conversation
… v6.0) ESP-IDF v6.0 ships mbedtls v4 which removed the legacy crypto API headers (aes.h, cipher.h, entropy.h, etc.) in favour of the PSA API. Guard these includes with MBEDTLS_VERSION_MAJOR < 4 to fix the build. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
uart_vfs_dev_use_nonblocking() and related functions were moved from esp_vfs_dev.h (deprecated) to driver/uart_vfs.h in ESP-IDF v5. Include it when both the UART driver and VFS components are enabled. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In ESP-IDF v6.0, soc/gpio_periph.h dropped its include of soc/gpio_reg.h, breaking the transitive include chain that previously made GPIO_OUT_REG and friends visible via driver/gpio.h. Include it explicitly when IDF >= 6. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In ESP-IDF v6.0, the legacy pcnt_unit_t enum and legacy PCNT constants (PCNT_UNIT_0..MAX) were removed along with the legacy driver API. The only remaining pcnt_unit_t is the opaque struct used by the new driver API, which bindgen can handle without the type blocklist workaround. Stop blocklisting pcnt_unit_t in bindgen for v6.0+ (detected by parsing header file, unfortunately), and gate the pcnt module (which provides the enum type and legacy constants) on ESP-IDF < v6.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Compute the GCC sysroot via riscv32-esp-elf-ld/xtensa-esp-elf-ld --print-sysroot in cargo_driver and expose it as gcc_sysroot in EspIdfBuildOutput, so build.rs can derive the picolibc include path without re-running chip detection logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ESP-IDF v6.0 switched from newlib to picolibc. Clang silently ignores GCC's -specs=picolibc.specs so bindgen falls back to the newlib sysroot headers, causing errors like 'unknown type name __FILE'. Detect the picolibc include directory relative to the GCC sysroot and inject it as -I before the sysroot headers so clang uses the correct stdlib headers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@drinkcat Thanks and interesting work! |
- ETH PHY: dp83848, ip101, ksz80xx, lan87xx, rtl8201. - SPI ETH: dm9051, w5500, ksz8851snl. When these components are added as extra_components (managed via the IDF component manager), their include dirs are already present in the CMake compile group and thus available to bindgen. Adding the #ifdef guards here causes bindgen to generate bindings for their functions automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
(updated -- added one more commit for ETH bindings -- HAL change pushed here: esp-rs/esp-idf-hal#578; SVC here: esp-rs/esp-idf-svc#650) |
Follows the same pattern as mdns and websocket client. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Replying to your picolibc comment on the other PR here.
Wow, that looks like some fun ,-P Some constants missing: And some potential trouble (Full logs https://gist.github.com/drinkcat/d45f0d5274766ae57580f8f65178d6cb) (but I think that's tomorrow's problem -- I'll take a look) |
Yep, no rush but we need to fix at some point. |
Looked a bit around, and noticed the
And with these (and crates.io overrides, etc.), Anyhow, a proper fix will take time, so, for the interest of this PR specifically... How bad do you feel those 3 mismatched constants are? I don't have a good perspective on how frequent filesystem usage would be on |
Nope. If I remember correctly, the reasons were:
You are right that you could apply the same reasoning for the current
Well it is bad as filesystems are used on top of esp-rs, typically with external storage like SD cards. |
|
Thanks! I filed #410 so that we don't forget about that Do you plan to make a new release with this sometimes soon? I think I need a new tag to merge the hal/svc PR with CI enabled (otherwise I can disable CI on 6.0 until a new release). |
We can release whenever we want, but merging the hal/svc changes do not require a release - you just need to have - in hal and svc - a patch that redirects sys to the GIT one. As you actually already did, except the branch should be |
Ok, I'll do that (and I guess you'll just have to remove that line before the next release) |
Submission Checklist 📝
cargo fmtcommand to ensure that all changed code is formatted correctly.cargo clippycommand to ensure that all changed code passes latest Clippy nightly lints.CHANGELOG.mdin the proper section.Pull Request Details 📖
Description
Hi! Making an attempt to add support for ESP-IDF v6.0.
Full log below (bottom to top), I attempted to order commits in order of trivial to... I'd really like your input.
esp-idf-svcMR).If the first few commits are ok and you'd like to go ahead with those, happy to carve them out into a different PR.
For transparency, I made extensive use of Claude to help me investigate and generate code, but human is deeply in the loop.
Testing
Compile tested in CI, needs related hal and svc changes, booted a small example on ESPC6 VROOM board.
bindings: add managed ETH PHY and SPI ETH component headers
When these components are added as extra_components (managed via the IDF
component manager), their include dirs are already present in the CMake
compile group and thus available to bindgen. Adding the #ifdef guards here
causes bindgen to generate bindings for their functions automatically.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
CHANGELOG.md: Update
.github/workflows/ci.yml: Add v6.0
build: inject picolibc include path for bindgen (ESP-IDF v6.0)
ESP-IDF v6.0 switched from newlib to picolibc. Clang silently ignores
GCC's -specs=picolibc.specs so bindgen falls back to the newlib sysroot
headers, causing errors like 'unknown type name __FILE'.
Detect the picolibc include directory relative to the GCC sysroot and
inject it as -I before the sysroot headers so clang uses the correct
stdlib headers.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
build: expose gcc_sysroot in EspIdfBuildOutput
Compute the GCC sysroot via riscv32-esp-elf-ld/xtensa-esp-elf-ld
--print-sysroot in cargo_driver and expose it as gcc_sysroot in
EspIdfBuildOutput, so build.rs can derive the picolibc include path
without re-running chip detection logic.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
pcnt: disable pcnt.rs for ESP-IDF v6.0+ (legacy API removed)
In ESP-IDF v6.0, the legacy pcnt_unit_t enum and legacy PCNT constants
(PCNT_UNIT_0..MAX) were removed along with the legacy driver API.
The only remaining pcnt_unit_t is the opaque struct used by the new
driver API, which bindgen can handle without the type blocklist workaround.
Stop blocklisting pcnt_unit_t in bindgen for v6.0+ (detected by parsing
header file, unfortunately), and gate the pcnt module (which provides
the enum type and legacy constants) on ESP-IDF < v6.0.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
bindings: explicitly include soc/gpio_reg.h for ESP-IDF v6.0+
In ESP-IDF v6.0, soc/gpio_periph.h dropped its include of soc/gpio_reg.h,
breaking the transitive include chain that previously made GPIO_OUT_REG and
friends visible via driver/gpio.h. Include it explicitly when IDF >= 6.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
bindings: include driver/uart_vfs.h to export uart_vfs_dev_* functions
uart_vfs_dev_use_nonblocking() and related functions were moved from
esp_vfs_dev.h (deprecated) to driver/uart_vfs.h in ESP-IDF v5. Include
it when both the UART driver and VFS components are enabled.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
bindings: guard mbedtls legacy crypto headers for mbedtls v4 (ESP-IDF v6.0)
ESP-IDF v6.0 ships mbedtls v4 which removed the legacy crypto API headers
(aes.h, cipher.h, entropy.h, etc.) in favour of the PSA API. Guard these
includes with MBEDTLS_VERSION_MAJOR < 4 to fix the build.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com