IFU 4.2 -> 4.3 unhandled exception

I’m testing IFU 4.2 to 4.3 and have this exception


Loading file SD\FIRMWARE2.HEX, block 303/333
Loading file SD\FIRMWARE2.HEX, block 304/333
Loading file SD\FIRMWARE2.HEX, block 305/333
Loading file SD\FIRMWARE2.HEX, block 306/333
    #### Exception System.ArgumentException - 0xfd000000 (1) ####
    #### Message: 
    #### GHI.Premium.System.SystemUpdate::SystemUpdateLoad [IP: 0000] ####
    #### GHI.Premium.System.SystemUpdate::Load [IP: 0085] ####
    #### IRC.FtpClient::LoadDataFromSD [IP: 004e] ####
    #### IRC.FtpClient::FlashAndReset_IRC [IP: 0031] ####
A first chance exception of type 'System.ArgumentException' occurred in GHI.Premium.SystemUpdate.dll
An unhandled exception of type 'System.ArgumentException' occurred in GHI.Premium.SystemUpdate.dll

happens always on the same point:


SystemUpdate.Load(ifutype, hex, BLOCK_SIZE);

parameters 2,byte[10240],10240
array size and content looks ok, any thoughts?

I have isolated my code in a separate program, must be something that i did wrong.
The files are on the SD and source location was:
C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.3 SDK\Firmwares\G120
I only copied the 3 hex files, not the signature files, is that ok?


using System;
using System.IO;  
using Microsoft.SPOT;
using Microsoft.SPOT.IO; 
using GHI.Premium.IO;
using GHI.Premium.System;

namespace IFU
{
    public class Program
    {
        static PersistentStorage MySD;
        const int BLOCK_SIZE = 10 * 1024;
        private static FileStream _fs;

        public static void Main()
        {

            MySD = new PersistentStorage("SD");
            MySD.MountFileSystem();

                //firmware + application update
                SystemUpdate.Initialize(SystemUpdate.SystemUpdateType.Config |
                     SystemUpdate.SystemUpdateType.Deployment |
                     SystemUpdate.SystemUpdateType.Firmware);

                LoadDataFromSD(@ "SD\IRC.HEX", SystemUpdate.SystemUpdateType.Deployment);
                LoadDataFromSD(@ "SD\CONFIG.HEX", SystemUpdate.SystemUpdateType.Config);
                LoadDataFromSD(@ "SD\FIRMWARE.HEX", SystemUpdate.SystemUpdateType.Firmware);
                LoadDataFromSD(@ "SD\FIRMWARE2.HEX", SystemUpdate.SystemUpdateType.Firmware);
            

            // Check to see if you can update
            if (SystemUpdate.CanUpdate)
            {
                SystemUpdate.FlashAndReset();
            }
        }

        // Loads the passed in file from the SD card into memory.
        static void LoadDataFromSD(string filename, SystemUpdate.SystemUpdateType 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);
                
                SystemUpdate.Load(ifutype, hex, BLOCK_SIZE);

                Debug.Print("Loading file " + filename + ", block " + i + "/" + blocknum);
            }

            _fs.Read(hex, 0, rest);
            SystemUpdate.Load(ifutype, hex, rest);

            _fs.Close();
            _fs.Dispose();

            _fs = null;
            hex = null;

            Debug.GC(true);
        }

    }
}


Just did a comparing test and if i take the hex files from 4.2 this runs just fine but if i take the 4.3 hex files then it fails…

I should be able to use IFU to upgrade both the firmware and application at the same time no? (ofc because a 4.2 compiled app will not run on 4.3)

@ GHI, is this a known open point for the final release?

@ David@ Emrol - We have not done any specific testing for upgrading from 4.2 to 4.3 using IFU. Can you try with the latest SDK just to be sure the issue remains?

Would an IFU upgrade from 4.2 to 4.3 make any sens?
The boot loader is different, whcih can not be updated with IFU. right?

I have no choice, deadlines are forcing me to ship devices with 4.2 to provide a partial functionality to customers but we need to update these with IFU to 4.3 when the final release is out.

@ John - i installed the new SDK and have these versions on PC - PCB to start from:

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

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

I used the newly installed hex files but have the same error in the same block.


Loading file SD\FIRMWARE2.HEX, block 302/333
Loading file SD\FIRMWARE2.HEX, block 303/333
Loading file SD\FIRMWARE2.HEX, block 304/333
Loading file SD\FIRMWARE2.HEX, block 305/333
Loading file SD\FIRMWARE2.HEX, block 306/333
    #### Exception System.ArgumentException - 0xfd000000 (1) ####
    #### Message: 
    #### GHI.Premium.System.SystemUpdate::SystemUpdateLoad [IP: 0000] ####
    #### GHI.Premium.System.SystemUpdate::Load [IP: 0085] ####
    #### IFU.Program::LoadDataFromSD [IP: 004b] ####
    #### IFU.Program::Main [IP: 0036] ####
A first chance exception of type 'System.ArgumentException' occurred in GHI.Premium.SystemUpdate.dll
An unhandled exception of type 'System.ArgumentException' occurred in GHI.Premium.SystemUpdate.dll

If i replace the hex files with the ones for 4.2 it run’s fine.

@ David@ Emrol - Reinhard Ostermeier is correct in that you cannot update the loader through IFU, I forgot that bit when replying last time. Running, or even updating to, a 4.3 firmware on a 4.2 loader is not a scenario that we support or even test. Any number of things can go wrong.

And as andre.m said, it is true you do not need to always update the loader, but that is within a framework version, not crossing between them.

@ John - I’m confused, if 4.2 -> 4.3 or whatever version update is not supported then why IFU has configuration and firmware types?

Or is it only a 3.xx - 4.xx that’s not supported?

If the bootloader has changed in a significant way (which is always hard to guess as long as a firmware does not list the compatible loader versions). it needs to be updated along with the firmware. This is not possible with IFU.
But a FW update from 4.2.8 to 4.2.9 or from 4.3.2 to 4.3.3 should usually be possible.
An update from 4.2.x to 4.3.x might work, but I would not bet any money on it.

So in fact IFU is only good for your own application and minor FW updates, like a bug fix release.
This is at least better than nothing and leads to another requirement often heard in the forums:
Support of multiple GHI SDK Versions on one development machine.
Because it’s not possible to upgrade all devices in the field to the latest firmware.

@ David@ Emrol - Reinhard is correct. It is usually possible for a firmware to run on a loader that is a very versions old, usually. That’s why you can use IFU to update from something like 4.2.10 to 4.2.11. The loader has changed a lot between 4.2.11 and 4.3.3, in addition to changing NETMF versions. Updating the firmware to 4.3.3 while the loader stays at 4.2.11 is not something we support.

This means i have to make a field trip to switzerland when the final 4.3 release is out. :whistle: It’s a nice country :wink:

Because of this we plan to add a USB cable between the PC and the G120 in our device at all time (we have USB Client with galvanic isolation :smiley: ).
Additionally we connect the LDR0/1 and reset to digital outputs in the device, which are controlled by the PC.
We then can connect remotely to the PC and do a loader update as if we are at the device.
Not nice to do this for many devices, but at least a possibility (and even automatable if FEZConfig supports a batch mode. @ John - does it?)

But if you have no PC near by: Have a nice trip :wink:

Yes indeed :wink: When you come here, drop by in our office :wink:

Cuno

@ Reinhard Ostermeier - It does not currently support a batch mode but it is something we would like to support at one point, though no promises.