IFU 4.3 unhandled exception

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);
        }

    }
}

Hello David

Do you mean performing IFU from 4.3 to 4.3 or from 4.2 to 4.3.

If 4.3 to 4.3 please check tiny booter version.
If 4.2 to 4.3 I am not sure this is supported due to the fact that bootloader have not the same footprint and memory allocation scheme. This may work or may not…

This 4.3 to 4.3, device is up to date but just wanted to update my 4.2 code and check IFU in 4.3

Version info:

Loader (TinyBooter) version information:
4.3.3.0 on this computer.
4.3.3.0 on this device.

The Loader (TinyBooter) is up to date. <<<

Firmware (TinyCLR) version information:
4.3.3.0 on this computer.
4.3.3.0 on this device.

The Firmware (TinyCLR) is up to date. <<<

@ David@ Emrol - Can you remove the application from IFU and see if it works?

So if you’re device is up to date I guess the problem is a bug in the GHI SDK or a problem in your application file.

What 's happening if you start loading CONFIG.HEX and Firmware files and finish by your application?

@ John & @ leforban

It’s the application hex file, this was version 4.2, if i replace this one with a version 4.3 the IFU is working as it should.

Thanks guy’s

Great!