In my application, I do the following on startup:
- calculate CRC32 of the present region of user application flash
- compare to retained (eeprom) CRC from previous runtime
- if there is a difference, activate the “DFU boot” app flag (my app does certain memory mapping migration chores etc in response to this)
This worked fine on the Boron, but I am not sure what the memory map is for the M-Som (Muon) that I am trying to port this functionality to (if I use the Boron memory map values to try and calculate this CRC I will get a bus fault):
//Check the linkapp CRC. If it's different, we need to reset sram also!
unsigned int linkapp_crc =
compute_CRC32((uint8_t*)(LINKAPP_MEMORY_ADDR_START), LINKAPP_SECTION_SIZE, 0, true, &crc32_mpeg2);
if(linkapp_crc != sram.linkapp_crc && sram.linkapp_crc != 0){
#ifdef VERBOSE_RETAINED_VARS
myLog.warn("New LinkApp CRC!");
#endif
reset_sram(__LINE__);
recall_eeprom();
linkapp_flags.dfu_boot = true;
//Run firmware migrations
#if SRAM_MAP_VERSION <= 0xC0DE0002
sram.e.hc3_primary_gnd_resistance_mohm = 0;
#endif
}
sram.linkapp_crc = linkapp_crc;
Here are the defines:
/**========================================================================
** PLATFORM-SPECIFIC
*========================================================================**/
#if (PLATFORM_ID == PLATFORM_BORON)
#define LINKAPP_SECTION_SIZE KB(256)
#define LINKAPP_MEMORY_ADDR_START 0xB4000
#elif (PLATFORM_ID == PLATFORM_MSOM)
#define LINKAPP_SECTION_SIZE KB(256)
#define LINKAPP_MEMORY_ADDR_START 0xD0D00 //What is this supposed to be?
#endif
Note that the Boron has a well defined memory map published here:
… but the M-SoM datasheet does not have any section called “memory map”…
So, ultimately the question boils down to: how can I evaluate if my app has a new firmware since previous check?