From 253d7ede77c5b3839d511485b8749498dde88d7b Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Wed, 2 Oct 2024 12:58:44 +0200 Subject: [PATCH 1/2] Add new chip detect magic value, ability to read chip revision --- espflash/src/targets/esp32p4.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/espflash/src/targets/esp32p4.rs b/espflash/src/targets/esp32p4.rs index a500028f..73b2f5ac 100644 --- a/espflash/src/targets/esp32p4.rs +++ b/espflash/src/targets/esp32p4.rs @@ -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] = &[ 0x4000_0000..0x4C00_0000, // IROM @@ -20,7 +20,7 @@ const FLASH_RANGES: &[Range] = &[ const PARAMS: Esp32Params = Esp32Params::new( 0x2000, 0x1_0000, - 0x3f_0000, // TODO: Update + 0x3f_0000, 18, FlashFrequency::_40Mhz, include_bytes!("../../resources/bootloaders/esp32p4-bootloader.bin"), @@ -52,15 +52,13 @@ impl Target for Esp32p4 { } #[cfg(feature = "serialport")] - fn major_chip_version(&self, _connection: &mut Connection) -> Result { - // TODO: https://github.com/espressif/esptool/blob/master/esptool/targets/esp32p4.py#L96 - Ok(0) + fn major_chip_version(&self, connection: &mut Connection) -> Result { + Ok(self.read_efuse(connection, 19)? >> 4 & 0x03) } #[cfg(feature = "serialport")] - fn minor_chip_version(&self, _connection: &mut Connection) -> Result { - // TODO: https://github.com/espressif/esptool/blob/master/esptool/targets/esp32p4.py#L92 - Ok(0) + fn minor_chip_version(&self, connection: &mut Connection) -> Result { + Ok(self.read_efuse(connection, 19)? & 0x0F) } #[cfg(feature = "serialport")] From 876d1334ec345ed1ef957b745a6a6f6fc1094575 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Mon, 7 Oct 2024 12:40:16 +0200 Subject: [PATCH 2/2] Update `CHANGELOG.md` --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10b9a6b7..7f2af8e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)