Skip to content

feat(esp32): remove unused fl/system/arduino.h leaks; unconditional heap_caps_* - #3728

Merged
zackees merged 1 commit into
masterfrom
feat/esp32-remove-arduino-soft-leaks
Jul 22, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/esp32-remove-arduino-soft-leaks

Conversation

@zackees

@zackees zackees commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Closes #3721. Part of meta #3715 (ESP Arduino-decoupling).

Problem

fl/system/arduino.h is a soft shim that pulls in the entire Arduino core (when present) at compile time. Two ESP32 TUs included it despite never referencing an Arduino symbol:

  • coroutine_esp32.impl.hpp — FreeRTOS-only implementation.
  • drivers/uart/uart_peripheral_esp.cpp.hpp — pure driver/uart.h implementation; its only "time" call is fl::micros(), the platform-agnostic fl:: facade (declared in platforms/time_platform.h), not anything from Arduino.h.

Separately, platforms/esp/memory_esp32.hpp forked getFreeHeap()/getMinFreeHeap() on defined(ARDUINO) — but on inspection both branches already call ESP-IDF SDK functions (esp_get_free_heap_size() vs heap_caps_get_free_size()), just from two different IDF heap-API generations. Neither branch is actually Arduino-specific, so the fork is unnecessary.

Fix

  • Drop the fl/system/arduino.h include from the two pure-IDF TUs.
  • memory_esp32.hpp now calls heap_caps_get_free_size()/heap_caps_get_minimum_free_size() unconditionally — esp_heap_caps.h is a core ESP-IDF header, present identically under Arduino-ESP32 (which bundles ESP-IDF) and bare ESP-IDF.

Scope note

drivers/i2s/i2s_lcd_cam_peripheral_mock.cpp.hpp's #ifdef ARDUINO fork was flagged by the original meta-issue audit but is left untouched here — it's host-stub-only test infrastructure (the whole file only compiles under FASTLED_STUB_IMPL or a non-Arduino host build) selecting between the stub Arduino shim and platforms/stub/time_stub.h for host testing. It has nothing to do with real ESP32 hardware builds.

Test plan

Summary by CodeRabbit

  • Bug Fixes
    • Improved ESP32 compatibility by standardizing heap memory reporting across supported build environments.
    • Reduced platform-specific header requirements for ESP32 coroutine and UART components.
    • No user-facing API or runtime behavior changes beyond more consistent heap statistics.

…eap_caps_*

Removes fl/system/arduino.h includes from two ESP32 TUs whose
implementation is already pure IDF and never references any Arduino
symbol: coroutine_esp32.impl.hpp (FreeRTOS-only) and
drivers/uart/uart_peripheral_esp.cpp.hpp (driver/uart.h + the fl::
facade for micros()). Every include of that shim pulls the whole
Arduino core into the TU whenever it's present, at zero benefit here.

(i2s_lcd_cam_peripheral_mock.cpp.hpp's #ifdef ARDUINO fork is left
alone — it's host-stub-only test infrastructure gated on
!ARDUINO-or-FASTLED_STUB_IMPL at the file level, selecting between the
stub Arduino shim and platforms/stub/time_stub.h for host testing.
Unrelated to real ESP32 hardware builds; out of scope here.)

Also rewrites platforms/esp/memory_esp32.hpp's getFreeHeap()/
getMinFreeHeap(): the #if defined(ARDUINO) fork there wasn't actually
Arduino-coupled — both branches called ESP-IDF SDK functions
(esp_get_free_heap_size vs heap_caps_get_free_size), just different
API generations. heap_caps_* is available identically under
Arduino-ESP32 and bare ESP-IDF, so the fork is unnecessary; call it
unconditionally.

Part of #3715. Closes #3721.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4f543074-1c16-44fd-8c52-085622286ba5

📥 Commits

Reviewing files that changed from the base of the PR and between 1404736 and 2514e39.

📒 Files selected for processing (3)
  • src/platforms/esp/32/coroutine_esp32.impl.hpp
  • src/platforms/esp/32/drivers/uart/uart_peripheral_esp.cpp.hpp
  • src/platforms/esp/memory_esp32.hpp
💤 Files with no reviewable changes (2)
  • src/platforms/esp/32/drivers/uart/uart_peripheral_esp.cpp.hpp
  • src/platforms/esp/32/coroutine_esp32.impl.hpp

📝 Walkthrough

Walkthrough

ESP32 platform headers remove an Arduino-specific include and replace conditional heap-statistic implementations with unconditional ESP-IDF heap capability APIs.

Changes

ESP32 Arduino decoupling

Layer / File(s) Summary
ESP32 include cleanup
src/platforms/esp/32/coroutine_esp32.impl.hpp, src/platforms/esp/32/drivers/uart/uart_peripheral_esp.cpp.hpp
Removes the Arduino shim include from the coroutine implementation and reorders the UART utility include.
ESP32 heap API unification
src/platforms/esp/memory_esp32.hpp
Always includes esp_heap_caps.h and uses heap capability APIs for free and minimum-free heap queries.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • 3715 — Covers the broader ESP Arduino-decoupling work implemented by these include and heap API changes.
  • 3722 — Covers the ESP32 memory refactor from ARDUINO dispatch to ESP-IDF heap capability APIs.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR covers the include removals and heap_caps refactor, but it does not add the required grep/CI ratchet against new fl/system/arduino.h includes. Add a grep or CI check under src/platforms/esp/** that fails on new fl/system/arduino.h includes, and verify the ESP acceptance criteria pass.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the ESP32 Arduino-shim cleanup and heap_caps refactor.
Out of Scope Changes check ✅ Passed The changes stay within the ESP32 dependency cleanup and heap query refactor described by the issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/esp32-remove-arduino-soft-leaks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees merged commit c69b338 into master Jul 22, 2026
11 checks passed
@zackees
zackees deleted the feat/esp32-remove-arduino-soft-leaks branch July 22, 2026 18:56
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

esp: remove soft fl/system/arduino.h leaks; memory_esp32.hpp → unconditional heap_caps_*

1 participant