cancel
Showing results for 
Search instead for 
Did you mean: 

Adding version number at hex file

haukeye
Associate II
Posted on November 16, 2016 at 08:58

Hi,

i'm using the STM32f4_discovery.

Is there a way to include version number/Varible that i can read its value/string,

when just viewing the file.

maybe an executable that reads the hex file and locate the variable ?

I'm not interested in quering through uart.

Thanks!!
8 REPLIES 8
Posted on January 12, 2017 at 21:11

It is just a representation of the binary data in the firmware image, you could write an app in C to read and review the content. Not unduly complicated. See

http://srecord.sourceforge.net/

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Posted on January 12, 2017 at 21:45

There is a compiler macro to fill a constant string with compile date and another macro for time. It will be in flash hence the hex or s19 or bin file.  I usually display on Lcd at boot for 2 seconds as a mean to check what FW is running inside. Would this be sufficient?

Posted on January 12, 2017 at 22:04

There is a compiler macro to fill a constant string with compile date and another macro for time

namely __DATE__ and __TIME__ , as per C99 §6.10.8.

JW

Posted on January 12, 2017 at 21:23

This assumes that the value is placed on a fixed known address. This is the most probable scenario, but the OP should know first how to achieve that (and AFAIK that is toolchain-specific).

Automating display of a constant variable identified only by its name is somewhat more challenging...

JW

Posted on January 12, 2017 at 21:35

Normally one puts a searchable magic value in the front of the string. For variables/symbols by name the .ELF/.AXF is the way to go, but more complicated.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AVI-crak
Senior
Posted on January 12, 2017 at 22:48

 .text :

 {

   . = ALIGN(0x200);

   KEEP(*(.text.METAINFO))

   . = ALIGN(4);

   *(.text)           /* .text sections (code) */

   *(.text*)          /* .text* sections (code) */

   *(.glue_7)         /* glue arm to thumb code */

   *(.glue_7t)        /* glue thumb to arm code */

   *(.eh_frame)

   KEEP (*(.init))

   KEEP (*(.fini))

   . = ALIGN(4);

   _etext = .;        /* define a global symbols at end of code */

 } >FLASH

#define METAINFA        __attribute__((__used__, section('.text.METAINFO')))

METAINFA const char META[] = {'LOCATION displays text test:' __DATE__ ', ' __TIME__ '.\r\n'};

For flash memory - the address of the text '.text.METAINFO' will be 0x08000200. Anytime and anywhere.

Posted on January 12, 2017 at 22:00

Like

static const char version[] = '(#)VERSION ' __DATE__ ' ' __TIME__;�?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 13, 2017 at 10:44

Why did the forum flag this for moderation? I've had two posts yesterday with the Source Code Formatting automatically flagged and presumably not visible, and now with the wrong time stamp.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..