Skip to content

CURRENT.UF2 ends with zero-filled blocks on ports whose app starts above the flash base #509

Open

Description

@hathach

src/ghostfat.c:132-133 sizes CURRENT.UF2 as _flash_size / 256 blocks, numbered from BOARD_FLASH_APP_START. But :454 stops filling blocks at BOARD_FLASH_ADDR_ZERO + _flash_size. So the last (BOARD_FLASH_APP_START - BOARD_FLASH_ADDR_ZERO) / 256 blocks are zero-filled sectors, not UF2 blocks, even though every valid block's numBlocks counts them.

  • mimxrt10xx (app at +0xC000): 192 blocks, 96 KiB of the file.
  • stm32f4/l4 (app at +0x10000): 256 blocks.

A reader that checks the whole file sees bad-magic blocks after the valid ones. The HIL battery (#507) compares only the app prefix, so it does not exercise the tail.

Remaining work:

  • Make the file size and numBlocks match the readable app span, (ADDR_ZERO + flash_size - APP_START) / 256, for all ports.
  • Add a check of the final block: ghostfat test, or a HIL readback of the last block.
  • Consider TUF2_ASSERT(BOARD_FLASH_APP_START < BOARD_FLASH_ADDR_ZERO + _flash_size) at ghostfat init, so a port whose app start lies outside the readable span (the blank-CURRENT.UF2 bug on mimxrt10xx, Add a local HIL contract and fix blank CURRENT.UF2 on mimxrt10xx #507, and stm32h7) fails loudly.

Found by reading the source during #507 (Codex review, confirmed by agent review). Pre-existing; out of #507's scope.

Activity

  1. added
    follow-up
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-up

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions