-1

I am developing a firmware that also has an update feature. For that I want to store the current version number of my firmware in ROM so it is retained even after power-off. Then when the user attempts to update the firmware, the program loads the current version number from ROM and compares it to the one provided by the user. It the user provided firmware is newer, the firmware is updated. My question is, how can I tell the compiler to store the global version number variable in ROM. I am using Keilv5.20 with an ARM compiler.

Update: The variable has to be a non-constant because if the user provides a newer version of the firmware, its value has to be updated.

wahab
  • 797
  • 2
  • 6
  • 24
  • Please define ROM. – tum_ Jun 21 '16 at 09:16
  • The Flash memory on the chip. – wahab Jun 21 '16 at 09:19
  • Does the device you're developing your firmware for has an OS? File system? Give us some more details on the target device if possible. – tum_ Jun 21 '16 at 09:50
  • I'm using LPC1857 with CMSIS-RTOS. – wahab Jun 21 '16 at 10:13
  • its right there in the users manual for that part on how to either use the eeprom (which is most l likely a fake eeprom interface using flash) or flash directly. if you are updating the firmware for this device then you already know how to write to the flash, just write the version number as well as the rest of the firmware. – old_timer Jun 21 '16 at 11:05
  • 1
    _"The variable has to be a non-constant because if the user provides a newer version of the firmware, its value has to be updated."_ - which is also true of all the other constant data, code, and everything else in the firmware, and thus is proved false by contradiction ;) – Notlikethat Jun 21 '16 at 11:27
  • 1
    @wahab "because if the user provides a newer version of the firmware, its value has to be updated". OK, please describe (in detail) how a user provides new version of firmware. – tum_ Jun 21 '16 at 11:30
  • Please clarify if you are writing a bootloader which is handling the programming, or if this is something done by an external flash programming tool. – Lundin Jun 21 '16 at 12:47

1 Answers1

0

If you are programming in C and if I understand correctly what you are trying to achieve, you just need to put:

const char FW_Version[] = "1.2.3.4";

in your code. And then compare the "user provided firmware version number" with this constant string.

tum_
  • 632
  • 1
  • 7
  • 16
  • You will also have to ensure that this variable is always allocated at a specific fixed address, or it will not work if the version data has to be read by an external device. – Lundin Jun 21 '16 at 12:45