cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX H7x5/H7x7 USB CDC bug

Mvan .31
Associate II

Hi there,

I'm using the H7 dual core MCU's and using the M4 core for USB CDC.

There is an issue with using the M4 core with USB CDC.

The reference manual states at page 137 that address 0x1FF00000 - 0x1FF1FFFF is available to the M7 core as "System Memory". For the M4 core it is reserved unfortunately.

This means that reading the "Unique device ID register" is not possible with the M4 core as it's at 0x1FF1E800.

However the Unique device ID register is read in usbd_desc.c at the function Get_SerialNum:

static void Get_SerialNum(void)
{
  uint32_t deviceserial0, deviceserial1, 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);
  }
}
#define         DEVICE_ID1          (UID_BASE)
#define         DEVICE_ID2          (UID_BASE + 0x4)
#define         DEVICE_ID3          (UID_BASE + 0x8)

This means that any STM32CubeMX generated USB CDC code using the M4 will hardfault.

This should be fixed!

Is there any other way of reading the Unique device ID registers from the M4 core?

Thanks.

Melvin

1 REPLY 1
Pavel A.
Evangelist III

The USB "unique serial number" is optional. If accessing that address makes problem, don't use the "serial number" in your design, or make it in any other way.

-- pa