From 9133c083e4c4601ca823045e65108ba1de899cb5 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 22 Dec 2023 10:18:54 +0100 Subject: [PATCH] fix: Rebase errors --- CHANGELOG.md | 1 + cargo-espflash/src/main.rs | 2 ++ espflash/src/bin/espflash.rs | 2 ++ espflash/src/flasher/mod.rs | 21 +++++---------------- espflash/src/image_format/mod.rs | 1 + espflash/src/targets/esp32.rs | 4 +--- espflash/src/targets/esp32c2.rs | 4 +--- espflash/src/targets/esp32c3.rs | 4 +--- espflash/src/targets/esp32c6.rs | 4 +--- espflash/src/targets/esp32h2.rs | 4 +--- espflash/src/targets/esp32s2.rs | 4 +--- espflash/src/targets/esp32s3.rs | 4 +--- espflash/src/targets/esp8266.rs | 2 -- espflash/src/targets/mod.rs | 2 -- 14 files changed, 18 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8df0b348..19d368ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add --chip argument for flash and write-bin commands (#514) - Add --partition-table-offset argument for specifying the partition table offset (#516) - Add `Serialize` and `Deserialize` to `FlashFrequency`, `FlashMode` and `FlashSize`. (#528) +- Add --min-chip-rev argument to specify minimum chip revision (#252) ### Fixed diff --git a/cargo-espflash/src/main.rs b/cargo-espflash/src/main.rs index 083fc334..80dc93d6 100644 --- a/cargo-espflash/src/main.rs +++ b/cargo-espflash/src/main.rs @@ -319,6 +319,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> { args.flash_args.format.or(metadata.format), args.flash_args.target_app_partition, flash_settings, + args.flash_args.min_chip_rev, )?; if args.flash_args.erase_parts.is_some() || args.flash_args.erase_data_parts.is_some() { @@ -568,6 +569,7 @@ fn save_image(args: SaveImageArgs) -> Result<()> { args.format.or(metadata.format), args.save_image_args.target_app_partition, flash_settings, + args.save_image_args.min_chip_rev, )?; save_elf_as_image( diff --git a/espflash/src/bin/espflash.rs b/espflash/src/bin/espflash.rs index e3bf0f3c..bed774bc 100644 --- a/espflash/src/bin/espflash.rs +++ b/espflash/src/bin/espflash.rs @@ -243,6 +243,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> { args.flash_args.format, args.flash_args.target_app_partition, flash_settings, + args.flash_args.min_chip_rev, )?; if args.flash_args.erase_parts.is_some() || args.flash_args.erase_data_parts.is_some() { @@ -313,6 +314,7 @@ fn save_image(args: SaveImageArgs) -> Result<()> { args.format, args.save_image_args.target_app_partition, flash_settings, + args.save_image_args.min_chip_rev, )?; save_elf_as_image( diff --git a/espflash/src/flasher/mod.rs b/espflash/src/flasher/mod.rs index 48c0662c..2e1c0ec8 100644 --- a/espflash/src/flasher/mod.rs +++ b/espflash/src/flasher/mod.rs @@ -10,6 +10,7 @@ use bytemuck::{Pod, Zeroable, __core::time::Duration}; use esp_idf_part::PartitionTable; use log::{debug, info, warn}; use miette::{IntoDiagnostic, Result}; +use serde::{Deserialize, Serialize}; use serialport::UsbPortInfo; use strum::{Display, EnumIter, EnumVariantNames}; @@ -901,22 +902,10 @@ impl Flasher { None }; - let flash_settings = FlashSettings::new( - flash_data.flash_settings.mode, - flash_data.flash_settings.size.or(Some(self.flash_size)), - flash_data.flash_settings.freq, - ); - - let image = self.chip.into_target().get_flash_image( - &image, - flash_data.bootloader, - flash_data.partition_table, - flash_data.target_app_partition, - flash_data.image_format, - chip_revision, - flash_data.min_chip_rev, - flash_settings, - )?; + let image = self + .chip + .into_target() + .get_flash_image(&image, flash_data, chip_revision)?; // When the `cli` feature is enabled, display the image size information. #[cfg(feature = "cli")] diff --git a/espflash/src/image_format/mod.rs b/espflash/src/image_format/mod.rs index 7e011ab3..ade8c666 100644 --- a/espflash/src/image_format/mod.rs +++ b/espflash/src/image_format/mod.rs @@ -20,6 +20,7 @@ use crate::{ flasher::{FlashFrequency, FlashMode, FlashSize}, targets::Chip, }; + mod direct_boot; mod esp8266; mod idf_bootloader; diff --git a/espflash/src/targets/esp32.rs b/espflash/src/targets/esp32.rs index c7e749e6..03e9135d 100644 --- a/espflash/src/targets/esp32.rs +++ b/espflash/src/targets/esp32.rs @@ -153,8 +153,6 @@ impl Target for Esp32 { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, _chip_revision: Option<(u32, u32)>, - min_rev_full: u16, - flash_settings: FlashSettings, ) -> Result + 'a>, Error> { let image_format = flash_data .image_format @@ -164,7 +162,7 @@ impl Target for Esp32 { ImageFormatKind::EspBootloader => Ok(Box::new(IdfBootloaderFormat::new( image, Chip::Esp32, - min_rev_full, + flash_data.min_chip_rev, PARAMS, flash_data.partition_table, flash_data.partition_table_offset, diff --git a/espflash/src/targets/esp32c2.rs b/espflash/src/targets/esp32c2.rs index 9684422e..848ec164 100644 --- a/espflash/src/targets/esp32c2.rs +++ b/espflash/src/targets/esp32c2.rs @@ -87,8 +87,6 @@ impl Target for Esp32c2 { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, _chip_revision: Option<(u32, u32)>, - flash_settings: FlashSettings, - min_rev_full: u16, ) -> Result + 'a>, Error> { let image_format = flash_data .image_format @@ -98,7 +96,7 @@ impl Target for Esp32c2 { ImageFormatKind::EspBootloader => Ok(Box::new(IdfBootloaderFormat::new( image, Chip::Esp32c2, - min_rev_full, + flash_data.min_chip_rev, PARAMS, flash_data.partition_table, flash_data.partition_table_offset, diff --git a/espflash/src/targets/esp32c3.rs b/espflash/src/targets/esp32c3.rs index 57d218ac..2f2cd195 100644 --- a/espflash/src/targets/esp32c3.rs +++ b/espflash/src/targets/esp32c3.rs @@ -74,8 +74,6 @@ impl Target for Esp32c3 { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, chip_revision: Option<(u32, u32)>, - // flash_settings: FlashSettings, - min_rev_full: u16, ) -> Result + 'a>, Error> { let image_format = flash_data .image_format @@ -85,7 +83,7 @@ impl Target for Esp32c3 { (ImageFormatKind::EspBootloader, _) => Ok(Box::new(IdfBootloaderFormat::new( image, Chip::Esp32c3, - min_rev_full, + flash_data.min_chip_rev, PARAMS, flash_data.partition_table, flash_data.partition_table_offset, diff --git a/espflash/src/targets/esp32c6.rs b/espflash/src/targets/esp32c6.rs index 8b7b85a5..035605cc 100644 --- a/espflash/src/targets/esp32c6.rs +++ b/espflash/src/targets/esp32c6.rs @@ -71,8 +71,6 @@ impl Target for Esp32c6 { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, _chip_revision: Option<(u32, u32)>, - min_rev_full: u16, - flash_settings: FlashSettings, ) -> Result + 'a>, Error> { let image_format = flash_data .image_format @@ -82,7 +80,7 @@ impl Target for Esp32c6 { ImageFormatKind::EspBootloader => Ok(Box::new(IdfBootloaderFormat::new( image, Chip::Esp32c6, - min_rev_full, + flash_data.min_chip_rev, PARAMS, flash_data.partition_table, flash_data.partition_table_offset, diff --git a/espflash/src/targets/esp32h2.rs b/espflash/src/targets/esp32h2.rs index ee44107c..943e6ba9 100644 --- a/espflash/src/targets/esp32h2.rs +++ b/espflash/src/targets/esp32h2.rs @@ -79,8 +79,6 @@ impl Target for Esp32h2 { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, _chip_revision: Option<(u32, u32)>, - min_rev_full: u16, - flash_settings: FlashSettings, ) -> Result + 'a>, Error> { let image_format = flash_data .image_format @@ -90,7 +88,7 @@ impl Target for Esp32h2 { ImageFormatKind::EspBootloader => Ok(Box::new(IdfBootloaderFormat::new( image, Chip::Esp32h2, - min_rev_full, + flash_data.min_chip_rev, PARAMS, flash_data.partition_table, flash_data.partition_table_offset, diff --git a/espflash/src/targets/esp32s2.rs b/espflash/src/targets/esp32s2.rs index 3c49fe91..cabb2e56 100644 --- a/espflash/src/targets/esp32s2.rs +++ b/espflash/src/targets/esp32s2.rs @@ -139,8 +139,6 @@ impl Target for Esp32s2 { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, _chip_revision: Option<(u32, u32)>, - min_rev_full: u16, - flash_settings: FlashSettings, ) -> Result + 'a>, Error> { let image_format = flash_data .image_format @@ -150,7 +148,7 @@ impl Target for Esp32s2 { ImageFormatKind::EspBootloader => Ok(Box::new(IdfBootloaderFormat::new( image, Chip::Esp32s2, - min_rev_full, + flash_data.min_chip_rev, PARAMS, flash_data.partition_table, flash_data.partition_table_offset, diff --git a/espflash/src/targets/esp32s3.rs b/espflash/src/targets/esp32s3.rs index d564ee42..f4df473a 100644 --- a/espflash/src/targets/esp32s3.rs +++ b/espflash/src/targets/esp32s3.rs @@ -93,8 +93,6 @@ impl Target for Esp32s3 { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, _chip_revision: Option<(u32, u32)>, - min_rev_full: u16, - flash_settings: FlashSettings, ) -> Result + 'a>, Error> { let image_format = flash_data .image_format @@ -104,7 +102,7 @@ impl Target for Esp32s3 { ImageFormatKind::EspBootloader => Ok(Box::new(IdfBootloaderFormat::new( image, Chip::Esp32s3, - min_rev_full, + flash_data.min_chip_rev, PARAMS, flash_data.partition_table, flash_data.partition_table_offset, diff --git a/espflash/src/targets/esp8266.rs b/espflash/src/targets/esp8266.rs index 42d79945..53f73564 100644 --- a/espflash/src/targets/esp8266.rs +++ b/espflash/src/targets/esp8266.rs @@ -73,8 +73,6 @@ impl Target for Esp8266 { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, _chip_revision: Option<(u32, u32)>, - min_rev_full: u16, - flash_settings: FlashSettings, ) -> Result + 'a>, Error> { let image_format = flash_data .image_format diff --git a/espflash/src/targets/mod.rs b/espflash/src/targets/mod.rs index 0baa2ae4..386d2c2d 100644 --- a/espflash/src/targets/mod.rs +++ b/espflash/src/targets/mod.rs @@ -297,8 +297,6 @@ pub trait Target: ReadEFuse { image: &'a dyn FirmwareImage<'a>, flash_data: FlashData, chip_revision: Option<(u32, u32)>, - min_rev_full: u16, - flash_settings: FlashSettings, ) -> Result + 'a>, Error>; /// What is the MAC address?