2021-09-01 11:54 PM
Hello All,
I have stm32h745I-disco board.
I want USB device as virtual comport.
I use cubeIDE and create project with it.
I am new on this dual core processors.
Thanks to the cubemx it is easy to create a basıc usb code.
When I create a usb_fs code with M7 core it works great.
After that I try to create with M4 core.It use same pins with M7 and cubemx generates code succesfully.
But when I debug the code it enters hardfault at m4 project stm32h7xx_it.c.
it stays in this handler for a while and after that enter hard fault handler.
* @brief This function handles USB On The Go FS global interrupt.
*/
void OTG_FS_IRQHandler(void)
{
/* USER CODE BEGIN OTG_FS_IRQn 0 */
/* USER CODE END OTG_FS_IRQn 0 */
HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
/* USER CODE BEGIN OTG_FS_IRQn 1 */
/* USER CODE END OTG_FS_IRQn 1 */
}
here is the call stack .
Best regards.
EMRE
2021-09-02 12:48 AM
I seem to recall that the M4 core can't access the UID which it uses to generate the serial number. No doubt examining the SCB registers would show this, or stepping through the code.
Go into Get_SerialNum and hardcode the serial number instead.
2021-09-02 03:47 AM
Hi TDK,
Thank you for helping.
I changed the Get_SerialNum function as like below.I get the values from M7 code.
deviceserial0 = 0x35813066;
deviceserial1 = 0x34385119;
deviceserial2 = 0x35383030;
// deviceserial0 = *(uint32_t *) DEVICE_ID1;
// deviceserial1 = *(uint32_t *) DEVICE_ID2;
// deviceserial2 = *(uint32_t *) DEVICE_ID3;
And it works now.
So this result gives us M4 could not reach these memory locations.
Do you have any idea about this.
Thanks.
EMRE
2021-09-02 11:43 AM
> Do you have any idea about this.
As I guessed, the M4 core can't access the UID register. What are you looking for? Do you think it should be able to or just want a code check?
The replacement code looks good. Note that it will give the same serial number for all boards, which isn't allowed for USB. But if you only have one board, it's fine.
2021-09-03 01:43 AM
Hi TDK,
I did not expect this result.I think the genereted code needs to handle this stuation.
After that I check document of processor.
UID resgisters adres is this.
#define UID_BASE (0x1FF1E800UL) /*!< Unique device ID register base address */
when I check the memory map as the image below.M4 at this location is reserved so only M7 read this.
Am I rigth?
Thanks for your help.
Regards.
EMRE
2021-09-03 12:04 PM
Yes, the M7 can read it and the M4 can't. As stated before.