Skip to content

Commit

Permalink
Add new chip detect magic value, ability to read chip revision for ES…
Browse files Browse the repository at this point in the history
…P32-P4 (#686)

* Add new chip detect magic value, ability to read chip revision

* Update `CHANGELOG.md`
  • Loading branch information
jessebraham authored Oct 7, 2024
1 parent 64099f0 commit c119e61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add new chip detect magic value, ability to read chip revision for ESP32-P4 (#686)

### Fixed
- Fixed `partition-table-offset` argument to accept offsets in hexadecimal (#682)

Expand Down
14 changes: 6 additions & 8 deletions espflash/src/targets/esp32p4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
targets::{Chip, Esp32Params, ReadEFuse, SpiRegisters, Target, XtalFrequency},
};

const CHIP_DETECT_MAGIC_VALUES: &[u32] = &[0x0];
const CHIP_DETECT_MAGIC_VALUES: &[u32] = &[0x0, 0x0ADDBAD0];

const FLASH_RANGES: &[Range<u32>] = &[
0x4000_0000..0x4C00_0000, // IROM
Expand All @@ -20,7 +20,7 @@ const FLASH_RANGES: &[Range<u32>] = &[
const PARAMS: Esp32Params = Esp32Params::new(
0x2000,
0x1_0000,
0x3f_0000, // TODO: Update
0x3f_0000,
18,
FlashFrequency::_40Mhz,
include_bytes!("../../resources/bootloaders/esp32p4-bootloader.bin"),
Expand Down Expand Up @@ -52,15 +52,13 @@ impl Target for Esp32p4 {
}

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

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

#[cfg(feature = "serialport")]
Expand Down

0 comments on commit c119e61

Please sign in to comment.