Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a bootloader and/or partition table other than the defaults have been provided, indicate such #339

Merged
merged 1 commit into from
Jan 10, 2023
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
19 changes: 16 additions & 3 deletions cargo-espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn main() -> Result<()> {
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));

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

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

let mut flasher = connect(&args.connect_args, config)?;
print_board_info(&mut flasher)?;

let chip = flasher.chip();
let target = chip.into_target();
let target_xtal_freq = target.crystal_freq(flasher.connection())?;
Expand All @@ -170,6 +168,8 @@ 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).into_diagnostic()?;

print_board_info(&mut flasher)?;

if args.flash_args.ram {
flasher.load_elf_to_ram(&elf_data)?;
} else {
Expand All @@ -187,6 +187,13 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
.or(metadata.partition_table.as_deref())
.or(build_ctx.partition_table_path.as_deref());

if let Some(path) = &bootloader {
println!("Bootloader: {}", path.display());
}
if let Some(path) = &partition_table {
println!("Partition table: {}", path.display());
}

let partition_table = match partition_table {
Some(path) => Some(parse_partition_table(path)?),
None => None,
Expand Down Expand Up @@ -428,6 +435,12 @@ fn save_image(args: SaveImageArgs) -> Result<()> {
}
println!("Merge: {}", args.save_image_args.merge);
println!("Skip padding: {}", args.save_image_args.skip_padding);
if let Some(path) = &args.save_image_args.bootloader {
println!("Bootloader: {}", path.display());
}
if let Some(path) = &args.save_image_args.partition_table {
println!("Partition table: {}", path.display());
}

save_elf_as_image(
args.save_image_args.chip,
Expand Down
19 changes: 17 additions & 2 deletions espflash/src/bin/espflash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn main() -> Result<()> {
check_for_update(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));

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

// Execute the correct action based on the provided subcommand and its
// associated arguments.
Expand Down Expand Up @@ -129,7 +129,16 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
flasher.load_elf_to_ram(&elf_data)?;
} else {
let bootloader = args.flash_args.bootloader.as_deref();
let partition_table = match args.flash_args.partition_table.as_deref() {
let partition_table = args.flash_args.partition_table.as_deref();

if let Some(path) = bootloader {
println!("Bootloader: {}", path.display());
}
if let Some(path) = partition_table {
println!("Partition table: {}", path.display());
}

let partition_table = match partition_table {
Some(path) => Some(parse_partition_table(path)?),
None => None,
};
Expand Down Expand Up @@ -191,6 +200,12 @@ fn save_image(args: SaveImageArgs) -> Result<()> {
}
println!("Merge: {}", args.save_image_args.merge);
println!("Skip padding: {}", args.save_image_args.skip_padding);
if let Some(path) = &args.save_image_args.bootloader {
println!("Bootloader: {}", path.display());
}
if let Some(path) = &args.save_image_args.partition_table {
println!("Partition table: {}", path.display());
}

save_elf_as_image(
args.save_image_args.chip,
Expand Down