Skip to content

Commit c119e61

Browse files
authored
Add new chip detect magic value, ability to read chip revision for ESP32-P4 (#686)
* Add new chip detect magic value, ability to read chip revision * Update `CHANGELOG.md`
1 parent 64099f0 commit c119e61

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Add new chip detect magic value, ability to read chip revision for ESP32-P4 (#686)
13+
1214
### Fixed
1315
- Fixed `partition-table-offset` argument to accept offsets in hexadecimal (#682)
1416

espflash/src/targets/esp32p4.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
targets::{Chip, Esp32Params, ReadEFuse, SpiRegisters, Target, XtalFrequency},
1111
};
1212

13-
const CHIP_DETECT_MAGIC_VALUES: &[u32] = &[0x0];
13+
const CHIP_DETECT_MAGIC_VALUES: &[u32] = &[0x0, 0x0ADDBAD0];
1414

1515
const FLASH_RANGES: &[Range<u32>] = &[
1616
0x4000_0000..0x4C00_0000, // IROM
@@ -20,7 +20,7 @@ const FLASH_RANGES: &[Range<u32>] = &[
2020
const PARAMS: Esp32Params = Esp32Params::new(
2121
0x2000,
2222
0x1_0000,
23-
0x3f_0000, // TODO: Update
23+
0x3f_0000,
2424
18,
2525
FlashFrequency::_40Mhz,
2626
include_bytes!("../../resources/bootloaders/esp32p4-bootloader.bin"),
@@ -52,15 +52,13 @@ impl Target for Esp32p4 {
5252
}
5353

5454
#[cfg(feature = "serialport")]
55-
fn major_chip_version(&self, _connection: &mut Connection) -> Result<u32, Error> {
56-
// TODO: https://github.com/espressif/esptool/blob/master/esptool/targets/esp32p4.py#L96
57-
Ok(0)
55+
fn major_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
56+
Ok(self.read_efuse(connection, 19)? >> 4 & 0x03)
5857
}
5958

6059
#[cfg(feature = "serialport")]
61-
fn minor_chip_version(&self, _connection: &mut Connection) -> Result<u32, Error> {
62-
// TODO: https://github.com/espressif/esptool/blob/master/esptool/targets/esp32p4.py#L92
63-
Ok(0)
60+
fn minor_chip_version(&self, connection: &mut Connection) -> Result<u32, Error> {
61+
Ok(self.read_efuse(connection, 19)? & 0x0F)
6462
}
6563

6664
#[cfg(feature = "serialport")]

0 commit comments

Comments
 (0)