Skip to content

Added total size padding override. Documented unused parameter#102

Open
ZhekaS wants to merge 2 commits into
tock:masterfrom
ZhekaS:add_padding
Open

Added total size padding override. Documented unused parameter#102
ZhekaS wants to merge 2 commits into
tock:masterfrom
ZhekaS:add_padding

Conversation

@ZhekaS

@ZhekaS ZhekaS commented Nov 25, 2025

Copy link
Copy Markdown

Fixes #101
Fixes #100

- Added an option --total-size-padding <padding> to override the default set by the specific architecture

  • Added an optional ELF symbol tbf_total_size_padding lookup that sets the override of the architecture specific padding
  • Added a note about --minimum-ram-size that it has no effect

@bradjc

bradjc commented Dec 3, 2025

Copy link
Copy Markdown
Contributor
* Added a note about `--minimum-ram-size` that it has no effect

Yes.

* Added an option `--total-size-padding <padding>` to override the default set by the specific architecture

I have two reservations about this option.

  1. It applies to all architectures. This would easily make invalid arm apps, or very large riscv apps.

  2. I think I generally understand the issue this is trying to address, but this option could hide an annoying failure case for users: they have two TABs for the same app, with the same architecture list, and one works and one doesn't. We've skirted around this issue by maintaining the assumption that architecture == MPU requirements.

    If we want to change that assumption, I would prefer that it be explicit so that users and tockloader can reason about the correct tbf to install, and when a tbf will not work on their board.

    We could have tockloader handle this. Or, we could include all riscv apps twice at different paddings. Or we could just change elf2tab to use the larger padding. Or we could have a more targeted flag to build with a different size. But I would like to have the upstream elf2tab continue to work across tock boards.

@ZhekaS

ZhekaS commented Dec 3, 2025

Copy link
Copy Markdown
Author
  1. I think I generally understand the issue this is trying to address, but this option could hide an annoying failure case for users: they have two TABs for the same app, with the same architecture list, and one works and one doesn't. We've skirted around this issue by maintaining the assumption that architecture == MPU requirements.
    If we want to change that assumption, I would prefer that it be explicit so that users and tockloader can reason about the correct tbf to install, and when a tbf will not work on their board.
    We could have tockloader handle this. Or, we could include all riscv apps twice at different paddings. Or we could just change elf2tab to use the larger padding. Or we could have a more targeted flag to build with a different size. But I would like to have the upstream elf2tab continue to work across tock boards.

OK, I think I see the issue that I totally missed when working on this PR, that the TAB might actually contain many TBFs with different size requirements. I guess a more targeted flag is indeed required.

EDIT:
@bradjc Do you think something like --total-size-padding=<arch>,<padding> would work?

EDIT2:
Alternatively, limit this functionality to the case when only a single ELF is supplied (however this is more of a workaround for a very specific case, as we might want to pack multiple ELFs for the same arch).

@ZhekaS

ZhekaS commented Feb 25, 2026

Copy link
Copy Markdown
Author

@bradjc I think the most "granular" control could be achieved by optionally passing the required padding size via a metadata in the ELF file itself, similarly to tbf_protected_region_size. Should I update the PR with the proposal?
Updated the PR with the proposal

Instead of a --total-size-padding command-line option that applies
uniformly to every ELF, read a per-binary `tbf_total_size_padding`
symbol from the ELF's symbol table. This is looked up in the same
pass as `tbf_protected_region_size` and, when present, overrides the
architecture-default trailing padding.
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.

--minimum-ram-size option is not respected Allow setting non-default padding

2 participants