diff --git a/README.md b/README.md index 7a60bf5..7c94d87 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ All fields, except for data, are 32 bit unsigned little endian integers. | 20 | 4 | Sequential block number; starts at 0 | | 24 | 4 | Total number of blocks in file | | 28 | 4 | File size or board family ID or zero | -| 32 | 476 | Data, padded with zeros | +| 32 | 476 | Data, padded with `0xFF` | | 508 | 4 | Final magic number, `0x0AB16F30` | The following C struct can be used: @@ -284,7 +284,8 @@ The first byte of tag contains its total size in bytes (including the size byte and type designation). The next three bytes designate the type of tag (if you want to define custom tags, pick them at random). -The last tag has size of `0` and type of `0`. +The last tag has a size of `0xFF` and a type of `0xFFFFFF`, which does match padding data. +For backward compatibility, also (size `0x00` and type `0x000000`) should be considered as last tag marker. Standard tag designations follow: * `0x9fc7bc` - version of firmware file - UTF8 semver string @@ -300,7 +301,7 @@ named `ACME Toaster mk3` (line breaks added for clarity): ``` 09 bc c7 9f 30 2e 31 2e 32 00 00 00 14 9d 0d 65 41 43 4d 45 20 54 6f 61 73 74 65 72 20 6d 6b 33 -00 00 00 00 +FF FF FF FF ``` Extension tags can, but don't have to, be repeated in all blocks. diff --git a/utils/uf2conv.py b/utils/uf2conv.py index 5a862c3..1063a81 100755 --- a/utils/uf2conv.py +++ b/utils/uf2conv.py @@ -73,7 +73,7 @@ def convert_from_uf2(buf): assert False, "Non-word padding size at " + ptr while padding > 0: padding -= 4 - outp.append(b"\x00\x00\x00\x00") + outp.append(b"\xFF\xFF\xFF\xFF") if familyid == 0x0 or ((hd[2] & 0x2000) and familyid == hd[7]): outp.append(block[32 : 32 + datalen]) curraddr = newaddr + datalen @@ -121,7 +121,7 @@ def convert_to_uf2(file_content): global familyid datapadding = b"" while len(datapadding) < 512 - 256 - 32 - 4: - datapadding += b"\x00\x00\x00\x00" + datapadding += b"\xFF\xFF\xFF\xFF" numblocks = (len(file_content) + 255) // 256 outp = [] for blockno in range(numblocks):