STM32G431 and G474 USB Serial not working - CPU crash

Post here first, or if you can't find a relevant section!
Post Reply
Tazzi
Posts: 20
Joined: Wed Jan 08, 2020 12:45 am

STM32G431 and G474 USB Serial not working - CPU crash

Post 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???
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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?
Tazzi
Posts: 20
Joined: Wed Jan 08, 2020 12:45 am

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

Post 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.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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 ?
Tazzi
Posts: 20
Joined: Wed Jan 08, 2020 12:45 am

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

Post 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?
Tazzi
Posts: 20
Joined: Wed Jan 08, 2020 12:45 am

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

Post 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
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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
Tazzi
Posts: 20
Joined: Wed Jan 08, 2020 12:45 am

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

Post 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:
Post Reply

Return to “General discussion”