Flight Controller Crashes/Resets on USB Device Reset / Replug / Reinit from Host device

Description

Steps to reproduce
1. flight controller is connected via USB
2. USB device is

  • reset without unplugging it, for example
    explicit reset via ioctl(fd, USBDEVFS_RESET, 0);
    implicit reset due to host computer reboot, by OS/BIOS

  • physically unplugged and then replugged (while FC remains powered through servo headers) and subsequently initialized by the OS

expected behaviour

  • graceful USB client device re-initialization. No effect on higher order firmware functions or flight control

actual behaviour

  • flight controller reboots (even if in flight , if USB connection is active in flight)

Debug Trace: (useless)
Program received signal SIGTRAP, Trace/breakpoint trap.
0x08000bd4 in ?? ()
(gdb) bt
#0 0x08000bd4 in ?? ()
#1 0xffffffff in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Code to reproduce:

find out dev tree of flight controller and explicitly reset it by sending aproprate ioctl:
on commandline:
$> lsusb | grep Clay
Bus 001 Device 117: ID 20a0:415e Clay Logic

usbreset /dev/bus/usb/001/117

with usbreset code snippet from
https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line

Additional info:
If GCS is connected via USBHID, and the reset is sent, controller does NOT reboot, but the telemetry stream is interrupted. Then two things can happen.
1.
If GCS is manually disconnected and reconnected to the USB device (which might change device ID - sometimes), then this step can be reproduced indefinitely

2. if GCS is kept in its degraded connection state or simply closed and not reconnected, any further RESET ioctl will crash/reset the flight controller. the same happens if GCS was never connected

Environment

STM32f4 for example Openpilot Revolution, revomini, ...

Status

Assignee

Eric Price

Reporter

Eric Price

Labels

None

Components

Fix versions

Affects versions

REL-15.09 - Supermoon Eclipse
REL-17.06
future_release
OP-REL-15.05
REL-16.09 - Black Rhino

Priority

Medium
Configure