zephyr/samples/mpu/mpu_stack_guard_test
Reto Schneider 7eabab2f5d samples, tests: Use semi-accurate project names
When using an IDE (e.g. Eclipse, Qt Creator), the project name gets
displayed. This greatly simplifies the navigation between projects when
having many of them open at the same time. Naming every project "NONE"
defeats this functionality.

This patch tries to use sensible project names while not duplicating
too much of what is already represented in the path. This is done by
using the name of the directory the relevant CMakeLists.txt file is
stored in. To ensure unique project names in the samples (and again, in
the tests folder) folder, small manual adjustments have been done.

Signed-off-by: Reto Schneider <code@reto-schneider.ch>
2018-10-27 21:31:25 -04:00
..
src
CMakeLists.txt samples, tests: Use semi-accurate project names 2018-10-27 21:31:25 -04:00
README.rst samples: mpu_stack_guard_test: Update console output in README 2018-08-27 16:24:48 -04:00
prj.conf
prj_stack_guard.conf arch: setup logging using new logger 2018-10-08 17:49:12 -04:00
sample.yaml tests/samples: rename 'app' tag to something meaningful 2018-10-16 09:17:51 -04: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:

.. zephyr-app-commands::
   :zephyr-app: samples/mpu/mpu_stack_guard_test
   :board: frdm_k64f
   :goals: build flash
   :compact:

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

.. zephyr-app-commands::
   :zephyr-app: samples/mpu/mpu_stack_guard_test
   :board: frdm_k64f
   :conf: prj_stack_guard.conf
   :goals: build flash
   :compact:

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

With the MPU enabled but the stack guard feature disabled:

.. code-block:: console

    ***** Booting Zephyr OS v1.13.0-rc1-14-gd47fada *****
    STACK_ALIGN 0x8
    MPU STACK GUARD Test
    Canary Initial Value = 0xf0cacc1a threads 0x20000ff8
    Canary = 0x20000128     Test not passed.
    ***** BUS FAULT *****
      Instruction bus error
      NXP MPU error, port 3
        Mode: Supervisor, Instruction Address: 0x20001030
        Type: Read, Master: 0, Regions: 0x8800
    ***** Hardware exception *****
    Current thread ID = 0x20000ff8
    Faulting instruction address = 0x20001030
    Fatal fault in essential thread! Spinning...

With the MPU enabled and the stack guard feature enabled:

.. code-block:: console

    ***** Booting Zephyr OS v1.13.0-rc1-14-gd47fada *****
    STACK_ALIGN 0x20
    MPU STACK GUARD Test
    Canary Initial Value = 0xf0cacc1a threads 0x20001100
    ***** BUS FAULT *****
      Stacking error
      NXP MPU error, port 3
        Mode: Supervisor, Data Address: 0x200011b0
        Type: Write, Master: 0, Regions: 0x8400
    ***** Hardware exception *****
    Current thread ID = 0x20001100
    Faulting instruction address = 0x0
    Fatal fault in thread 0x20001100! Aborting.