ARM Cortex MX
From ErikaWiki
Contents |
ARM Cortex MX support
ERIKA Enterprise supports ARM Cortex MX microcontrollers.
The support for RT-Druid is now available.
The Cortex M0 support includes:
- support for IAR and ARM KEIL Compilers;
- support for single and multi stack configurations;
- ISR Type 1 and Type 2 supported;
- support for IAR J-Link and Keil ULINK2 Debuggers.
The Cortex M4 support includes:
- support for Texas Instruments TMS470 and ARM KEIL Compilers;
- support for single and multi stack configurations;
- ISR Type 1 and Type 2 supported;
- support for Texas Instruments Stellaris ICDI and Keil ULINK2 Debuggers.
- Supported IDEs:
- IAR Embedded Workbench. (Cortex M0)
- Texas Instruments Code Composer Studio. (Cortex M4)
- Keil uVision. (Cortex M0 and Cortex M4)
- Mode of operation:
- Mono-stack: The Monostack configuration of the ERIKA Kernel models the fact that all tasks and ISRs in the system share the same stack.
- Multi-stack: Every task can have its private stack, or it can share it with other tasks.
MCUs
- The MCUs currently supported are the following:
- NXP LPC12xx. (Cortex M0)
- Texas Instruments Stellaris LM4F232xxxx. (Cortex M4)
- STMicroelectronics STM32F4xx. (Cortex M4)
Boards
- The boards currently supported are the following:
- NXP LPCXpresso LPC1227 demo board. (Cortex M0)
- Texas Instruments Stellaris LM4F232H5QD evaluation board. (Cortex M4)
- STMicroelectronics STM32F4DISCOVERY Evaluation board. (Cortex M4)
- List of functions:
- Currently the NXP LPCXpresso demo board (Cortex M0) is supported through the CMSIS library.
- Currently the Texas Instruments Stellaris LM4F232H5QD (Cortex M4) evaluation board is supported through AUTOSAR Drivers.
- Currently the STM32F4DISCOVERY Evaluation board (Cortex M4) is supported through the STM32F4-Discovery Board Drivers.
Download and install
RT-Druid and Erika Enterprise RTOS (version 1.6.1) can be freely downloaded from the following web address:
Once downloaded, extract all the files contained in it and copy the folder named eclipse in your preferred directory on your PC (a recommended path is: C:\Evidence\). Now, launch the program by double-clicking on the executable eclipse.exeinside the C:\Evidence\eclipse folder and choose the path of your workspace. The workspace is the default working directory in which the projects will be created.
If you want to download only a selected revision of the kernel, open the Cygwin shell and get an anonymous SVN checkout typing this command:
svn co svn://svn.tuxfamily.org/svnroot/erika/erikae/repos/ee/trunk/ee -r number_of_revision
Note: Cygwin can be downloaded from this web site: http://www.cygwin.com/ To use SVN, the Cygwin SVN package must to be installed using the Cygwin Setup utility.
The Cortex MX plug-in for Eclipse is part of the official distribution of RT-Druid.
- The procedure to update Erika and RT-Druid plugins is described at Tutorial: Update ERIKA and RT-Druid.
Target Configuration and Programming
ERIKA is configured through RT-Druid and an OIL file
Compiler Path
It is possible to choose the path of the compiler in three different ways:
- environment var:
- IAR compiler: the IAR_CCDIR variable is able to override the path compiler set in RT-Druid during the build progress.
- Texas Instruments TMS40 compiler: CCS_INSTALL_ROOT variable is able to override the path compiler set in RT-Druid during the build progress.
- Keil ARM compiler: ARM_ROOT variable is able to override the path compiler set in RT-Druid during the build progress.
- configuration file:
- gui:
- inside eclipse preferences, it is possible to set the paths of above compilers.
CPU
CPU_DATA
must be set to CORTEX_MX
.
The exact model is specified with the MODEL
item (supported values are M0
for Cortex M0 and M4
for Cortex M4).
The compiler is specificed with the COMPILER_TYPE
item (supported values are IAR
and KEIL
for M0
model and CCS
and KEIL
for M4
).
Example of a CPU_DATA section:
CPU_DATA = CORTEX_MX { MODEL = M4; APP_SRC = "code.c"; COMPILER_TYPE = KEIL; MULTI_STACK = TRUE { IRQ_STACK = TRUE { SYS_SIZE=512; }; }; };
MCU
MCU_DATA
must be set to LPCXPRESSO
for NXP LPCXpresso LPC12xx, to STM32
for STMicroelectronics STM32F4xx or to STELLARIS
for Texas Instruments Stellaris LM4F232xxxx.
The only item supported is MODEL
, which can be either LPC12xx
for LPCXPRESSO
, STM32F4xx
for STM32
or LM4F232xxxx
for STELLARIS
.
Example of a MCU_DATA section:
MCU_DATA = STELLARIS { MODEL = LM4F232xxxx; };
Interrupt Handling
Interrupts in ERIKA are handled in different manner between NXP LPC12xx MCU (Cortex M0) and Texas Instruments Stellaris LM4F232xxxx MCU (Cortex M4).
NXP LPC12xx MCU (Cortex M0)
NXP LPC12xx MCU is configured to have a fixed Interrupt Vector Table specified in pkg/mcu/nxp_lpcxpresso_lpc12xx/src/iar/startup_LPC12xx.s assembly file. Each entry has a fixed symbol that must be the parameter of ISR1()
or ISR2()
ISR signature.
This scheme of ISR handling can be changed by rewriting the startup_LPC12xx.s changing the Interrupt Vector Table.
Texas Instruments Stellaris LM4F232XXXX MCU (Cortex M4 )
Texas Instruments Stellaris LM4F232XXXX MCU (Cortex M4) is configured to have a flexible Interrupt Vector Table specified in pkg/mcu/ti_stellaris_lm4f232xxxx/src/ee_startup_keil.s for Keil/uVision compiler and in pkg/mcu/ti_stellaris_lm4f232xxxx/src/ee_vtable_ccs.c for Texas Instruments TMS470 compiler. Each entry is specified by the following macro:
EE_<ARCH>_<ENTRY>_ISR
Where <ARCH>
is the architecture depended identifier (E.g. CORTEX_MX
), and <ENTRY>
is the fixed Interrupt Vector Table Entry identifier (E.g. GPIO_A
).
To define each ISR an ISR
object is needed to be added in the CPU
object of the OSEK/VDX configuration:
ISR <SYMBOL> { CATEGORY = <ISR_TYPE>; ENTRY = "<ENTRY>"; };
Where <ISR_TYPE>
is the type of the ISR (1 or 2), <SYMBOL>
is the symbol that must be the parameter of ISR<ISR_TYPE>()
ISR signature, and <ENTRY>
is the fixed Interrupt Vector Table Entry identifier.
OSEK/VDX Extensions
This Section contains information about the OSEK/VDX Extensions (or optional features) that have been implemented for the ARM Cortex MX support. Some of these features are not yet implemented in all the portings of ERIKA Enterprise.
Resource Managament at ISR level
This feauture is automatically enabled by RT-Druid during the configuration generation step. To specify that a Resource is used by both a Task and a ISR you need to add that respource to the corrisponding ISR object as follows:
TASK Task1 { ... RESOURCE = "ResourceA"; }; ISR <SYMBOL> { PRIORITY = <PRIORITY_LEVEL>; CATEGORY = <ISR_TYPE>; ENTRY = "<ENTRY>"; RESOURCE = "ResourceA"; }; RESOURCE ResourceA { RESOURCEPROPERTY = STANDARD; };
System Timer
The OSEK/VDX standard provides support for a System Counter (a counter that is automatically linked to hardware timers). The System Timer is used to give a coherent timing reference across the entire application.
In ERIKA Enterprise, this special counter has been named System Timer. To use it, you need to set a specific attribute in a Counter definition. Please note that only one counter can be the System Timer.
A Counter which is not a System Counter must be incremented manually using the primitive IncrementCounter.
The following is an example OIL definition for a System Counter:
CPU_DATA = CORTEX_MX { CPU_CLOCK = 16.0; ... }; COUNTER SystemTimer { MINCYCLE = 1; MAXALLOWEDVALUE = 2147483647; TICKSPERBASE = 1; TYPE = HARDWARE { DEVICE = "SYSTICK"; SYSTEM_TIMER = TRUE; }; SECONDSPERTICK = 0.001; };
The meaning of the various attributes is as follows:
- CPU_DATA/CPU_CLOCK is used to declare the clock frequency (in MHZ)
- COUNTER/TYPE must be set to "HARDWARE", and SYSTEM_TIMER must be set to true.
- COUNTER/TYPE/DEVICE must be a valid device that can be used for a system timer. Currently, for Cortex ARM MX only "SYSTICK" is a valid device for system timer.
- SECONDSPERTICK is used to declare the wanted time duration of one hardware tick in seconds.
The System Timer can be attached to ALARMs as usual, as in the following example:
ALARM AlarmExample { COUNTER = SystemTimer; ACTION = ACTIVATETASK{ TASK = TaskExample; }; };
Libraries
- The software libraries currently supported are:
- Cortex Microcontroller Software Interface Standard (CMSIS) Version 2.1. (Cortex M0 ONLY)
CMSIS OIL file configuration
To enable CMSIS Library with NPX LPCXpresso LPC1227 demo board, the following code is needed in the OS
object of the OSEK/VDX configuration:
EE_OPT = "__ADD_LIBS__"; LIB = ENABLE { NAME = "CMSIS"; }; EE_OPT = "__USE_LPC12XX_CMSIS_V2__";
It's possible to include all library functions by EE_OPT
attribute in the OS
object of the OSEK/VDX configuration:
EE_OPT = "__USE_CMSIS_ALL__";
It's possibile to include ONLY selected library modules functions by EE_OPT
attributes in the OS
object of the OSEK/VDX configuration:
EE_OPT = "__USE_CMSIS_SYSCTRL__"; EE_OPT = "__USE_CMSIS_GPIO__"; EE_OPT = "__USE_CMSIS_IOCON__"; ...
AUTOSAR Drivers
Texas Instruments Stellaris LM4F232H5QD evaluation board is supported through AUTOSAR Drivers. Documentation can be found at Stellaris AUTOSAR Drivers.
Examples
- The examples and tests are available in this folders:
- examples/cortex_mx/lpc12xx: NXP LPCXpresso LPC1227 demo board examples (Cortex M0)
- examples/cortex_mx/lm4f232xxxx: Texas Instruments Stellaris LM4F232H5QD evaluation board examples (Cortex M4)
Inside lm4f232xxxx examples folder you can find a benchmark project too.
KEIL uVision and RT-Druid Eclipse
MDK-ARM Plug-in Configuration
KEIL uVision sopport an Eclipse plu-in called MDK-ARM Plug-in.
The MDK-ARM Plug-in components have the default installation path C:\Keil\Eclipse.
No additional software is required. However, the MDK-ARM Plug-in must be configured for the Eclipse environment.
- Launch Eclipse and define a workspace (default workspace can be accepted).
- Open the menu Help - Install New Software.
- Click Add...
- Click Local...
- Select Disco locale (C:) -> Keil -> Eclipse and Click OK.
- Fill "Name:" (Keil MDK-ARM) and Click OK.
- Enable "Keil MDK-ARM", Disable "Contact all update sites during install to find required software" and Click Next.
- On the next screen, Click Finish.
- And finally Click Restart Now.
- On a successful installation, Eclipse displays a menu µVision and µVision icons in the toolbar.
To Debug an application see "MDK-ARM Plugin for Eclipse" in Keil uVision Help.
Building stand-alone libee.a using RT-Druid Eclipse
- Launch Eclipse and define a workspace (default workspace can be accepted).
- Open the menu File - New - RT-Druid Oil and C/C++ Project.
- Fill "Project name:" (EEApp) and Click Finish.
- Write conf.oil file with
EE_OPT = "__NO_APP__"
attibute inOS
object and NOAPP_SRC
attibutes inCPU_DATA
object. - conf.oil file used here can be found in examples/cortex_mx/lm4f232xxxx/EElib0/conf.oil
- Open the menu Project, check that "Build Automatically" is not selected and press "Build Project".
- Finally stand-alone libee.a is built in Debug directory.
Building ERIKA based application using KEIL uVision
To build an ERIKA based application using KEIL uVision, it needs that a stand-alone libee.a was built previously. See ARM Cortex MX#Building stand-alone libee.a using RT-Druid Eclipse above.
- Launch Keil uVision.
- Open the menu Project - New uVision Project...
- Select project folder, fill "File name:" (KEEApp) then Click Save.
- Select Device (Texas Instruments LM4F232H5DQ) and Click OK.
- In the next dialog click No because Erika provides its own startup code.
- Rename the target (TI Stellaris LM4F232H5QD) and sources group (EE).
- Right Click on source group EE and select "Add Files to Group 'EE'".
- Select libee.a built previously, Click Add and then Close.
- Click on added libee.a.
- Open the menu Project - Options for File 'libee.a'...
- Change "File Type:" from "Assembly language file" to "Library file" and Click OK.
- Right Click on "TI Stellaris LM4F232H5QD" target and select "Add Group...".
- Rename the added group to "src".
- Add in the group 'src' the startup assembly file for TI Stellaris LM4F232H5QD provided with Erika Enterprise pkg/mcu/ti_stellaris_lm4f232xxxx/src/ee_startup_keil.s
- Add in the gourp 'src' the application source file (E.g. main.c).
- main.c file used here can be found in examples/cortex_mx/lm4f232xxxx/EElib0/main.c
- Right Click on "TI Stellaris LM4F232H5QD" target and select "Options for Target 'TI Stellaris LM4F232H5QD'..."
- In the Target tab change "Floating Point Hardware:" from "Use FPU" to "Not Used".
- In the C/C++ tab Click "Include Paths" button "...".
- Adds Erika Enterprise and eecfg include paths for the application and click OK.
- In the Asm tab adds Erika Enterprise and eecfg include paths for the application (see above) and adds "--cpreproc" in "Misc Controls" input box.
- In the Linker tab adds "--entry EE_cortex_mx_default_reset_ISR --first EE_cortex_mx_vtable" in "Misc Controls" input box.
- Open the menu Project - Build target
- Open the menu Debug - Start/Stop Debug Session
Benchmarks
We run a limited set of benchmarks for the kernel, which are available at the page Erika Enterprise Benchmark for Cortex M4. Other benchmarks are available on the Category:Benchmarks.
See also
- Tutorial: Installing ERIKA and RT-Druid, and compile your first application
- Tutorial: RT-Druid and OIL basics
- NXP Semiconductor - Microcontrollers (LPCXpresso) - Web site
- Texas Instruments - Stellaris LM4F232 USB+CAN Evaluation Kits - Web site
- IAR Systems Web site
- Keil Embedded Development Tools Web site