-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Cortex-M: initial stack alignment #2976
Merged
kaspar030
merged 2 commits into
RIOT-OS:master
from
jnohlgard:pr/cortex-m-initial-stack-alignment
May 18, 2015
Merged
Cortex-M: initial stack alignment #2976
kaspar030
merged 2 commits into
RIOT-OS:master
from
jnohlgard:pr/cortex-m-initial-stack-alignment
May 18, 2015
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AAPCS requires stack pointers to be aligned on a double word boundary. In addition, Clang-3.6 assumes the stack pointer is always aligned to a 8 byte boundary upon function entry, at least in armv7-m, causing hard-to-find errors in the compiled code.
AAPCS requires stack pointers to be aligned on a double word boundary. In addition, Clang-3.6 assumes the stack pointer is always aligned to a 8 byte boundary upon function entry, at least in armv7-m, causing hard-to-find errors in the compiled code. This is the same implementation as for the Cortex-M4
I have tested on CM4, but not CM3. Could someone test this on a CM3 board? To verify:
|
Verified on Cortex-M3 for STM32F103. |
ACK, but I would like to have some of the hardware guys to take another look. |
@kaspar030, ping! |
Well, looks OK, doesn't break anything as far as I can see. ACK. |
kaspar030
added a commit
that referenced
this pull request
May 18, 2015
cortex-m: initial stack alignment to 64bit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Platform: ARM
Platform: This PR/issue effects ARM-based platforms
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The initial stack passed to the thread entry point was always anti-aligned to a 64 bit boundary (meaning the address is aligned to 32 bit, and never to 64 bits)
The cause is bit 9 in xPSR being set in the stacked xPSR when initializing the thread stack in
thread_arch_stack_init
.I have changed the initialization for Cortex-M3 and Cortex-M4 to clear the faulty bit and also cleaned up the comments a bit and added extra handling for aligning the stack on a 64-bit boundary.
Procedure Call Standard for the ARM® Architecture requires that the stack pointer is aligned on a 8 byte boundary upon function entry. Clang relies on this behaviour which caused problems in
auto_init_net_if
on mulle, but I am guessing this is not the only location where this caused problems. GCC does not seem to assume 64 bit alignment, at least not with-Os
and lower.