microsoft / uf2

UF2 file format specification
Other
849 stars 164 forks source link

Can a UF2 file only have one family ID? #51

Closed charkster closed 3 years ago

charkster commented 3 years ago

Is it possible to concatenate multiple UF2 files which have different family IDs? If all the flags were 0x2000 shouldn't that allow the single UF2 file to be programmed correctly on different mcu architectures? I am wanting to create complex valid UF2 files for testing #48 feature in uf2conv.py . I did not properly handle multiple family IDs in pull request #49 . If multiple family IDs are allowed, how can I create UF2 files properly? Do the magic numbers need to be different before the files are concatenated? Thanks.

mmoskal commented 3 years ago

you can simply cat them together, see second paragraph here https://github.com/microsoft/uf2/blob/master/README.md#family-id

charkster commented 3 years ago

Thank you. I concatenated 2 different family ID UF2 files to make a single UF2 file, and then I inputted that to uf2conv.py to create a bin file. I used the -f option to specify the family ID that I wanted the bin file for. The padding calculation sees the difference in addresses from one family ID to the next family ID and reports that "More than 10M of padding need". Am I using uf2conv.py incorrectly in this manner, or would a change be needed to only process blocks of the provided family ID? I have made a few changes to the Header information feature, to allow for multiple family IDs, including a better way to determine the base addresses and bin file sizes. I am excited about getting the Header information feature working for UF2 files with various family IDs, as I would like to include these complex UF2 files in my github repositories... to make a common function available to different MCUs as a single file. But there needs to be a way for people to parse the UF2 to see which MCUs families are supported. I apologize if I am suggesting features beyond the scope of what uf2conv.py was intended for.

charkster commented 3 years ago

I committed changes to support multiple family ID UF2 files. I will go ahead and submit a pull request. I tested on UF2 files with 1, 2 and 3 concatenated UF2 files. I was able to extract a bin file for a specified family ID. The Header Information feature is working well... it summarizes details for all the different family IDs in the single file. I did my best to minimize code changes and match the existing script style.

mmoskal commented 3 years ago

Looks good, merged! Please re-open if needed.