Skip to content

fix(logging): Add wrapper when using wifi without esp_diagnostics#12188

Merged
me-no-dev merged 2 commits intoespressif:masterfrom
lucasssvaz:fix/diag_wrap
Jan 12, 2026
Merged

fix(logging): Add wrapper when using wifi without esp_diagnostics#12188
me-no-dev merged 2 commits intoespressif:masterfrom
lucasssvaz:fix/diag_wrap

Conversation

@lucasssvaz
Copy link
Member

Description of Change

This pull request adds support for wrapper functions around ESP-IDF logging APIs to ensure compatibility with WiFi libraries, even when the esp_diagnostics component is not enabled. The changes introduce a new source file with wrapper implementations and update the build system to include and link these wrappers only when necessary.

Build system updates:

  • Added cores/esp32/esp32-hal-log-wrapper.c to the build sources so it is compiled as part of the project.
  • Updated the linker flags in CMakeLists.txt to wrap esp_log_write and esp_log_writev only when CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP is not enabled, ensuring the correct wrapper functions are linked.

New wrapper implementation:

  • Introduced cores/esp32/esp32-hal-log-wrapper.c, which provides simple pass-through wrappers for esp_log_write and esp_log_writev when the external diagnostics wrapper is not present. This prevents linker errors when WiFi libraries expect these symbols.

Test Scenarios

Tested locally

@lucasssvaz lucasssvaz self-assigned this Dec 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello lucasssvaz, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 1bdd29f

@lucasssvaz lucasssvaz mentioned this pull request Dec 30, 2025
1 task
@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Test Results

 90 files   90 suites   28m 4s ⏱️
 66 tests  66 ✅ 0 💤 0 ❌
676 runs  676 ✅ 0 💤 0 ❌

Results for commit 1bdd29f.

♻️ This comment has been updated with latest results.

@lucasssvaz lucasssvaz force-pushed the fix/diag_wrap branch 2 times, most recently from 9a5c048 to 014d68d Compare December 30, 2025 23:40
@lucasssvaz lucasssvaz marked this pull request as ready for review December 31, 2025 14:49
@lucasssvaz lucasssvaz requested review from a team, SuGlider and me-no-dev as code owners December 31, 2025 14:49
@lucasssvaz lucasssvaz added Area: Arduino as ESP-IDF component Issues about Arduino used as component in ESP-IDF Status: Review needed Issue or PR is awaiting review labels Dec 31, 2025
Copy link
Collaborator

@SuGlider SuGlider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucasssvaz - I think that it would be good to add DIAG_USE_EXTERNAL_LOG_WRAP to the KConfig file (https://github.com/espressif/arduino-esp32/blob/master/Kconfig.projbuild).

Not sure which would be the best default value for it.
Please evalutate it.

In case its default value is y, you may just remove it from sdkconfig.defaults file

@lucasssvaz
Copy link
Member Author

It comes from esp_diagnostics. We have it enabled by default in lib-builder. This PR is to avoid issues when using Arduino as a component like in #11634

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds logging wrapper functions to support WiFi libraries when the esp_diagnostics component is not enabled. Previously, examples relied on CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP to enable diagnostics wrappers, but this PR provides a simpler pass-through wrapper implementation within arduino-esp32 itself.

Key changes:

  • Added esp32-hal-log-wrapper.c with pass-through wrapper implementations for esp_log_write and esp_log_writev
  • Updated build system to conditionally compile and link the wrappers when CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP is not set
  • Removed CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y from example sdkconfig files, allowing automatic wrapper provisioning

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
cores/esp32/esp32-hal-log-wrapper.c New file providing pass-through wrapper implementations for ESP-IDF logging functions when esp_diagnostics is not enabled
CMakeLists.txt Added the wrapper source file to build and conditionally added linker flags to wrap logging functions
idf_component_examples/hw_cdc_hello_world/sdkconfig.defaults Removed explicit CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP setting, allowing automatic wrapper provisioning
idf_component_examples/hello_world/sdkconfig.defaults Removed explicit CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP setting, allowing automatic wrapper provisioning

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lucasssvaz lucasssvaz added Status: Pending Merge Pull Request is ready to be merged and removed Status: Review needed Issue or PR is awaiting review labels Jan 8, 2026
@me-no-dev me-no-dev merged commit 028ad2b into espressif:master Jan 12, 2026
65 checks passed
@lucasssvaz lucasssvaz deleted the fix/diag_wrap branch January 17, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Arduino as ESP-IDF component Issues about Arduino used as component in ESP-IDF Status: Pending Merge Pull Request is ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants