ntoll / uflash

A module and command to easily flash Python onto the BBC's micro:bit device.
http://micropython.org/
MIT License
101 stars 27 forks source link

Ensure the fs hex string injected into the Universal Hex is memory aligned #74

Closed carlosperate closed 3 years ago

carlosperate commented 3 years ago

USB uses 512 byte blocks (or a multiple of 512), and DAPLink depends on some Universal Hex records (like the Block Start record) to be well aligned within their "section" (the part that contains micro:bit V1 or V2 code).

This commit ensures the generated filesystem hex records follow the same alignment, so that when they are injected into the Universal Hex this is maintained.

This should have been done as part of the original Universal Hex implementation in https://github.com/ntoll/uflash/pull/70, as it is part of the official spec, but I missed it: https://tech.microbit.org/software/spec-universal-hex/

uFlash itself does not ensure the Universal Hex is aligned, but the string will be aligned it was generated by the microbit-universal-hex library (which I do use to update the hex): https://github.com/microbit-foundation/microbit-universal-hex

As uFlash does generated aligned hex strings it preserves whatever alignment the original Universal Hex sting has.

carlosperate commented 3 years ago

@ntoll could you review this PR whenever you have a chance? We need to push it to Mu as well: https://github.com/mu-editor/mu/pull/1636

Thanks!

ntoll commented 3 years ago

@carlosperate is there a related PR in Mu..? Happy to merge that too.

carlosperate commented 3 years ago

@carlosperate is there a related PR in Mu..? Happy to merge that too.

Yep, thanks!: https://github.com/mu-editor/mu/pull/1636 If you could merge this one too that would be great: https://github.com/mu-editor/mu/pull/1633

ntoll commented 3 years ago

Done. And (as always) many thanks.