K22F keep version in binary file

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

K22F keep version in binary file

ソリューションへジャンプ
1,439件の閲覧回数
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,435件の閲覧回数
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,436件の閲覧回数
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,426件の閲覧回数
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 件の賞賛
返信