Align uf2 blocks to flash erase pages #763

Closed
timokroeger wants to merge 1 commit from uf2-gaps into develop
timokroeger commented 2022-03-22 10:27:07 -05:00 (Migrated from github.com)

Fixes #762

The rp2040 bootrom uses the uf2 block number to determine when to erase a flash sector:
github.com/raspberrypi/pico-bootrom@c09c7f0855/bootrom/virtual_disk.c (L205)

When there is a gap in target addresses between two uf2 blocks this logic does not work out.
As a workaround align all uf2 blocks to page erase boundary, so that the bootrom always removes the correct sector.

Fixes #762 The rp2040 bootrom uses the uf2 block number to determine when to erase a flash sector: https://github.com/raspberrypi/pico-bootrom/blob/c09c7f08550e8a36fc38dc74f8873b9576de99eb/bootrom/virtual_disk.c#L205 When there is a gap in target addresses between two uf2 blocks this logic does not work out. As a workaround align all uf2 blocks to page erase boundary, so that the bootrom always removes the correct sector.
kilograham commented 2022-03-22 14:37:03 -05:00 (Migrated from github.com)

Argh; good catch on the bootrom bug.

Two things:

  1. The changes should be limited to flash UF2 generation
  2. I'm not sure the fix is quite right, because the block_num needs to change whenever the flash sector number does, and this is relative to the start of flash not the previous UF2 block address. I think a simpler, and the easier one conceptually, would be just to include zeroed data for any unused pages in a sector (they are going to be erased anyway).
Argh; good catch on the bootrom bug. Two things: 1) The changes should be limited to flash UF2 generation 2) I'm not sure the fix is quite right, because the block_num needs to change whenever the flash sector number does, and this is relative to the start of flash not the previous UF2 block address. I think a simpler, and the easier one conceptually, would be just to include zeroed data for any unused pages in a sector (they are going to be erased anyway).
timokroeger commented 2022-03-23 05:01:45 -05:00 (Migrated from github.com)

Implemented your feedback, the code is much more readable now.

Implemented your feedback, the code is much more readable now.
kilograham commented 2022-05-03 13:44:30 -05:00 (Migrated from github.com)

Actually see #800

Actually see #800

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!763
No description provided.