This learning path will introduce the steps to create a basic RTX based RTOS application, making use of the latest features of CMSIS .
For more information on the latest update, see the CMSIS v6 is here blog.
You will use Keil MDK through this Learning Path. If you are using Arm Development Studio refer to the appropriate comments.
If using Arm Keil Studio for Visual Studio Code
please go to
Build an RTX5 RTOS application with Keil Studio (VS Code)
.
Open the ‘Pack installer’ and install the latest CMSIS packs. At a minimum the following should be installed for this learning path:
ARM::CMSIS
ARM::CMSIS-RTX
ARM::CMSIS-View
Add required CMSIS-Packs
via the CMSIS Pack Manager
perspective.
This Learning Path is written for the supplied (Cortex-M4) Fixed Virtual Platform (FVP), however it could be run on any of the 10000+ devices supported by CMSIS-Pack .
In Pack Installer
browse for your device, and install any suggested Device Specific
pack.
In the MDK menu, navigate to Project
> New uVision Project
, and create a new project (recommend to locate in a new folder).
When creating the project navigate to File
> New
> Project...
> C/C++
> C Project
.
Then select CMSIS C/C++ Project
, using Arm Compiler for Embedded 6
.
You will then be prompted to Select Device
for your project. A list of all devices with their CMSIS-Packs installed will be shown.
For this example, select Arm
> Arm Cortex-M4
> ARMCM4
. Click OK
.
You will first be presented with the Manage Run-Time Environment
dialog, which allows you to specify the CMSIS software components that will be used in the project.
Under CMSIS
, select CORE
, as well as RTOS2 (API)
> Keil RTX5
, in Source
form. You will also need to select CMSIS
> OS Tick (API)
> SysTick
.
Under Device
, select Startup
(C Startup
).
These are the minimal components needed for such an application. Click OK
.
Run-time environment is managed by the .rteconfig
file within the project.
A project can contain many targets, which refer to the platform that a particular build will run on. The default name is Target 1
. To give a meaningful name, click Manage Project Items
, and rename the target (for example, to FVP
), as well as optionally the Source Group 1
(to Source
) that will contain the source code. Arranging code in these folders allows for easy sharing across different target builds.
Click OK
to save.
Default Configuration
names are Debug
and Release
.
Name and other settings (see below) are managed in Project Properties
(Alt+Enter
), under C/C++ Build
> Settings
.
Click Options for Target
, to open that dialog. This is where build and other settings can be made.
In the Debug
tab, select Models Cortex-M Debugger
. Click Settings
, and browse for the FVP provided with MDK in the Command
pane.
Keil_v5/ARM/avh-fvp/bin/models/FVP_MPS2_Cortex-M4_MDK.exe
MDK versions 5.37 and earlier will find the FVP at:
Keil_v5/ARM/FVP/MPS2_Cortex-M/FVP_MPS2_Cortex-M4_MDK.exe
In 5.38 and 5.39 the FVP is installed at:
Keil_v5/ARM/VHT/VHT_MPS2_Cortex-M4_MDK.exe
In 5.40 and later the FVP is installed at:
Keil_v5/ARM/avh-fvp/bin/models/FVP_MPS2_Cortex-M4_MDK.exe
Ignore this step for now. Debug configuration will be set up later.
Navigate to C/C++ (AC6)
tab, and (optionally) change optimization level to -O2
for high performance code.
You may also wish to disable Warnings, change language options, or other settings.
Use scatter-loading to define the memory map to the linker.
The memory map for the FVP is given in the documentation .
Navigate to the Linker
tab, and de-select Use Memory Layout from Target Dialog
(as you shall create your own).
Click the browse (...
) button and create a text file in the same folder as the project.
Click Edit
to open the file in the IDE. The following is a typical scatter file for the FVP.
LOAD 0x0 0x400000 {
ROOT 0x0 0x400000 {
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO) }
RAM 0x20000000 0x40000 {
.ANY (+RW +ZI) }
ARM_LIB_HEAP 0x20040000 EMPTY 0x10000 {}
ARM_LIB_STACK 0x20050000 EMPTY 0x10000 {}
}
The IDE recognizes .sct
files as scatter files, and provides a graphical representation of the layout in a Memory Map
tab.