hathach / tinyusb

An open source cross-platform USB stack for embedded system
https://www.tinyusb.org
MIT License
4.66k stars 996 forks source link

Race condition/memory corruption on CH32V307 #2650

Closed PoroCYon closed 1 month ago

PoroCYon commented 1 month ago

Operating System

Linux

Board

CH32V307 (using both the SCDZ devboard and a custom board)

Firmware

Provided at https://github.com/PoroCYon/tinyusb-bug-repro --- both a CH32V307 version, and an RP2040 version which does functions correctly.

What happened ?

On the CH32V307, using DFU, the following effects may be observed:

How to reproduce ?

Compile and load the provided firmware onto the chip. Then run dfu-util -D payload.py. Watch how the data in the hexdump changes, the CRC changes (for hard to spot single-byte errors), and how sometimes, hangs/crashes occur.

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

This gist contains three log files:

Screenshots

No response

I have checked existing issues, dicussion and documentation

PoroCYon commented 1 month ago

(cc @gregdavill since he is the author of the driver/backend/port?)

HiFiPhile commented 1 month ago

There is a PR regarding ch32 issues, you can give a try: https://github.com/hathach/tinyusb/pull/2392/

PoroCYon commented 1 month ago

2392 indeed seems to fix the issues, thanks! (Should this issue be closed as a duplicate then?)

HiFiPhile commented 1 month ago

Glad it works, it can be closed once PR merged.