-
Notifications
You must be signed in to change notification settings - Fork 3k
USBDevice not working on STM32H743, debug and trace problems #13641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@JojoS62 thank you for raising this issue.Please take a look at the following comments: We cannot automatically identify a release based on the version of Mbed OS that you have provided. |
I'm a step further, Debugging and tracing failed because PA9/PA10 was used for serial output and interferred with VBus/ID detection. These functions are not enabled in USBPhy init, but the AF functions in the PinMap_USB_FS are set.
Excluding PA9/PA10 from PinMap_USB_FS makes no difference. I tried again to use HSI48 as clock source, but in this case USB_CoreReset() runs into timeout when waiting for reset done. Increasing the timeout up to 10 s did not help. It looks also that CRS must be enabled for HSI48 USB clock, but still timeout in USB_CoreReset(). |
After lots of testing, I found a sensible line in the HAL code in mbed-os/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_ll_usb.c Lines 1078 to 1086 in 6642394
When stepped through this code, I got more communication. I increased the HAL_Delay from 3 to 200ms and now I'm getting the follwing trace:
The delay after clearing the SDIS bit must be >=180 ms, strange long. But the device is still not recognized correctly. My MCU is a H743VI with Revision "V". I 've got same results on a NUCLEO_H743ZI with an older Rev "Y" MCU. A difference is, that on Rev "Y" I can use HSI48 as clock source for USB. On Rev V, HSI48 and PLL1Q do not work, USB is hanging in USB_CoreReset on wait for while((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST). |
Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. |
I've generated a simple USB program in STM32CubeIDE and it works fine. Initialisation is almost the same, but I couldn't find the difference that makes it working. |
Its driving me nuts, it seems to be related to the Mbed ticks. |
You could try to disable deepsleep to check if issue comes when MCU goes in STOP MODE 2 ? |
thanks, I had added a DeepSleepLock already. But it seems to have no effect, It looks also like the deepsleep (deep power down) is disabled when a debugger is attached. |
But this seems to be the origin of the problem. Now I have removed "SLEEP" from the target and USB and timer is running. |
I have checked again lp_ticker. The configuration with LSE seems to be ok, but the wakeup interrupts are fired very slow and randomly, in a range of about 30 ... 150 s. Then I routed LSE to MCO1 and I have seen no clock here, so that was a hardware problem, something wrong with the 32k xtal. Then I have changed lp_ticker to use LSI and now the MCU wakes up as intended. But with this config, USB does not work, ints are not fired. USB is only working with "target.device_has_remove": ["SLEEP"], what I still don't understand. Shouldn't be a call to sleep_manager_unlock_deep_sleep(); enough? |
I have checked again lp_ticker. The configuration with LSE seems to be ok, but the wakeup interrupts are fired very slow and randomly, in a range of about 30 ... 150 s. Then I routed LSE to MCO1 and I have seen no clock here, so that was a hardware problem, something wrong with the 32k xtal. Then I have changed lp_ticker to use LSI and now the MCU wakes up as intended. But with this config, USB does not work, ints are not fired. USB is only working with
|
Call sleep_manager_lock_deep_sleep(), not unlock ? |
I think I've got it, that was really hard. and adding this to USBPhyHw::init for USE_USB_OTG_FS is working now:
Its strange that ULPI clock must be disabled, but without it is also not working. I found a comment above the HAL macros
|
yes, I have used lock, not unlock. That was a copy error. |
Made some grep... |
yes, that works also, only disabling ULPI sleep clock. So the comment about default is clock enabled is true. I have used a CubeMX project as reference and it worked, but more likely because it does not use WFI for sleeping. |
I have tested this fix also for the new target H7A3 from your PR. It works also, but some devices have two USB interfaces and it is not clear for me which to use. Now I do
There are macros without interface number, but they were moved to the legacy hal folder. |
yes, fixed. |
Description of defect
I tried to activate USBDevice on a custom target with Devebox H743 board. The USB code compiles for this target, but the host does not get a valid USB device information. The same issue is observed on a Nucleo H743ZI2 board and reported in the forum:
https://forums.mbed.com/t/mbed-nucleo-h7743zi2-doesnt-support-usbdevice/8241/7
So it does not look target hardware specific.
Tests with different sources for USB clock (HSI48, PLL3Q) were not successfull. So I tried to set breakpoints in the HAL_USB callbacks. These breakpoints were not hit. Only when I set a breakpoint in USBPhyHw::_usbisr(void) the target stops and after continue, also the bp in the SOF callback is reached.
Next step was to add tr_info() calls and enable mbed_trace. This did not work also. An initial printf("hello world\n") is printed, followed by a 0xff hex.
A test with the same program and modified USBPhy_STM32.cpp on a F401 MCU is working as expected. The USBMidi is recognized by the windows host and midi output from the sample code is generated. The trace outputs from the callbacks are pinted as well.
Don't know it it maybe related to this H743 issue:
#11422
Target(s) affected by this defect ?
STM32H743xI
NUCLEO_H743ZI2
Toolchain(s) (name and version) displaying this defect ?
GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025
What version of Mbed-os are you using (tag or sha) ?
mbed-os-6.3.0
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
mbed-cli
How is this defect reproduced ?
An updated USBPHy_STM32.cpp with test traces can be found in this branch:
https://github.com/JojoS62/mbed-os/tree/test-USB-H743
The text was updated successfully, but these errors were encountered: