Skip to content

Commit c891384

Browse files
Add app descriptor check to save image (#920)
* feat: Add check_idf_bootloader to save_image * chore: Rename check_idf_bootloader to check_app_descriptor * docs: Update changelog * revert: check_idf_bootloader name change
1 parent 12a177a commit c891384

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

CHANGELOG.md

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

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

1213
### Changed
1314

cargo-espflash/src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
336336
// Read the ELF data from the build path and load it to the target.
337337
let elf_data = fs::read(build_ctx.artifact_path.clone()).into_diagnostic()?;
338338

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

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

619+
if args.save_image_args.image.check_app_descriptor && args.format == ImageFormatKind::EspIdf {
620+
check_idf_bootloader(&elf_data)?;
621+
}
622+
620623
// Since we have no `Flasher` instance and as such cannot print the board
621624
// information, we will print whatever information we _do_ have.
622625
println!("Chip type: {}", args.save_image_args.chip);

espflash/src/bin/espflash.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
263263
// Read the ELF data from the build path and load it to the target.
264264
let elf_data = fs::read(&args.image).into_diagnostic()?;
265265

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

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

346+
if args.save_image_args.image.check_app_descriptor && args.format == ImageFormatKind::EspIdf {
347+
check_idf_bootloader(&elf_data)?;
348+
}
349+
347350
// Since we have no `Flasher` instance and as such cannot print the board
348351
// information, we will print whatever information we _do_ have.
349352
println!("Chip type: {}", args.save_image_args.chip);

espflash/src/cli/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub struct ImageArgs {
259259
pub mmu_page_size: Option<u32>,
260260
/// Flag to check the app descriptor in bootloader
261261
#[arg(long, default_value = "true", value_parser = clap::value_parser!(bool))]
262-
pub check_app_descriptor: Option<bool>,
262+
pub check_app_descriptor: bool,
263263
}
264264

265265
/// ESP-IDF image format arguments

0 commit comments

Comments
 (0)