2025-01-20 04:46 AM
STM32CubeMX 6.13.0
MCU: STM32H747
The generated code for USB device, class: CDC on Core M4 causes HardFault.
The reason is the following definitions in the usbd_desc.c file:
#define DEVICE_SERIAL0 (*(uint32_t *) 0x11223344)
#define DEVICE_SERIAL1 (*(uint32_t *) 0x55667788)
#define DEVICE_SERIAL2 (*(uint32_t *) 0x12345678)
The code should probably look like this:
#define DEVICE_SERIAL0 (0x11223344)
#define DEVICE_SERIAL1 (0x55667788)
#define DEVICE_SERIAL2 (0x12345678)
Note: the literals come from the STM32CubeMX tool:
The code for the M7 core uses the UID for a serial number, but the M4 core does not have access to the system memory region.
Regards,
Peter