K22F keep version in binary file

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

K22F keep version in binary file

跳至解决方案
1,479 次查看
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 项奖励
回复
1 解答
1,475 次查看
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 项奖励
回复
2 回复数
1,476 次查看
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 项奖励
回复
1,466 次查看
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 项奖励
回复