mirror of
https://github.com/Ralim/IronOS-Meta.git
synced 2025-04-15 11:27:48 +00:00
TS101 rework for Miniware DFU (#44)
* Refactor output to allow turning hex duplication on/off * Rough out being able to merge image files & firmware files * Update output_hex.py * Update TS101 to require merge * Remove TS101 from CI * . * add py3-intelhex * Update img2logo.py
This commit is contained in:
@@ -10,7 +10,6 @@ class HexOutput:
|
||||
INTELHEX_END_OF_FILE_RECORD = 0x01
|
||||
INTELHEX_EXTENDED_LINEAR_ADDRESS_RECORD = 0x04
|
||||
INTELHEX_BYTES_PER_LINE = 16
|
||||
INTELHEX_MINIMUM_SIZE = 4096
|
||||
|
||||
@classmethod
|
||||
def split16(cls, word):
|
||||
@@ -53,20 +52,19 @@ class HexOutput:
|
||||
) # low 8 bits
|
||||
|
||||
@classmethod
|
||||
def writeFile(cls, file_name: str, data: bytearray, data_address: int):
|
||||
def writeFile(
|
||||
cls,
|
||||
file_name: str,
|
||||
data: bytearray,
|
||||
data_address: int,
|
||||
minimum_hex_file_size: int,
|
||||
):
|
||||
"""write block of data in Intel hex format"""
|
||||
with open(file_name, "w", newline="\r\n") as output:
|
||||
|
||||
def write(generator):
|
||||
output.write("".join(generator))
|
||||
|
||||
if len(data) % cls.INTELHEX_BYTES_PER_LINE != 0:
|
||||
raise ValueError(
|
||||
"Program error: Size of LCD data is not evenly divisible by {}".format(
|
||||
cls.INTELHEX_BYTES_PER_LINE
|
||||
)
|
||||
)
|
||||
|
||||
address_lo = data_address & 0xFFFF
|
||||
address_hi = (data_address >> 16) & 0xFFFF
|
||||
|
||||
@@ -79,7 +77,7 @@ class HexOutput:
|
||||
)
|
||||
|
||||
size_written = 0
|
||||
while size_written < cls.INTELHEX_MINIMUM_SIZE:
|
||||
while size_written < minimum_hex_file_size:
|
||||
offset = address_lo
|
||||
for line_start in range(0, len(data), cls.INTELHEX_BYTES_PER_LINE):
|
||||
write(
|
||||
@@ -90,8 +88,6 @@ class HexOutput:
|
||||
)
|
||||
)
|
||||
size_written += cls.INTELHEX_BYTES_PER_LINE
|
||||
if size_written >= cls.INTELHEX_MINIMUM_SIZE:
|
||||
break
|
||||
offset += cls.INTELHEX_BYTES_PER_LINE
|
||||
|
||||
write(cls.intel_hex_line(cls.INTELHEX_END_OF_FILE_RECORD, 0, ()))
|
||||
|
||||
Reference in New Issue
Block a user