2024-09-20 02:04 AM
when i used the usb_host and opened the dma and dcache, the usb cannot work I have divided the memory area used by USB DMA into RAM-D2,I have configured R2 MPU_ACCESS_NOT_BUFFERABLE , MPU_ACCESS_NOT_CACHEABLE , MPU_ACCESS_NOT_SHAREABLE and
MPU_TEX_LEVEL1 and when I turn off DCAHCE, USB host and dma can be used normally,or I can use SCB->CACR |= SCB_CACR_FORCEWT_Msk And use __DSB() in the HAL_SCD_ShenfyURBChange_Callback function; It can also be used, but I'm not sure if it will affect performance. Is there any way not to turn off dcache and not to use SCB->CACR |= SCB_CACR_FORCEWT_Msk for dcache.
But I use USB_OTG_FS dma enable=ENABLE and turn on dcache to make it work as a cdc device, It can work normally,I don't need to turn off dcache or use SCB->CACR |= SCB_CACR_FORCEWT_Msk, but usb_host can not work , i find when i open the dcache and dma in usb host I do get 2-5 trasnfers through, and then it stalls.
Solved! Go to Solution.
2024-09-20 02:23 AM
2024-09-20 02:23 AM
I have continued to address the byte alignment issue regarding DMA
2024-10-10 01:56 AM
Hi @andy817501
Since the USB DMA and cache might not be coherent, you need to ensure that cache lines are properly invalidated before DMA reads and flushed after DMA writes.
To do so, invalidate DCache before DMA Read:
SCB_InvalidateDCache_by_Addr((uint32_t*)buffer, size);
Then, clean DCache after DMA Write:
SCB_CleanDCache_by_Addr((uint32_t*)buffer, size);
Would you mind sharing your workaround?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.