-
Notifications
You must be signed in to change notification settings - Fork 1k
Serial USB on STM32G431KB not working #1283
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
Hi @JiriBilek
Unfortunately, I will be able to investigate this soon as I'm busy on other task to release the core 2.0.0. |
@fpistm Thanks for your reply. BTW, I looked at |
Right, I've tested with Nucleo G474RE. |
Just update:
|
Hi @JiriBilek As a workaround you can add this in your sketch to have USB: extern PCD_HandleTypeDef g_hpcd;
extern "C" void USB_LP_IRQHandler(void)
{
HAL_PCD_IRQHandler(&g_hpcd);
} I will provide soon a fix for this. |
Hi @fpistm , |
Thanks for the feedback. |
Fix stm32duino#1283 Signed-off-by: Frederic Pillon <[email protected]>
Fix stm32duino#1283 Signed-off-by: Frederic Pillon <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
First I want to thank you for the effort in maintaining this library for us. I like the opportunity to quickly create an app for various STM32 MCUs.
The problem I am going to describe is related to my custom board.
If this library and its support is constrained to STM32 Boards only, please feel free to close this issue.
My device
I made a custom board with STM32G431KB. The board works fine with eclipse compiled code not related to Arduino (CubeMX generated). As I realized the board is quite similar to Nucleo-G431KB, I was curious if the board would work with stm32duino. The basic difference between my board and the Nucleo is that I don't solder the oscillator and hence don't use external clock (HSE).
Describe the bug
I am stuck with the USB CDC. The board runs fine in other configurations but selecting any of the two USB Support (if available): CDC options causes the board to freeze on start (it never reaches setup() function) and the PC is reporting unrecognized USB Device.
The board does not freeze when selecting the HID (keyboard and mouse) option but I can't test it if it works somehow :-(
To Reproduce
Try any sketch and compile it with USB Support: CDC option.
Desktop:
Board:
Custom design based on STM32G431KBT6, similar to Nucleo-G431KB except the external oscillator is not soldered on mine board. USB CDC runs fine on code generated with CubeMX.
Additional context
The lack of the external oscillator should not be an issue, I learned from the code that this library doesn't use it anyway.
Arduino_Core_STM32/variants/NUCLEO_G431KB/variant.cpp
Line 61 in 5a0dcfc
I somehow traced the application from the start and found that the clock setup may be wrong. However, after fixing it (code posted below), the execution of the code ends on
Arduino_Core_STM32/system/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd.c
Line 971 in 5a0dcfc
From this call the processor never returns. It may be related with the USB enumeration process that's interrupt driven but tracing this is unfortunately over my abilities.
Fixing the clock setup
I think the USB Clock domain must be enabled. As I am not able to test it on Nucleo board I am inserting the code here instead of making a PR.
It is replacement of the function:
Arduino_Core_STM32/variants/NUCLEO_G431KB/variant.cpp
Line 59 in 5a0dcfc
My other thoughts
I compared stm32g4xx_hal_pcd.c file with mine generated by MXCube on another project and they are different. I tried to replace this file but it didn't help. It was only a shot in the dark, I don't think it's a good idea to change only one file in the HAL layer.
The text was updated successfully, but these errors were encountered: