Skip to content

Commit 911b28d

Browse files
committed
If a bootloader and/or partition table other than the defaults have been provided, indicate such
1 parent 59d62c1 commit 911b28d

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

cargo-espflash/src/main.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn main() -> Result<()> {
133133
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
134134

135135
// Load any user configuration, if present.
136-
let config = Config::load().unwrap();
136+
let config = Config::load()?;
137137

138138
// Execute the correct action based on the provided subcommand and its
139139
// associated arguments.
@@ -158,8 +158,6 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
158158
let cargo_config = CargoConfig::load(&metadata.workspace_root, &metadata.package_root);
159159

160160
let mut flasher = connect(&args.connect_args, config)?;
161-
print_board_info(&mut flasher)?;
162-
163161
let chip = flasher.chip();
164162
let target = chip.into_target();
165163
let target_xtal_freq = target.crystal_freq(flasher.connection())?;
@@ -170,6 +168,8 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
170168
// Read the ELF data from the build path and load it to the target.
171169
let elf_data = fs::read(build_ctx.artifact_path).into_diagnostic()?;
172170

171+
print_board_info(&mut flasher)?;
172+
173173
if args.flash_args.ram {
174174
flasher.load_elf_to_ram(&elf_data)?;
175175
} else {
@@ -187,6 +187,13 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
187187
.or(metadata.partition_table.as_deref())
188188
.or(build_ctx.partition_table_path.as_deref());
189189

190+
if let Some(path) = &bootloader {
191+
println!("Bootloader: {}", path.display());
192+
}
193+
if let Some(path) = &partition_table {
194+
println!("Partition table: {}", path.display());
195+
}
196+
190197
let partition_table = match partition_table {
191198
Some(path) => Some(parse_partition_table(path)?),
192199
None => None,
@@ -428,6 +435,12 @@ fn save_image(args: SaveImageArgs) -> Result<()> {
428435
}
429436
println!("Merge: {}", args.save_image_args.merge);
430437
println!("Skip padding: {}", args.save_image_args.skip_padding);
438+
if let Some(path) = &args.save_image_args.bootloader {
439+
println!("Bootloader: {}", path.display());
440+
}
441+
if let Some(path) = &args.save_image_args.partition_table {
442+
println!("Partition table: {}", path.display());
443+
}
431444

432445
save_elf_as_image(
433446
args.save_image_args.chip,

espflash/src/bin/espflash.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn main() -> Result<()> {
100100
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
101101

102102
// Load any user configuraiton, if present.
103-
let config = Config::load().unwrap();
103+
let config = Config::load()?;
104104

105105
// Execute the correct action based on the provided subcommand and its
106106
// associated arguments.
@@ -129,7 +129,16 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
129129
flasher.load_elf_to_ram(&elf_data)?;
130130
} else {
131131
let bootloader = args.flash_args.bootloader.as_deref();
132-
let partition_table = match args.flash_args.partition_table.as_deref() {
132+
let partition_table = args.flash_args.partition_table.as_deref();
133+
134+
if let Some(path) = bootloader {
135+
println!("Bootloader: {}", path.display());
136+
}
137+
if let Some(path) = partition_table {
138+
println!("Partition table: {}", path.display());
139+
}
140+
141+
let partition_table = match partition_table {
133142
Some(path) => Some(parse_partition_table(path)?),
134143
None => None,
135144
};
@@ -191,6 +200,12 @@ fn save_image(args: SaveImageArgs) -> Result<()> {
191200
}
192201
println!("Merge: {}", args.save_image_args.merge);
193202
println!("Skip padding: {}", args.save_image_args.skip_padding);
203+
if let Some(path) = &args.save_image_args.bootloader {
204+
println!("Bootloader: {}", path.display());
205+
}
206+
if let Some(path) = &args.save_image_args.partition_table {
207+
println!("Partition table: {}", path.display());
208+
}
194209

195210
save_elf_as_image(
196211
args.save_image_args.chip,

0 commit comments

Comments
 (0)