@@ -369,13 +369,18 @@ def _fill_header(region_list, current_region):
369
369
_ , type , subtype , data = member
370
370
member_size = Config .header_member_size (member )
371
371
if type == "const" :
372
- fmt = {"8" : "<B" , "16" : "<H" , "32" : "<L" , "64" : "<Q" }[subtype ]
372
+ fmt = {
373
+ "8le" : ">B" , "16le" : "<H" , "32le" : "<L" , "64le" : "<Q" ,
374
+ "8be" : "<B" , "16be" : ">H" , "32be" : ">L" , "64be" : ">Q"
375
+ }[subtype ]
373
376
header .puts (start , struct .pack (fmt , int (data , 0 )))
374
377
elif type == "timestamp" :
375
- fmt = {"32" : "<L" , "64" : "<Q" }[subtype ]
378
+ fmt = {"32le" : "<L" , "64le" : "<Q" ,
379
+ "32be" : ">L" , "64be" : ">Q" }[subtype ]
376
380
header .puts (start , struct .pack (fmt , time ()))
377
381
elif type == "size" :
378
- fmt = {"32" : "<L" , "64" : "<Q" }[subtype ]
382
+ fmt = {"32le" : "<L" , "64le" : "<Q" ,
383
+ "32be" : ">L" , "64be" : ">Q" }[subtype ]
379
384
size = sum (_real_region_size (region_dict [r ]) for r in data )
380
385
header .puts (start , struct .pack (fmt , size ))
381
386
start += Config .header_member_size (member )
@@ -387,8 +392,9 @@ def _fill_header(region_list, current_region):
387
392
ih = header
388
393
else :
389
394
ih = intelhex_offset (region_dict [data ].filename , offset = region_dict [data ].start )
390
- if subtype == "CRCITT32" :
391
- header .puts (start , struct .pack ("<l" , zlib .crc32 (ih .tobinarray ())))
395
+ if subtype .startswith ("CRCITT32" ):
396
+ fmt = {"CRCITT32be" : ">l" , "CRCITT32le" : "<l" }[subtype ]
397
+ header .puts (start , struct .pack (fmt , zlib .crc32 (ih .tobinarray ())))
392
398
elif subtype .startswith ("SHA" ):
393
399
if subtype == "SHA256" :
394
400
hash = hashlib .sha256 ()
0 commit comments