diff --git a/util/uf2conv.py b/util/uf2conv.py index 97e11cd32e..5e875a3b32 100755 --- a/util/uf2conv.py +++ b/util/uf2conv.py @@ -9,6 +9,19 @@ import os.path import argparse import json +# Don't even need -b. hex has this embedded +# > ./util/uf2conv.py .build/lotus_ansi_default.hex -o ansi.uf2 -b 0x10000000 -f rp2040 --convert --blocks-reserved 1 +# Converted to 222 blocks +# Converted to uf2, output size: 113664, start address: 0x10000000 +# Wrote 113664 bytes to ansi.uf2 +# # 113664 / 512 = 222 +# +# > ./util/uf2conv.py serial.bin -o serial.uf2 -b 0x100ff000 -f rp2040 --convert --blocks-offset 222 +# Converted to 1 blocks +# Converted to uf2, output size: 512, start address: 0x100ff000 +# Wrote 512 bytes to serial.uf2 + + UF2_MAGIC_START0 = 0x0A324655 # "UF2\n" UF2_MAGIC_START1 = 0x9E5D5157 # Randomly selected @@ -124,7 +137,7 @@ def convert_to_carray(file_content): outp += "\n};\n" return bytes(outp, "utf-8") -def convert_to_uf2(file_content): +def convert_to_uf2(file_content, blocks_reserved=0, blocks_offset=0): global familyid datapadding = b"" while len(datapadding) < 512 - 256 - 32 - 4: @@ -139,7 +152,7 @@ def convert_to_uf2(file_content): flags |= 0x2000 hd = struct.pack(b"