There are a set of open source example projects that made available alongside the Armv8-M Memory Model and MPU User Guide . The source code for these example projects is available in the GitHub repository .
This example demonstrates simple real-time kernel context switching operations between two threads using MPU regions that are available in Arm Cortex-M processors. You can build and run the example project using the versions of tools and software listed below:
With this example you can create a very simple RTOS (Real Time Operating System) capable of dealing with context switching and thread isolation. For simplicity, only two threads, thread A and thread B, are created.
Basic context switching and thread isolation requirements considered for this example are listed below:
You can build the example project with Arm Compiler for Embedded version 6.18 using the supplied Eclipse project. To import this project, follow the guidelines in the section Import an existing Eclipse project in the Arm Development Studio Getting Started Guide .
To build the project within the Arm DS IDE:
The built executable from previous step can run on an Armv8-M FVP model supplied with Arm Development Studio. A ready to use launch configuration file
rtos_context_switch.launch is provided with the example project.
Follow the steps below to run the executable using this configuration:
rtos_context_switchfrom the list of Generic Arm C/C++ Application configurations.
You should see the following output in the target console view when you run this example:
Pentagonal number: 2262 Pentagonal number: 2380 Pentagonal number: 2501 ... Fibonacci number: 0 Fibonacci number: 1 Fibonacci number: 2 Fibonacci number: 3
You have now successfully run a bare-metal context switching application on an Arm Cortex-M target.