This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: MPU Problem

Part Number: TM4C123GH6PM

我在使用TM4C123GH6PM時有遇到一個關於記憶體保護(MPU)的問題,在這裡面會有一個API函數"void MPURegionSet(uint32_t ui32Region,uint32_t ui32Addr,uint32_t ui32Flags)"需要填入內存的訪問權限
"MPU_RGN_PERM_PRV_NO_USR_NO - no access in privileged or user mode",其中我想請問在TM4C123GH6PM這一顆晶片,

(1)特權權限和用戶權限是可以設定的嗎?我不知道我一開機後,開始在main函數中寫程式時,此時是在用戶權限還是特權權限。

(2)當我只要填入"MPU_RGN_PERM_PRV_RO_USR_NO ",晶片上就是變成可讀,填入"MPU_RGN_PERM_PRV_RW_USR_NO" 就變成可讀可寫,我好像都是處在特權權限模式下,

我該怎麼切換成用戶模式,來試驗用戶模式的MPU設定功能呢?

(3)MPU是否可以限制晶片ICE( in circuit emulator)的行為?例如我設定成"MPU_RGN_PERM_PRV_RO_USR_NO",這樣是否可以阻止data下載到Flash,或將程式燒錄至FLASH?




(1) Can privilege and user access permissions be configured using the "void MPURegionSet(uint32_t ui32Region, uint32_t ui32Addr, uint32_t ui32Flags)" API function? I'm not sure whether I am in user mode or privilege mode when I start writing code in the main function after booting up on the TM4C123GH6PM microcontroller.

(2) When I use "MPU_RGN_PERM_PRV_RO_USR_NO," it seems that the chip becomes read-only, and with "MPU_RGN_PERM_PRV_RW_USR_NO," it becomes readable and writable. It appears that I am in privilege mode. How can I switch to user mode to test the MPU settings in user mode?

(3) Can the MPU restrict the behavior of the in-circuit emulator (ICE) on the TM4C123GH6PM microcontroller? For example, if I configure it with "MPU_RGN_PERM_PRV_RO_USR_NO," can this prevent data downloads to Flash or programming of Flash memory using the ICE?



  • Hi,

    我们已将您的问题升级到英文论坛寻求帮助,如有答复将尽快回复您。

    Thanks

  • Hi,

    请参考以下答复:

    (1) Can privilege and user access permissions be configured using the "void MPURegionSet(uint32_t ui32Region, uint32_t ui32Addr, uint32_t ui32Flags)" API function? I'm not sure whether I am in user mode or privilege mode when I start writing code in the main function after booting up on the TM4C123GH6PM microcontroller.

      Please refer to Programming Model in the datasheet for explanation on Privileged and Unprivileged. After reset, the processor is in Thread mode with Privileged access. The software can use all the instructions and has access to all resources. To change to Unprivileged access, the software can program the CONTROL register. 

      The MPURegionSet() AP is used to The MPU divides the memory map into a number of regions and defines the location, size, access permissions, and memory attributes of
    each region. Refer to MPU section in the datasheet for details. 

    (2) When I use "MPU_RGN_PERM_PRV_RO_USR_NO," it seems that the chip becomes read-only, and with "MPU_RGN_PERM_PRV_RW_USR_NO," it becomes readable and writable. It appears that I am in privilege mode. How can I switch to user mode to test the MPU settings in user mode?

    MPU_RGN_PERM_PRV_RO_USR_NO means that the region you setup is only read accessible in privileged mode and no user access. MPU_RGN_PERM_PRV_RW_USR_NO means the region is read and write accessible in privileged mode and no user access. 

    To switch to user mode, you need to program the CONTROL register as described earlier.

    (3) Can the MPU restrict the behavior of the in-circuit emulator (ICE) on the TM4C123GH6PM microcontroller? For example, if I configure it with "MPU_RGN_PERM_PRV_RO_USR_NO," can this prevent data downloads to Flash or programming of Flash memory using the ICE?

    We don't think it will work. Debugger is in privilege mode so MPU has no effect. You must program the BOOTCFG register for the DBG1 and DBG0 bits to disable JTAG access. Once disabled, the only way to reenable JTAG access to go through a full unlock operation which will mass-erase the device. 

    Thanks