K22F keep version in binary file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K22F keep version in binary file

Jump to solution
888 Views
karamanr
Contributor I

Hi,
I have been trying to insert a version number of my application into its binary. I noticed that the Freedom Bootloader example has this implemented and I have been trying to use something similar with the LED blinky example as a start. However, so far I have not been able to insert the version like the Bootloader example does. I tried porting the property_kinetis source file and the property header file to work with the blinky example as I noticed these are key for the bootloader example but no success so far. What is the best way to approach this and is it possible at all? 

0 Kudos
Reply
1 Solution
884 Views
ErichStyger
Specialist I

You need to reference your version number information somehow from your application, otherwise it gets removed by the linker.

something like this:

static const unsigned char *versionInfo="1.2.2.4";

int main(void) {

  if (versionInfo[0] == '\0') { /* check just to reference it. */

      return -1;

  }

...

....

}

View solution in original post

0 Kudos
Reply
2 Replies
885 Views
ErichStyger
Specialist I

You need to reference your version number information somehow from your application, otherwise it gets removed by the linker.

something like this:

static const unsigned char *versionInfo="1.2.2.4";

int main(void) {

  if (versionInfo[0] == '\0') { /* check just to reference it. */

      return -1;

  }

...

....

}

0 Kudos
Reply
875 Views
bobpaddock
Senior Contributor III

Marking with the 'used' attribute, if using GCC, will also prevent the linker from removing what it thinks is unused.

#define ATTR_USED __attribute__ ((used))

static const unsigned char *versionInfo="1.2.2.4" ATTR_USED:

 

0 Kudos
Reply