P0: Gyro Cal button causes USB disconnect — "The device has been lost" #42

Closed
opened 2026-02-28 22:02:32 -05:00 by seb · 0 comments
Owner

Bug

Pressing GYRO CAL in the web UI sends the G command. The FC disconnects immediately — WebSerial reports "Read error: The device has been lost."

Likely cause

mpu6000_calibrate() blocks for ~1 second (1000 samples). During that time:

  • safety_refresh() (IWDG watchdog) is NOT being called frequently enough
  • IWDG fires at 50ms timeout → MCU hard resets → USB disconnects

PR #39 added a safety_refresh() call every 40 iterations inside the recal block, but mpu6000_calibrate() itself is a blocking loop that does NOT call safety_refresh() internally. The refresh in main.c only runs AFTER calibrate returns — too late.

Fix

Add safety_refresh() calls INSIDE mpu6000_calibrate() loop — e.g. every 10 samples. Or temporarily increase IWDG timeout before recal. Or feed the watchdog in the SysTick handler during calibration.

Priority

P0 — button exists in UI but crashes the connection.

## Bug Pressing GYRO CAL in the web UI sends the `G` command. The FC disconnects immediately — WebSerial reports "Read error: The device has been lost." ## Likely cause `mpu6000_calibrate()` blocks for ~1 second (1000 samples). During that time: - `safety_refresh()` (IWDG watchdog) is NOT being called frequently enough - IWDG fires at 50ms timeout → MCU hard resets → USB disconnects PR #39 added a `safety_refresh()` call every 40 iterations inside the recal block, but `mpu6000_calibrate()` itself is a blocking loop that does NOT call `safety_refresh()` internally. The refresh in main.c only runs AFTER calibrate returns — too late. ## Fix Add `safety_refresh()` calls INSIDE `mpu6000_calibrate()` loop — e.g. every 10 samples. Or temporarily increase IWDG timeout before recal. Or feed the watchdog in the SysTick handler during calibration. ## Priority **P0** — button exists in UI but crashes the connection.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#42
No description provided.