avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Version/Signature in Flash


From: Michael Stocker
Subject: Re: Version/Signature in Flash
Date: Wed, 19 Jan 2022 13:48:57 +0100

Hallo Klaus,

you can always define your own sections at a fixed location in flash and write anything you like in there.
But every time you start a new section the previous one is closed implicitly. So it cannot be in the middle of another section.
It also cannot go at the beginning of flash because the interrupt vectors are expected to be there.

You can put anything into a section as long as it fits. Here for example a 32-bit signature:

const uint32_t __attribute__((section(".my_signature"))) signature = 0xCAFEBABE;

The linker then needs an additional argument to know where this section is:

-Wl,--section-start=. my_signature =0x7FFC

Where 0x7FFC is the byte-offset in flash not the word-offset. 0x7FFC would mean the end of flash on an ATmega328P.

Hope this helps.

Michael



Am 2022-01-18 um 11:21 schrieb Klaus Rudolph <lts-rudolph@gmx.de>:

Hi,

is there already a defined wy to place a user defined signature in the
flash memory?

Use Case: Simply put some version info, maybe a a string with given
format or a git hash id or whatever in a specified flash area.

I see we have a section ".signature" but this is in use for a predefined
3 byte signature. I also see in the linker scripts that there is
something called "user_signatures" but that seems to be unsupported for
the rest of the linker script. But maybe I looked in the wrong file...

Any suggestions?

Thanks
Klaus



reply via email to

[Prev in Thread] Current Thread [Next in Thread]