Main Site Documentation

EWR Data No Longer Surviving Reset


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?


EWR is flushed in the background, so a hard reset before data is flushed will cause you to lose it…

To force flushing, there is a function in GHIElectronics.NETMF.System.Util.FlushExtendedWeakReferences…


Oh that might be it - phew I’ll give that a go tomorrow, thanks, I have hope again :slight_smile:

Do you know if there are limitations as a result of forcing a flush?




Is it critical to have the latest firmware installed on my EMX board?

In fact I have just updated to with the latest GHI Pack


This method is only available in the last SDK so yes.


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


If you try a soft reboot it works?
Can you make a small program that generates the issue so we can try it here?


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?

Thanks so much for your help on this!


please email ghielec at ghielectronics…


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.

Job Done :slight_smile:

Thanks to GHI chaps for this solution.


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.


I have the same problem with my embedded master module. After 3000 writes more or less, the data doesn’t survive the reset. This occurs every year.

But we can’t erase the complete memory every year. We have produced some units of our development, and can’t retrieve the units, erase them, etc.

I have tried the FlushExtendedWeakReferences method. Is there any diferent solution?


There is the in-file update that lets you update everything and I believe you can use it to update the config region.