@@ -24,7 +24,11 @@ use log::{debug, info};
24
24
use miette:: { IntoDiagnostic , Result , WrapErr } ;
25
25
use serialport:: { SerialPortType , UsbPortInfo } ;
26
26
27
- use self :: { config:: Config , monitor:: monitor, serial:: get_serial_port_info} ;
27
+ use self :: {
28
+ config:: Config ,
29
+ monitor:: { monitor_with, LogFormat } ,
30
+ serial:: get_serial_port_info,
31
+ } ;
28
32
use crate :: {
29
33
elf:: ElfFirmwareImage ,
30
34
error:: { Error , MissingPartition , MissingPartitionTable } ,
@@ -131,9 +135,15 @@ pub struct FlashArgs {
131
135
/// Path to a CSV file containing partition table
132
136
#[ arg( long, value_name = "FILE" ) ]
133
137
pub partition_table : Option < PathBuf > ,
138
+ /// Label of target app partition
139
+ #[ arg( long, value_name = "LABEL" ) ]
140
+ pub target_app_partition : Option < String > ,
134
141
/// Load the application to RAM instead of Flash
135
142
#[ arg( long) ]
136
143
pub ram : bool ,
144
+ /// Logging format.
145
+ #[ arg( long, short = 'f' , default_value = "serial" , requires = "monitor" ) ]
146
+ pub log_format : LogFormat ,
137
147
}
138
148
139
149
/// Operations for partitions tables
@@ -171,6 +181,9 @@ pub struct SaveImageArgs {
171
181
/// Custom partition table for merging
172
182
#[ arg( long, short = 'T' , requires = "merge" , value_name = "FILE" ) ]
173
183
pub partition_table : Option < PathBuf > ,
184
+ /// Label of target app partition
185
+ #[ arg( long, value_name = "LABEL" ) ]
186
+ pub target_app_partition : Option < String > ,
174
187
/// Don't pad the image to the flash size
175
188
#[ arg( long, short = 'P' , requires = "merge" ) ]
176
189
pub skip_padding : bool ,
@@ -185,6 +198,9 @@ pub struct MonitorArgs {
185
198
/// Connection configuration
186
199
#[ clap( flatten) ]
187
200
connect_args : ConnectArgs ,
201
+ /// Logging format.
202
+ #[ arg( long, short = 'f' , default_value = "serial" ) ]
203
+ pub log_format : LogFormat ,
188
204
}
189
205
190
206
/// Select a serial port and establish a connection with a target device
@@ -291,11 +307,12 @@ pub fn serial_monitor(args: MonitorArgs, config: &Config) -> Result<()> {
291
307
115_200
292
308
} ;
293
309
294
- monitor (
310
+ monitor_with (
295
311
flasher. into_interface ( ) ,
296
312
elf. as_deref ( ) ,
297
313
pid,
298
314
args. connect_args . baud . unwrap_or ( default_baud) ,
315
+ args. log_format ,
299
316
)
300
317
. into_diagnostic ( ) ?;
301
318
@@ -314,6 +331,7 @@ pub fn save_elf_as_image(
314
331
merge : bool ,
315
332
bootloader_path : Option < PathBuf > ,
316
333
partition_table_path : Option < PathBuf > ,
334
+ target_app_partition : Option < String > ,
317
335
skip_padding : bool ,
318
336
) -> Result < ( ) > {
319
337
let image = ElfFirmwareImage :: try_from ( elf_data) ?;
@@ -355,6 +373,7 @@ pub fn save_elf_as_image(
355
373
& image,
356
374
bootloader,
357
375
partition_table,
376
+ target_app_partition,
358
377
image_format,
359
378
None ,
360
379
flash_mode,
@@ -395,6 +414,7 @@ pub fn save_elf_as_image(
395
414
& image,
396
415
None ,
397
416
None ,
417
+ None ,
398
418
image_format,
399
419
None ,
400
420
flash_mode,
@@ -508,6 +528,7 @@ pub fn flash_elf_image(
508
528
elf_data : & [ u8 ] ,
509
529
bootloader : Option < & Path > ,
510
530
partition_table : Option < PartitionTable > ,
531
+ target_app_partition : Option < String > ,
511
532
image_format : Option < ImageFormatKind > ,
512
533
flash_mode : Option < FlashMode > ,
513
534
flash_size : Option < FlashSize > ,
@@ -530,6 +551,7 @@ pub fn flash_elf_image(
530
551
elf_data,
531
552
bootloader,
532
553
partition_table,
554
+ target_app_partition,
533
555
image_format,
534
556
flash_mode,
535
557
flash_size,
0 commit comments