Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autosize tasks #476

Closed
wants to merge 15 commits into from
Closed

Autosize tasks #476

wants to merge 15 commits into from

Conversation

mkeeter
Copy link
Collaborator

@mkeeter mkeeter commented Mar 25, 2022

This removes explicit task sizes (in app.toml) in favor of calculating sizes at build-time

  • Each task is built as a staticlib
  • The staticlib is linked manually into a maximum-size address space
  • The size of the resulting binary is recorded
  • Once all tasks are built, we do address allocation as usual
  • Each task is relinked into a minimal allocation

The build proceeds as usual from here.

To implement this system, I dramatically refactored dist.rs. In particular, package() now builds a struct Packager and calls functions on it. It's still awkwardly stateful: some functions require other functions to have run first, to populated data in the struct. Still, I think it's an improvement over the previous 650-LOC single function.

This does not handle kernel autosizing, because

  • The kernel needs to know the task memory map before building
  • We need to know the size of the kernel before building the task memory map

@mkeeter mkeeter mentioned this pull request Jun 8, 2022
mkeeter added a commit that referenced this pull request Jun 10, 2022
This PR implements task autosizing, at long last!

It builds on the previous work with relocatable task builds (#584). After
building the relocatable task ELF file, it runs a "dummy link" against a
linker script with "infinite" memory (in practice, the entirety of memory
available on the chip). It then parses the resulting (static) binary to extract
sizes.

After finding sizes for every task, it runs the same memory packer as before,
then relinks each task with the resulting memory.

Task sizes are based on the target microcontroller, with a new `alignment`
parameter passed to `allocate_one`.

There are extensive changes to `cargo xtask sizes` to make it more generically
useful, decoupling the suggestions from the "find the size of a static ELF".

WARNING: this changes the format of the exported JSON files!

In addition, there are a bunch of new helper functions in `Config` to help with
task and memory sizing / alignment.

This fixes #474 and maybe #439, and deprecates #476
@mkeeter
Copy link
Collaborator Author

mkeeter commented Jun 10, 2022

Closed in favor of #595

@mkeeter mkeeter closed this Jun 10, 2022
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.

1 participant