zephyr/samples/mpu_stack_guard_test
Vincenzo Frascino 14a892f7a4 samples: Add mpu stack guard test
This patch adds the mpu_stack_guard_test to the available samples.
The purpose of this test is to exercize the thread stack guard enabled
via MPU on arm platforms.

Change-Id: I4665a20956d9e6d0dd4b5cc862e82040a53afafc
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-16 09:28:06 -05:00
..
src samples: Add mpu stack guard test 2017-05-16 09:28:06 -05:00
Makefile samples: Add mpu stack guard test 2017-05-16 09:28:06 -05:00
README.rst samples: Add mpu stack guard test 2017-05-16 09:28:06 -05:00
prj.conf samples: Add mpu stack guard test 2017-05-16 09:28:06 -05:00
prj_stack_guard.conf samples: Add mpu stack guard test 2017-05-16 09:28:06 -05:00
testcase.ini samples: Add mpu stack guard test 2017-05-16 09:28:06 -05:00

README.rst

.. _mpu_stack_guard_test:

MPU Stack Guard Test
####################

Overview
********

This is a simple application that demonstrates basic thread stack guarding on
the supported platforms.
A thread spawned by the main task recursively calls a function that fills the
thread stack up to where it overwrites a preposed canary.
If the MPU is enabled and the Stack Guard feature is present the test succeeds
because an MEM Faults exception prevents the canary from being overwritten.
If the MPU is disabled the test fails because the canary is overwritten.

Building and Running
********************

This project outputs to the console.
To build the test with the MPU disabled:

.. code-block:: console

   $ cd samples/mpu_stack_guard_test
   $ make

To build the test with the MPU enabled and the stack guard feature present:

.. code-block:: console

   $ cd samples/mpu_stack_guard_test
   $ make CONF_FILE=prj_stack_guard.conf

Sample Output
=============

With the MPU disabled:

.. code-block:: console

   ***** BOOTING ZEPHYR OS v1.7.99 - BUILD: Mar 29 2017 11:07:09 *****
   MPU STACK GUARD Test
   Canary Initial Value = 0xf0cacc1a
   Canary = 0x200003a8     Test not passed.
   ...

With the MPU enabled and the stack guard feature present:

.. code-block:: console

   ***** BOOTING ZEPHYR OS v1.7.99 - BUILD: Mar 29 2017 11:20:10 *****
   MPU STACK GUARD Test
   Canary Initial Value = 0xf0cacc1a
   [general] [DBG] arm_core_mpu_configure: Region info: 0x200003ac 0x400
   ***** MPU FAULT *****
     Executing thread ID (thread): 0x200003ac
     Faulting instruction address:  0x0
     Stacking error
   Fatal fault in thread 0x200003ac! Aborting.
   ***** HARD FAULT *****
     Fault escalation (see below)
   ***** MPU FAULT *****
     Executing thread ID (thread): 0x200003ac
     Faulting instruction address:  0x8000466
     Stacking error
   Fatal fault in ISR! Spinning...