Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

System.Exception when I now run my code after upgrade to 4.3

Upgrading from 4.2 to 4.3

Best Answer Chris Walker, 14 May 2015 - 08:08 PM

Hi Riaan,

Ah, this makes sense :)

Here is the schematic for Netduino Plus 2:
http://www.netduino....2/schematic.pdf

And here is the schematic for Netduino 3 Wi-Fi:
http://www.netduino....i_schematic.pdf

(Cpu.Pin)0x12 is a direct hardware access mapping to STM32 MCU pin B2.

On Netduino Plus 2, we included a dual-FET on pin PB2 that enabled power to shields. This was a feature exclusive to the gen2 boards. We included that feature mostly to enable low power draws during USB enumeration for compatibility with official USB enumeration current specs, but we found that users overwhelmingly preferred being able to power the board via 3.3V/5V (without reverse-FET power loss) instead. We realized that it was going to be confusing to expose this feature to users, since all GPIO pins would also need to be turned off until the FET was enabled...and so for all the above reasons we removed this FET on gen3 (and focused on adding features and enhancing the power subsystem's raw power and low-current efficiency instead).

On Netduino 3 Wi-Fi, MCU pin B2 is connected to the CC3100's /RESET pin. If you try using that pin from code, either your code or the CC3100 initialization code will fail (due to an exclusive lock on that pin).

Does your project require being able to power up/down the shield on the fly? If so, then the gen2 hardware may be the best pick for your application. Almost all shields are designed in a way which doesn't require changing their power on/off state on the fly, but I know there are always edge cases (and scenarios where you might want to save current).

BTW, once we have Shield Base supported on Netduino 3, you could technically also hack into the FETs that control power to each GoBus port...although we generally recommend against messing with the plug-and-play subsystem.

Does that shed more light on your experience?

Chris Go to the full post


  • Please log in to reply
11 replies to this topic

#1 Riaan Mastenbroek

Riaan Mastenbroek

    Member

  • Members
  • PipPip
  • 19 posts

Posted 13 May 2015 - 10:29 PM

Hi,

 

When I run my code that worked fine in 4.2 on my Netduino Plus 2 I now get this error on my Netduino 3 :

 

A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll. When I continue I get this error:

 

An unhandled exception of type 'System.NullReferenceException' occurred in Netduino.IP.LinkLayers.CC3100

 

It seems like this error happens in the Main method after approx 200-500 ms.

 

Any Ideas....I would hate to revert back.

 

riaan

 

 



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 May 2015 - 12:36 AM

Hi riaan,

What line of code is throwing this exception? Or is it happening on a background thread?

If you run a simple blinky app, does everything work as expected?

If this is a bug (and not just an auto-retry operation on a background thread which is surfacing exception data to the output window) we'd really appreciate your feedback hunting it down.

Chris

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 May 2015 - 01:03 AM

P.S.

Also, as a diagnostic: can you erase your app really quickly (using the Settings > Tools feature of Netduino Update)?

I know that sounds like a funny request...but it may fix the issue. We once experience an odd scenario which we haven't been able to reproduce since--but where assemblies from two deployments get mixed up. Erasing the current app or reflashing the board should get it back into a known-good state.

Chris

#4 Riaan Mastenbroek

Riaan Mastenbroek

    Member

  • Members
  • PipPip
  • 19 posts

Posted 14 May 2015 - 06:30 AM

Hi,

 

I think I might know what is going on. My SDK installed on my PC seems like v 4.1 as per the deployment:

 

********************************************************

 

Found debugger!
 
Found debugger!
 
Create TS.
 
 Loading start at 8065cf4, end 808ce94
 
Assembly: mscorlib (4.3.1.0)
 
Assembly: Microsoft.SPOT.Native (4.3.1.0)
 
Assembly: Microsoft.SPOT.Hardware (4.3.1.0)
 
Assembly: Microsoft.SPOT.Net (4.3.1.0)
 
Assembly: Microsoft.SPOT.Net.Security (4.3.1.0)
 
Assembly: System (4.3.1.0)
 
Assembly: System.Net.Security (4.3.1.0)
 
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.3.1.0)
 
Assembly: Microsoft.SPOT.IO (4.3.1.0)
 
Assembly: System.IO (4.3.1.0)
 
Assembly: Microsoft.SPOT.Hardware.PWM (4.3.1.0)
 
Assembly: Microsoft.SPOT.Hardware.Usb (4.3.1.0)
 
Assembly: Netduino.IP (1.0.0.0)
 
Assembly: Netduino.IP.Interop (1.0.0.0)
 
Assembly: Netduino.IP.LinkLayers.CC3100 (1.0.0.0)
 
Assembly: SecretLabs.NETMF.Diagnostics (4.3.1.0)
 
Assembly: GoBus (1.5.0.0)
 
Assembly: SecretLabs.NETMF.Hardware.Netduino (4.3.1.0)
 
Assembly: Microsoft.SPOT.Hardware.OneWire (4.3.1.0)
 
Loading Deployment Assemblies.
 
Attaching deployed file.
 
Assembly: NetduinoApplication2 (1.0.0.0)
 
Attaching deployed file.
 
Assembly: SecretLabs.NETMF.IO (4.3.1.0)
 
Attaching deployed file.
 
Assembly: NetDuino.Domain (1.0.0.0)
 
Attaching deployed file.
 
Assembly: SecretLabs.NETMF.Hardware (4.3.1.0)
 
Resolving.
 
The debugging target runtime is loading the application assemblies and starting execution.
Ready.
 
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\mscorlib.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Native.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Net.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\System.IO.dll', Symbols loaded.
 Invalid address 0 and range 40 Ram Start 20000000, Ram end 20030000
 
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll', Symbols loaded.
 Invalid address 1000fbb4 and range 4 Ram Start 20000000, Ram end 20030000
 
 Invalid address 0 and range 40 Ram Start 20000000, Ram end 20030000
 
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'Netduino.IP'
 Invalid address 1000fbb4 and range 4 Ram Start 20000000, Ram end 20030000
 
 Invalid address 0 and range 40 Ram Start 20000000, Ram end 20030000
 
 Invalid address 1000fbb4 and range 4 Ram Start 20000000, Ram end 20030000
 
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'Netduino.IP.Interop'
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'Netduino.IP.LinkLayers.CC3100'
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Secret Labs\Netduino SDK\Assemblies\v4.3\le\SecretLabs.NETMF.Diagnostics.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Secret Labs\Netduino SDK\Assemblies\v4.3\le\GoBus.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Secret Labs\Netduino SDK\Assemblies\v4.3\le\SecretLabs.NETMF.Hardware.Netduino.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Assemblies\le\Microsoft.SPOT.Hardware.OneWire.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\_Dev\LiquidataFlow\trunk\Src\NetDuino\NetDuino.Domain\bin\Debug\le\NetDuino.Domain.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'D:\Temp\NetduinoApplication2\NetduinoApplication2\bin\Debug\le\NetduinoApplication2.exe', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Secret Labs\Netduino SDK\Assemblies\v4.3\le\SecretLabs.NETMF.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.12.dll' (Managed): Loaded 'C:\Program Files (x86)\Secret Labs\Netduino SDK\Assemblies\v4.3\le\SecretLabs.NETMF.Hardware.dll', Symbols loaded.
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll
The program '[13] Micro Framework application: Managed' has exited with code 0 (0x0).
 
 
********************************************************
 
But my device has this on:
 
Connecting to Netduino3_Netduino...Connected
HalSystemInfo.halVersion:               4.3.1.0
HalSystemInfo.halVendorInfo:            Netduino 3 Wi-Fi (v4.3.2.1) by Secret Labs LLC
HalSystemInfo.oemCode:                  34
HalSystemInfo.modelCode:                177
HalSystemInfo.skuCode:                  4105
HalSystemInfo.moduleSerialNumber:       00000000000000000000000000000000
HalSystemInfo.systemSerialNumber:       0000000000000000
ClrInfo.clrVersion:                     4.3.1.0
ClrInfo.clrVendorInfo:                  Netduino 3 Wi-Fi (v4.3.2.1) by Secret Labs LLC
ClrInfo.targetFrameworkVersion:         4.3.1.0
SolutionReleaseInfo.solutionVersion:    4.3.2.1
SolutionReleaseInfo.solutionVendorInfo: Netduino 3 Wi-Fi (v4.3.2.1) by Secret Labs LLC
SoftwareVersion.BuildDate:              May  8 2015
SoftwareVersion.CompilerVersion:        410894
FloatingPoint:                          True
SourceLevelDebugging:                   True
ThreadCreateEx:                         True
LCD.Width:                              0
LCD.Height:                             0
LCD.BitsPerPixel:                       0
AppDomains:                             True
ExceptionFilters:                       True
IncrementalDeployment:                  True
SoftReboot:                             False
Profiling:                              False
ProfilingAllocations:                   False
ProfilingCalls:                         False
IsUnknown:                              False
 
****************************************************
 
I uninstalled everything and then followed the download links and updated my Firmware using the tool to update.
 
Seems like this error occur at a fixed time interval and must be some background thread. I have only been developing for around 2 months...so please tell me if I am doing something wrong here.
 
One more thing....I did exactly the same the the netduino plus 2 (upgrading) but it runs fine. Very Weird....
 
Thanks!
 
Riaan 


#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 May 2015 - 07:44 AM

Hi riann,

It looks like the update is installed properly (4.3.2.1 firmware, built on 4.3.1 NETMF core). So that's a good start.

If you run a simple blinky app, does everything work as expected?

I'm wondering if one of the assemblies loaded into your project has a static constructor which is causing a conflict.

Also, to confirm: the exception happens before your first line of code executes, correct? If you start the program with single-stepping, can you step "into" the exception?

Chris

#6 Riaan Mastenbroek

Riaan Mastenbroek

    Member

  • Members
  • PipPip
  • 19 posts

Posted 14 May 2015 - 08:02 AM

Hi Chris,

 

Looking at this, indeed! I have a singleton class and it seems like the error happens when I have a singleton (static constructor) used. Just running a normal application seems fine until I add that code. It works in met Netduino 2 though.

 

 

I can only confirm this tonight - I am at work currently and the netduino project is a part time project in my spare time.

 

Just like to say though, I really really really LOVE this product. Where I previously had to run a pc and connect to moxa GSM devices which is expensive and really over designed for what I want to do I can now simply use my netduino and do everything in one little box.

 

Riaan



#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 May 2015 - 08:14 AM

Hi Riann,

Looking at this, indeed! I have a singleton class and it seems like the error happens when I have a singleton (static constructor) used. Just running a normal application seems fine until I add that code. It works in met Netdu

Ah yes... NETMF calls static constructors before the main application starts (regardless of whether or not the respective classes are used...which is different than standard .NET behavior).

Can you step into your static code and see where the exception gets thrown?

Just like to say though, I really really really LOVE this product. Where I previously had to run a pc and connect to moxa GSM devices which is expensive and really over designed for what I want to do I can now simply use my netduino and do everything in one little box.

I love that you love Netduino so much :) Please share your projects with the community when you can!

Chris

#8 Riaan Mastenbroek

Riaan Mastenbroek

    Member

  • Members
  • PipPip
  • 19 posts

Posted 14 May 2015 - 08:25 AM

Hi Chris,

 

I will do that tonight but what I could see last night was that the exception seems to be thrown in when the debugger starts (in the trace above) and then it brings that popup box during execution of code - but it happens in the code at various places. If I put a breakpoint at the beginning it happens at the breakpoint but when I put a breakpoint later in the code it happens there. That being said, if I put the breakpoint too late then I dont catch the exception and get the popup thrown - what leads met to believe it is a timing issue - it wil run the code up to a point in time then break, adding a breakpoint earlier just gives an exception earlier because time is used to break...if that makes sense. So I can get this in the first line of code or the 50th but up to eg the 70th it will never pass that if I remove all break points.

 

I could not step into the exception though - it seems like it happens in the c++ unmanaged code.

 

I will remove my singleton instance and test again tonight to confirm though.

 

Riaan



#9 Riaan Mastenbroek

Riaan Mastenbroek

    Member

  • Members
  • PipPip
  • 19 posts

Posted 14 May 2015 - 07:20 PM

Okay,

 

I found the place where the error happens but I dont now why it is happening. This is what i did:

 

1.) I have a Modem class that implements singleton pattern using static constructor. I changed it to a normal class

 

2.) Now the line where the error occurs became apparent and the system constantly gave the hardware error on the following line:

 

It seems like the static class is initialized at startup and that is why the error is thrown at startup which made it very difficult to find. Making it a normal class the instance is created later and one can see the error line :)

 

public OutputPort ShieldPower = new OutputPort((Cpu.Pin)0x012, false);

 

This line is used to power up my GPRS Shield V2

 

3.) I removed the declaration and power up routine and then it works 100%

 

What is strange is that the code worked on Netduino Plus 2 and not on Netduino 3 with exactly the same firmware on both.

 

Any ideas?

 

Riaan



#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 May 2015 - 08:08 PM   Best Answer

Hi Riaan,

Ah, this makes sense :)

Here is the schematic for Netduino Plus 2:
http://www.netduino....2/schematic.pdf

And here is the schematic for Netduino 3 Wi-Fi:
http://www.netduino....i_schematic.pdf

(Cpu.Pin)0x12 is a direct hardware access mapping to STM32 MCU pin B2.

On Netduino Plus 2, we included a dual-FET on pin PB2 that enabled power to shields. This was a feature exclusive to the gen2 boards. We included that feature mostly to enable low power draws during USB enumeration for compatibility with official USB enumeration current specs, but we found that users overwhelmingly preferred being able to power the board via 3.3V/5V (without reverse-FET power loss) instead. We realized that it was going to be confusing to expose this feature to users, since all GPIO pins would also need to be turned off until the FET was enabled...and so for all the above reasons we removed this FET on gen3 (and focused on adding features and enhancing the power subsystem's raw power and low-current efficiency instead).

On Netduino 3 Wi-Fi, MCU pin B2 is connected to the CC3100's /RESET pin. If you try using that pin from code, either your code or the CC3100 initialization code will fail (due to an exclusive lock on that pin).

Does your project require being able to power up/down the shield on the fly? If so, then the gen2 hardware may be the best pick for your application. Almost all shields are designed in a way which doesn't require changing their power on/off state on the fly, but I know there are always edge cases (and scenarios where you might want to save current).

BTW, once we have Shield Base supported on Netduino 3, you could technically also hack into the FETs that control power to each GoBus port...although we generally recommend against messing with the plug-and-play subsystem.

Does that shed more light on your experience?

Chris

#11 Lunddahl

Lunddahl

    Advanced Member

  • Members
  • PipPipPip
  • 152 posts
  • LocationEurope, Denmark

Posted 14 May 2015 - 08:41 PM

deleted, Chris beat me to it...



#12 Riaan Mastenbroek

Riaan Mastenbroek

    Member

  • Members
  • PipPip
  • 19 posts

Posted 15 May 2015 - 08:19 AM

Hi Chris,

 

Makes sense, I do not have any need to power the board up/down so I will remove that part of my code - I thought that it was a necessity to do... Thanks for all the help and support!!! We can close this issue.

 

Again, great product!!!

 

Riaan






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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