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

Hi Team,

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

(2) When using "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 the customer is in privilege mode. Could you help tell how to switch  touser 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 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?

Could you help check this case? Thanks.

Best Regards,

Cherry

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

    Hi Cherry,

      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 using "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 the customer is in privilege mode. Could you help tell how to switch  touser 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 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?

     

    I 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.