File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,9 @@ pub struct ImageArgs {
253
253
/// MMU page size.
254
254
#[ arg( long, value_name = "MMU_PAGE_SIZE" , value_parser = parse_u32) ]
255
255
pub mmu_page_size : Option < u32 > ,
256
+ /// Whether to apply padding for secure boot v2
257
+ #[ arg( long) ]
258
+ pub secure_pad_v2 : bool ,
256
259
}
257
260
258
261
#[ derive( Debug , Args ) ]
@@ -1060,6 +1063,7 @@ pub fn make_flash_data(
1060
1063
flash_settings,
1061
1064
image_args. min_chip_rev ,
1062
1065
image_args. mmu_page_size ,
1066
+ image_args. secure_pad_v2 ,
1063
1067
)
1064
1068
}
1065
1069
Original file line number Diff line number Diff line change @@ -477,6 +477,7 @@ pub struct FlashData {
477
477
pub flash_settings : FlashSettings ,
478
478
pub min_chip_rev : u16 ,
479
479
pub mmu_page_size : Option < u32 > ,
480
+ pub secure_pad_v2 : bool ,
480
481
}
481
482
482
483
impl FlashData {
@@ -488,6 +489,7 @@ impl FlashData {
488
489
flash_settings : FlashSettings ,
489
490
min_chip_rev : u16 ,
490
491
mmu_page_size : Option < u32 > ,
492
+ secure_pad_v2 : bool ,
491
493
) -> Result < Self , Error > {
492
494
// If the '--bootloader' option is provided, load the binary file at the
493
495
// specified path.
@@ -520,6 +522,7 @@ impl FlashData {
520
522
flash_settings,
521
523
min_chip_rev,
522
524
mmu_page_size,
525
+ secure_pad_v2,
523
526
} )
524
527
}
525
528
}
Original file line number Diff line number Diff line change @@ -401,6 +401,18 @@ impl<'a> IdfBootloaderFormat<'a> {
401
401
segment_count += 1 ;
402
402
}
403
403
404
+ if flash_data. secure_pad_v2 {
405
+ let current_size = data. len ( ) ;
406
+ let padding_size = ( 65536 - ( ( current_size + 56 ) % 65536 ) ) % 65536 ;
407
+ let padding_bytes = vec ! [ 0 ; padding_size] ;
408
+ let segment = Segment {
409
+ addr : 0 ,
410
+ data : Cow :: Owned ( padding_bytes) ,
411
+ } ;
412
+ checksum = save_segment ( & mut data, & segment, checksum) ?;
413
+ segment_count += 1 ;
414
+ }
415
+
404
416
let padding = 15 - ( data. len ( ) % 16 ) ;
405
417
let padding = & [ 0u8 ; 16 ] [ 0 ..padding] ;
406
418
data. write_all ( padding) ?;
You can’t perform that action at this time.
0 commit comments