E4C6
Skip to content

Disable WiFi when using Ethernet to save memory - #9456

Merged
bdraco merged 1 commit into
devfrom
disable_wifi_ethernet_pr
Jul 12, 2025
Merged

Disable WiFi when using Ethernet to save memory#9456
bdraco merged 1 commit into
devfrom
disable_wifi_ethernet_pr

Conversation

@bdraco
@bdraco bdraco commented Jul 12, 2025
Copy link
Copy Markdown
Member

What does this implement/fix?

This PR explicitly disables WiFi in ESP-IDF when using the Ethernet component, resulting in significant memory savings. Since WiFi and Ethernet are mutually exclusive (enforced by CONFLICTS_WITH = ["wifi"]), there's no need to compile in the WiFi stack for Ethernet-only configurations.

Memory savings observed:

  • RAM: 1,856 bytes saved (4.3% reduction)
  • Flash: 10,420 bytes saved (1.0% reduction)

The change also disables CONFIG_SW_COEXIST_ENABLE (WiFi/Bluetooth coexistence) since it's not needed without WiFi, providing additional memory savings for Ethernet+Bluetooth configurations.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable): N/A

Pull request in esphome-docs with documentation (if applicable): N/A

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

# No configuration changes needed - this optimization is automatic
# when using Ethernet with ESP-IDF
esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf

ethernet:
  type: IP101
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO0_IN
  phy_addr: 1
  power_pin: GPIO5

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@codecov-commenter
codecov-commenter commented Jul 12, 2025
Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.60%. Comparing base (0138ef3) to head (53295fd).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #9456   +/-   ##
=======================================
  Coverage   59.60%   59.60%           
=======================================
  Files          50       50           
  Lines       10261    10261           
  Branches     1379     1379           
=======================================
  Hits         6116     6116           
  Misses       3786     3786           
  Partials      359      359           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco
bdraco commented Jul 12, 2025
Copy link
Copy Markdown
Member Author

Works great with my proxies

Comment on lines +345 to +350
# Disable WiFi when using Ethernet to save memory
if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_ESP_WIFI_ENABLED", False)
# Also disable WiFi/BT coexistence since WiFi is disabled
add_idf_sdkconfig_option("CONFIG_SW_COEXIST_ENABLE", False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow, that's simple 😅

@bdraco
bdraco commented Jul 12, 2025
Copy link
Copy Markdown
Member Author
Screenshot 2025-07-11 at 7 04 33 PM

@bdraco
bdraco commented Jul 12, 2025
Copy link
Copy Markdown
Member Author

Flashed pretty much every ethernet device I have. all good

@bdraco
bdraco marked this pull request as ready for review July 12, 2025 05:16
@bdraco
bdraco enabled auto-merge (squash) July 12, 2025 05:17
@bdraco
bdraco merged commit 634aa55 into dev Jul 12, 2025
24 checks passed
@bdraco
bdraco deleted the disable_wifi_ethernet_pr branch July 12, 2025 05:19
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0