[audio_device] Allow user-defined memory attributes for DMA buffers #3427
yamamo2shun1
started this conversation in
General
Replies: 1 comment
-
It's not how it works. When DMA is enabled, DWC2 doesn't support transfer directly into/from fifo, a linear buffer is used, that's why CFG_TUD_EDPT_DEDICATED_HWFIFO=0. USB->lin_buf_out->ep_out_sw_buf
tu_static CFG_TUD_MEM_SECTION struct {
#if CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX > 0
TUD_EPBUF_DEF(buf_1, CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX);
#endif
#if CFG_TUD_AUDIO > 1 && CFG_TUD_AUDIO_FUNC_2_EP_OUT_SZ_MAX > 0
TUD_EPBUF_DEF(buf_2, CFG_TUD_AUDIO_FUNC_2_EP_OUT_SZ_MAX);
#endif
#if CFG_TUD_AUDIO > 2 && CFG_TUD_AUDIO_FUNC_3_EP_OUT_SZ_MAX > 0
TUD_EPBUF_DEF(buf_3, CFG_TUD_AUDIO_FUNC_3_EP_OUT_SZ_MAX);
#endif
} lin_buf_out;Your hardfault is caused something else. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Environment
CFG_TUD_DWC2_DMA_ENABLE=1)Problem
When using DWC2 in DMA mode (
CFG_TUD_DWC2_DMA_ENABLE=1) on Cortex-M7 withDCache enabled, the audio class buffers cause cache coherency issues.
Root Cause
In audio_device.c#L76-L85,
IN_SW_BUF_MEM_ATTRandOUT_SW_BUF_MEM_ATTRuse
TU_ATTR_ALIGNED(4)whenCFG_TUD_EDPT_DEDICATED_HWFIFO=0.However, per tusb_option.h#L311-L319,
CFG_TUD_EDPT_DEDICATED_HWFIFO=1is only set for Slave mode, not DMA mode.
This means DMA mode uses software buffers (
ep_in_sw_buf,ep_out_sw_buf)that are accessed by DMA but placed in cacheable memory.
Proposed Fix
Add
#ifndefguards to allow users to override buffer memory attributes viatusb_config.h:Before (audio_device.c#L76-L85):
After
User configuration (
tusb_config.h):Beta Was this translation helpful? Give feedback.
All reactions