Netduino home hardware projects downloads community

Jump to content


Photo

Netduino 2 Firmware v4.3.1 with GCC support


  • Please log in to reply
25 replies to this topic

#1 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1585 posts
  • LocationCzech Republic

Posted 17 March 2014 - 12:39 PM

Prerequisites

 

How to build the firmware with GCC

  • Install GCC, preferably to short path with no spaces, e.g. C:\GCC
  • Install .NET Micro Framework Porting Kit 4.3 QFE1 (C:\MicroFrameworkPK_v4_3)
  • Copy C:\MicroFrameworkPK_v4_3 to C:\Netduino2
  • Extract Netduino 2 Firmware v4.3.1 source to C:\Netduino2, overwrite all
  • Extract Netduino 2 Firmware v4.3.1 source for GCC to C:\Netduino2, overwrite all
  • Launch cmd.exe
    cd \Netduino2
    setenv_gcc 4.8.3 C:\GCC
    msbuild Solutions\Netduino2\dotnetmf.proj /p:Flavor=Release /v:m
    
  • The build should succeed, with a few warnings
  • Extract NetduinoUpdate_4.3.1.0.zip (C:\NetduinoUpdate_4.3.1.0)
  • Copy the firmware image C:\Netduino2\BuildOutput\THUMB2\GCC4.8\le\FLASH\release\Netduino2\bin\tinyclr.hex\ER_FLASH to C:\NetduinoUpdate_4.3.1.0\Firmware\Netduino2_4_3_1_0\ER_FLASH.s19 (rename - add extension)
  • Open ER_FLASH.s19 in you favorite text editor and delete the first line (starts with S0), save.
  • Launch NetduinoUpdate.exe, plug in your Netduino 2 and update the firmware.

 

