Skip to content

Add load support for universal binaries#349

Open
will-v-pi wants to merge 5 commits into
developfrom
universal-load
Open

Add load support for universal binaries#349
will-v-pi wants to merge 5 commits into
developfrom
universal-load

Conversation

@will-v-pi

Copy link
Copy Markdown
Contributor

This adds support to picotool load for loading universal binaries, and other multi-family UF2s

The existing --family flag can be used to select which family to load from the UF2 - otherwise it picks using the partition table, or based on the supported families for the device for RP2040 or SRAM binaries (no partition table)

Also fixes picotool info and other command support for 2.3.0 universal binaries, which have rearranged blocks that picotool was handling incorrectly

Fixes #344

Also adds supported family IDs to models, used to check if family is supported for SRAM loads (and RP2040 flash loads)

This fixes picotool load for the universal binaries
New ones split the last RP2040 block after all the RP2350 blocks to prevent Windows errors, so fix build_rmap_uf2 to handle that
Add robustness for invalid UF2 files

Allow loading BIN/ELF files into SRAM/RP2040 regardless of the guessed family ID, to match prior behaviour
Now it also ignores UF2 compatibility checks for RP2040 and SRAM binaries too
Comment thread main.cpp Outdated
Comment on lines +3326 to +3327
std::find(family_ids.begin(), family_ids.end(), family_id) != family_ids.end()
&& std::find(family_ids.begin(), family_ids.end(), family_id) + 1 == std::find(family_ids.begin(), family_ids.end(), block.file_size)

@lurch lurch Jul 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to cache the values of std::find(family_ids.begin(), family_ids.end(), block.file_size) and std::find(family_ids.begin(), family_ids.end(), family_id), rather than computing them multiple times?
The runtime reduction would probably be fairly minimal, but it might make the code a bit more readable?

Comment thread main.cpp
if (std::find(available_family_ids.begin(), available_family_ids.end(), override_family_id) == available_family_ids.end()) {
fos << "WARNING: Requested family ID " << family_name(override_family_id) << " not found in UF2 file, ";
fos << "so loading the first family ID found in the UF2 file (" << family_name(available_family_ids[0]) << "), ";
fos << "into where family ID " << family_name(override_family_id) << " would go\n";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the word "partition" appear between "into" and "where"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also apply on RP2040, or to SRAM binaries - although in those cases it’ll just error if --family isn’t compatible with the device, rather than placing it anywhere, so there might be a better way to word this? Basically it loads it as if it had the family specified by --family

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "into the location where family ID XXXX would normally go." ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants