I’m developing an application for Photon and Electron. I would like to calculate a memory (flash) checksum or CRC in the setup(), to be sure on which application is currently running on my devices.
Moreover, I would like to use this CRC to detect memory corruption when the application will be running in the field.
I know the memory map as described in the Photon datasheet. I guess my application is “user part”, so the range that I have to check is from 0x80A0000 to 0x80C0000 (128 KB).
I could define in my code these addresses and calculate the CRC in this range but is there a .H with this addresses already defined ?
I tried to look for it in github but without success.
Moreover I get a different memory range for Electron: application from 0x8080000 to 0x80A0000 (128 KB) and I would like to have the same source code for both.
I could use PLATFORM_ID to distinguish Photon / Electron but I think is better to use a system include file, if available.
@giovanni.cavicchioli, you can use code like this to identify your application and to make it available as a Particle.varialble() for example:
// This strips the path from the filename #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) char gDeviceInfo; //adjust size as required in setup()... Particle.variable("deviceInfo",gDeviceInfo); snprintf(gDeviceInfo, sizeof(gDeviceInfo) ,"App: %s, Date: %s, Time: %s, Sysver: %s" ,__FILENAME__ ,__DATE__ ,__TIME__ ,(const char*)System.version() // cast required for String );
Adding a CRC to look for corruption in already verified flashed code is not really viable. If the falsh your code is located in is corrupted, how do you know it will run to be able to know it was corrupted!
Thank you peekay123, this could be a good idea. But during developing, I compile and download on many devices and using compiling time with TIME gave me different value on the same SW.
I just would like to know if it is available a include file with memory map addresses.