fix(threads/cortex_m): don't save high regs on first schedule #369
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.
Description
I noticed that threading on the nrf5340 is currently broken/ hard faults.
Some debugging showed that the problem is that on run, the
PendSV
tries to stored the r4-r11 registers in a null pointer.This didn't cause any problems on the rpi-pico or nrf54840, but apparently for the nrf5340/ CortexM33 it's problematic.
To fix this, we have to skip storing/ loading of r4-r11 if the pointer is zero, i.e. when there was no previously running thread whose context has to be saved.
An alternative would be to directly in the
sched
code whencurrent_pid.is_none()
return 0 so that no context save/ reload happens, but then thepsp
update would also be skipped and we'd manually have to do that before returning the0
.The PR also includes some small optimizations/ clean-ups in
sched
.Issues/PRs references
The bug was a side-effekt of #262.
Open Questions
Change checklist