-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UF2 considerations #1095
Comments
@mmoskal I'm currently looking into adding UF2 into DAPLink, and I was wondering if you'd consider option 2.1 listed above, and reserve something like the |
I agree with your "Won't Implement" items and I don't think that we should work on the "Could implement" item until it is an actual requirement. On the Open Questions:
|
Sounds good 👍
Perhaps tools or editors/IDEs that scan for the UF2.TXT file to detect UF2 devices. Not sure if DAPLink users would benefit from this, but mostly I'm not familiar with the tools that might check it.
Extending something like One specific advantage of option 2.1 (a range of DAPLink Family IDs that with the Board ID as the 2 least significant bytes) is that if we had a single UF2 file with separate flash data for two different Board IDs with the same Target MCU, this would result in using 2 different Family IDs. The advantage here that each BoardID/FamilyID would have its own range of blocks, so, FamilyID 0xDA91_0001 can have 20 blocks 0 to 20, and FamilyID 0xDA91_0002 can have 15 blocks 0 to 15. |
@microbit-carlos I would suggest doing both 2.1 and 2.3 in the bootloader, that is I'm happy with This way, for micro:bit you could use the ID for NRF52833, but if you need to you can also use The |
I remember I created this PR draft. I made Uf2 to ack just like a variant of HEX in binary form. Anyway, I'm here to test new code. So let's explore the awesome features UF2 is going to provide. |
Thanks everyone!
Yeah, I agree this sounds like the best option.
Just to clarify, in this case with "bootloader" you mean the DAPLink Interface that is responsible for flashing the target MCU, or do you mean the DAPLink bootloader responsible for updating the DAPLink Interface?
I hadn't done this in my initial implementation (mostly to keep it simple). I didn't noticed this in other UF2 bootloaders, but I guess the majority would be design to accept a single FamilyID (even though there is a FamilyID for nRF52833 and another for nRF5 generic, implementations are likely only including one). I assume most UF2 bootloaders would also struggle with a UF2 file that contains blocks with a valid Family ID and blocks without a Family ID? Or do they protect against that?
We have a "generic micro:bit V2" Board ID, and then a separate one as well for V2.00, V.21 and V2.2. Might be simpler to use the 0xDA91_xxxx + "generic micro:bit V2" (0xDA91_9903) as the "micro:bit V2 Family ID" in the UF2 json file? The other thing to consider is that in cases like the micro:bit V2.2x where the Interface and Target MCUs could both have the same Family ID, as they can both be an nRF52833 (although technically it is treated like a nRF52820 and it could use that FamilyID instead). In this type of situation a DAPLink Interface UF2 file could be accidentally flashed into the target, or the other way around, and being able to avoid that is a useful feature. One way to approach this could be to reserve 2 ranges of Family IDs, one specifically for the DAPLink Interface and another for the Target. My preference would be to have another range for DAPLink interfaces, and the DAPLink bootloader could only permit that range for updating the Interface (so it would ignore other "compatible" Family IDs). @mathias-arm are you happy with the discussion so far? Thank you @elfmimi! Your work is present in the branch I built on top of: I'll push my latest changes before the end of the week, just need to debug an issue timing out when there are multiple family IDs in one file. |
I think the UF2 Family ID discussion is interesting, but still confusing. What I want to understand how:
I think the distinction can be done between |
I've pushed to my fork the current WIP branch, as it might help illustrate my current approach. Consider this branch ongoin and untested: The DAPLink Interface will flash a block if:
These checks can be overwritten in each target via
My suggestion for this would (which is not implemented in the branch) be to have a second "DAPLink range" of Family IDs, but only to identify the DAPLink Interfaces (by the DAPLink bootloader). So this way:
Alternatively we could achieve a similar end result using an "extension tag" for DAPLink Interface data, for the bootloader to identify them and flash them, and the Interface to reject them.
Yes, but without the extra family ID or extension tag, the bootloader might not be able to tell the difference between Interface and Target data. Technically the interface will start at address 0x8000, but since the blocks could arrive in any order we might not know where the first block address starts until half way through the file. |
Forgot about that one! Also forgot the DAPLink interface runs all the time ;) I was talking about it.
Right, I'm pretty sure most bootloaders will fail if you give them UF2 file with multiple "options" (either multiple matching familyID or no family ID). That is unless the blocks are in order, in which case they will reboot after the first one is done. If it's not too much bother, it would be nice to support this family-latching (and treat no family as family 0 or something), for better user experience.
I'm starting to feel this familyID is more like productID, with the "fallback" familyID being the whole MCU family. This is not so important for pure dev boards used by pro-devs but much more important in cases like micro:bit. So I think for the interface UF2 images I would invent new unrelated IDs. You don't want people flashing random NRF52833 images on your interface chip.
Ranges are good. But does DAPLink have different 99xx numbers for micro:bits with different interface chips? |
Yeah, I think that should be fine. Looking into the order of checks, to keep things simple I'm thinking UF2 blocks without any Family ID could always be flashed.
Great, at some point I'll send a PR with the micro:bit V1.x and V2.x IDs.
Great, so I was thinking
Yes, 9903 is a generic ID for all V2 boards, 9904 is for boards specifically with a KL27z Interface, 9905 for nRF52833 Interface, and 9906 for nRF52820 Interface. |
We can definitely reserve family 0!
Alternatively, you could just not flash blocks with no family ID at all. There are no legacy UF2 files to support in this case. DA90 is good. |
I'm looking at adding UF2 on top of the Universal Hex out-of-order blocks implementation:
I've rebased this branch, which has a basic UF2 implementation already working:
There are a few things we need to consider before finishing the implementation.
Everything here is up for discussion, this is just my initial proposal.
Won't Implement
Some things that I'll l likely not implement at this point:
write_uf2()
and include it in their porttarget_flash_program_page()
can already verify data written if automation is enabledCould implement
Some things that are not implemented yet but can consider adding.
blockNo
andnumBlocks
microsoft/uf2#91Open questions
target_family_descriptor
to include the UF2 family IDs for supported families?The text was updated successfully, but these errors were encountered: