Skip to content
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

Ensure that stack pointer is correctly aligned during thread creation on MSP430 #881

Merged
merged 1 commit into from
Mar 17, 2014
Merged

Ensure that stack pointer is correctly aligned during thread creation on MSP430 #881

merged 1 commit into from
Mar 17, 2014

Conversation

rousselk
Copy link
Contributor

I encountered an error on my beta Z1 port during enter_ISR(), because of an odd (mis-aligned SP register).

When debugging, I noticed the lack of a correct check for misalignment during thread creation on MSP430. This is my proposed correction.

@rousselk
Copy link
Contributor Author

Maybe would it be a good idea to ensure correct alignment of stack in thread_create() function in core/thread.c, just like the TCB is already aligned on 32-bit boundary in the very same function?


*stk = (unsigned short) sched_task_exit;
--stk;
*stackptr = (unsigned short) sched_task_exit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't the decreasing need to come before the setting, like it was before? In the start stk points to the byte after the end of the stack, doesn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aah, indeed. My bad.
I'm correcting that right away.

@rousselk
Copy link
Contributor Author

Done. SP should now have the right value after thread creation on MSP430 (it surely seems to be so under Cooja).

@Kijewski
Copy link
Contributor

I have no means to test this, but the change looks good. 👍

@OlegHahm
Copy link
Member

Will test ASAP, but agree with @Kijewski: looks good.

Concerning the alignment check in thread.c. @LudwigOrtmann and I thought about this some time ago, but apparently failed to create a ticket.

@OlegHahm OlegHahm self-assigned this Mar 15, 2014
@OlegHahm OlegHahm added this to the Release NEXT MAJOR milestone Mar 15, 2014
@rousselk
Copy link
Contributor Author

Well, these fixes (along with PR #882, and #101 in projects repository) allow me to pass the test_cc2420 test application on Z1.

@OlegHahm
Copy link
Member

Tested on MSB-430h. ACK and go.

OlegHahm added a commit that referenced this pull request Mar 17, 2014
Ensure that stack pointer is correctly aligned during thread creation on MSP430
@OlegHahm OlegHahm merged commit a427cce into RIOT-OS:master Mar 17, 2014
@rousselk rousselk deleted the msp430-stackptr-align branch March 18, 2014 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: MSP Platform: This PR/issue effects MSP-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants