Memory Protection Unit (MPU) TEST

Overview

This test provides a set options to check the correct MPU configuration against the following security issues:

  • Read at an address that is reserved in the memory map.
  • Write into the boot Flash/ROM.
  • Run code located in SRAM.

If the MPU configuration is correct each option selected ends up in an MPU fault.

Building and Running

This project can be built and executed as follows:

# On Linux/macOS
cd $ZEPHYR_BASE/samples/mpu/mpu_test
mkdir build && cd build
# On Windows
cd %ZEPHYR_BASE%\samples\mpu\mpu_test
mkdir build & cd build
cmake -GNinja -DBOARD=v2m_beetle ..
ninja
ninja flash

To build the single thread version, use the supplied configuration file for single thread: prj_single.conf:

# On Linux/macOS
cd $ZEPHYR_BASE/samples/mpu/mpu_test
mkdir build && cd build
# On Windows
cd %ZEPHYR_BASE%\samples\mpu\mpu_test
mkdir build & cd build
cmake -GNinja -DBOARD=v2m_beetle -DCONF_FILE=prj_single.conf ..
ninja run

To build a version that allows writes to the flash device, edit prj.conf, and follow the directions in the comments to enable the proper configs.

Sample Output

uart:~$ mpu read
***** BUS FAULT *****
  Precise data bus error
  BFAR Address: 0x24000000
***** Hardware exception *****
Current thread ID = 0x20000400
Faulting instruction address = 0x80004a8
Fatal fault in thread 0x20000400! Aborting.