Skip to content

Commit df3d335

Browse files
committed
Remove ESP_HAL_CONFIG_XTAL_FREQUENCY
1 parent 3def49d commit df3d335

File tree

3 files changed

+10
-73
lines changed

3 files changed

+10
-73
lines changed

esp-hal/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
### Removed
2424

25+
- The `ESP_HAL_CONFIG_XTAL_FREQUENCY` configuration option has been removed (#4517)
2526

2627
## [v1.0.0] - 2025-10-30
2728

esp-hal/esp_config.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,6 @@ options:
2727
default:
2828
- value: false
2929

30-
# Ideally, we should be able to set any clock frequency for any chip. However,
31-
# currently only the 32 and C2 implements any sort of configurability, and
32-
# the rest have a fixed clock frequency.
33-
- name: xtal-frequency
34-
description: "The frequency of the crystal oscillator, in MHz. Set to `auto` to
35-
automatically detect the frequency. `auto` may not be able to identify the clock
36-
frequency in some cases. Also, configuring a specific frequency may increase
37-
performance slightly."
38-
default:
39-
- if: 'chip == "esp32" || chip == "esp32c2"'
40-
value: '"auto"'
41-
- if: 'chip == "esp32c3" || chip == "esp32c6" || chip == "esp32s2" || chip == "esp32s3"'
42-
value: '"40"'
43-
- if: 'chip == "esp32h2"'
44-
value: '"32"'
45-
constraints:
46-
- if: 'chip == "esp32" || chip == "esp32c2"'
47-
type:
48-
validator: enumeration
49-
value:
50-
- 'auto'
51-
- '26'
52-
- '40'
53-
- if: 'chip == "esp32c3" || chip == "esp32c6" || chip == "esp32s2" || chip == "esp32s3"'
54-
type:
55-
validator: enumeration
56-
value:
57-
- '40'
58-
- if: 'chip == "esp32h2"'
59-
type:
60-
validator: enumeration
61-
value:
62-
- '32'
63-
active: 'chip == "esp32" || chip == "esp32c2"'
64-
6530
- name: spi-address-workaround
6631
description: "Enables a workaround for the issue where SPI in
6732
half-duplex mode incorrectly transmits the address on a single line if the

esp-hal/src/clock/mod.rs

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,52 +1116,23 @@ impl Clocks {
11161116
#[cfg(systimer)]
11171117
#[inline]
11181118
pub(crate) fn xtal_freq() -> Rate {
1119-
if esp_config::esp_config_str!("ESP_HAL_CONFIG_XTAL_FREQUENCY") == "auto"
1120-
&& let Some(clocks) = Self::try_get()
1121-
{
1119+
if let Some(clocks) = Self::try_get() {
11221120
return clocks.xtal_clock;
11231121
}
11241122

11251123
Self::measure_xtal_frequency().frequency()
11261124
}
11271125

1128-
#[cfg(not(esp32))] // unused
1129-
const fn xtal_frequency_from_config() -> Option<XtalClock> {
1130-
let frequency_conf = esp_config::esp_config_str!("ESP_HAL_CONFIG_XTAL_FREQUENCY");
1131-
1132-
for_each_soc_xtal_options!(
1133-
(all $( ($freq:literal) ),*) => {
1134-
paste::paste! {
1135-
return match frequency_conf.as_bytes() {
1136-
b"auto" => None,
1137-
1138-
// If the frequency is a pre-set value for the chip, return the associated enum variant.
1139-
$( _ if esp_config::esp_config_int_parse!(u32, frequency_conf) == $freq => Some(XtalClock::[<_ $freq M>]), )*
1140-
1141-
_ => None,
1142-
};
1143-
}
1144-
};
1145-
);
1146-
}
1147-
11481126
#[cfg(not(esp32))] // unused - the build-time config can be removed in favour of explicit configuration via esp_hal::init
11491127
fn measure_xtal_frequency() -> XtalClock {
1150-
if let Some(clock) = const { Self::xtal_frequency_from_config() } {
1151-
// Use the configured frequency
1152-
clock
1153-
} else if esp_config::esp_config_str!("ESP_HAL_CONFIG_XTAL_FREQUENCY") == "auto" {
1154-
// TODO: we should be able to read from a retention register, but probe-rs flashes a
1155-
// bootloader that assumes a frequency, instead of choosing a matching one.
1156-
let mhz = RtcClock::estimate_xtal_frequency();
1157-
1158-
debug!("Working with a {}MHz crystal", mhz);
1159-
1160-
// Try to guess the closest possible crystal value.
1161-
XtalClock::closest_from_mhz(mhz)
1162-
} else {
1163-
unreachable!("Invalid crystal frequency configured, this should not be possible.")
1164-
}
1128+
// TODO: we should be able to read from a retention register, but probe-rs flashes a
1129+
// bootloader that assumes a frequency, instead of choosing a matching one.
1130+
let mhz = RtcClock::estimate_xtal_frequency();
1131+
1132+
debug!("Working with a {}MHz crystal", mhz);
1133+
1134+
// Try to guess the closest possible crystal value.
1135+
XtalClock::closest_from_mhz(mhz)
11651136
}
11661137
}
11671138

0 commit comments

Comments
 (0)