Skip to content

cortex-m-rt linker script symbols are hard to use with thumbv8 MSPLIM #564

@korken89

Description

@korken89

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:

- 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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions