Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodetect xtal-freq #1165

Merged
merged 6 commits into from
Feb 14, 2024
Merged

Autodetect xtal-freq #1165

merged 6 commits into from
Feb 14, 2024

Conversation

SergioGasquez
Copy link
Member

@SergioGasquez SergioGasquez commented Feb 13, 2024

Draft until properly tested:

  • Tried testing it using a simple apps and debugging it with probe-rs but encountered Disabled breakpoints probe-rs/probe-rs#2180.
  • I've also tried creating esp-flasher-stubs using esp-hal with this changes and I was able to flash 26 and 40 Mhz C2s but espflash will report 40MHz as xtal freq in both cases (Its guessed using UART_CLKDIV_REG, which is the same for both xtal freqs not sure why).

Tests:

@SergioGasquez SergioGasquez linked an issue Feb 13, 2024 that may be closed by this pull request
@SergioGasquez SergioGasquez changed the title feat: Autodetect xtal-freq Autodetect xtal-freq Feb 13, 2024
@SergioGasquez SergioGasquez force-pushed the feat/detect-xtal branch 2 times, most recently from aa18174 to f325ee5 Compare February 13, 2024 18:30
@SergioGasquez
Copy link
Member Author

I think the current PR already solves #1164, but it does not resolve the TODO of implementing estimate_xtal_frequency for C6 and H2. Only ESP32 and ESP32-C2 use estimate_xtal_frequency to select the xtal-freqs, the rest of the chips are hardcoded freqs.

We could also implement the estimate_xtal_frequency for the missing targets and use it to resolve #1127 as @jessebraham suggested.

@jessebraham
Copy link
Member

jessebraham commented Feb 13, 2024

Probably fine to implement those in a separate PR rather than hold things up here, but your call obviously. I think removing the crystal frequency features is a huge win already!

@jessebraham
Copy link
Member

Sorry I updated the CI workflow without thinking, so this will need a quick rebase

@SergioGasquez SergioGasquez marked this pull request as ready for review February 13, 2024 21:41
Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

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

Nice!!! Thanks for looking into this, I'm stoked to remove some features :D.

I have a few comments, but nothing major. I don't actually have any 26/24mhz esp's so I can't test it myself, sorry.

esp-hal/src/rtc_cntl/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/clock/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/clock/mod.rs Show resolved Hide resolved
Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

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

Besides the other comments LGTM - tested with ESP32-C2 26MHz

Copy link
Contributor

@JurajSadel JurajSadel left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! LGTM!

@MabezDev MabezDev added this pull request to the merge queue Feb 14, 2024
Merged via the queue into esp-rs:main with commit 3282442 Feb 14, 2024
17 checks passed
@SergioGasquez SergioGasquez deleted the feat/detect-xtal branch February 14, 2024 11:10
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.

Can we auto detect xtal reliably at runtime?
5 participants