HTTPS SSH

Oberon MFUpdate Sample

This solution contains a MFUpdate sample that installs an update to a NETMF device. The solution contains two projects:

  • Demo, which demonstrates the use of MFUpdate by installing an assembly. Blinks red during execution.
  • Update, will be installed by the Demo application. Blinks green during execution.

Upon execution of the Demo application the board will blink red. The application then installs the Update application which is contained as a resource in the Demo application using MFUpdate. During the firmware upgrade the board will blink blue. When MFUpdate has finished the board starts the newly installed Update application and will blink green.

An error condition in MFUpdate will be displayed by a led that is blinking in pink.

Deploying Firmware Updates with MFUpdate

The function DeployFirmwareUpdate located in the Demo project demonstrates the use of MFUpdate. The function takes a byte array and deploys the data to the update region. Upon completition and verification the update is installed by the bootloader (the device reboots).

In order for MFUpdate to install an update the data needs to specifically preprocessed. Below we include the post build event to generate an update file for a NETMF assembly:

cd $(TargetDir)le
set SdkDir=%ProgramFiles%\Microsoft .NET Micro Framework\v4.3
dir *.pe /B > pefiles.txt
"%SdkDir%"\Tools\MetaDataProcessor.exe -create_database pefiles.txt $(ProjectName).dat
"%SdkDir%"\Tools\MetaDataProcessor.exe -dump_dat $(ProjectName).dat
echo 0x080A0000 D Deploy > symdefs.txt
"$(SolutionDir)\BuildHelperBinaries\"buildhelper -symdef symdefs.txt Deploy -compress $(ProjectName).dat $(ProjectName).nmf

The first five lines will generate a compressed dat file that contains the assembly data. The line

echo 0x080A0000 D Deploy > symdefs.txt

specifies the deployment location. In this case the file is deployed to the assembly memory region. The line

C:\MicroFrameworkPK_v4_3\BuildOutput\public\release\Server\dll\buildhelper -symdef symdefs.txt Deploy -compress $(ProjectName).dat $(ProjectName).nmf

prepares the .dat-file for MFUpdate. Since the buildhelper application is not distributed with the NETMF installer we have included it in the BuildHelperBinaries folder. The post build step of the Update project already uses this binary folder to build a compatible update. We recommend that users copy the contents of the BuildHelperBinaries folder to the "%ProgramFiles%\Microsoft .NET Micro Framework\v4.3\Tools\". An updated post build event would look like this:

cd $(TargetDir)le
set SdkDir=%ProgramFiles%\Microsoft .NET Micro Framework\v4.3
dir *.pe /B > pefiles.txt
"%SdkDir%"\Tools\MetaDataProcessor.exe -create_database pefiles.txt $(ProjectName).dat
"%SdkDir%"\Tools\MetaDataProcessor.exe -dump_dat $(ProjectName).dat
echo 0x080A0000 D Deploy > symdefs.txt
"%SdkDir%"\Tools\"buildhelper -symdef symdefs.txt Deploy -compress $(ProjectName).dat $(ProjectName).nmf
copy $(ProjectName).nmf "$(SolutionDir)\Demo\Resources\"$(ProjectName).nmf

Demo Application

In order to make the update more consistent we store the "Update" firmware update directly as a managed resource. The firmware update is generated as a post-build event and copied to the Resources folder of the Demo project.

Changes

For MFUpdate, a unique update id is used. In previous versions of UpdateDemo, a constant update id was used, and therefore the Update flash had to be erased before the update as a work around.

A note to MountaineerUSB Users

MountaineerUSB users need to modify the post build event in the Update project and change the line

echo 0x080A0000 D Deploy > symdefs.txt

to

echo 0x08080000 D Deploy > symdefs.txt

Otherwise MFUpdate will deploy the firmware to a different block and the newly installed assembly won't be executed. The address for the Deployment region can be seen in the Erase function in MFDeploy when the device is connected.

The solution needs to be rebuilt in order for the changes to be applied.