tinyusb icon indicating copy to clipboard operation
tinyusb copied to clipboard

synopsys dcd_dwc2 device mode bug

Open ClarkyKent opened this issue 3 years ago • 4 comments

Operating System

Linux

Board

STM32H743x

Firmware

I am using custom FW where FreeRTOS is used and have 2 CDC in device mode. Vbus sensing is enabled.

What happened ?

If I power on the board with USB already connected. Everything is fine. 2 USB com ports get detected on host machine(Linux/Windows) and everything woks fine as intended. But if I power on our board without USB(as board has a battery as main source of power) and I do not attach USB, STM32H743 resets itself as soon as it executes connect dcd_connect(rhport);

How to reproduce ?

In order to reproduce this bug, it is important to have a board which is powered by a battery instead of USB. and then run any example from example. STM32h7 should reset when it tries to connect to USB after dcd_connect(rhport); command.

Debug Log as txt file

No response

Screenshots

No response

ClarkyKent avatar Jun 22 '22 08:06 ClarkyKent

I have kind of found the solution to this. so replying here.

Once I have removed this following line in function dcd_init everything work as as intended. // Clear A override, force B Valid //dwc2->gotgctl = (dwc2->gotgctl & ~GOTGCTL_AVALOEN) | GOTGCTL_BVALOEN | GOTGCTL_BVALOVAL;

Even-though MCU is powered on and stack BLE is initialized, it does not resets itself anymore. and if i connect an USB , it starts to enumerate and it shows USB device on HOST machine.

I do not know if forcing B valid is necessary , and when i see the manual of STM32H7 it states that these registers are available only in Host mode.

image

image

ClarkyKent avatar Jun 22 '22 08:06 ClarkyKent

In order to reproduce this bug, it is important to have a board which is powered by a battery instead of USB. and then run any example from example. STM32h7 should reset when it tries to connect to USB after dcd_connect(rhport); command.

can you specify which example to run and on which specific dev board.

hathach avatar Jun 22 '22 11:06 hathach

Till now I tested on my custom PCB with STM32H743II for dual_cdc (with freertos)

EDIT: After building cdc_msc_freertos example code, on STM32H743ZI nucleo board it seems MCU does not resets itself with Nucleo board. But at the same time if removing line in dcd_init as stated in my previous post does not have any negative effect as well.

I will investigate further and let you know.

ClarkyKent avatar Jun 22 '22 13:06 ClarkyKent

also, on your custom board, did the reset happen with bare-metal example e.g cdc_msc (without freertos) ?

hathach avatar Jun 24 '22 05:06 hathach