Recover after a watchdog reset

50 views
Skip to first unread message

Peter Kwan

unread,
Oct 17, 2012, 5:20:13 AM10/17/12
to lufa-s...@googlegroups.com
I have a project based on a version of LUFA CDC Demo, probably the
Virtual Serial demo running on a 90USB1286. It runs OK but I hit a
snag with the watchdog. After the watchdog does a reset the system
doesn't reconnect. On either Linux or Windows the comm port is no
longer available, although it appears in the device list in Windows.

When it fails I found that USB_DeviceState is set to DEVICE_STATE_Unattached.

I thought that USB_Init() was all that I had to do but this doesn't work.
I then tried USB_Disable() then a four second delay followed by
USB_Init() but that doesn't work either.

The question is, what else do I need to do to restore the availability
of the comm port after the watchdog has done a reset?

Peter

Sebastian Steppeler

unread,
Oct 17, 2012, 5:33:06 AM10/17/12
to lufa-s...@googlegroups.com
what happens if you do a hardware reset? does it work then?
If you have a program talking to the virtual serial and you disconnect the usb port  while it is running you might get into trouble with a blocked driver.
where did you get the info about the device state, that it is unattached?

regards,
Sebastian

2012/10/17 Peter Kwan <peter...@gmail.com>

Peter

--
You received this message because you are subscribed to the Google Groups "LUFA Library Support List" group.
To post to this group, send email to lufa-s...@googlegroups.com.
To unsubscribe from this group, send email to lufa-support...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/lufa-support?hl=en.


Peter Kwan

unread,
Oct 17, 2012, 7:29:31 AM10/17/12
to lufa-s...@googlegroups.com
There is no data being transferred at the time that I trigger the
watchdog. The unattached flag that gets set is one I can trace using
JTAG debug looking at USB_DeviceState. Also the Windows sound signals
a disconnected USB device. On both Windows and Linux it then stays
disconnected, ignoring my call to USB_Init(). On Windows if I unplug
and then replug it boots like normal but Windows thinks that the port
doesn't exist. But on Linux it starts correctly and everything is
working.

Peter

Sebastian Steppeler

unread,
Oct 17, 2012, 7:39:52 AM10/17/12
to lufa-s...@googlegroups.com
okay I ment just the port beeing allocated by i.e. a terminal program. its irrelevant if there is actual data throughput.
is your usb device bus powered?
is the device not listed in the hardware list when you replug it on windows? or is it just not available as com port?

2012/10/17 Peter Kwan <peter...@gmail.com>

Peter Kwan

unread,
Oct 17, 2012, 8:16:57 AM10/17/12
to lufa-s...@googlegroups.com
The sequence is. I connect the unit which is USB bus powered. It comes
up as COM16. I trigger the watchdog by doing while(1); and the unit
disconnects and is no longer in the Device Manager list. The unit does
USB_Init() every 4 seconds but it never is acknowledged. I unplug the
unit and plug it back in again. It appears as COM16 in DeviceManager
but this time it doesn't appear in the list of available COM ports for
my terminal program. However, if I unplug it for longer, say five
minutes then will start normally.
Fortunately it isn't a big deal for me as I don't intend to use it
under Windows.

Donald Delmar Davis

unread,
Oct 17, 2012, 12:47:06 PM10/17/12
to lufa-s...@googlegroups.com
Are you disabling the watchdog immediately in the boot(or bootloader)
sequence?

The watchdog will remain active until you unplug the device and is
probably re-rebooting the chip before it has time to enumerate.

Also (dean I havent checked your code lately but) any bootloaders
should be watchdog aware in that they should disable the watchdog
before doing much else.
otherwise you get stuck in a loop where it never exits the bootloader.

Don.
>>>>> sup...@googlegroups.com.

Dean Camera

unread,
Oct 21, 2012, 9:35:33 AM10/21/12
to LUFA Library Support List
What length of time is the watchdog configured for? The bootloaders
should turn it off, but I may need to move the code earlier in the
initialization -- although even the shortest nominal timeout should be
plenty to run the bootloader startup code.

One thing that springs to mind is that Windows won't acknowledge
devices dropping off and back on the bus very quickly; it will become
confused and won't attempt a re-enumeration. The procedure I generally
follow in my bootloaders when I need to do this is to turn off the USB
interface, wait around 500ms, then perform the jump or watchdog reset.
That time seems sufficient to make the host realize the device needs
to be enumerated again to detect the new firmware.

- Dean

On Oct 17, 2:17 pm, Peter Kwan <peterk.v...@gmail.com> wrote:
> The sequence is. I connect the unit which is USB bus powered. It comes
> up as COM16. I trigger the watchdog by doing while(1); and the unit
> disconnects and is no longer in the Device Manager list. The unit does
> USB_Init() every 4 seconds but it never is acknowledged. I unplug the
> unit and plug it back in again. It appears as COM16 in DeviceManager
> but this time it doesn't appear in the list of available COM ports for
> my terminal program. However, if I unplug it for longer, say five
> minutes then will start normally.
> Fortunately it isn't a big deal for me as I don't intend to use it
> under Windows.
>
> On 17 October 2012 12:39, Sebastian Steppeler <sebion7...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > okay I ment just the port beeing allocated by i.e. a terminal program. its
> > irrelevant if there is actual data throughput.
> > is your usb device bus powered?
> > is the device not listed in the hardware list when you replug it on windows?
> > or is it just not available as com port?
>
> > 2012/10/17 Peter Kwan <peterk.v...@gmail.com>
>
> >> There is no data being transferred at the time that I trigger the
> >> watchdog. The unattached flag that gets set is one I can trace using
> >> JTAG debug looking at USB_DeviceState. Also the Windows sound signals
> >> a disconnected USB device. On both Windows and Linux it then stays
> >> disconnected, ignoring my call to USB_Init(). On Windows if I unplug
> >> and then replug it boots like normal but Windows thinks that the port
> >> doesn't exist. But on Linux it starts correctly and everything is
> >> working.
>
> >> Peter
>
> >> On 17 October 2012 10:33, Sebastian Steppeler <sebion7...@googlemail.com>
> >> wrote:
> >> > what happens if you do a hardware reset? does it work then?
> >> > If you have a program talking to the virtual serial and you disconnect
> >> > the
> >> > usb port  while it is running you might get into trouble with a blocked
> >> > driver.
> >> > where did you get the info about the device state, that it is
> >> > unattached?
>
> >> > regards,
> >> > Sebastian
>
> >> > 2012/10/17 Peter Kwan <peterk.v...@gmail.com>
Reply all
Reply to author
Forward
0 new messages