Switch to user mode on K82 with MPU

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Switch to user mode on K82 with MPU

ソリューションへジャンプ
1,513件の閲覧回数
EugeneHiihtaja
Senior Contributor I

Hello !

On K82 MPU is always enabled  and Region 0 provisioned with record what give access to whole memore space for all masters in user and privileged mode.

I have start to think how-to port freeRTOS-MPU for K82 is show busFault if task try to drop to user mode by using control register.

/* Set the privilege level to user mode if xRunningPrivileged is false. */
portFORCE_INLINE static void vPortResetPrivilege( BaseType_t xRunningPrivileged )
{
   if( xRunningPrivileged != pdTRUE )
   {
      __asm volatile ( " mrs r0, control \n" \
      " orr r0, #1 \n" \
      " msr control, r0 \n" \
      :::"r0", "memory" );
   }
}

BusFault is enabled and first call of this function cause BusFault even all memory areas accesable in User mode.

If all Tasks created as privileged, this function is not called and no any problems.

Current assumption that K82 require more complicate sequence and may be MPU should be disabled/enabled globally.

But in user mode may be not possible to reenable MPU.

Could you suggest if this sequence is OK for K82 with MPU ?

Regards,

Eugene

0 件の賞賛
返信
1 解決策
1,342件の閲覧回数
EugeneHiihtaja
Senior Contributor I

Hi Xiangjun Rong !

If I completely disable MPU block , it is not problem at all.

But if I disable Master0 in region 0

/* Invalidate Region 0 for Master 0, remove background region with wide access right. */
master0 = prvComposeRegionRightMPU(kSYSMPU_SupervisorEqualToUsermode, kSYSMPU_UserNoAccessRights);
SYSMPU_SetRegionRwxMasterAccessRights(SYSMPU, 0, 0, &master0);

Nothing dosn't work.

So for remove wide access to everything, I have splitted accesses right for master0 for multiple

Regions, e.g Flash, SRAM, etc. separately.

But Region 0 is still have full access right for Master1 ( Debug ) what can't be removed in principle.

Other Masters 2-4 I have disabled as well.

Regards,

Eugene

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,343件の閲覧回数
EugeneHiihtaja
Senior Contributor I

Hi Xiangjun Rong !

If I completely disable MPU block , it is not problem at all.

But if I disable Master0 in region 0

/* Invalidate Region 0 for Master 0, remove background region with wide access right. */
master0 = prvComposeRegionRightMPU(kSYSMPU_SupervisorEqualToUsermode, kSYSMPU_UserNoAccessRights);
SYSMPU_SetRegionRwxMasterAccessRights(SYSMPU, 0, 0, &master0);

Nothing dosn't work.

So for remove wide access to everything, I have splitted accesses right for master0 for multiple

Regions, e.g Flash, SRAM, etc. separately.

But Region 0 is still have full access right for Master1 ( Debug ) what can't be removed in principle.

Other Masters 2-4 I have disabled as well.

Regards,

Eugene

0 件の賞賛
返信
1,342件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Eugene,

If you disable MPU function, do you have issue when you configure to user mode?

BR

Xiangjun Rong

0 件の賞賛
返信