cancel
Showing results for 
Search instead for 
Did you mean: 

Code Generation - USB OTG HS STM32H723ZGT6

MatthewsEffects
Associate III

Ran into a issue with a fresh blank project, only USB OTG HS turned on. 
Computer would recognize the usb device but as soon as I would turn any level of optimization on the computer would no longer detect the usb and show it as connected. 

 

I was able to load a usb HID mouse example with no problems which meant this was a code issue somewhere. 
Through process of elimination i was able to track down that the only real difference between the projects was 3 lines of code in the usbd_desc.c file. 

on line 377  is function "static void Get_SerialNum(void)"
in it the following code. 

static void Get_SerialNum(void)

{

uint32_t deviceserial0;

uint32_t deviceserial1;

uint32_t deviceserial2;

deviceserial0 += deviceserial2;

if (deviceserial0 != 0)

{

IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);

IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);

}

}

 

 

as you might notice these lines are uniniatlized, this is the code generating bug. 

 

uint32_t deviceserial0;

uint32_t deviceserial1;

uint32_t deviceserial2;

 

by simply changing those 3 lines to the following i was able to get usb communication working even with optimized for speed level or any optimization. 

 

uint32_t deviceserial0, deviceserial1, deviceserial2;

deviceserial0 = *(uint32_t *) DEVICE_ID1;

deviceserial1 = *(uint32_t *) DEVICE_ID2;

deviceserial2 = *(uint32_t *) DEVICE_ID3;

 

This appears to be a error in the code generation of the stm32cube ide as I've tried/tested on multiple fresh/new projects for this chip and it always has this issue. 

Leaving these undefined seems to cause a problem once optimization is turned on. 

1 ACCEPTED SOLUTION

Accepted Solutions
STTwo-32
ST Employee

Hello @MatthewsEffects 

This is a known issue that has been fixed on the last Release of the STM32CubeMX (V6.11.1). Please update to this version to obtain the correction.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
STTwo-32
ST Employee

Hello @MatthewsEffects 

This is a known issue that has been fixed on the last Release of the STM32CubeMX (V6.11.1). Please update to this version to obtain the correction.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.