circuitpython: hard fault on serial disconnect on MacroPad RP2040
CircuitPython version
Adafruit CircuitPython 9.0.0-alpha.6-33-g9f016796e0-dirty on 2024-01-22; Adafruit Macropad RP2040 with rp2040
Code/REPL
# N/A; also happens with freshly reformatted CIRCUITPY drive
Behavior
soft reboot
Auto-reload is off.
Running in safe mode! Not running saved code.
You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Hard fault: memory access or instruction error.
Please file an issue with your program at github.com/adafruit/circuitpython/issues.
Press reset to exit safe mode.
Press any key to enter the REPL. Use CTRL-D to reload.
Description
Happens after some random number of serial disconnects, either at the REPL or at the “code done running” prompt. Only tested using tio
on macOS 13.6.3. The CIRCUITPY volume also unmounts, with a warning about unsafe unmount, so I’m guessing it actually detached from USB in the process.
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 49 (4 by maintainers)
Note that
hw_endpoint_lock_update()
is null, so calls tohw_endpoint_start_next_buffer()
are unprotected against concurrent calls from user and IRQ level.@eightycc thanks so much for the coordinated traces! The Beagle trace confirms what I’ve seen before in a previous context: some CDC control requests sent by macOS are aborted. It also confirms that my suspicions are likely correct, that the RP2040 hardware doesn’t clear some state for a SETUP packet that it probably should.
There are 4 OUT control transfers of length 7, which are CDC Set Line Coding, followed by 3 no-data control transfers, which are CDC Set Control Line State.
The first 2 Set Control Line State are aborted, and simply doesn’t poll the status stage for the third, for some reason.
There are 3
hw_endpoint_xfer_start ep 0 in 0
in the trace, corresponding to the status stage of the Set Line Coding, followed by the status stages of the 2 Set Control Line State. The second one panics due to an existing active transfer.It’s likely to be a lower-level problem, possibly with the Pico SDK. On a hunch, I uploaded a Blink sketch from the Arduino IDE, Philhower core v3.6.2. connecting and then disconnecting with
tio
causes the program to freeze and the device to become unresponsive on USB CDC until physically reset.I’m causing the disconnects by exiting
tio
by using Ctrl-T Q. That shouldn’t cause a hard fault in CircuitPython.