Skip to content

Support region padding for MPU programming#146

Open
thejpster wants to merge 3 commits intorust-embedded:mainfrom
thejpster:support-padding
Open

Support region padding for MPU programming#146
thejpster wants to merge 3 commits intorust-embedded:mainfrom
thejpster:support-padding

Conversation

@thejpster
Copy link
Copy Markdown
Contributor

@thejpster thejpster commented Mar 6, 2026

Make it easier to set up the MPU

  • Add an API to get the various linker output sections (aarch32_rt::region)
  • Adjust link.x to allow for adjustable alignment of regions
  • Adjust link.x to allow for adjustable padding between stacks
  • Add an example that programs the MPU

The MPS3-AN536 padding is set at 64K, so that the normal build and the +d32 build end up with the same memory map (otherwise their output for the mpu_region example would be different).

@thejpster thejpster changed the title Support region padding for MPU programming Support region padding for MPU programming (requires #127) Mar 6, 2026
@thejpster thejpster changed the title Support region padding for MPU programming (requires #127) Support region padding for MPU programming Mar 20, 2026
Copy link
Copy Markdown

@wt wt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything I didn't mention looks okay assuming all the magic numbers in the reference files are correct.

* Add an API to get the various linker output sections (aarch32_rt::region)
* Adjust link.x to allow for adjustable alignment of regions
* Adjust link.x to allow for adjustable padding between stacks
* Add an example that programs the MPU
Copy link
Copy Markdown

@wt wt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a bug as per my comment. PTAL.

I think we were both trying to be a half step too clever to avoid the Option.

Region::Rodata => Region::Bss,
Region::Bss => Region::Data,
Region::Data => Region::Uninit,
Region::Uninit => return None,
Copy link
Copy Markdown

@wt wt Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will Uninit ever be returned? I think when self.current is Uninit on entry to this function, it will return None (never returning old in that case) and skip over returning the Uninit enum.

I think making self.current an Option and then making all the current arms valued with Some(x) (no return statement) and None with returning None will fix that.

FWIW, I also wondering if we should rename self.current to self.next and old to current.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmm, that explains why the build actions hung.

As suggested in code review, now we're less likely to forget to update the
Iterator when adding new regions/stacks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants