2022-08-07 09:20 AM
I have referred to this document but it gives no solution.
https://community.st.com/s/article/how-to-enable-dma-in-usb-with-stm32h7-devices?t=1659888985140
I have tried putting all the USB variables and arrays into a noncacheable region of AXI1 RAM but the USB is not firing up. I will provide more details of what is happening after I debug...
2022-08-07 09:53 AM
Solved problem...
Sorry this was not true after I reset the device. As Piranha says below it is only the pointer....
I was using CDC and it's buffer was allocated inside the init function:
USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
...
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_HandleTypeDef));
...
}
#define _NO_CACHE_USB_ __attribute__((section (".DATA_RAM_NOCACHE")))
USBD_CDC_HandleTypeDef _NO_CACHE_USB_ *hcdc;static uint8_t
USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
...
hcdc = (USBD_CDC_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_HandleTypeDef));
...
}
After moving it out and assigning it a non cacheable region the USB works as expected
2022-08-07 11:01 AM
You have moved only the pointer to the allocated memory, which doesn't solve anything...
https://community.st.com/s/question/0D50X00009XkZZeSAN/cubemx-static-usbd-setting
2022-08-07 11:08 AM
Indeed it was a red herring.
There is a strange phenomena though... It works immediately after flashing a DCACHE'ed build but only once and it borks afte a reset... wierd.
I also neglected to say that I am using the MPU to set the area of AXI1 RAM to non catchable. (probably obvious).
So, as Piranha rightly pointed out - I only moved the pointer. Therefore I moved hcdc to the stack "hcdc [1]". Still no dice. As far as I can see I have moved all the variables used by HAL_USB to the non cachable region - alas I am shooting in the dark and I suppose a more through understanding of the IP DMA is required on my part