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

Hardware watchdog on Netduino Plus


  • Please log in to reply
35 replies to this topic

#21 ToniA

ToniA

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 12 March 2013 - 08:18 AM

OK, I have been looking at the code, and my plan for fixing the MFDeploy issue is to use the onboard switch and led like this:

  • Short press on power-up -> onboard led lights up, then turns off -> watchdog disabled, CLR starts normally
  • Long press on power-up -> onboard led lights up, then blinks quickly a few times -> watchdog disabled, waits for firmware upload
  • No button press on power-up -> watchdog enabled, CLR starts normally

Additionally, I've been thinking how to feed the watchdog from the managed application side. If I introduce any new methods or properties etc. it means that all applications using those must also link with additional DLL's. I was thinking of this:

  • The CLR feeds the watchdog until the first time 'Watchdog.enabled = true' is called
  • After this, each call to 'Watchdog.enabled = true' would reset the watchdog counter and the CLR would not feed the watchdog any more

A bit ugly, but wouldn't require any extra DLL's. Now I just need to implement these :)



#22 Gavin G.

Gavin G.

    Member

  • Members
  • PipPip
  • 11 posts

Posted 12 March 2013 - 07:17 PM

What you said about [color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]feeding the watchdog from the managed application side. would probably provide a quick fix for the issues that I'm seeing in my setup.[/color]

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]Setup:[/color]

  • Netduino plus works as a Client
  • Connects to locally hosted server application via TCP/IP socket communication
  • Once Netduino plus connects to server I use a GUI tied to the server to command and keep track of connections

Problem:

  • Once Netduino plus connects to the server, something causes the watchdog to kick in and reset the chip at set time intervals roughly 1 min 14 secs after the Netduino plus connects to the server.
  • Note 1: If I leave the Netduino there not connected the server the watchdog won't trigger a reset
  • ?Note 2: This doesn't happen with non custom firmware, with non custom firmware the problem comes from when I do something like manually disconnecting the Ethernet cable which causes it to hang.

What I wanted it do:

  • If there was ever a network disconnect for whatever reason (e.g. I unplug the Ethernet cable), if the Netduino plus couldn't resolve the socket connection to the server it would force a reset after a set time of hanging.

If some how you got the watchdog managed from the application side, I could kick it every X amount of seconds. Like you said ugly fix to the issue, but it will work until i can narrow down what's forcing the resets at set time intervals during connections.


Gavin G.

 

"The most important thing is to keep the most important thing the most important thing."

- From the book "Foundation design", by Coduto, Donald P.


#23 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 12 March 2013 - 07:30 PM

Additionally, I've been thinking how to feed the watchdog from the managed application side. If I introduce any new methods or properties etc. it means that all applications using those must also link with additional DLL's.

  It is also possible to add private fields and access them via reflection, in derived classes or extension methods. This has been done by Secret Labs for I2C (Custom_InternalAddress), SPI (Custom_BitsPerTransfer in ExtendedSpiConfiguration).



#24 OZ8ET

OZ8ET

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts
  • LocationHundested, Denmark

Posted 16 March 2013 - 10:28 AM

There is a problem using the MF-Deploy tool to change Network configuration on NP Gen1 with this firmware.

It takes foreveer to get the Configuration window to show. 

If I take power off-on, it shows.



#25 ToniA

ToniA

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 16 March 2013 - 12:06 PM

Yes, I noticed the same. Actually, I somehow got the firmware all messed up if I didn't follow this procedure:

  • You need to have the firmware deployed
  • Connect the Netduino Plus to USB while holding the onboard botton down
  • When you do a 'Ping' in MFDeploy, it should tell you it's running the tinybooter, not CLR
  • Now do the network setup

I already implemented the TinyBooter feature to react differently on short and long press on bootup, now I need to focus on the watchdog side. I also compiled the whole software with RVDS 4.1.



#26 OZ8ET

OZ8ET

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts
  • LocationHundested, Denmark

Posted 17 March 2013 - 11:03 AM

Sorry - has the download a new bootloader? - if so when did you change it? is there any description on how to use?

Thanks again for your great work.

Erik



#27 ToniA

ToniA

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 17 March 2013 - 06:36 PM

Hi Erik, still working on it. I think I got it all done, but I need to do some more tests tomorrow evening. If I don't find any problems, I'll publish the binaries tomorrow.



#28 ToniA

ToniA

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 18 March 2013 - 04:48 PM

OK, here's my new 1-wire + watchdog firmware for Netduino Plus, based on official 4.2.0.1, with CW2's 1-wire, compiled with RVDS 4.1.

 

Flashing instructions:


    [*]Reset the NetduinoPlus by connecting 3.3V to the golden square
    [*]Disconnect and reconnect the USB
    [*]Install the TinyBooterDecompressor.bin with SAM-BA
    [*]Disconnect the USB cable and reconnect it while PRESSING AND HOLDING THE ONBOARD BUTTON until the onboard LED blinks quickly
    [*]Deploy the firmware using MFDeploy
    [*]Disconnect and reconnect the USB AGAIN while PRESSING AND HOLDING THE ONBOARD BUTTON until the onboard LED blinks quickly
    [*]Set the network configuration with MFDeploy
    [*]Disconnect and reconnect the USB (don't press the button), and you're done
    [/list]

    The Tinybooter has three modes:

    • Onboard button is not touched -> boot up with watchdog enabled
    • Press the onboard button while connecting the USB -> release the button after the LED turns off but before it starts blinking -> boot up with watchdog disabled -> can use MFDeploy to deploy large applications
    • Press and hold the onboard button while connecting the USB until the onboard LED first turns off and then blinks -> boots to TinyBooter for firmware upload and for setting the network configuration

    The watchdog also has three modes on the application

    • 'Watchdog.enabled' is not set in the program -> watchdog is active and is automatically fed by the CLR
    • 'Watchdog.enabled = false' -> watchdog is explicitly disabled -> same functionality as in the stock firmware
    • 'Watchdog.enabled = true' -> watchdog is explicitly enabled and cannot be disabled -> the watchdog must be fed by the application by calling 'Watchdog.enabled = true' periodically. If this is not done, or if the application crashes, a watchdog reset will happen

    A sample application

    • Please note that the watchdog is not active when connected to the debugger -> stop debugging and reconnect the USB
    • To verify the functionality, comment out the 'Watchdog.enabled' row in FeedWatchdog and see the board doing a reset after a short while
    using System;using System.Net;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.NetduinoPlus;namespace WatchdogDemo{    public class Program    {        static void FeedWatchdog(object o)        {            // Each time the watchdog is enabled, it's also fed            // This is a bit of a workaround, but at least it didn't            // require any interface changes            Watchdog.Enabled = true;        }        public static void Main()        {            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);            // When the watchdog is enabled, it also must be fed from the managed app            Watchdog.Enabled = true;            Timer WatchdogTimer = new Timer(new TimerCallback(FeedWatchdog), null, 1000, 1000);            while (true)            {                Thread.Sleep(50);                led.Write(!led.Read());            }        }    }}

    The firmware source code is here: https://github.com/T...tduino-watchdog

    Attached Files


  • strent and Gavin G. like this

#29 OZ8ET

OZ8ET

    Advanced Member

  • Members
  • PipPipPip
  • 72 posts
  • LocationHundested, Denmark

Posted 18 March 2013 - 07:59 PM

Thank you Toni - great job!

Erik



#30 strent

strent

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts

Posted 31 March 2013 - 12:33 AM

Latest version is much more stable, thanks ToniA!

 

Unfortunately my SD Card that worked fine in 4.1, doesn't work in 4.2 :(

Throws the Unsupported Exception in System.IO



#31 mohammad

mohammad

    Advanced Member

  • Members
  • PipPipPip
  • 79 posts

Posted 14 May 2013 - 07:47 PM

Latest version is much more stable, thanks ToniA!

 

Unfortunately my SD Card that worked fine in 4.1, doesn't work in 4.2 :(

Throws the Unsupported Exception in System.IO

 

Is your SD card more than 2GB? The firmware 4.2 only knows the SD cards 2GB and 1GB.



#32 mohammad

mohammad

    Advanced Member

  • Members
  • PipPipPip
  • 79 posts

Posted 21 May 2013 - 11:46 PM

 

This might be useful for your watchdog prodecures: http://forums.netdui...-netduino-plus/ (although it is a software reboot).



#33 ToniA

ToniA

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 23 May 2013 - 01:15 PM

That's not a watchdog, it's a scheduled reboot.

 

have you tried out my firmware build? What are the problems you mention in the other thread ('I had a problem for 1 month to use a Watchdog mechanism in Netduino Plus') ?



#34 mohammad

mohammad

    Advanced Member

  • Members
  • PipPipPip
  • 79 posts

Posted 23 May 2013 - 07:39 PM

That's not a watchdog, it's a scheduled reboot.

 You are right, so I should not consider them interchangeably.

 

have you tried out my firmware build?

No, since the firmware of your library was different from mine.

 

 

What are the problems you mention in the other thread ('I had a problem for 1 month to use a Watchdog mechanism in Netduino Plus') ?

The watchdog problem :) to reboot the Netduino Plus after a specific time.



#35 CyberChris

CyberChris

    New Member

  • Members
  • Pip
  • 2 posts

Posted 18 August 2013 - 05:56 PM

Hello,

 

today I tried to flash my Netduino Puls with the 4.2.0 + CW2 OneWire. As it looks, the firmware is properly installed.

HalSystemInfo.halVersion:               4.2.0.0HalSystemInfo.halVendorInfo:            Netduino Plus (v4.2.0.1) by Secret Labs LLC [CW2 mod]HalSystemInfo.oemCode:                  34HalSystemInfo.modelCode:                177HalSystemInfo.skuCode:                  4097HalSystemInfo.moduleSerialNumber:       00000000000000000000000000000000HalSystemInfo.systemSerialNumber:       0000000000000000ClrInfo.clrVersion:                     4.2.0.0ClrInfo.clrVendorInfo:                  Netduino Plus (v4.2.0.1) by Secret Labs LLC [CW2 mod]ClrInfo.targetFrameworkVersion:         4.2.0.0SolutionReleaseInfo.solutionVersion:    4.2.0.0SolutionReleaseInfo.solutionVendorInfo: Netduino Plus (v4.2.0.1) by Secret Labs LLC [CW2 mod]SoftwareVersion.BuildDate:              Mar 15 2013SoftwareVersion.CompilerVersion:        410713FloatingPoint:                          TrueSourceLevelDebugging:                   TrueThreadCreateEx:                         TrueLCD.Width:                              0LCD.Height:                             0LCD.BitsPerPixel:                       0AppDomains:                             TrueExceptionFilters:                       TrueIncrementalDeployment:                  TrueSoftReboot:                             TrueProfiling:                              FalseProfilingAllocations:                   FalseProfilingCalls:                         FalseIsUnknown:                              False
DeviceInfo:  HAL build info: 4.2.0.0, Netduino Plus (v4.2.0.1) by Secret Labs LLC [CW2 mod]  OEM Product codes (vendor, model, SKU): 34, 177, 4097  Serial Numbers (module, system):    00000000000000000000000000000000    0000000000000000  Solution Build Info: 4.2.0.0, Netduino Plus (v4.2.0.1) by Secret Labs LLC [CW2 mod]  AppDomains:    default, id=1  Assemblies:    mscorlib,4.2.0.0    Microsoft.SPOT.Native,4.2.0.0    Microsoft.SPOT.Hardware,4.2.0.0    Microsoft.SPOT.Net,4.2.0.0    System,4.2.0.0    Microsoft.SPOT.Hardware.SerialPort,4.2.0.0    Microsoft.SPOT.IO,4.2.0.0    System.IO,4.2.0.0    Microsoft.SPOT.Hardware.PWM,4.2.0.1    Microsoft.SPOT.Hardware.OneWire,4.2.0.0    SecretLabs.NETMF.Diagnostics,4.2.0.0    SecretLabs.NETMF.Hardware.Netduino,4.2.1.0    SecretLabs.NETMF.Hardware.NetduinoPlus,4.2.2.0    OneWireTestApp,1.0.0.0    CW.NETMF.OneWire,1.0.0.0    SecretLabs.NETMF.Hardware,4.2.0.0

But CW2 sample application does not work. If I start it, using the Debugger I get an [font="arial, helvetica, sans-serif;"]'System.NotSupportedException' occurred in OneWireTestApp.exe'[/font]

when the follwing line is executed:

oneWire = new OneWire(Pins.GPIO_PIN_D8);

Any ideas what goes wrong here? For me it Looks as the CLR can't find the entrypoint for CW2 OneWire functions. But why?

 

Regards,

 Chris



#36 ToniA

ToniA

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 18 August 2013 - 06:10 PM

This is .NET Micro 4.2. You should use the native .NET Micro 1-wire interfaces. The low-level code is CW2's code.






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.