-
Notifications
You must be signed in to change notification settings - Fork 1.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
Detect more startup config errors on Cortex M #832
Detect more startup config errors on Cortex M #832
Conversation
In a week or so, I plan to replicate these changes to all the other ARMv7-M targets and to the ARMv8-M targets too. I might also be able to replicate them to ARMv6-M. Then I'll remove the "draft" flag on this PR. Meantime, please feel free to review. Better now than after the replication. 😄 |
Delay replication (copy_files.py) to simplify review for now.
Style issue addressed here was previously existing
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #832 +/- ##
=======================================
Coverage 93.78% 93.78%
=======================================
Files 6 6
Lines 3184 3184
Branches 885 885
=======================================
Hits 2986 2986
Misses 91 91
Partials 107 107
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
A couple of issues with Cortex-M0 (ARMv6-M).
I suggest we either remove the preexisting comment or revert ARMv6-M, leaving it out of this PR. Happy to do whatever the team would like. EDIT: I've updated the comment. |
SVC is not used in the CM0 port, and some FreeRTOS demos do not install the SVC vector.
Applications doing something "special" with their vectors may encounter a backward compatibility issue after this PR. For example, if they "re-vector" the FreeRTOS interrupts (which must be done very carefully), then if they try to upgrade FreeRTOS to a version that includes this PR, the new assert statements could fail. Thus I have added The PR as of this writing defaults |
Also, |
I am looking at it and should be able to merge in couple of days. Thank you for your patience. |
@aggarg No worries at all. If you do decide to merge this, I will raise a PR to That is a concept issue with this PR -- that some existing applications will be affected. |
Also update the only remaining MPU port RVDS/ARM_CM4_MPU. Signed-off-by: Gaurav Aggarwal <[email protected]>
Signed-off-by: Gaurav Aggarwal <[email protected]>
Signed-off-by: Gaurav Aggarwal <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
As usual thanks Gaurav for all the work. Next time I will be sure to point out specifically when I haven't compiled with IAR. That way, first reviewers will have a better chance of resolving any build issues I missed, before it gets to later reviewers. (Actually, a few months ago I asked IAR to sponsor a license for this kind of open-source contribution, but it didn't work out.) |
No worries at all Jeff. Thank you for this change - this will really help to catch issue which are otherwise hard to debug in forums! |
The change request is addressed in this PR. Dismiss this change request.
@jefftenney Thanks for this great contribution! |
Description
Add new assert statements in
xPortStartScheduler()
on Cortex M to verify correct installation of the PendSV and SVCall handlers. These same assertion statements also verify VTOR is set properly for targets with a modifiable VTOR register. These are common causes of startup issues for Cortex M users.On ARMv7-M and ARMv8-M, add explicit setting of SVCall priority to 0 (the maximum priority). Prior to this PR the port code depended on system startup code not to change the priority from its default of 0. This a rare cause of startup issues for Cortex M users. (See last link below.) For consistency, replicate this new method of setting SVCall priority to the ARMv7-M MPU ports, replacing the previous mechanism used by those ports to set SVCall priority.
Test Steps
ARMv7-M: Execute demo application with and without
#define vPortSVCHandler SVC_Handler
and#define xPortPendSVHandler PendSV_Handler
in FreeRTOSConfig.h. Before this PR, the application works correctly with both #defines, and doesn't work correctly without either one. After this PR, the application still works correctly with both #defines, and has an assert failure without either one, as intended.ARMv6-M: Same as above but the port doesn't use vPortSVCHandler; test with and without xPortPendSvHandler defined. XMC1000 demo cannot be used for this test.
ARMv7-M / ARMv8-M: Use demo application. First thing in main() set VTOR to the wrong value. Before this PR, xPortStartScheduler() hard faults. After this PR, an assert failure detects the issue, as intended.
Checklist:
Related Issues
https://forums.freertos.org/t/prvportstartfirsttask-fails-at-svc-0/18288
https://forums.freertos.org/t/hard-fault-encountered-after-vtaskstartscheduler-is-invoked/17476
https://forums.freertos.org/t/freertos-does-not-execute-first-task-after-svc-0-call/16124
https://forums.freertos.org/t/xportstartscheduler-fails-because-basepri-is-non-zero/15509
...
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.