Main Site Documentation

MFDEPLOY Command Line funnies


#1

Hi,

I have setup my environment to extend and deploy NETMF 4.3 on my Cerbuino - with a big thanks for all the hard work by @ taylorza and @ patc and those who contributed to their posts.

I’d like to complete the process by doing the firmware flash via the command line (the MFDEPLOY UI is really clunky).

Microsoft info for the command line can be found here ( http://msdn.microsoft.com/en-us/library/cc544583.aspx ) and the PING and ERASE functions seem to work really well.

However, when I try the DEPLOY as follows …

C:\MicroFrameworkPK_v4_3\Solutions\FEZCerberus\TinyCLR>"C:\MicroFrameworkPK_v4_3\BuildOutput\public\Release\Server\dll\MFDEPLOY.EXE" DEPLOY:C:\MicroFrameworkPK_v4_3\BuildOutput\THUMB2\GCC4.6\le\FLASH\release\FEZCerberus\bin\tinyclr.hex\ER_CONFIG;C:\MicroFrameworkPK_v4_3\BuildOutput\THUMB2\GCC4.6\le\FLASH\release\FEZCerberus\bin\tinyclr.hex\ER_FLASH /i:USB:Cerb-Family_Gadgeteer

I get the following …

Error: file not found: C:\MicroFrameworkPK_v4_3\BuildOutput\THUMB2\GCC4.6\le\FLASH\release\FEZCerberus\bin\tinyclr.hex\ER_CONFIG.sig

Any ideas?


#2

Did you check that file is there?


#3

@ Architect - LOL :slight_smile:

The file is NOT there. I don’t ask it to be, and the MFDEPLOY UI deploys without it. I am not sure why the command line even looks for it … am I missing something?


#4

There must be a flag for mfdeploy to not look for it. I think you see a “default” behavior. Just speculating.


#5

@ Architect - My logic exactly. If there is such a flag, it is undocumented :frowning:

Has anybody else tried this before?


#6

PortingKit has full source of the MFDeploy tool. I would go there and check what is different in command line mode and UI mode. You can even compile it and debug it. :wink:


#7

@ Architect - What you say makes sense, but only if somebody else hasn’t already figured it out :slight_smile:

I will wait for a day or so, hoping for a quick answer, and then will dig in and figure it out myself :slight_smile:


#8

Up to you. :smiley: GHI has built their own MFDeploy tool by the way:

http://www.tinyclr.com/forum/topic?id=10954


#9

@ JackN - I’m quite sure SIG Files are mandatory for ER_CONFIG and ER_FLASH, but effectively not to deploy HEX files such as TInybooter and so on…


#10

@ LouisCpro - You may be right, but I checked my entire output directory, and there are no SIG files. Yet, when I deploy using the MFDEPLOY UI, everything works perfectly. I will follow @ Architect’s suggestion and dive into the MFDEPLOY source code … I’m sure the answer lies somewhere in there :slight_smile:


#11

@ JackN - Try to have a look on how MFDeploy behavior changes between UI and not UI. Maybe it considers that UI need user actions so that a key is not necessary to ensure integrity and prevent hacking, but when command line, it is…


#12

@ LouisCpro and @ Architect … thank you for pointing me in the right direction.

It turns out that the porting kit source, incorrectly (IMHO) fails when you don’t have a signature file when you run from the command line. I say that, because if you step deeper into the MFDeployEngine code, it correctly handles the situation when the signature file doesn’t exist.

My solution was to edit the file … C:\MicroFrameworkPK_v4_3\Framework\Tools\MFDeploy\Application\ArgumentParser.cs and on line 336, comment out the following 5 lines of code


if (!File.Exists(signature_file))
  {
    Console.WriteLine(string.Format(Properties.Resources.ErrorFileNotFound, signature_file));
    break;
  }

Rebuild the porting kit, and now the command line I declared at the beginning of this topic correctly deployes the firmware!

"C:\MicroFrameworkPK_v4_3\BuildOutput\public\Release\Server\dll\MFDEPLOY.EXE" DEPLOY:C:\MicroFrameworkPK_v4_3\BuildOutput\THUMB2\GCC4.6\le\FLASH\release\FEZCerberus\bin\tinyclr.hex\ER_CONFIG;C:\MicroFrameworkPK_v4_3\BuildOutput\THUMB2\GCC4.6\le\FLASH\release\FEZCerberus\bin\tinyclr.hex\ER_FLASH /i:USB:Cerb-Family_Gadgeteer

PS. Is this the right solution? I don’t know, but it sure does exactly what I need it to do :slight_smile: Can somebody please mark this as the as the answer? I can’t seem to do it because I created the topic.


#13

Seems ok to me. If it safe without signature then I would just output a warning.


#14

It would be prefered to add a new command line param such as /UNSIGNED to tell MFDEPLOY to accept even without Signed file.

Like this, you will be able to do both with and without without having to recompile in one or other needed situation…


#15

That would be even better, I agree!


#16

You also could create sig files with an empty key.

  1. Create an empty key file with MFDeploy
  2. sign your hex file with the empty.key file using MFDeploy
  3. Depoly your hax file (which is now signed)
    If your device has no key set, it will accept hex files which are signed with empty key.

#17

@ Reinhard Ostermeier - Thank you. I considered this, but there seems to be no way to automate that entire process from the command line. I’m coding extensions to NETMF, and wanted to make it easy to compile & deploy the firmware for testing … without having to get caught up in MFDeploy’s very clunky UI. It is a cycle that I repeat a couple of times per hour and having a post-build (in Visual Studio 11) command to do that has made things a lot smoother :slight_smile:


#18

You have to create key file once and then it is same command line post build step.


#19

@ Architect - What about step #2 … Sign your hex file with the empty key?

(Sorry if I’m asking dumb questions, I blame lack of experience rather than ignorance :slight_smile:


#20

You also could use the MFDeploy Engine directly.
By this you could do everything MFDeploy can do directly from C#/VB.net code.
I’ve started some tool using MFDeployEngine, but because of other projects I only came to Connect and Reboot.
But in general it’s easy to use, and you get a more direct feedback (in form of return codes and exceptions) as from a command line output and exit code.
The precompiled dll you can find in the NETMF installation folder under Tools.
The source code is in the NETMF sources from codeplex.
To see how to use it you could look into the MFDeploy source code.