-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add DWC2 cache maintenance routines for STM32 #2963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
e84efd2
e19ff3e
37316e0
424d743
ea02e92
970c8b7
211c2e3
ffab23c
3287cfa
3eb0451
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,15 +35,19 @@ | |
/* Entry Point */ | ||
ENTRY(Reset_Handler) | ||
|
||
/* Highest address of the user mode stack */ | ||
_estack = ORIGIN(DTCM) + LENGTH(DTCM); /* end of "DTCM" Ram type memory */ | ||
|
||
_Min_Heap_Size = 0x200; /* required amount of heap */ | ||
_Min_Stack_Size = 0x400; /* required amount of stack */ | ||
|
||
__FLASH_BEGIN = 0x08000000; | ||
__FLASH_SIZE = 0x00010000; | ||
|
||
|
||
__RAM_BEGIN = 0x24000000; | ||
__RAM_SIZE = 0x4FC00; | ||
__RAM_NONCACHEABLEBUFFER_SIZE = 0x4000; | ||
__RAM_NONCACHEABLEBUFFER_SIZE = 0x400; | ||
|
||
/* Memories definition */ | ||
MEMORY | ||
|
@@ -59,9 +63,6 @@ MEMORY | |
FLASH (xrw) : ORIGIN = __FLASH_BEGIN, LENGTH = __FLASH_SIZE | ||
} | ||
|
||
/* Highest address of the user mode stack */ | ||
_estack = ORIGIN(DTCM) + LENGTH(DTCM); /* end of "DTCM" Ram type memory */ | ||
|
||
/* Sections */ | ||
SECTIONS | ||
{ | ||
|
@@ -99,14 +100,14 @@ SECTIONS | |
. = ALIGN(4); | ||
} >FLASH | ||
|
||
.ARM.extab : | ||
.ARM.extab (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | ||
{ | ||
. = ALIGN(4); | ||
*(.ARM.extab* .gnu.linkonce.armextab.*) | ||
. = ALIGN(4); | ||
} >FLASH | ||
|
||
.ARM : | ||
.ARM (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | ||
{ | ||
. = ALIGN(4); | ||
__exidx_start = .; | ||
|
@@ -115,7 +116,7 @@ SECTIONS | |
. = ALIGN(4); | ||
} >FLASH | ||
|
||
.preinit_array : | ||
.preinit_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | ||
{ | ||
. = ALIGN(4); | ||
PROVIDE_HIDDEN (__preinit_array_start = .); | ||
|
@@ -124,7 +125,7 @@ SECTIONS | |
. = ALIGN(4); | ||
} >FLASH | ||
|
||
.init_array : | ||
.init_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | ||
{ | ||
. = ALIGN(4); | ||
PROVIDE_HIDDEN (__init_array_start = .); | ||
|
@@ -134,7 +135,7 @@ SECTIONS | |
. = ALIGN(4); | ||
} >FLASH | ||
|
||
.fini_array : | ||
.fini_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | ||
{ | ||
. = ALIGN(4); | ||
PROVIDE_HIDDEN (__fini_array_start = .); | ||
|
@@ -182,7 +183,7 @@ SECTIONS | |
{ | ||
__NONCACHEABLEBUFFER_BEGIN = .;/* create symbol for start of section */ | ||
KEEP(*(noncacheable_buffer)) | ||
__NONCACHEABLEBUFFER_END = .; /* create symbol for start of section */ | ||
__NONCACHEABLEBUFFER_END = .; /* create symbol for end of section */ | ||
} > RAM_NONCACHEABLEBUFFER | ||
|
||
/* User_heap_stack section, used to check that there is enough "DTCM" Ram type memory left */ | ||
|
@@ -196,6 +197,11 @@ SECTIONS | |
. = ALIGN(8); | ||
} >DTCM | ||
|
||
.dtcm_data : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we remove this, and use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it's possible, MPU config need to be added to BSP to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wait, does the current code configure this section as non-cacheable, while noncacheable_buffer section need extra works, or both of them need to be configured the same way ? if removing this requires extra works, then we can keep it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I've added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so it is possible to use the default noncacheable_buffer section instead of adding new one. That would allow us to use the stock IAR linker as well ? You may want to pull first, since, I push the fix for the linker issue with clang (need to have memory value before provide, and drop the READONLY keywords) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think so, hope MPU config generated by Cube support both compilers. But the default size of 0x400 is too small for RTT buffer. |
||
{ | ||
*(dtcm_data) | ||
} >DTCM | ||
|
||
/* Remove information from the compiler libraries */ | ||
/DISCARD/ : | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,39 +36,39 @@ | |
#endif | ||
|
||
//------------- Device DCache declaration -------------// | ||
#define TUD_EPBUF_DCACHE_SIZE(_size) (CFG_TUD_MEM_DCACHE_ENABLE ? \ | ||
#define TUD_EPBUF_DCACHE_SIZE(_size) (TUD_EPBUF_DCACHE_ALIGNED ? \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why we need to replace CFG_TUD_MEM_DCACHE_ENABLE by TUD_EPBUF_DCACHE_ALIGNED, DCACHE when enabled is certainly required the memory to be in cache line alginment ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My idea is to control DCache alignment not only by
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the point to introduce
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, let me keep it simple. |
||
(TU_DIV_CEIL(_size, CFG_TUD_MEM_DCACHE_LINE_SIZE) * CFG_TUD_MEM_DCACHE_LINE_SIZE) : (_size)) | ||
|
||
// Declare an endpoint buffer with uint8_t[size] | ||
#define TUD_EPBUF_DEF(_name, _size) \ | ||
union { \ | ||
CFG_TUD_MEM_ALIGN uint8_t _name[_size]; \ | ||
uint8_t _name##_dcache_padding[TUD_EPBUF_DCACHE_SIZE(_size)]; \ | ||
TU_ATTR_ALIGNED(TUD_EPBUF_DCACHE_ALIGNED ? CFG_TUD_MEM_DCACHE_LINE_SIZE : 1) uint8_t _name##_dcache_padding[TUD_EPBUF_DCACHE_SIZE(_size)]; \ | ||
} | ||
|
||
// Declare an endpoint buffer with a type | ||
#define TUD_EPBUF_TYPE_DEF(_type, _name) \ | ||
union { \ | ||
CFG_TUD_MEM_ALIGN _type _name; \ | ||
uint8_t _name##_dcache_padding[TUD_EPBUF_DCACHE_SIZE(sizeof(_type))]; \ | ||
TU_ATTR_ALIGNED(TUD_EPBUF_DCACHE_ALIGNED ? CFG_TUD_MEM_DCACHE_LINE_SIZE : 1) uint8_t _name##_dcache_padding[TUD_EPBUF_DCACHE_SIZE(sizeof(_type))]; \ | ||
} | ||
|
||
//------------- Host DCache declaration -------------// | ||
#define TUH_EPBUF_DCACHE_SIZE(_size) (CFG_TUH_MEM_DCACHE_ENABLE ? \ | ||
#define TUH_EPBUF_DCACHE_SIZE(_size) (TUH_EPBUF_DCACHE_ALIGNED ? \ | ||
(TU_DIV_CEIL(_size, CFG_TUH_MEM_DCACHE_LINE_SIZE) * CFG_TUH_MEM_DCACHE_LINE_SIZE) : (_size)) | ||
|
||
// Declare an endpoint buffer with uint8_t[size] | ||
#define TUH_EPBUF_DEF(_name, _size) \ | ||
union { \ | ||
CFG_TUH_MEM_ALIGN uint8_t _name[_size]; \ | ||
uint8_t _name##_dcache_padding[TUH_EPBUF_DCACHE_SIZE(_size)]; \ | ||
TU_ATTR_ALIGNED(TUH_EPBUF_DCACHE_ALIGNED ? CFG_TUH_MEM_DCACHE_LINE_SIZE : 1) uint8_t _name##_dcache_padding[TUH_EPBUF_DCACHE_SIZE(_size)]; \ | ||
} | ||
|
||
// Declare an endpoint buffer with a type | ||
#define TUH_EPBUF_TYPE_DEF(_type, _name) \ | ||
union { \ | ||
CFG_TUH_MEM_ALIGN _type _name; \ | ||
uint8_t _name##_dcache_padding[TUH_EPBUF_DCACHE_SIZE(sizeof(_type))]; \ | ||
TU_ATTR_ALIGNED(TUH_EPBUF_DCACHE_ALIGNED ? CFG_TUH_MEM_DCACHE_LINE_SIZE : 1) uint8_t _name##_dcache_padding[TUH_EPBUF_DCACHE_SIZE(sizeof(_type))]; \ | ||
} | ||
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.