My Extended Weak Reference data used to be able to survive a hard reset, but now all data is lost. It survives a soft re-start (i.e. re-playing in Visual Studio) but if the power is removed or the RESET button hit then all data is lost.
Anyone have any hints / diagnostics on why this might be?
Is there a way to find out how much space there is left for the EWR data after the code has been deployed?
Well, I’m now up and running with the latest SDK and have added the .FlushExtendedWeakReferences calls along with a 2 second thread sleep each time I assign my Serialized data class to the EWR.Target but it still doesn’t seem to be preserved past a full power reset.
Could it just be a data limit? I’m trying to store seven Single[1440] arrays, two Single[13] arrays, a Single[720] and one tiny Int32[4] boot logger array.
Is this just too much for my EMX to remember? (I know I wouldn’t be able to remember that much data if this was embedded inside me).
// EWR Boot Logger:
// stores an integer array to EWR to count the number of boots and also save the last booted date
// 4 storage cells are specified. Datestamp could be used to note for clock change
ewrIntBootData = ExtendedWeakReference.RecoverOrCreate(typeof(EWRBootDataClass), 0, ExtendedWeakReference.c_SurvivePowerdown | ExtendedWeakReference.c_SurviveBoot);
ewrIntBootData.Priority = (Int32)ExtendedWeakReference.PriorityLevel.System;
objBootDataStore = (BootDataStorage)ewrIntBootData.Target; // load EWR data (if any) into inBootArray container
if (objBootDataStore == null) {
// First time run - build boot array
objBootDataStore = new BootDataStorage(); // initalise array as not done so
objBootDataStore.SngDataArray[0] = 1;
objBootDataStore.SngDataArray[1] = Int32.Parse(time.get_DateString());
objBootDataStore.SngDataArray[2] = time.get_K();
objBootDataStore.SngDataArray[3] = 2; // IntTempProfileSelected - default '2' Efficient
occupant.IntSetpointProfileSelected = objBootDataStore.SngDataArray[3];
} else { // intBootCounter > 0
// Not first time run. Load statistics and advance counts
objBootDataStore.SngDataArray[0] += 1;
objBootDataStore.SngDataArray[1] = Int32.Parse(time.get_DateString()); // TODO: develop this to set date on power failure with no backup battery;
objBootDataStore.SngDataArray[2] = time.get_K();
occupant.IntSetpointProfileSelected = objBootDataStore.SngDataArray[3];
}
ewrIntBootData.Target = objBootDataStore; // re-save data back to EWR for the future
GHIElectronics.NETMF.System.Util.FlushExtendedWeakReferences();
Thread.Sleep(2000);
By soft rebooting do you mean getting Visual Studio to re-run the program (ie pressing F5)? This works fine and the data is kept the next time the code re-starts.
But if I click the RESET button on the EMX board the data is lost.
I’ll build a simple app now. Where shall I post it? Or can I email directly?
For anyone else experiencing a similar issue where your EMX or Cobra seems to loose it’s ability to remember EWRs try the following:
Uninstal and reinstall the latest GHI SDK.
Access the EMX/Cobra through TeraTerm via the Serial COM port - it can be confusing to work out which com port the USB connection refers to, but it is possible (mine was 7)
When connected type E then Y - only capital letters work by the way - this erases all the memory.
Then type X to get the board ready to recieve the new TinyBooter file. You will see CCCCCCCC… appear in the TeraTerm window when it’s ready to transfer the file.
In the menu select: File > Transfer > XMODEM > Send …
Navigate to the TinyBooter firmware in Program Files > GHI Electronics > EMX > Firmware > TinyBooter and send that .GHI file.
Then you need to run MFDeploy and update the firmware with the HEX files found in the above ‘Firmware’ directory.
When transferring the TinyBooter.GHI file through TeraTerm REMEMBER to select the 1K radio button option.
Also if you’re having trouble finding the EXM/Cobra in TeraTerm (the Serial port list) you might need to re-boot the board while holding down the three buttons: “Up, Select and Down”. This holds the boot sequence at a point where TeraTerm can access the device.