Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ target/

# Ignore any files used by text editors or operating systems.
.vscode/
.zed/
.DS_Store
*.swp
.idea/

!espflash/src/target
!espflash/src/target
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix Windows connection issue by aligning reset sequence with `esptool` including RTS/DTR workaround (#999)
- Fix board-info misreporting the crystal frequency of ESP32-C5 (#1005)

### Removed

Expand Down
12 changes: 7 additions & 5 deletions espflash/src/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,12 +911,14 @@ impl Chip {
}
Chip::Esp32c3 => Ok(XtalFrequency::_40Mhz), // Fixed frequency
Chip::Esp32c5 => {
const UART_CLKDIV_REG: u32 = 0x6000_0014; // UART0_BASE_REG + 0x14
const UART_CLKDIV_MASK: u32 = 0xfffff;
const XTAL_CLK_DIVIDER: u32 = 1;
const PCR_SYSCLK_CONF_REG: u32 = 0x6009_6110; // PCR_BASE_REG + 0x110
const PCR_CLK_XTAL_FREQ_MASK: u32 = 0x7F;
const PCR_CLK_XTAL_FREQ_SHIFT: u32 = 24;
Comment on lines +914 to +916
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I just read this out of the TRM, but sure we can say it comes from esptool :D


let sysclk_conf_reg = connection.read_reg(PCR_SYSCLK_CONF_REG)?;
let est_xtal =
(sysclk_conf_reg >> PCR_CLK_XTAL_FREQ_SHIFT) & PCR_CLK_XTAL_FREQ_MASK;

let uart_div = connection.read_reg(UART_CLKDIV_REG)? & UART_CLKDIV_MASK;
let est_xtal = (connection.baud()? * uart_div) / 1_000_000 / XTAL_CLK_DIVIDER;
let norm_xtal = if est_xtal > 45 {
XtalFrequency::_48Mhz
} else {
Expand Down
Loading