Skip to content

Cache bootloader firmware writes#2002

Open
NickeZ wants to merge 2 commits into
BitBoxSwiss:masterfrom
NickeZ:nickez/erase-first-then-flash
Open

Cache bootloader firmware writes#2002
NickeZ wants to merge 2 commits into
BitBoxSwiss:masterfrom
NickeZ:nickez/erase-first-then-flash

Conversation

@NickeZ

@NickeZ NickeZ commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Approximately halfs the current flashing time to 55s.


Erase the full firmware area on OP_ERASE, then cache sequential 4 KiB firmware chunks into 8 KiB flash blocks. Flush cached blocks once, using flash_append() when the target block is already erased and flash_write() otherwise.

Also reject signature data before all declared firmware chunks have been received and flushed.

Verification:

  • ./scripts/dev_exec.sh ./scripts/format
  • ./scripts/dev_exec.sh make bootloader
  • ./scripts/dev_exec.sh make unit-test
  • ./scripts/dev_exec.sh make run-unit-tests

Erase the full firmware area on OP_ERASE, then cache sequential 4 KiB firmware chunks into 8 KiB flash blocks. Flush cached blocks once, using flash_append() when the target block is already erased and flash_write() otherwise.

Also reject signature data before all declared firmware chunks have been received and flushed.

Verification:
- ./scripts/dev_exec.sh ./scripts/format
- ./scripts/dev_exec.sh make bootloader
- ./scripts/dev_exec.sh make unit-test
- ./scripts/dev_exec.sh make run-unit-tests
@NickeZ NickeZ requested a review from benma June 30, 2026 08:14

@benma benma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems overly complicated, I think the cache/flush is not needed?

Why not just erase in OP_ERASE, and just use flash_append with 4kB chunks during flashing?

Also reject signature data before all declared firmware chunks have been received and flushed.

Why? One can't successfully do it anyway beforehand, as that API call rejects on invalid signatures. Can't hurt but seems not needed.

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