Mono bootloader for Netduino (and sample apps)
#1
Posted 13 February 2011 - 10:26 PM
#2
Posted 13 February 2011 - 10:30 PM
If deploying the bootloader from Mac/Linux, you'll need to use a serial connection from your computer to your Netduino. If using a Netduino or Netduino Plus, use our custom MFDeploy build for Windows to switch your Netduino to serial deployment. Or compile the Netduino firmware from scratch after setting the debug port to COM1/COM2 in platform.h and deploy it to your Netduino using SAM-BA on Linux.
[Bootloader HEX for Netduino Plus is attached; bootloader HEX for Netduino and Netduino Mini coming later today which will require v4.1.1 alpha 6+ firmware]
Chris
Attached Files
#3
Posted 13 February 2011 - 11:19 PM
The build process has two steps: (1) compile; (2) shrink ("minimize").
To compile your Netduino app, you'll use the mcs.exe compiler (from Visual Studio or from Mono 2.12). The .NET MF compiler support was too new to make it into the upcoming Mono 2.10 release, so for the moment you'll need to install Mono 2.10 and then build the Mono 2.12 compiler from source.
We'll build the MonoBlinky app using Mono in the following example.
Step 1: compile MonoBlinky using Mono's new C# compiler (Mono 2.10 installed to default directory, Mono source in c:\mono)
C:\Downloads\MonoBlinky\> SET NETMF_LIB="C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le" C:\Downloads\MonoBlinky\> SET NETDUINO_LIB="C:\Program Files (x86)\Secret Labs\Netduino SDK\Assemblies\v4.1\le" C:\Downloads\MonoBlinky\> "c:\program files (x86)\mono-2.10\bin\mono.exe" "c:\mono\mcs\mcs\mcs.exe" /reference:%NETMF_LIB%\Microsoft.SPOT.TinyCore.dll /reference:%NETMF_LIB%\Microsoft.SPOT.Native.dll /reference:%NETMF_LIB%\mscorlib.dll /reference:%NETMF_LIB%\Microsoft.SPOT.Hardware.dll /reference:%NETDUINO_LIB%\SecretLabs.NETMF.Hardware.dll /reference:%NETDUINO_LIB%\SecretLabs.NETMF.Hardware.Netduino.dll /out:MonoNetduinoApp.exe /target:exe /nostdlib Program.cs Properties\AssemblyInfo.cs
To compile a DLL, use /target:library and /out:assemblyname.dll instead.
You can also copy all the assemblies to your project's source code folder to avoid the extra path variables.
This will output your app as MonoNetduinoApp.exe, a traditional .NET assembly. Now we'll strip out extraneous data and convert it to the .NET MF "PE" assembly format.
Step 2: compress ("minimize") our app (assembly)
C:\Downloads\MonoBlinky\> SET NETMF_BIN="C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Tools" C:\Downloads\MonoBlinky\> "%NETMF_BIN%\MetaDataProcessor.exe" -loadHints mscorlib "%NETMF_LIB%\mscorlib.dll" -parse MonoNetduinoApp.exe -minimize -endian le -compile MonoNetduinoApp.pe
To run your Mono-compiled app, copy the resulting MonoNetduinoApp.pe file to a MicroSD card and insert it into your Netduino Plus (or use a shield on your Netduino or a MicroSD breakout board with your Netduino Mini). The MonoNetduinoBootloader app on your Netduino will then load the app automatically during powerup/restart.
Chris
#4
Posted 14 February 2011 - 12:24 AM
#5
Posted 24 August 2011 - 06:49 AM
#6
Posted 03 September 2011 - 06:50 PM
#7
Posted 03 September 2011 - 09:16 PM
#8
Posted 05 September 2011 - 12:26 AM
Hi jefe,
Here's a full set of instructions from the Wiki:
http://wiki.netduino....ashx?HL=sam,ba
Let me know if you need anything else!
Chris
Wow. Thanks, Chris. Perfect! I should have looked harder for this myself. I'll let you know how it works out.
#9
Posted 04 January 2012 - 07:07 PM
#10
Posted 06 January 2012 - 02:52 AM
I've found an unusual behavior when loading assemblies off the SDcard. When executing the following code (flashing LED running with two threads) from the provided MonoNetduinoBootloader it hangs at the line
assembly = Assembly.Load(assemblyData);in MonoNetduinoBootloader. However, if at this stage the reset button is pressed the assembly is executed as expected.
using System; using System.Threading; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace MonoNetduinoApp { public class Program { static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); public static void Main() { // write your code here Thread flashLedThread = new Thread(flashLed); flashLedThread.Start(); Thread.Sleep(Timeout.Infinite); } public static void flashLed() { while (true) { led.Write(!led.Read()); Thread.Sleep(250); } } } }
Also, when attempting to run the following code (using a button interrupt to turn on LED) it hangs the same as above. However, if at this stage the button is pressed the app continues to run but a System.NullReferenceException is thrown and the "Netduino app invalid. Please verify that class name is MonoNetduinoApp and startup method is Main." is printed.
using System; using System.Threading; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace MonoNetduinoApp { public class Program { static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); public static void Main() { // write your code here InterruptPort Button = new InterruptPort(Pins.ONBOARD_SW1,false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); Button.OnInterrupt += new NativeEventHandler(Button_OnInterrupt); Thread.Sleep(Timeout.Infinite); } static void Button_OnInterrupt(uint data1, uint data2, DateTime time) { led.Write(data2 == 1); } } }
I can get my main assembly running, mentioned in the above post, if I take out the button interrupt and press the reset button on the hang-up, however this is not a practical solution. Can anyone else re-create this problem and perhaps find a solution.
Thanks again
Ryan
P.S. I am not using Mono to compile (just straight Visual Studio, Windows) and I want to use SDcard assemblies for more flexibility in firmware updates
#11
Posted 14 February 2012 - 01:47 AM
#12
Posted 26 February 2012 - 03:10 PM
#13
Posted 26 February 2012 - 04:02 PM
#14
Posted 02 July 2014 - 03:17 PM
Hi Chris, What are the limitations of this method? I can get your two examples running but when I try to load a larger assembly it fails to run (no error is reported, netduino plus is unresponsive, runs when loaded in the traditional manor). I have put all the references that are used in the assembly into the bootloader program (necessary?) with no luck. Perhaps I need to do something differently when using multiple classes (also threading) or the memory foot print is now too large? Any help with this would be appreciated. Thanks again. Ryan Firmware v4.1.1 BETA 1 Traditional Method Total: (11856 RAM - 100832 ROM - 53025 METADATA) .pe file on SDcard (11KB) The debugging target runtime is loading the application assemblies and starting execution. Total: (12120 RAM - 101992 ROM - 53394 METADATA)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users