Page 1 of 1

STM32G431 and G474 USB Serial not working - CPU crash

Posted: Mon Jul 12, 2021 4:53 am
by Tazzi
I am currently working with a Nucleo G431 and G474 boards, both are experiencing the same problem where as soon as "USB Support CDC (generic Serial" is selected from the build menu, it appears the CPU never runs the sketch and I believe it is crashing instantly?

With that option enabled, you cannot even blink an LED. As soon as its disabled, it will begin working again.
Here is a basic sketch to run when your build menu has the USB Support CDC selected that has the issue.

Code: Select all

void setup()
{
	pinMode(PA5, OUTPUT);
	delay(50);
}

void loop()
{
	digitalWrite(PA5, HIGH);
	delay(500);
	digitalWrite(PA5, LOW);
	delay(500);
}
Any thoughts on what to try???

Re: STM32G431 and G474 USB Serial not working - CPU crash

Posted: Mon Jul 12, 2021 7:21 am
by fpiSTM
Hi @Tazzi

I've just tested with a Nucleo G474RE and it works as expected. Even USB is well enumerated.
Which core version you used ? Arduino IDE version? Other selected options?

Re: STM32G431 and G474 USB Serial not working - CPU crash

Posted: Mon Jul 12, 2021 9:16 am
by Tazzi
I am on the latest core, 2.0.0. On the latest Arduino IDE (1.8.15).
Options selected exactly are:
Board Nucleo G474RE
U(S)ART support Enabled (generic Serial)
USB Support (if available): CDC (generic serial supersesde U(S)ART)
USB speed: Low/Full Speed
Optimize Smallest (-Os default)
C Runtime Library: Newlib Nano (default)
Upload method: SWD

I should have specified, I am talking about using the native CDC USB serial which will be pins PA12 (USB_DP) and PA11(USB_DM).

The Nucleos Serial from the STLink Virtual comport works perfectly fine, but native USB does not work. Whole processor crashes when having USB Support select as per above.

The led blink sketch I did fails if the above is selected.

Re: STM32G431 and G474 USB Serial not working - CPU crash

Posted: Mon Jul 12, 2021 9:38 am
by fpiSTM
Tazzi wrote: Mon Jul 12, 2021 9:16 am I should have specified, I am talking about using the native CDC USB serial which will be pins PA12 (USB_DP) and PA11(USB_DM).

The Nucleos Serial from the STLink Virtual comport works perfectly fine, but native USB does not work. Whole processor crashes when having USB Support select as per above.

The led blink sketch I did fails if the above is selected.
I know about the USB selected and I've tested with USB enable. As I mentioned in my previous post, USB is well enumerated.
Did you made some HW change on the Nucleo? Do you wired something on PA11/PA12 and How ?

Re: STM32G431 and G474 USB Serial not working - CPU crash

Posted: Mon Jul 12, 2021 11:54 pm
by Tazzi
fpiSTM wrote: Mon Jul 12, 2021 9:38 am I know about the USB selected and I've tested with USB enable. As I mentioned in my previous post, USB is well enumerated.
Did you made some HW change on the Nucleo? Do you wired something on PA11/PA12 and How ?
Oh ok. I did a second fresh install of arduino and 2.0 core onto another computer, and the exact same issue occurs. As soon as USB CDC is enabled, the processor does not run at all. When USB is disabled, the LED indicator flashes which is all the sketch is setup to do.

There is no hardware or modifications to either Nucleo board. I know USB works since if I connect to PA11/PA12 and then use STM32cube IDE with a CDC USB example, it enumerates and displays in device manager.

Are you possibly on a newer commit of the new 2.0 core? Maybe something has been changed?

Re: STM32G431 and G474 USB Serial not working - CPU crash

Posted: Tue Jul 13, 2021 3:35 am
by Tazzi
Ok so just downloaded the latest commit from git, and USB works now.

The official 2.0.0 release does not work for USB though.

As of today, latest release was this: https://github.com/stm32duino/Arduino_C ... a39cd39731

Re: STM32G431 and G474 USB Serial not working - CPU crash

Posted: Tue Jul 13, 2021 12:24 pm
by fpiSTM
Tazzi wrote: Tue Jul 13, 2021 3:35 am Ok so just downloaded the latest commit from git, and USB works now.

The official 2.0.0 release does not work for USB though.

As of today, latest release was this: https://github.com/stm32duino/Arduino_C ... a39cd39731
Damned, I've forgot to set my git on 2.0.0 tag.
So yes, I've made some fix around USB. Just to be precise your link is not a release just a commit:

As of today, latest commit was this: https://github.com/stm32duino/Arduino_C ... a39cd39731

Re: STM32G431 and G474 USB Serial not working - CPU crash

Posted: Fri Jul 16, 2021 3:45 am
by Tazzi
fpiSTM wrote: Tue Jul 13, 2021 12:24 pm
Tazzi wrote: Tue Jul 13, 2021 3:35 am Ok so just downloaded the latest commit from git, and USB works now.

The official 2.0.0 release does not work for USB though.

As of today, latest release was this: https://github.com/stm32duino/Arduino_C ... a39cd39731
Damned, I've forgot to set my git on 2.0.0 tag.
So yes, I've made some fix around USB. Just to be precise your link is not a release just a commit:

As of today, latest commit was this: https://github.com/stm32duino/Arduino_C ... a39cd39731
Oh thankyou for that clarification!!

Next will be playing with the FD CAN implementation, I believe Iv seen a couple threads about it... I am sure I will be back with something else to work out :lol: