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 {
253253 /// MMU page size.
254254 #[ arg( long, value_name = "MMU_PAGE_SIZE" , value_parser = parse_u32) ]
255255 pub mmu_page_size : Option < u32 > ,
256+ /// Whether to apply padding for secure boot v2
257+ #[ arg( long) ]
258+ pub secure_pad_v2 : bool ,
256259}
257260
258261#[ derive( Debug , Args ) ]
@@ -1060,6 +1063,7 @@ pub fn make_flash_data(
10601063 flash_settings,
10611064 image_args. min_chip_rev ,
10621065 image_args. mmu_page_size ,
1066+ image_args. secure_pad_v2 ,
10631067 )
10641068}
10651069
Original file line number Diff line number Diff line change @@ -477,6 +477,7 @@ pub struct FlashData {
477477 pub flash_settings : FlashSettings ,
478478 pub min_chip_rev : u16 ,
479479 pub mmu_page_size : Option < u32 > ,
480+ pub secure_pad_v2 : bool ,
480481}
481482
482483impl FlashData {
@@ -488,6 +489,7 @@ impl FlashData {
488489 flash_settings : FlashSettings ,
489490 min_chip_rev : u16 ,
490491 mmu_page_size : Option < u32 > ,
492+ secure_pad_v2 : bool ,
491493 ) -> Result < Self , Error > {
492494 // If the '--bootloader' option is provided, load the binary file at the
493495 // specified path.
@@ -520,6 +522,7 @@ impl FlashData {
520522 flash_settings,
521523 min_chip_rev,
522524 mmu_page_size,
525+ secure_pad_v2,
523526 } )
524527 }
525528}
Original file line number Diff line number Diff line change @@ -401,6 +401,18 @@ impl<'a> IdfBootloaderFormat<'a> {
401401 segment_count += 1 ;
402402 }
403403
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+
404416 let padding = 15 - ( data. len ( ) % 16 ) ;
405417 let padding = & [ 0u8 ; 16 ] [ 0 ..padding] ;
406418 data. write_all ( padding) ?;
You can’t perform that action at this time.
0 commit comments