USB Device DMA memory corruption
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-02-21 03:11 AM
Hi,
I am using an STM32F7556NG microcontroller, connecting it to a host PC via USB, with the STM32 acting as a virtual COM port.
I have enabled DMA, an I have noticed very strange behaviour. By supplying a address 0x20024b6C as the DMA address by writing to the DOEPDMA register, after the USB transaction is completed, I have inspected the memory and it seems that SETUP packet data of the the previous SETUP transaction has been written to the address 0x20024B54, which is 6 words before the given DMA address! After viewing the memory of the chip in a memory browser, the SETUP packet for the last transaction can be found at 0x40060081, which is way beyond the USB FIFO, which is very strange.
Page 1448 of the reference manual does say that:
'The application must always allocate some extra space in the Receive data FIFO, to be
able to receive up to three SETUP packets on a control endpoint.� The space to be reserved is 10 Words. Three Words are required for the firstSETUP packet, 1 Word is required for the Setup stage done Word and 6 Wordsare required to store two extra SETUP packets among all control endpoints.� 3 Words per SETUP packet are required to store 8 bytes of SETUP data and 4bytes of SETUP status (Setup packet pattern). The core reserves this space in thereceive data.� FIFO to write SETUP data only, and never uses this space for data packets.'Does this mean that a buffer used for DMA should be larger than actually expected? Or even that a large buffer should be used and the DMA address given should be 10 words into the buffer?
Kind regards
Jack
#usb #cdc #dma