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

Support a .noinit section for variables #996

Merged
merged 1 commit into from
Mar 19, 2020

Commits on Mar 19, 2020

  1. Support a .noinit section for variables

    This is inspired by the linker sripts on the AVR architecture, which
    support a .noinit section (or any section starting with .noinit,
    actually) for variables that should be allocated an address in RAM, but
    not be initialized to any particular value (not even zero) on startup.
    These can then be used to remember values across resets.
    
    From the sketch perspective, this works exactly the same as on AVR: Just
    annote a global variable with `__attribute__((__section__(".noinit")))`
    and it will have an unpredictable value on power-up and retain its value
    during resets.
    
    To implement this without having to change all board-specific linker
    scripts, the linker commandline is changed to pass the board-specific
    linker script to the `--default-script` linker script, and change the
    main linker script (passed to `--script`, previously `-T`) to a generic
    "override" linker script. This new generic linker script contains an
    `INSERT BEFORE` command, which causes the linker to load it *in addition
    to* the default linker script, while adding an extra `.noinit` output
    section in the right place.
    
    Because these new variables take up RAM but have their own section in
    the .elf file, they should be accounted for in the size summary after
    compilation. This is done by adapting the `recipe.size.regex.data` entry
    to include this new section.
    matthijskooijman committed Mar 19, 2020
    Configuration menu
    Copy the full SHA
    5b86121 View commit details
    Browse the repository at this point in the history