Skip to content

Conversation

@bugadani
Copy link
Contributor

cc #4502

@bugadani bugadani mentioned this pull request Nov 18, 2025
23 tasks
@bugadani bugadani changed the title Redo ESP32-C2 clocktree Redo ESP32-C2 clocktree, remove ESP_HAL_CONFIG_XTAL_FREQUENCY Nov 18, 2025
@bugadani bugadani force-pushed the c2-clocktree branch 3 times, most recently from 1314a69 to f6eb79b Compare November 18, 2025 15:11
@bugadani bugadani force-pushed the c2-clocktree branch 5 times, most recently from 3b794cb to f42ff8d Compare November 20, 2025 10:07
@bugadani bugadani marked this pull request as ready for review November 20, 2025 10:07
@bugadani
Copy link
Contributor Author

/hil full

@github-actions
Copy link

github-actions bot commented Nov 20, 2025

Triggered full HIL run for #4517.

Run: https://github.com/esp-rs/esp-hal/actions/runs/19533125842

Status update: ❌ HIL (full) run failed (conclusion: failure).

@bugadani
Copy link
Contributor Author

/hil full

@github-actions
Copy link

github-actions bot commented Nov 20, 2025

Triggered full HIL run for #4517.

Run: https://github.com/esp-rs/esp-hal/actions/runs/19533561326

Status update: ✅ HIL (full) run succeeded.

@bugadani bugadani marked this pull request as draft November 20, 2025 12:24
@bugadani bugadani requested a review from Copilot November 20, 2025 18:11
Copilot finished reviewing on behalf of bugadani November 20, 2025 18:13
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 refactors the ESP32-C2 clock tree implementation and removes the ESP_HAL_CONFIG_XTAL_FREQUENCY configuration option. The changes introduce a comprehensive clock tree structure for ESP32-C2 with proper clock node definitions, multiplexers, and dividers. The clock frequency is now automatically detected at runtime rather than configured at compile time.

  • Introduces a complete clock tree definition for ESP32-C2 including all clock sources, multiplexers, and dividers
  • Removes the ESP_HAL_CONFIG_XTAL_FREQUENCY build-time configuration in favor of runtime detection
  • Cleans up ESP32 peripheral clock handling by removing redundant TIMG0/1_PERIPHERAL_CLOCK nodes

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
esp-metadata/devices/esp32c2.toml Adds comprehensive clock tree definition with system clocks, peripheral clocks, and timer-specific clock configurations
esp-metadata/devices/esp32.toml Removes TIMG peripheral clock definitions and adds TODO comment about APB clock tracking
esp-metadata-generated/src/_generated_esp32c2.rs Generates clock tree types, configuration structs, and management functions for ESP32-C2
esp-metadata-generated/src/_generated_esp32.rs Removes generated code for TIMG peripheral clocks
esp-metadata-generated/src/_build_script_utils.rs Updates build script configuration flags for new clock nodes
esp-hal/src/timer/timg.rs Adds clock configuration for TIMG0 function clock
esp-hal/src/soc/esp32c2/mod.rs Adds public clocks module
esp-hal/src/soc/esp32c2/clocks.rs New implementation file with clock detection, PLL configuration, and clock tree management
esp-hal/src/soc/esp32/clocks.rs Removes peripheral clock handling and updates crystal frequency detection logic
esp-hal/src/rtc_cntl/rtc/esp32c2.rs Comments out RTC clock configuration (marked for future work)
esp-hal/src/clock/mod.rs Removes ESP_HAL_CONFIG_XTAL_FREQUENCY handling and simplifies XTAL frequency measurement
esp-hal/src/clock/clocks_ll/esp32c2.rs Removes old clock configuration functions (moved to new implementation)
esp-hal/esp_config.yml Removes xtal-frequency configuration option
esp-hal/CHANGELOG.md Documents removal of ESP_HAL_CONFIG_XTAL_FREQUENCY option

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

@bugadani
Copy link
Contributor Author

Current status: scanner example fails to print any devices, I presume one of the clocks aren't started.

@bugadani
Copy link
Contributor Author

Ok, so the issue wasn't that a clock wasn't running. Instead the problem was caused by trying to store the XTAL frequency in Hz instead of in MHz in RTC_CNTL_STORE4, which ended up setting the DISABLE_ROM_LOG bit, which disabled the serial output.

@bugadani bugadani marked this pull request as ready for review November 21, 2025 13:29
@bugadani bugadani marked this pull request as draft November 21, 2025 13:30
@bugadani bugadani force-pushed the c2-clocktree branch 2 times, most recently from ccc44de to 629f6ec Compare November 21, 2025 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant