cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX 6.11 USB CDC Code Generation Bug

Eralp
Associate III

When i moved to new version of CubeMX and regenerate code for my H7 USB project i got compiler warning about some variables. Here is difference between old and new generated usbd_desc.c file;

Old file:

static void Get_SerialNum(void)
{
  uint32_t deviceserial0;
  uint32_t deviceserial1;
  uint32_t deviceserial2;

  deviceserial0 = *(uint32_t *) DEVICE_ID1;
  deviceserial1 = *(uint32_t *) DEVICE_ID2;
  deviceserial2 = *(uint32_t *) DEVICE_ID3;

  deviceserial0 += deviceserial2;

  if (deviceserial0 != 0)
  {
    IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
    IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
  }
}

 

New file:

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 can see deviceserial0, deviceserial1 and deviceserial2 variables defined but not assigned.

I fixed it myself, here is the solution in usbddesc_c.ftl file for M4 and M7 cores:

From: (at line 728 and 735)

[#if cpucore=="ARM_CORTEX_M4"]
[#elseif cpucore=="ARM_CORTEX_M7"]

To:

[#if cpucore=="ARM_CORTEX_M4" && (CLASS_FS=="CDC" | CLASS_HS=="CDC")]
[#elseif cpucore=="ARM_CORTEX_M7" | CLASS_FS!="CDC" | CLASS_HS!="CDC"]
1 ACCEPTED SOLUTION

Accepted Solutions
Mahmoud Ben Romdhane
ST Employee

Hello @Eralp 

Thank you for reporting.

Actually, this issue has been already reported internally to Dev team for correction (under internal ticket number 177153) and this will be fixed ASAP.

I suggest that you take a look at this Post.

Thanks.

Mahmoud

View solution in original post

1 REPLY 1
Mahmoud Ben Romdhane
ST Employee

Hello @Eralp 

Thank you for reporting.

Actually, this issue has been already reported internally to Dev team for correction (under internal ticket number 177153) and this will be fixed ASAP.

I suggest that you take a look at this Post.

Thanks.

Mahmoud