Skip to content

UF2 considerations #1095

@microbit-carlos

Description

@microbit-carlos

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:

  • File containers
    • This requires knowledge in DAPLink about the target filesystem, so it's generic enough for all boards
    • Any particular board that might want to implement this could probably add hook into write_uf2() and include it in their port
  • CURRENT.TXT
    • No special reason, simply trying to reduce scope for now
    • If implemented it should probably be with a compile-time flag selectable per port
  • MD5 checksum
    • target_flash_program_page() can already verify data written if automation is enabled
    • But this is more useful to avoid writing data to flash (reduces flashing time). So, this is only useful when page-by-page erase and programming is enabled, as otherwise it does a full chip erase when it receives the first valid data block.

Could implement

Some things that are not implemented yet but can consider adding.

  • Tracking that all individual blocks have been received
    • This requires a buffer with a bit per block, so for a device with 256 KB and 256 bytes per block, it'd need 1 KB of RAM. Unsure if this is viable for all DAPLink ports
      • Alternatively this feature could be turned off by default, and enabled via compile-time flag
    • UF2 files with multiple targets could also require an arbitrary number of flag buffers, although we could only track the blocks relevant for the current target
    • vfs_manager tracks the UF2 file size, so and if fewer blocks than expected arrive it will throw an error
      • However, this does not protect from the OS sending the same block more than once (perhaps it creates a temporary file, or metadata file)

Open questions

  1. Should UF2.TXT file be created in the MSC drive?
    • If implemented we might want to add it as a compile-time flag as well
  2. UF2 FamilyID corresponds to a generic MCU family or specific MCU variants, but it doesn't quite match the Mbed/DAPLink Board ID
    • 2.1) We could try to allocate a range of FamilyID values where the top 2 most significant bytes represent "this is DAPLink family" and the 2 least significant bytes match the Board ID
    • 2.2) We could use extension tags. The existing "device type identifier" could work, but we could create a DAPLink specific one to include the Board ID.
    • 2.3) Should we also expand target_family_descriptor to include the UF2 family IDs for supported families?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions