Re: Version/Signature in Flash
Jim Brain <[email protected]> Wed, 19 Jan 2022 09:30:15 -0600
| Newsgroups | gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------kLsn95TX3V67QXUi0VqyRaDF
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
On 1/19/2022 7:13 AM, Michael Stocker wrote:
> You are right.
>
> -Wl,--undefined=signature
>
> This will keep it in flash and not let the linker strip its value.
> Also when preparing your .hex file for flashing you may need to
> explicitly tell the sections you want.
>
> avr-objcopy -j .text -j .data -j .my_signature -O ihex prog.elf prog.hex
>
> Cheers
>
> Michael
>
This may be a naive question, but is it possible to "place" the
signature in a specific location in the resulting output file, padding
the file to the required size to include the signature?
Use case:
One of the projects I utilize defines a 4 byte signature at the end of
the AVR code space (top 4 bytes), and it checks that signature in the
bootloader to see if an update on storage is newer than the one
installed. Right now, the main developer has created a Perl script that
pulls the resulting object file, padds it out, and puts the 4 bytes at
the end. It would be nice to do all of that in the linker.
--------------kLsn95TX3V67QXUi0VqyRaDF
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">On 1/19/2022 7:13 AM, Michael Stocker
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:[email protected]">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
You are right.
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; line-height:
normal; font-family: Menlo; color: rgba(0, 0, 0, 0.85098);
background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>-Wl,--undefined=signature</div>
<div><br class="">
</div>
<div>This will keep it in flash and not let the linker strip its
value.</div>
<div>Also when preparing your .hex file for flashing you may
need to explicitly tell the sections you want.</div>
<div><br class="">
</div>
<div><span style="color: rgba(0, 0, 0, 0.85098); font-family:
Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>avr-objcopy </span><span
style="color: rgba(0, 0, 0, 0.85098); font-family: Menlo;
background-color: rgb(255, 255, 255);" class="">-j .text -j
.data -j .my_signature -O ihex prog.elf prog.hex</span> </div>
<div><br class="">
</div>
<div>Cheers</div>
<div><br class="">
</div>
<div>Michael</div>
<div><br class="">
</div>
</div>
</blockquote>
<p>This may be a naive question, but is it possible to "place" the
signature in a specific location in the resulting output file,
padding the file to the required size to include the signature?</p>
<p>Use case:</p>
<p>One of the projects I utilize defines a 4 byte signature at the
end of the AVR code space (top 4 bytes), and it checks that
signature in the bootloader to see if an update on storage is
newer than the one installed. Right now, the main developer has
created a Perl script that pulls the resulting object file, padds
it out, and puts the 4 bytes at the end. It would be nice to do
all of that in the linker.</p>
<br>
</body>
</html>
--------------kLsn95TX3V67QXUi0VqyRaDF--