Embedding Version Number in 1st Code Page

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does anyone know how I can create a code page that will link into the top of a GCC project? It only has to be 6 or 8 bytes but I think it needs to go in between the code entery point which I think has a jmp and the code. I'd probably checksum or CRC the version information to know it is valid.

I want to be able to read the first page with a boot loader and determine the version number of the code. I guess I could use the EEPROM but I'd rather trust the code image.

If anyone has any ideas that would be great.

-M

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The thread linked below is closely related to your question. You may find ans answer there.

pass C code variable to makefile

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you realise that PROGMEM data is placed immediately after the interrupt vector table and that for any given AVR the size of the reset jump and the vector table is a fixed/known size? So just add one PROGMEM string to your code:

const char ver[] PROGMEM = { 
"Program version "__DATE__" "__TIME__"\r\n\" };

and that will be placed at a fixed place in flash. If there's any question about being able to find it again then use:

const char ver[] PROGMEM = { 
"@(#)Program version "__DATE__" "__TIME__"\r\n\" };

and then search flash (using pgm_read_byte()) for the "@(#)" sequence. In fact, doing this, it doesn't matter where the string is located in flash.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson,

Sorry didn't reply sooner, but thanks! Good info.

-M

PS Remove the trailing slash

const char ver[] PROGMEM = {
"@(#)Program version "__DATE__" "__TIME__"\r\n" };