AnsweredAssumed Answered

Update K82 MPU regions during runtime

Question asked by Eugene Hiihtaja on Jun 13, 2018
Latest reply on Jun 21, 2018 by Jing Pan

Hello !

 

I try to study usage of K82 MPU for FreeRTOS like OS.

 

I can see in original FreeRTOS MPU few places where all 4 regions of generic ARM MPU is updated on fly.

Prepared valued are copied directly to MPU registers.

 

/* ARM generic */
" ldr r2, =0xe000ed9c \n" /* Region Base Address register. */
" ldmia r1!, {r4-r11} \n"     /* Read 4 sets of MPU registers. */
" stmia r2!, {r4-r11} \n"     /* Write 4 sets of MPU registers. */

 

In K82 case, one region is represented by 4 dwords and prepared MPU region values from TCB ( for 4 regions ) can

be copied by operations like this :

 

/* K82 */
" ldr r2, =0x4000D410 \n" /* Region Base Address register. */ // 1,2
" ldmia r1!, {r4-r11} \n"      /* Read 2 sets of MPU registers. */
" stmia r2!, {r4-r11} \n"      /* Write 2 sets of MPU registers. */
" ldr r2, =0x4000D430 \n"  /* Region Base Address register. */ // 3,4
" ldmia r1!, {r4-r11} \n"      /* Read 2 sets of MPU registers. */
" stmia r2!, {r4-r11} \n"      /* Write 2 sets of MPU registers. */

 

In case of ARM, priviliged/nonprivileged mode is switched in control register.

 

 

But what in case of K82 ?

 

How I can update MPU region entries during runtime ?

 

Should I also disable MPU or current way of FreeRTOS is sufficient for K82 as well ?

 

I can see the next MPU region scheme :

 

Region 0 is reserved for debug purposes and should be invalidated when it is no need.

Regions 1-4 are preconfigured one time for protect static flash/data regions

Regions 5-8 are updated during runtime when task switch happens.

Regions 9-12 are invalidated at start up and set to 0.

So MPU is always enabled.

 

How-to properly and in what mode update regions  5-8 ?

 

Thank you !

 

Eugene

Outcomes