@@ -544,7 +544,7 @@ def _get_eol_textfile(eolstyle, platform):
544544 raise ValueError ("wrong eolstyle %s" % repr (eolstyle ))
545545 _get_eol_textfile = staticmethod (_get_eol_textfile )
546546
547- def write_hex_file (self , f , write_start_addr = True , eolstyle = 'native' ):
547+ def write_hex_file (self , f , write_start_addr = True , eolstyle = 'native' , byte_count = 16 ):
548548 """Write data to file f in HEX format.
549549
550550 @param f filename or file-like object for writing
@@ -555,6 +555,7 @@ def write_hex_file(self, f, write_start_addr=True, eolstyle='native'):
555555 @param eolstyle can be used to force CRLF line-endings
556556 for output file on different platforms.
557557 Supported eol styles: 'native', 'CRLF'.
558+ @param byte_count number of bytes in the data field
558559 """
559560 fwrite = getattr (f , "write" , None )
560561 if fwrite :
@@ -656,7 +657,7 @@ def write_hex_file(self, f, write_start_addr=True, eolstyle='native'):
656657 # produce one record
657658 low_addr = cur_addr & 0x0FFFF
658659 # chain_len off by 1
659- chain_len = min (15 , 65535 - low_addr , maxaddr - cur_addr )
660+ chain_len = min (byte_count - 1 , 65535 - low_addr , maxaddr - cur_addr )
660661
661662 # search continuous chain
662663 stop_addr = cur_addr + chain_len
0 commit comments