Skip to main content
Jackle
Associate II
June 30, 2021
Solved

Can't get STM32G0B1VE USB device work.

  • June 30, 2021
  • 8 replies
  • 10463 views

I use STM32CubeIDE1.6.1 to generate USB device (CDC VCP mode) code for STM32G0B1VE. The PC could not recognize the USB. I tried internal HSI48 clock and PLLQ for USB (clock frequency verified by MCO), I pulled up DP through 1.5k resistor by a GPIO after about 2 seconds once starting the code. I'm using Windows 10. Please help!

@Imen DAHMEN​ 

This topic has been closed for replies.
Best answer by Jackle

I noticed you're using STM32Cube FW_G0 V1.5.0 which is higher version than mine.

So, I downloaded the latest STM32CubeIDE1.7.0. Guess what? It's working now.

I'm not sure what it was. I assume the new version just fixed something.

Thanks go to @MichaelSweden​ @Imen DAHMEN​ @Nawres GHARBI​ 

8 replies

Technical Moderator
June 30, 2021

Hello @Jackle​ ,

First of all, check the USB connection, and try switching to another USB port.

Then, try increase the heap size of the application. You can follow this article USB device not recognized, it may help you on this issue.

 Please keep me informed about your progress on this.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Jackle
JackleAuthor
Associate II
June 30, 2021

I did increase heap to 0x2000 and stack to 0x800 and I tried different port. No luck. Do we have an executable code that I can download to verify the hardware or connection? Did we test the STM32CubeIDE on STM32G0B/C?

Technical Moderator
June 30, 2021

I recommend you to upgrade the ST-Link firmware version using STM32 ST-LINK Utility: go to ST-LINK>firmware update,

 Then disconnect and connect your board.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Jackle
JackleAuthor
Associate II
June 30, 2021

0693W00000BcT5PQAV.pngAs recommended, the upgrade of ST-Link firmware didn't fix the issue. Still can't recognize the USB.

Technical Moderator
June 30, 2021

Did you upgraded the USB driver in the device manager ?

0693W00000BcTA0QAN.pngImen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Jackle
JackleAuthor
Associate II
June 30, 2021

0693W00000BcTMaQAN.pngI did. But it can't recognize my VCP USB. My debugger works fine. It's just the USB I tried to get as VCP doesn't work.

Technical Moderator
July 1, 2021

Hi @Jackle​ ,

It's strange ! Maybe you have an issue with your PC.

Can you please check with other board ?

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Jackle
JackleAuthor
Associate II
July 1, 2021

No, changing PC or board doesn't make any difference.

I can see signals on the DP and DM lines when I just plug in USB.

I suspect it's the PC driver problem or USB device Descriptor problem.

Can you please verify the default setting as shown in the screenshot here?

Please confirm that STM32G0B1VE has been tested with STM32CubeIDE for USB VCP (CDC) device only FS mode so that we will have confidence before digging further. Thanks.

0693W00000BcaYTQAZ.png@Imen DAHMEN​ 

Technical Moderator
July 5, 2021

Hi @Jackle​ ,

I haven't tested this as I'm working from home and I don't have access to that specific board, but that should work.

Have you checked the D+ and D- line? Maybe DP/DM are swapped !

Have you tried to run one of the working STM32Cube examples ? If no, please try this in order to deduce if the problem here seems related to the hardware or software environment or was caused by ST-Link.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Jackle
JackleAuthor
Associate II
July 6, 2021

If I swap DP/DM, then there will be no USB detected even. So, this is not the case. I have tried UART, GPIO, Timer and all work fine.

I don't have a USB example code to try and I don't know where I can find one.

DWeb_2
Associate III
July 5, 2021

The Host will try to send info about the baudrate,... via USB to the device. This config needs to be saved somewhere. For some reason, the ST middleware leaves this up to the user (maybe for multiple VCOM on one chip ??). I had the same problems, and found a solution somewhere in the ST Forum. Can't remember where sadly.

Anyway, search for the file "usbd_cdc_if.c". Search for the function "CDC_Control_FS". Replace the following lines into the appropriate cases:

 case CDC_SET_LINE_CODING: //a host sends the line encoding to this device, save it
 	tempbuf[0]=pbuf[0];
		tempbuf[1]=pbuf[1];
		tempbuf[2]=pbuf[2];
		tempbuf[3]=pbuf[3];
		tempbuf[4]=pbuf[4];
		tempbuf[5]=pbuf[5];
		tempbuf[6]=pbuf[6];
 break;
 
 case CDC_GET_LINE_CODING: //a host wants to read the saved encoding for this device
		pbuf[0]=tempbuf[0];
		pbuf[1]=tempbuf[1];
		pbuf[2]=tempbuf[2];
		pbuf[3]=tempbuf[3];
		pbuf[4]=tempbuf[4];
		pbuf[5]=tempbuf[5];
		pbuf[6]=tempbuf[6];
 break;

tempbuf can be static in the function scope or, as I did it, somewhere on global RAM:

/* USER CODE BEGIN PRIVATE_VARIABLES */
uint8_t tempbuf[7];
/* USER CODE END PRIVATE_VARIABLES */

Good luck!

DWeb_2
Associate III
July 5, 2021

In case that does not solve your problem, try downloading Wireshark. It has a powerful USB sniffer with analytics functions, which might help you.

Amin.TAYEBI
Associate II
July 9, 2021

Hi friend.my suggestion is to test your scenario in another PC, or you can use virtual box and install virtual windows or linux and test your scenario then if there it works or not.

Jackle
JackleAuthor
Associate II
July 9, 2021

It has been tested on two different pcs windows 7 and windows 10. No luck.