- added the fourth area to all my task parameters (all tasks are created using xTaskCreateRestricted);
- took out the lines setting portMPUREGIONBASEADDRESSREG and portMPUREGIONATTRIBUTE_REG for the privileged flash area in prvSetupMPU (mpu/port.c);
- changed a few lines at the start of mpu/portmacro.h from ~~~
Extending number of MPU regions
I’m using GCC on a Cortex-M4F (LPC43xx family).
I need more than the 3 configurable MPU regions for this port. I decided to do away with the privileged flash area because I don’t need it (privileged background map is enabled and my unprivileged flash area does not reach there, so privileged accesses are enabled by default and unprivleged accesses are blocked).
What I did:
Extending number of MPU regions
Never mind, I found it… xPortPendSVHandler in mpu/port.c only swaps in 4 regions at most (including the stack region), so I added a few lines that fixed it. If anyone has the same problem, delete line 495 and add this in its place (assuming you defined the appropriate symbol):
~~~
if !defined(FREERTOSEXTRAMPU_REGION)
" stmia r2!, {r4-r11} n" // original line
else
" stmia r2, {r4-r11} n" // don't update r2
" ldmia r1!, {r4-r5} n" // load 1 set of MPU regs
" stmia r2, {r4-r5} n" // write 1 set of MPU regs