Skip to content

Commit 8b6d0a1

Browse files
committed
Fix host buffer alignment setting
1 parent f1e006d commit 8b6d0a1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/portable/chipidea/ci_hs/ci_hs_imxrt.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ TU_ATTR_ALWAYS_INLINE static inline void imxrt_dcache_clean(void const* addr, ui
7878
TU_ATTR_ALWAYS_INLINE static inline void imxrt_dcache_invalidate(void const* addr, uint32_t data_size) {
7979
const uintptr_t addr32 = (uintptr_t) addr;
8080
if (imxrt_is_cache_mem(addr32)) {
81+
// Invalidating does not push cached changes back to RAM so we need to be
82+
// *very* careful when we do it. If we're not aligned, then we risk resetting
83+
// values back to their RAM state.
84+
// if (addr32 % 32 != 0) {
85+
// TU_BREAKPOINT();
86+
// }
8187
SCB_InvalidateDCache_by_Addr((void*) addr32, (int32_t) data_size);
8288
}
8389
}

src/tusb_option.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,11 @@
431431

432432
// Attribute to align memory for host controller
433433
#ifndef CFG_TUH_MEM_ALIGN
434-
#define CFG_TUH_MEM_ALIGN TU_ATTR_ALIGNED(4)
434+
#ifdef CFG_TUSB_MEM_ALIGN
435+
#define CFG_TUH_MEM_ALIGN CFG_TUSB_MEM_ALIGN
436+
#else
437+
#define CFG_TUH_MEM_ALIGN TU_ATTR_ALIGNED(4)
438+
#endif
435439
#endif
436440

437441
//------------- CLASS -------------//

0 commit comments

Comments
 (0)