Skip to content

Instantly share code, notes, and snippets.

@yahyatawil
Created February 24, 2021 07:35
Show Gist options
  • Save yahyatawil/d9a9f55443095c7d81f7f04f66a5f270 to your computer and use it in GitHub Desktop.
Save yahyatawil/d9a9f55443095c7d81f7f04f66a5f270 to your computer and use it in GitHub Desktop.

Preserve variable value between software resets resets

in 'MEMORY' section:

MEMORY { ROMEM (rx) : ORIGIN = 0x0000C000, LENGTH = 976K RWMEM (rwx) : ORIGIN = 0x10000000, LENGTH = 383K NOINIT (rwx) :ORIGIN = 0x1005FC00, LENGTH = 1k }

and the following in 'SECTIONS': .noinit(NOLOAD) : { *(.noinit*) } > NOINIT

Variable:

uint8_t rst_cnt __attribute__ ((section (".noinit")));

it was indeed located (according to map file) as expected: .noinit 0x000000001005fc00 0x1 (.noinit) .noinit 0x000000001005fc00 0x1 bin/example.o 0x000000001005fc00 rst_cnt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment