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

Software reset


  • Please log in to reply
38 replies to this topic

#1 Dustin

Dustin

    New Member

  • Members
  • Pip
  • 5 posts

Posted 09 October 2010 - 03:31 AM

Is there a way to programmatically reset the Netduino? I am repurposing the onboard switch, but I want to trigger a reset if the switch has been held down for an extended period of time. Thanks, Dustin

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 October 2010 - 03:36 AM

Hi Dustin, Thanks for the post, and welcome to the community! We could create a software reset feature. Would other users like that feature as well? Also, you can wire a switch to the /RESET pin header if you'd like an easy way to reset the Netduino. It will still act as a reset--even if the onboard pushbutton is repurposed as a GPIO. Chris

#3 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 09 October 2010 - 03:47 AM

Hi Dustin,

Thanks for the post, and welcome to the community!

We could create a software reset feature. Would other users like that feature as well?

Also, you can wire a switch to the /RESET pin header if you'd like an easy way to reset the Netduino. It will still act as a reset--even if the onboard pushbutton is repurposed as a GPIO.

Chris


It's a neat idea... I guess there is no reason why not to have it. Yeah I would like that feature as well

#4 Crispin

Crispin

    Advanced Member

  • Members
  • PipPipPip
  • 65 posts
  • LocationLondon, England, Earth

Posted 09 October 2010 - 10:28 AM

Is there a way to programmatically reset the Netduino? I am repurposing the onboard switch, but I want to trigger a reset if the switch has been held down for an extended period of time.

Thanks,
Dustin



You could just wire the reset header to a digital pin and hold it high and bring it low to reset it. Or the other way round, my aging memory...

Software reset would be nice.
--
Take a seat, I'll be right with you.

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 October 2010 - 02:24 PM

You could just wire the reset header to a digital pin and hold it high and bring it low to reset it. Or the other way round, my aging memory...


Now that Crispin mentions that...

Dustin, for this particular application you want to reset the device after holding the pushbutton for a certain period of time correct? Well, if you simply dispose of your switch's InputPort after that amount of time, the pushbutton will become a reset button again :) The blue user LED would turn on to let the user know that the board is being reset and when they let go the board will restart...

Chris

#6 Dustin

Dustin

    New Member

  • Members
  • Pip
  • 5 posts

Posted 09 October 2010 - 03:13 PM

Now that Crispin mentions that...

Dustin, for this particular application you want to reset the device after holding the pushbutton for a certain period of time correct? Well, if you simply dispose of your switch's InputPort after that amount of time, the pushbutton will become a reset button again :) The blue user LED would turn on to let the user know that the board is being reset and when they let go the board will restart...

Chris



Thanks Chris. That is a great idea and sounds like it will work exactly as I want it to.

Thanks to everyone for the other great suggestions as well.

Dustin

#7 Miha

Miha

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 19 January 2011 - 12:07 AM

Dustin, for this particular application you want to reset the device after holding the pushbutton for a certain period of time correct? Well, if you simply dispose of your switch's InputPort after that amount of time, the pushbutton will become a reset button again :) The blue user LED would turn on to let the user know that the board is being reset and when they let go the board will restart...


I just got my ND+ today and decided to play a bit with it. Tested this among other things and this does not seem to work. I initialize the switch as an InterruptPort though, if that makes a difference? When I dispose it, I stop getting events, but the switch won't funciton as a reset switch. Any ideas?

Miha

#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 19 January 2011 - 01:29 AM

I just got my ND+ today and decided to play a bit with it. Tested this among other things and this does not seem to work. I initialize the switch as an InterruptPort though, if that makes a difference? When I dispose it, I stop getting events, but the switch won't funciton as a reset switch. Any ideas?


Hi Miha,

If you erase your current Netduino app (using MFDeploy), does pressing the pushbutton reset your device?

Chris

#9 Mark H

Mark H

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts
  • LocationPerth, Western Australia

Posted 19 January 2011 - 02:56 AM

There is a far easier way everyone has overlooked :) Use the watchdog service in Microsoft.SPOT.Hardware. http://msdn.microsof...y/ee436617.aspx Set a timeout of 1milisecond. Set Enabled property on the watchdog to true. Thread.Sleep for 100ms. Watchdog will reboot the device.

#10 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 19 January 2011 - 12:42 PM

The watchdog class sounds interesting. My Netduino home automation project is always on and generally sits there waiting for a web request or a button press. I found once after I'd gone on holiday for a week that it had locked up. Obviously I'll check my code for memory leaks, improve error handling, etc. but it might be useful to allow it to reset itself. Maybe even a weekly reboot just in case.

#11 Miha

Miha

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 19 January 2011 - 08:52 PM

If you erase your current Netduino app (using MFDeploy), does pressing the pushbutton reset your device?


I don't know how to erase an app? Couldn't find anything in MFDeploy that would led me to undeploying the app. I did however change the program to not use the switch 1 and it of course works when it is not used by the program itself. As I mentioned, I'm using the onboard switch via InterruptPort class.

Use the watchdog service in Microsoft.SPOT.Hardware.

http://msdn.microsof...y/ee436617.aspx


This sounds interesting, but unfortunately, it does not work. :blink:

When looking at it via debugger, the property Enabled is false after I set it to true. I tried HardReboot, SoftRebutt, DebugBreak_Native behaviours. I set the Timeout to 100 * TimeSpan.TicksPerMillisecond. Then I set it to
TimeSpan.FromTicks(1 * TimeSpan.TicksPerSecond);
What is strange is that if I check the Timeout property in the debugger, it says 00:00:00.


On a related note, the ND would freeze every once in a while (~ every 5 deploys) and I have to unplug it and plug it back.

Miha

#12 Mark H

Mark H

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts
  • LocationPerth, Western Australia

Posted 20 January 2011 - 07:10 AM

I've only used the watchdog on FEZ/GHI products. I assumed it was implemented on the NetDuino.

TimeSpan ts = new TimeSpan(0, 0, 0, 0, 1);

Will create a 1ms timespan faster (object creation time wise) than your call above.

Fred,
What you actually want is to use the watchdog how it's intended - rather than just arbitrarily rebooting your device - wait until it locks up and then reboot it. Simply create a timer that executes once ever 5 seconds or so which resets the watchdog timer, and set the watchdog to 5.5-6s. If it doesn't get reset - the watchdog "expires" and restarts the device.

#13 Miha

Miha

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 20 January 2011 - 08:17 AM

I've only used the watchdog on FEZ/GHI products. I assumed it was implemented on the NetDuino.


Could someone confirm this or maybe I am using it in the wrong way?

Miha

#14 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 20 January 2011 - 08:26 AM

Hi Miha, Watchdog is not implemented in the Atmel drivers for the .NET MF microcontroller, but we could certainly add it. It would need to be in v4.1.2+ though, as v4.1.1 is moving into feature complete status. Would this be very useful for your projects? We've been thinking of adding it to another .NET MF chip support package for another project here at Secret Labs. Chris

#15 Miha

Miha

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 20 January 2011 - 01:55 PM

Watchdog is not implemented in the Atmel drivers for the .NET MF microcontroller, but we could certainly add it. It would need to be in v4.1.2+ though, as v4.1.1 is moving into feature complete status.

Would this be very useful for your projects? We've been thinking of adding it to another .NET MF chip support package for another project here at Secret Labs.


This would certainly be very useful. What is the current workaround? Can I connect digital pin (ie 13) to reset perhaps and just set the pin output to true? Do I need a resistor in between?

How does the reset pin function, exactly? Does it need 3.3V or does it need connection to ground for it to reset the ND?

Miha

#16 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 20 January 2011 - 03:01 PM

Watchdog is not implemented in the Atmel drivers for the .NET MF microcontroller, but we could certainly add it.

Please excuse my ignorance, but regarding the software reset wouldn't it be easier just to implement PowerState.RebootDevice(...) methods (if it is not working already)? Watchdog may be useful too, but I have seen in the source code that it is being used by the CRL runtime itself, so it may not be guaranteed to work as expected (e.g. one enables/disables watchdog in user code and the runtime disables/enables it back during its internal (scheduling) operations).

#17 JonnyBoats

JonnyBoats

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts
  • LocationPhillips, ME

Posted 20 January 2011 - 03:03 PM

Hi Miha,

Watchdog is not implemented in the Atmel drivers for the .NET MF microcontroller, but we could certainly add it. It would need to be in v4.1.2+ though, as v4.1.1 is moving into feature complete status.

Would this be very useful for your projects? We've been thinking of adding it to another .NET MF chip support package for another project here at Secret Labs.

Chris


Chris, Plus 1 for this feature.A watchdog timer is critical for lots of applications.

#18 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 21 January 2011 - 08:45 AM

Especially if the board is a bit buggy ^^. "another .NET MF chip support package for another project" also sounds very interesting though. I'd rather see that one first.

#19 Jarrod Sinclair

Jarrod Sinclair

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • LocationSF Bay Area, CA

Posted 21 January 2011 - 06:53 PM

Please excuse my ignorance, but regarding the software reset wouldn't it be easier just to implement PowerState.RebootDevice(...) methods (if it is not working already)? Watchdog may be useful too, but I have seen in the source code that it is being used by the CRL runtime itself, so it may not be guaranteed to work as expected (e.g. one enables/disables watchdog in user code and the runtime disables/enables it back during its internal (scheduling) operations).



In order to call "PowerState.RebootDevice(True, 500);" your code must be in an operation state. The purpose of having a watchdog on a embedded device is that way if you have an unrecoverable error, some code hangs the device, or you just plain run out of memory, it will reset it's self. At this stage many of you (myself included) are just using these devices at home in "controled" conditions where we can rest them at will. However, if you wanted to build a device like Fred or Dayland (for home automation) then this type of feature would be critical.

Chris,
In my opinion - if / when you guys implement this you should only be able to set the watchdog timeout length, not enable or disable it from managed code. Default it to say 10,000ms (10 second of system hang or unresponsiveness). Then if someone does not want to use it they can set the timeout to DateTime.MaxValue or uint.MaxValue. in addition you need a way of telling the manage environment that this has happened. Like something as part of SecretLabs.NETMF.Hardware, a class called Watchdog and then Timeout (int or DateTime.Timespan) and ResetCount (read only int)

Thoughts?

- Jarrod

#20 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 21 January 2011 - 07:05 PM

In order to call "PowerState.RebootDevice(True, 500);" your code must be in an operation state.

I was proposing a solution to the original request, which is "but I want to trigger a reset if the switch has been held down for an extended period of time." - to handle a switch interrupt, the code is supposed to be in operational state.




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.