FIXED BUG configKERNEL_INTERRUPT_PRIORITY must be left shifted accord… #64
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_PRIORITY
is 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.h
file. 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.