File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,9 @@ pub struct SaveImageOpts {
124
124
/// Custom partition table for merging
125
125
#[ clap( long, short = 'T' ) ]
126
126
pub partition_table : Option < PathBuf > ,
127
+ /// Don't pad the image to the flash size
128
+ #[ clap( long, short = 'P' ) ]
129
+ pub skip_padding : bool ,
127
130
}
128
131
129
132
fn main ( ) -> Result < ( ) > {
@@ -423,6 +426,7 @@ fn save_image(
423
426
opts. merge ,
424
427
bootloader,
425
428
partition_table,
429
+ opts. skip_padding ,
426
430
) ?;
427
431
428
432
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ pub fn save_elf_as_image(
172
172
merge : bool ,
173
173
bootloader_path : Option < PathBuf > ,
174
174
partition_table_path : Option < PathBuf > ,
175
+ skip_padding : bool ,
175
176
) -> Result < ( ) > {
176
177
let image = ElfFirmwareImage :: try_from ( elf_data) ?;
177
178
@@ -237,13 +238,15 @@ pub fn save_elf_as_image(
237
238
file. write_all ( & segment. data ) . into_diagnostic ( ) ?;
238
239
}
239
240
240
- // Take flash_size as input parameter, if None, use default value of 4Mb
241
- let padding_bytes = vec ! [
242
- 0xffu8 ;
243
- flash_size. unwrap_or( FlashSize :: Flash4Mb ) . size( ) as usize
244
- - file. metadata( ) . into_diagnostic( ) ?. len( ) as usize
245
- ] ;
246
- file. write_all ( & padding_bytes) . into_diagnostic ( ) ?;
241
+ if !skip_padding {
242
+ // Take flash_size as input parameter, if None, use default value of 4Mb
243
+ let padding_bytes = vec ! [
244
+ 0xffu8 ;
245
+ flash_size. unwrap_or( FlashSize :: Flash4Mb ) . size( ) as usize
246
+ - file. metadata( ) . into_diagnostic( ) ?. len( ) as usize
247
+ ] ;
248
+ file. write_all ( & padding_bytes) . into_diagnostic ( ) ?;
249
+ }
247
250
} else {
248
251
let flash_image = chip. get_flash_image (
249
252
& image,
Original file line number Diff line number Diff line change @@ -79,6 +79,9 @@ pub struct SaveImageOpts {
79
79
/// Custom partition table for merging
80
80
#[ clap( long, short = 'T' ) ]
81
81
pub partition_table : Option < PathBuf > ,
82
+ /// Don't pad the image to the flash size
83
+ #[ clap( long, short = 'P' ) ]
84
+ pub skip_padding : bool ,
82
85
}
83
86
84
87
fn main ( ) -> Result < ( ) > {
@@ -197,6 +200,7 @@ fn save_image(opts: SaveImageOpts) -> Result<()> {
197
200
opts. merge ,
198
201
opts. bootloader ,
199
202
opts. partition_table ,
203
+ opts. skip_padding ,
200
204
) ?;
201
205
202
206
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments