ARM Cortex MX

From ErikaWiki

Jump to: navigation, search

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:

  1. support for IAR and ARM KEIL compiler toolchains;
  2. support for single and multi stack configurations;
  3. ISR Type 1 and Type 2 supported;
  4. support for IAR J-Link and ARM KEIL ULINK2 Debuggers.

The Cortex M4 support includes:

  1. support for Texas Instruments and ARM KEIL compiler toolchains;
  2. support for single and multi stack configurations;
  3. ISR Type 1 and Type 2 supported;
  4. support for Texas Instruments Stellaris ICDI and ARM KEIL ULINK2 Debuggers.
  • 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

Boards

Download and install

RT-Druid and ERIKA Enterprise RTOS 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.

Target Configuration and Programming

ERIKA Enterprise 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 toolchain: the IAR_CCDIR variable is able to override the path compiler set in RT-Druid during the build progress.
    • Texas Instruments compiler toolchain: CCS_INSTALL_ROOT variable is able to override the path compiler set in RT-Druid during the build progress.
    • ARM KEIL compiler toolchain: 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.

Compiler Legacy

Limited to Texas Instruments (Cortex-M4) and ARM KEIL (Cortex-M0 and Cortex-M4) compiler toolchains, it's possible to select the legacy support by followings EE_OPTs in the OS object of the OSEK/VDX configuration OIL file.

  • Texas Instruments CCSv4 4.2.4.00033 TMS470 Code Composer Tools 4.9.0 and older:
 EE_OPT = "__CCS_4_2_4_00033_OLDER__";
  • Texas Instruments CCSv4 4.2.4.00005 TMS470 Code Composer Tools 4.9.3:
 EE_OPT = "__CCS_4_2_5_00005_TMS470_4_9_3__";
  • ARM KEIL uVision 4.53.00 and older:
 EE_OPT = "__KEIL_4_54_OLDER__";

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 LPCXpresso LPC12xx MCU (Cortex M0) and Texas Instruments Stellaris LM4F232xxxx or STMicroelectronics STM32F4xx MCUs (Cortex M4).

NXP LPCXpresso 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 and STMicroelectronics STM32F4xx MCUs (Cortex M4 )

Texas Instruments Stellaris LM4F232xxxx and STMicroelectronics STM32F4xx MCUs (Cortex M4) are configured to have a flexible Interrupt Vector Table specified in pkg/mcu/ti_stellaris_lm4f232xxxx/src/ee_startup_keil.s and in pkg/mcu/st_stm32_stm32f4xx/src/startup_stm42f4xx_keil.s for ARM KEIL compiler toolchain and in pkg/mcu/ti_stellaris_lm4f232xxxx/src/ee_vtable_ccs.c for Texas Instruments compiler toolchain. 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. All of these features are not yet implemented in Cortex M0 (NXP LPCXpresso LPC12xx MCU) porting 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

CMSIS OIL file configuration

To enable CMSIS Library for 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__";
 ...

SPD OIL file configuration

To enable SPD Libraries for STMicroelectronics STM32F4DISCOVERY Evaluation board, the following code is needed in the OS object of the OSEK/VDX configuration:

 EE_OPT = "__ADD_LIBS__";
 LIB = ENABLE { NAME = "CMSIS"; };
 LIB = ENABLE { NAME = "EVAL"; };
 LIB = ENABLE { NAME = "SPD"; };
 EE_OPT = "__USE_STM32F4XX_CMSIS__";
 EE_OPT = "__USE_STM32F4XX_EVAL__";
 EE_OPT = "__USE_STM32F4XX_SPD__";

It's possible to include all libraries functions by EE_OPT attribute in the OS object of the OSEK/VDX configuration:

 EE_OPT = "__USE_SPD_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_SPD_ADC__";
 EE_OPT = "__USE_SPD_SPI__";
 EE_OPT = "__USE_SPD_TIM__";
 ...

StellarisWare OIL file configuration

To enable StellarisWare Libraries for Texas Instruments Stellaris LM4F232H5QD Evaluation Board, the following code is needed in the OS object of the OSEK/VDX configuration:

 EE_OPT = "__ADD_LIBS__";
 LIB = ENABLE { NAME = "STELLARISWARE"; };
 EE_OPT = "__STELLARISWARE_EK_LM4F232__";
 EE_OPT = "__STELLARISWARE_DRIVER_LIB__";
 EE_OPT = "__STELLARISWARE_GRAPHICS_LIB__";

