-
Notifications
You must be signed in to change notification settings - Fork 177
Description
Hi all,
I'm adding flip-link-like functionality to a project using a Cortex-M33, so I plan to set MSPLIM to the end of statically
allocated RAM. I checked the cortex-m-rt crate for available public symbols to set MSPLIM, and I want to set it to __euninit, which is where the stack and statically allocated memory collide. However, there isn't a public symbol for this. Moreover, double-underscore symbols are private as stated here:
cortex-m/cortex-m-rt/link.x.in
Lines 3 to 7 in 6a324a8
| - Symbols that start with a double underscore (__) are considered "private" | |
| - Symbols that start with a single underscore (_) are considered "semi-public"; they can be | |
| overridden in a user linker script, but should not be referred from user code (e.g. `extern "C" { | |
| static mut __sbss }`). |
What would be the best course of action here?
To me it seems that either one adds a feature like set-msplim to cortex-m to extend cortex_m::register::msplim with a method that uses the internal symbol from cortex-m-rt, or add a public symbol in cortex-m-rt to indicate "end of statically allocated memory" so users can setup MSPLIM themselves in pre_init.
Right now I'll do the following, but it is technically allowed to break in any patch release (even if we don't do that in practice):
#[cortex_m_rt::pre_init]
unsafe fn pre_init() {
extern "C" {
static __euninit: u32;
}
msplim::write(addr_of!(__euninit) as u32);
}