Important notes

  • GCC support added and verified only for Netduino 2 (mainly due to resource/time constraints),
  • Other GCC toolchains might work or need only minor changes, but make sure they have support for long-long and long-double (IIRC Yagarto does not have it by default) - otherwise formatted string output for C# long and double does not work,
  • Included are a few bug fixes and modifications from my NETMF Fork project (which will be released probably later this year):
    • Fixed MMP : error MMP0000: 0x80131700 (#221, #2202),
    • Fixed GCC compiler errors in BitConverter.cpp (#2216),
    • Added ABORTS_REDUCESIZE symbol to exclude interactive debugging code (#1908),
    • Added support for recent Keil MDK-ARM toolchain (#1795)

 

Attached Files

 

Edit 2014-03-18 19:30 UTC: Added Visual Studio to prerequisite list



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7165 posts
  • LocationNew York, NY

Posted 17 March 2014 - 12:57 PM

CW2, you rock. Thanks so much for all your time putting this together!

Chris

#3 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 83 posts

Posted 17 March 2014 - 01:00 PM

Awesome! I'm giving this a shot today. Will report back.

#4 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 83 posts

Posted 17 March 2014 - 02:14 PM

Me watching the command prompt:

30igves.gif

 

Success!...now to see if the firmware modifications have made any improvements..

 

THANK YOU!



#5 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 169 posts
  • LocationNorway

Posted 17 March 2014 - 03:24 PM

Hi CW2, great work! 

 

I'm trying to follow the guide, but when I run 'setenv_gcc 4.8.3 C:\GCC' I get a warning saying:

 

Compiler: GCC 4.8.3 C:\GCC
WARNING: Could not find vsvars32.bat.
WARNING: VISUAL C++ DOES NOT APPEAR TO BE INSTALLED ON THIS MACHINE
 
So it appears there are some more Prerequisites that should be in the top list. I've got Visual Studio 2013 Ultimate installed, and it contains Visual C++.
 
Also, if I ignore that warning, and run 'msbuild...' then it says that msbuild is not a recognized command. So it would appear that msbuild isn't installed either. 
 
Shouldn't all this have been in place after installing Visual Studio 2013 Ultimate? What else is required?


#6 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 83 posts

Posted 17 March 2014 - 03:38 PM

 

Hi CW2, great work! 

 

I'm trying to follow the guide, but when I run 'setenv_gcc 4.8.3 C:\GCC' I get a warning saying:

 

Compiler: GCC 4.8.3 C:\GCC
WARNING: Could not find vsvars32.bat.
WARNING: VISUAL C++ DOES NOT APPEAR TO BE INSTALLED ON THIS MACHINE
 
 

 

 

Hey Frode, 

 

I struggled with those errors and spent a lot of time searching when I was first trying out previously, but I am using VS2012 /V11.0

 

You may want to look at this: 

http://stackoverflow...-of-the-vs-comm

 

ALSO, try running command prompt as administrator.

 

The above fixed those errors for me.



#7 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1585 posts
  • LocationCzech Republic

Posted 17 March 2014 - 03:46 PM

So it appears there are some more Prerequisites that should be in the top list. I've got Visual Studio 2013 Ultimate installed, and it contains Visual C++.


According to .NET Micro Framework Porting Kit 4.3 ReleaseNotes.txt "Either Visual Studio 2012 (Express edition or greater) or both .NET Framework 3.5 and Windows SDK for Windows" is required.
 
In order to get Visual Studio 2013 working, you'd have to modify setenv_base.cmd - add %VS120COMNTOOLS% to the block of conditions, or simply change the existing %VS110COMNTOOLS% to 12. However, I am not sure this would be enough, due to the MSBuild 2013 changes and several project files having incorrect and/or missing ToolsVersion attribute.



#8 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 83 posts

Posted 17 March 2014 - 03:46 PM

I noticed this flash at the top of the build process output, but it does seem to successfully build new firmware... (Highlighted in yellow) Could not locate the .NET Framework SDK. Browsing to that registry location..There's no SDKInstallRootv2.0 key there. Only InstallRoot. I do have Windows SDK v7.1 installed. 

 

Does this affect the Netduino build? Do I need to install .Net2.0 framework?

 

EWfDaZZ.jpg

 

I tried adding the key with the value: C:\Windows\Microsoft.NET\Framework64\v2.0.50727 and still get the same error.



#9 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1585 posts
  • LocationCzech Republic

Posted 17 March 2014 - 03:57 PM

Does this affect the Netduino build? Do I need to install .Net2.0 framework?

 

No, you can safely ignore this warning. IIRC it is caused by incorrect ToolsVersion attribute value in a few project files, which causes MSBuild 3.5 to be run, instead of 4.0. I have already fixed such issues, but in separate 'cleanup' branch, which will be integrated into a future release...



#10 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 83 posts

Posted 17 March 2014 - 04:11 PM

Thanks!

 

Another thing I noticed, the FIRST time I compiled, a lot of messages in the output window mentioned Linking.Subsequently compiling my modified firmware, it does not show this linking in the output window I even added a /t:Rebuild



#11 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1585 posts
  • LocationCzech Republic

Posted 17 March 2014 - 04:58 PM

Those are libraries and stubs for tools and Windows2 solution, which do not need to be rebuilt when you make changes to a particular solution (your firmware).

 

There are a few 'clean' targets, you can display them for example by launching

msbuild Solutions\Netduino2\dotnetmf.proj /t:Help 

For a 'complete clean' build, delete the build output directory

rmdir /s /q BuildOutput


#12 gismo

gismo

    Advanced Member

  • Members
  • PipPipPip
  • 83 posts

Posted 17 March 2014 - 10:01 PM

Thanks! 

 

I've made some changes the STM32_i2c_functions.cpp file located here: C:\MicroFrameworkPK_v4_3\DeviceCode\Targets\Native\Netduino_STM32\DeviceCode\STM32_I2C 

 

It compiled with no errors, I loaded it, and code works fine...though the I2c "bug" I'm experiencing it still there...Is it really that easy? How can I be sure my changes made it's way into the compile firmware?

 

Thanks!



#13 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1585 posts
  • LocationCzech Republic

Posted 17 March 2014 - 10:42 PM

Well, assuming that you don't have JTAG/SWD in-circuit debugger, the options are... ...challenging  ;)

  • At first, modify the value of <OEMSystemInfoString/> in Solutions\Netduino2\Netduino2.settings - you can then verify (e.g. in MFDeploy) that the device is running your updated firmware,
  • For diagnostic output that appears in the debugger (Visual Studio or MFDeploy) use CLR_Debug::Printf(...) (#include <TinyCLR_Debugging.h> or #include <TinyCLR_Runtime.h>).
  • For low-level diagnostic output you could use hal_printf or debug_printf; it is usually better to reconfigure STDIO and DEBUG_TEXT_PORT to serial port (e.g. COM1) instead of USB (default).
  • The above functions significantly affect code timing and might not be available/should not be called in a particular context (such as interrupt handler) - there you are left with pin toggling (LED blinking, logic analyzer).


#14 richhas

richhas

    New Member

  • Members
  • Pip
  • 3 posts

Posted 28 March 2014 - 09:03 PM

Thank you CW2 - I got all entangled in the GCC Arm tooling build problems a few months back - just wanted to add some native code for custom hardware. This is great.

 

One clarification please. When you say Netduino 2 only - do you mean that no support for ND Plus 2?

 

Any thoughts on how to keep this work up to date as new versions of the MF and SL firmware are released over time?

 

 

Thanks,

 

Rich



#15 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1585 posts
  • LocationCzech Republic

Posted 28 March 2014 - 11:06 PM

One clarification please. When you say Netduino 2 only - do you mean that no support for ND Plus 2?

 

Yes, the GCC-related modifications have been made for Netduino 2 firmware only. But the most-important ones were made in the core .NET Micro Framework source code and are shared by Netduino Plus 2 firmware too - basically, adding a proper scatterfile and fixing possible GCC compiler errors in the additional libraries the Plus 2 firmware uses (network etc.) should be all that is needed to make GCC built firmware for the Plus 2.

 

Any thoughts on how to keep this work up to date as new versions of the MF and SL firmware are released over time?

 

Well, the modifications are available under Apache 2.0 license, so both Microsoft .NET Framework and Secret Labs teams can easily integrate them into their respective code  ;)  And there are always alternative ways  :P



#16 nhale

nhale

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts
  • LocationHeidelberg, Germany

Posted 03 April 2014 - 09:20 AM

Don't get me wrong but can maybe also explain the advantages, why I should use that? What's the benefits or what problem is solved? Just have no clue and ask myself if I should take a look at it ;-)



#17 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1585 posts
  • LocationCzech Republic

Posted 03 April 2014 - 10:20 AM

Don't get me wrong but can maybe also explain the advantages, why I should use that? What's the benefits or what problem is solved? Just have no clue and ask myself if I should take a look at it ;-)

 

Well, you don't have to use that (if you mean the firmware source). Adding GCC support allows you to use free GCC-based toolchains to compile the firmware - otherwise, you have to pay several thousand dollars for commercial ARM toolchains (such as Keil MDK).



#18 nhale

nhale

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts
  • LocationHeidelberg, Germany

Posted 03 April 2014 - 05:54 PM

 

otherwise, you have to pay several thousand dollars for commercial ARM toolchains (such as Keil MDK).

thanks, that was the missing information ;-)



#19 Stormstar

Stormstar

    New Member

  • Members
  • Pip
  • 6 posts

Posted 06 April 2014 - 05:43 PM

Thanks, this is a great tutorial!

The only thing i was missing is that i need to hold the reset button when plugging in the device for NetduinoUpdater.exe.

Maybe a point to add in the last steps of your tutorial :), thnx!



#20 Stormstar

Stormstar

    New Member

  • Members
  • Pip
  • 6 posts

Posted 06 April 2014 - 06:52 PM

I tried to build the Netduino Plus 2 but this one isn't working, does somebody know how to fix it? i don't get any informative exceptions






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2010-2014 Secret Labs LLC  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.