Main Site Documentation

Bad Memory Detected


With a G120, if i program the module over serial, the program load is successful. If I load from a USB drive, with SystemUpdate, I get the following error:

[quote]GHI Electronics, LLC
G120™ GHI low-level loader Rev 1.01

Bad Memory Detected!! Please Contact GHI[/quote]



@ stevepx -

What do you mean “with SystemUpdate” ?


I mean when I use the SystemUpdate class from the GHI.Premium.System namespace.


@ stevepx -

You mean IFU?

I don’t think IFU caused that problem!
Show us your code, please?

And after the bug happened, using serial then it comes back normally?


Yes, IFU leaves this module blank and the low level loader generates the error message I included in the first post.

This code works with no error on other modules, only this one, so far, produces an error.

Here is the code (modified from the example):

using System;
using System.IO;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.IO;

using GHI.Premium.Hardware.LowLevel;
using GHI.Premium.System;
using wd = GHI.Premium.Hardware.LowLevel.Watchdog;

namespace GHITest
	class Update
		public Update(String fileName, Lcd8Wire lcd)
			lcd.SendAllLines("Updating...", "", "", "");

			SystemUpdate.Initialize(/*SystemUpdate.SystemUpdateType.Config | 
									SystemUpdate.SystemUpdateType.Firmware |*/

			LoadDataFromUsb(fileName, SystemUpdate.SystemUpdateType.Deployment);

			if (SystemUpdate.CanUpdate)
				lcd.SendAllLines("Update successful,", "restarting...", "", "");
				lcd.SendAllLines("Update FAILED,", "Shutting down...", "", "");

		static void LoadDataFromUsb(string filename, SystemUpdate.SystemUpdateType ifutype)
			int rest;
			byte[] hex;
			long len;
			int blocknum;
			FileStream fs = null;
			const int BLOCK_SIZE = 10 * 1024;

				fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
				len = fs.Length;

				blocknum = (int)len / BLOCK_SIZE;
				rest = (int)len % BLOCK_SIZE;
				hex = new byte[BLOCK_SIZE];

				for (int i = 0; i < blocknum; i++)
					Debug.Print("Loading file " + filename + ", block " + i + "/" + blocknum);

					fs.Read(hex, 0, BLOCK_SIZE);
					hex = Program.DecryptData(hex);
					SystemUpdate.Load(ifutype, hex, BLOCK_SIZE);

				Debug.Print("Loading file " + filename + ", block " + blocknum + "/" + blocknum);
				fs.Read(hex, 0, rest);
				hex = Program.DecryptData(hex);
				SystemUpdate.Load(ifutype, hex, rest);				
			catch (Exception ex)
				if (fs != null)

				fs = null;
				hex = null;


[quote=“stevepx”]This code works with no error on other modules, only this one, so far, produces an error.
So is it correct to conclude that only one of a number of G120 modules gave you this bad memory error?

Interesting to know that there could be a memory problem in the G120 units and you stumbled on way to detect that! I wonder if it was the external RAM?

It’s a good idea for someone (not me!) to write a diagnostics code that will check all memory (internal and external RAM, Flash, and EEPROM) in any module or main-board for errors, like the diagnostics programs we used to use to check PC memory.