It's possible to include all libraries functions by EE_OPT attribute in the OS object of the OSEK/VDX configuration:

 EE_OPT = "__USE_STELLARISWARE_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_STELLARISWARE_ADC__";
 EE_OPT = "__USE_STELLARISWARE_SSI__";
 EE_OPT = "__USE_STELLARISWARE_TIMER__";
 ...

AUTOSAR "Like" Drivers

Texas Instruments Stellaris LM4F232H5QD Evaluation Board (Cortex M4) is supported through AUTOSAR "Like" Drivers too. Documentation can be found at Stellaris AUTOSAR Drivers.

Examples

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).
Eclipse Workspace Selection Dialog.
  • Open the menu Help - Install New Software.
Eclipse New Software Installation.
  • Click Add...
Eclipse Software Repository Install Dialog.
  • Click Local...
Eclipse Local Software Repository Selection Dialog.
  • Select Disco locale (C:) -> Keil -> Eclipse and Click OK.
Eclipse Local Software Repository Folder Selection Dialog.
  • Fill "Name:" (Keil MDK-ARM) and Click OK.
Eclipse Local Software Repository Selection Dialog.
  • Enable "Keil MDK-ARM", Disable "Contact all update sites during install to find required software" and Click Next.
Eclipse Software Repository Install Dialog.
  • On the next screen, Click Finish.
Eclipse Software Installation Details Dialog.
  • And finally Click Restart Now.
Eclipse Software Installation Details Dialog.
  • On a successful installation, Eclipse displays a menu ┬ÁVision and ┬ÁVision icons in the toolbar.
Eclipse New Software Installation.

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).
Eclipse Workspace Selection Dialog.
  • Open the menu File - New - RT-Druid Oil and C/C++ Project.
RT-Druid Oil and C/C++ Project Menu Selection.
  • Fill "Project name:" (EEApp) and Click Finish.
C Project Setting-up.
Application Oil file writing.
  • Open the menu Project, check that "Build Automatically" is not selected and press "Build Project".
Application Building.
  • Finally stand-alone libee.a is built in Debug directory.
Application Build Finished.

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.
Keil uVision Main Window.
  • Open the menu Project - New uVision Project...
Keil uVision New Project Selection.
  • Select project folder, fill "File name:" (KEEApp) then Click Save.
Keil uVision New Project Creation.
  • Select Device (Texas Instruments LM4F232H5DQ) and Click OK.
Keil uVision Device Selection.
  • In the next dialog click No because Erika provides its own startup code.
Keil uVision Device Selection.
  • Rename the target (TI Stellaris LM4F232H5QD) and sources group (EE).
Keil uVision Device Selection.
  • Right Click on source group EE and select "Add Files to Group 'EE'".
  • Select libee.a built previously, Click Add and then Close.
Keil uVision "Add Files to Group 'EE'".
  • Click on added libee.a.
  • Open the menu Project - Options for File 'libee.a'...
Keil uVision "Options for File 'libee.a'...".
  • Change "File Type:" from "Assembly language file" to "Library file" and Click OK.
Keil uVision "Options for File 'libee.a'...".
  • 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
Keil uVision Startup File.
Keil uVision Application Source File.
  • 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".
Keil uVision Taget Setup.
  • In the C/C++ tab Click "Include Paths" button "...".
Keil uVision C/C++ Setup.
  • Adds Erika Enterprise and eecfg include paths for the application and click OK.
Keil uVision Include Path Folder Setup.
  • In the Asm tab adds Erika Enterprise and eecfg include paths for the application (see above) and adds "--cpreproc" in "Misc Controls" input box.
Keil uVision Assembly Setup.
  • In the Linker tab adds "--entry EE_cortex_mx_default_reset_ISR --first EE_cortex_mx_vtable" in "Misc Controls" input box.
Keil uVision Linker Setup.
  • Open the menu Project - Build target
Keil uVision Build Target.
  • Open the menu Debug - Start/Stop Debug Session
Keil uVision 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

Personal tools