Skip to content
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

Process out-of-order vfs sectors for Universal Hex in block format #1092

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

microbit-carlos
Copy link
Contributor

@microbit-carlos microbit-carlos commented Feb 3, 2025

Tested in a VM with macOS 13.1, which had the issue where files larger than 1 MB would be sent out-of-order:

13.0 also had an issue where the OS was trying to read back some metadata files it was writtin to the MICROBIT drive, and that caused issues when DAPLink sent back zeros. That metadata issue was fixed in 13.1, but the out-of-order was still present until 13.2, so 13.1 is the best version to test this.

When blocks are received out of order the data passed to
board_detect_incompatible_image() via
flash_decoder_validate_target_image() might not be the first block
of flash data, as expected by the microbitv2 imcompatibility
detection, so pass the address to the function and perform the
check.
When Universalh Hex was created two formats where specified, the
segment format, which is currently used due to faster parsing, and
the block format.

The block format was design so that each 512-bytes of hex
characters contain enough info to be self contained, however it
was never tested in a systen that sent blocks out-of-order.

The original vfs_manager expects all file blocks to arrive
sequentially in order. This update adds a check of "self contained
blocks" and a sticky flag that process these blocks whatever order
they arrive and ignores all other non-self-contained vfs sectors
received.
This frees up about 168 bytes with 10.3.1, which is needed to
fit more features in some bootladers that were alredy at the
.text limit.
@microbit-carlos
Copy link
Contributor Author

microbit-carlos commented Feb 14, 2025

The CI was failing because the kl27z_bl was running out of .text memory, as a build from the main branch only has around 320 bytes left from the 32 KBs allocated to the bootloaders. This affected the kl27z_microbit_bl as well, as it has even less free space, and would probably affect other bootloaders too.

So I've merged PR #1097 here to save enough flash to get these to builds successfully again.

I don't mind if we merge it all together in this PR, or merge PR #1097 first and then I rebase this PR afterwards, either way works for me.

@microbit-carlos microbit-carlos marked this pull request as ready for review February 14, 2025 00:42
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.

1 participant