{{ message }}
FIXED BUG configKERNEL_INTERRUPT_PRIORITY must be left shifted accord…#64
Merged
Conversation
…ing to ref: "Cortex-M Internal Priority Representation" https://www.freertos.org/RTOS-Cortex-M3-M4.html
Member
fpistm
approved these changes
Jun 6, 2023
Author
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 value of setting
configKERNEL_INTERRUPT_PRIORITYis interpreted at a low level on Cortex M ports as a priority setting mask, so it must be left shifted to the most significant bits.REF: "Cortex-M Internal Priority Representation" https://www.freertos.org/RTOS-Cortex-M3-M4.html
The line brought in at commit 0ab4bbd9507f2c8fd15ae1ca755aee6334860ad9:
is a BUG, since it sets the kernel preemption interrupt to a very high priority (numerically low). This can lead to subtle memory corruption issues which are fairly hard to debug. The proper value consistent with how this priority setting is used by the port and the intention of the mistaken commit to lower the value (raise the logical priority) from the actual lowest priority level of 15 would thus be:
Background:
I discovered this bug, because I had used the Github main branch as a reference to make my own
STM32FreeRTOSConfig.hfile. I was experiencing persistent hard faults and submitted this issue for help. Eventually, I solved this problem when I accidentally remade my config from an older stable version before the above mentioned commit. I was confused about why one of my test systems became stable but the other didn't. I eventually diffed the configs to find out this mistaken interrupt priority configuration in the main branch.