I ported my test app for IFU 4.2 → 4.3
https://www.ghielectronics.com/community/forum/topic?id=16263&page=1
to 4.3 and there i have this error:
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
#### Exception System.ArgumentException - 0xfd000000 (1) ####
#### Message:
#### GHI.Processor.InFieldUpdate::NativeLoad [IP: 0000] ####
#### GHI.Processor.InFieldUpdate::Load [IP: 004d] ####
#### IFU.Program::LoadDataFromSD [IP: 004b] ####
#### IFU.Program::Main [IP: 001b] ####
A first chance exception of type 'System.ArgumentException' occurred in GHI.Hardware.dll
An unhandled exception of type 'System.ArgumentException' occurred in GHI.Hardware.dll
The program '[8] Micro Framework application: Managed' has exited with code 0 (0x0).
on this line with the first block:
GHI.Processor.InFieldUpdate.Load(ifutype, hex, BLOCK_SIZE);
Sample code:
using System;
using System.IO;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using GHI.IO;
using GHI.Utilities ;
namespace IFU
{
public class Program
{
static GHI.IO.Storage.IRemovable MySD;
const int BLOCK_SIZE = 10 * 1024;
private static FileStream _fs;
public static void Main()
{
MySD = new GHI.IO.Storage.SDCard();
MySD.Mount();
//firmware + application update
GHI.Processor.InFieldUpdate.Initialize(GHI.Processor.InFieldUpdate.Types.Configuration |GHI.Processor.InFieldUpdate.Types.Application|GHI.Processor.InFieldUpdate.Types.Firmware);
LoadDataFromSD(@ "SD\IRC.HEX", GHI.Processor.InFieldUpdate.Types.Application);
LoadDataFromSD(@ "SD\CONFIG.HEX", GHI.Processor.InFieldUpdate.Types.Configuration);
LoadDataFromSD(@ "SD\FIRMWARE.HEX", GHI.Processor.InFieldUpdate.Types.Firmware);
LoadDataFromSD(@ "SD\FIRMWARE2.HEX", GHI.Processor.InFieldUpdate.Types.Firmware);
GHI.Processor.InFieldUpdate.FlashAndReset();
}
// Loads the passed in file from the SD card into memory.
static void LoadDataFromSD(string filename, GHI.Processor.InFieldUpdate.Types ifutype)
{
int rest;
byte[] hex;
long len;
int blocknum;
_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++)
{
_fs.Read(hex, 0, BLOCK_SIZE);
GHI.Processor.InFieldUpdate.Load(ifutype, hex, BLOCK_SIZE);
Debug.Print("Loading file " + filename + ", block " + i + "/" + blocknum);
}
_fs.Read(hex, 0, rest);
GHI.Processor.InFieldUpdate.Load(ifutype, hex, rest);
_fs.Close();
_fs.Dispose();
_fs = null;
hex = null;
Debug.GC(true);
}
}
}