@@ -9,13 +9,13 @@ use clap::{Args, CommandFactory, Parser, Subcommand};
9
9
use espflash:: {
10
10
cli:: {
11
11
self , board_info, checksum_md5, completions, config:: Config , connect, erase_flash,
12
- erase_partitions, erase_region, flash_elf_image, monitor:: monitor, partition_table ,
13
- print_board_info, read_flash, save_elf_as_image, serial_monitor, ChecksumMd5Args ,
14
- CompletionsArgs , ConnectArgs , EraseFlashArgs , EraseRegionArgs , EspflashProgress ,
15
- FlashConfigArgs , MonitorArgs , PartitionTableArgs , ReadFlashArgs ,
12
+ erase_partitions, erase_region, flash_elf_image, make_flash_data , monitor:: monitor,
13
+ partition_table , print_board_info, read_flash, save_elf_as_image, serial_monitor,
14
+ ChecksumMd5Args , CompletionsArgs , ConnectArgs , EraseFlashArgs , EraseRegionArgs ,
15
+ EspflashProgress , FlashConfigArgs , MonitorArgs , PartitionTableArgs , ReadFlashArgs ,
16
16
} ,
17
17
error:: Error as EspflashError ,
18
- flasher:: { parse_partition_table, FlashData , FlashSettings } ,
18
+ flasher:: parse_partition_table,
19
19
logging:: initialize_logger,
20
20
targets:: { Chip , XtalFrequency } ,
21
21
update:: check_for_update,
@@ -267,12 +267,14 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
267
267
args. flash_args . no_verify ,
268
268
args. flash_args . no_skip ,
269
269
) ?;
270
- flasher. verify_minimum_revision ( args. flash_args . min_chip_rev ) ?;
270
+ flasher. verify_minimum_revision ( args. flash_args . image . min_chip_rev ) ?;
271
271
272
- // If the user has provided a flash size via a command-line argument, we'll
272
+ // If the user has provided a flash size via a command-line argument or config , we'll
273
273
// override the detected (or default) value with this.
274
274
if let Some ( flash_size) = args. build_args . flash_config_args . flash_size {
275
275
flasher. set_flash_size ( flash_size) ;
276
+ } else if let Some ( flash_size) = config. flash . size {
277
+ flasher. set_flash_size ( flash_size) ;
276
278
}
277
279
278
280
let chip = flasher. chip ( ) ;
@@ -292,40 +294,12 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
292
294
if args. flash_args . ram {
293
295
flasher. load_elf_to_ram ( & elf_data, Some ( & mut EspflashProgress :: default ( ) ) ) ?;
294
296
} else {
295
- let bootloader = args
296
- . flash_args
297
- . bootloader
298
- . as_deref ( )
299
- . or ( config. bootloader . as_deref ( ) )
300
- . or ( build_ctx. bootloader_path . as_deref ( ) ) ;
301
-
302
- let partition_table = args
303
- . flash_args
304
- . partition_table
305
- . as_deref ( )
306
- . or ( config. partition_table . as_deref ( ) )
307
- . or ( build_ctx. partition_table_path . as_deref ( ) ) ;
308
-
309
- if let Some ( path) = & bootloader {
310
- println ! ( "Bootloader: {}" , path. display( ) ) ;
311
- }
312
- if let Some ( path) = & partition_table {
313
- println ! ( "Partition table: {}" , path. display( ) ) ;
314
- }
315
-
316
- let flash_settings = FlashSettings :: new (
317
- args. build_args . flash_config_args . flash_mode ,
318
- args. build_args . flash_config_args . flash_size ,
319
- args. build_args . flash_config_args . flash_freq ,
320
- ) ;
321
-
322
- let flash_data = FlashData :: new (
323
- bootloader,
324
- partition_table,
325
- args. flash_args . partition_table_offset ,
326
- args. flash_args . target_app_partition ,
327
- flash_settings,
328
- args. flash_args . min_chip_rev ,
297
+ let flash_data = make_flash_data (
298
+ args. flash_args . image ,
299
+ & args. build_args . flash_config_args ,
300
+ config,
301
+ build_ctx. bootloader_path . as_deref ( ) ,
302
+ build_ctx. partition_table_path . as_deref ( ) ,
329
303
) ?;
330
304
331
305
if args. flash_args . erase_parts . is_some ( ) || args. flash_args . erase_data_parts . is_some ( ) {
@@ -532,47 +506,18 @@ fn save_image(args: SaveImageArgs, config: &Config) -> Result<()> {
532
506
let build_ctx = build ( & args. build_args , & cargo_config, args. save_image_args . chip ) ?;
533
507
let elf_data = fs:: read ( build_ctx. artifact_path ) . into_diagnostic ( ) ?;
534
508
535
- let bootloader = args
536
- . save_image_args
537
- . bootloader
538
- . as_deref ( )
539
- . or ( config. bootloader . as_deref ( ) )
540
- . or ( build_ctx. bootloader_path . as_deref ( ) )
541
- . map ( |p| p. to_path_buf ( ) ) ;
542
-
543
- let partition_table = args
544
- . save_image_args
545
- . partition_table
546
- . as_deref ( )
547
- . or ( config. partition_table . as_deref ( ) )
548
- . or ( build_ctx. partition_table_path . as_deref ( ) )
549
- . map ( |p| p. to_path_buf ( ) ) ;
550
-
551
509
// Since we have no `Flasher` instance and as such cannot print the board
552
510
// information, we will print whatever information we _do_ have.
553
511
println ! ( "Chip type: {}" , args. save_image_args. chip) ;
554
512
println ! ( "Merge: {}" , args. save_image_args. merge) ;
555
513
println ! ( "Skip padding: {}" , args. save_image_args. skip_padding) ;
556
- if let Some ( path) = & args. save_image_args . bootloader {
557
- println ! ( "Bootloader: {}" , path. display( ) ) ;
558
- }
559
- if let Some ( path) = & args. save_image_args . partition_table {
560
- println ! ( "Partition table: {}" , path. display( ) ) ;
561
- }
562
514
563
- let flash_settings = FlashSettings :: new (
564
- args. build_args . flash_config_args . flash_mode ,
565
- args. build_args . flash_config_args . flash_size ,
566
- args. build_args . flash_config_args . flash_freq ,
567
- ) ;
568
-
569
- let flash_data = FlashData :: new (
570
- bootloader. as_deref ( ) ,
571
- partition_table. as_deref ( ) ,
572
- args. save_image_args . partition_table_offset ,
573
- args. save_image_args . target_app_partition ,
574
- flash_settings,
575
- args. save_image_args . min_chip_rev ,
515
+ let flash_data = make_flash_data (
516
+ args. save_image_args . image ,
517
+ & args. build_args . flash_config_args ,
518
+ config,
519
+ build_ctx. bootloader_path . as_deref ( ) ,
520
+ build_ctx. partition_table_path . as_deref ( ) ,
576
521
) ?;
577
522
578
523
let xtal_freq = args
0 commit comments