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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- `save-image` now checks if the ELF contains the app descriptor (#920)

### Changed

Expand Down
7 changes: 5 additions & 2 deletions cargo-espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
// Read the ELF data from the build path and load it to the target.
let elf_data = fs::read(build_ctx.artifact_path.clone()).into_diagnostic()?;

// Check if the ELF contains the app descriptor, if required.
if args.flash_args.image.check_app_descriptor.unwrap_or(true) {
if args.flash_args.image.check_app_descriptor && args.format == ImageFormatKind::EspIdf {
check_idf_bootloader(&elf_data)?;
}

Expand Down Expand Up @@ -617,6 +616,10 @@ fn save_image(args: SaveImageArgs, config: &Config) -> Result<()> {
let build_ctx = build(&args.build_args, &cargo_config, args.save_image_args.chip)?;
let elf_data = fs::read(&build_ctx.artifact_path).into_diagnostic()?;

if args.save_image_args.image.check_app_descriptor && args.format == ImageFormatKind::EspIdf {
check_idf_bootloader(&elf_data)?;
}

// Since we have no `Flasher` instance and as such cannot print the board
// information, we will print whatever information we _do_ have.
println!("Chip type: {}", args.save_image_args.chip);
Expand Down
7 changes: 5 additions & 2 deletions espflash/src/bin/espflash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
// Read the ELF data from the build path and load it to the target.
let elf_data = fs::read(&args.image).into_diagnostic()?;

// Check if the ELF contains the app descriptor, if required.
if args.flash_args.image.check_app_descriptor.unwrap_or(true) {
if args.flash_args.image.check_app_descriptor && args.format == ImageFormatKind::EspIdf {
check_idf_bootloader(&elf_data)?;
}

Expand Down Expand Up @@ -344,6 +343,10 @@ fn save_image(args: SaveImageArgs, config: &Config) -> Result<()> {
.into_diagnostic()
.wrap_err_with(|| format!("Failed to open image {}", args.image.display()))?;

if args.save_image_args.image.check_app_descriptor && args.format == ImageFormatKind::EspIdf {
check_idf_bootloader(&elf_data)?;
}

// Since we have no `Flasher` instance and as such cannot print the board
// information, we will print whatever information we _do_ have.
println!("Chip type: {}", args.save_image_args.chip);
Expand Down
2 changes: 1 addition & 1 deletion espflash/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub struct ImageArgs {
pub mmu_page_size: Option<u32>,
/// Flag to check the app descriptor in bootloader
#[arg(long, default_value = "true", value_parser = clap::value_parser!(bool))]
pub check_app_descriptor: Option<bool>,
pub check_app_descriptor: bool,
}

/// ESP-IDF image format arguments
Expand Down
Loading