Difference between revisions of "AVR8"

From ERIKA WIKI
Jump to: navigation, search
(Configuration and Programming)
(BOARD)
 
(42 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Introduction =
+
= introduction =
Embedded microcontroller units are spreading in thousands of applications, ranging from single to distributed systems, control applications, multimedia, communication, medical applications and many others. Modern microcontrollers, which are growing in computational power, speed and interfacing capabilities, are more and more feeling the need of tools to make the development of complex scalable applications easier.
+
This manual describes the porting details of the ERIKA Enterprise v3 kernel(s) for the Atmel (now Microchip) families of microcontrollers which support 8/16-bit RISC AVR cores (aka AVR8).
  
This manual describes the porting details of the ERIKA Enterprise v3 kernel(s) for the Atmel families of microcontrollers which supports 8/16-bit RISC AVR cores (aka AVR8).
+
= AVR8 Features Supported =
  
== ERIKA Enterprise v3 and RT-Druid v3 for AVR8 ==
+
The following are the main features of the currently implemented support:
Embedded applications often require tight control on the temporal behavior of each single activity in the system. Real-time complex system systems such as Wireless Sensor Networks are nowadays deployed in academic and industrial environments. The very limited set of resources available in the popular hardware platforms, and the diversified domains of WSN applications, require the adoption of an Operating System responding to the following pre-requisites:
 
* minimum footprint to fit the limited RAM capacity (of the order of few KB);
 
* tunable scheduling algorithm to handle the execution of the tasks;
 
* an application interface acting on the kernel layer and well decoupled from OS service implementation.
 
  
ERIKA Enterprise v3 and RT-Druid v3 represent the answer of Evidence Srl for the development of scalable real-time applications for AVR8.
+
* Development tools
 +
** Support for AVR GCC compiler [http://winavr.sourceforge.net/download.html WinAVR]
 +
* Microcontrollers
 +
** [http://www.microchip.com/design-centers/8-bit/avr-mcus Microchip AVR MCUs] Families
 +
*** [https://www.microchip.com/wwwproducts/en/ATmega328P Microchip ATmega328P] Specific MCU.
 +
* Evaluation Boards
 +
** [https://store.arduino.cc/arduino-uno-rev3 Arduino Uno Board] (ATmega328p)
 +
* External Libraries
 +
** Full support for [https://www.arduino.cc/en/Main/Software Arduino SDK 1.8.5];
  
ERIKA Enterprise v3 provides AVR8 developers the following features:
+
== Tutorials ==
  
* Traditional RTOS features:
+
The following tutorials are available for this architecture:
** Support for four conformance classes to match different application requirements;
+
* [[AVR8_-_Arduino_application_build_on_Windows|AVR8: Arduino application build on Windows]]
** Support for preemptive and non-preemptive multitasking;
 
** Support for fixed priority scheduling;
 
** Support for stack sharing techniques, and one-shot task model to reduce the overall stack usage;
 
** Support for shared resources;
 
** Support for periodic activations using Alarms;
 
** Support for centralized Error Handling;
 
** Support for hook functions before and after each context switch.
 
  
* RT-Druid development environment
+
= Configuration and Programming =
** Development environment based on the Eclipse IDE;
 
** Support for the OIL language for the specification of the RTOS configuration;
 
** Graphical configuration plugin to easily generate the OIL configuration file and to easily configure the RTOS parameters;
 
** Full integration with the Cygwin development environment to provide a Unix-style scripting environment;
 
** Apache ANT scripting support for code generation.
 
  
* AVR8 integration features
+
ERIKA Enterprise is configured through [[Tutorial: RT-Druid and OIL basics | RT-Druid and an OIL file]] and some other properties.
** Support for AVR8 GCC compiler;
 
** Support for the following families Atmel MCUs:
 
*** [http://www.atmel.com/products/microcontrollers/avr/megaAVR.aspx megaAVR]
 
** Support for following boards
 
*** [https://store.arduino.cc/arduino-uno-rev3 Arduino Uno Board] (ATmega328p)
 
** List of functions:
 
*** Full support for [https://www.arduino.cc/en/Main/Software Arduino SDK 1.8.5];
 
  
== Integration with other tools for AVR8 ==
+
The following sections describe the properties and OIL fields customized for Atmel (now Microchip) AVR8 architecture.
ERIKA Enterprise and RT-Druid aims to the best integration with the existing tools for development available from the AVR microcontrollers.
 
RT-Druid will be used to quickly configure the application, setting temporal parameters of real-time tasks, memory requirements, stack allocation and many other parameters. Moreover, RT-Druid generates the application template, and leaves the developer the task to implement the logic of each single task.
 
While programming the application, the developer can exploit the power and flexibility offered by the primitives of the ERIKA Enterprise real-time kernel.
 
ERIKA Enterprise also supports the compiling environments provided by Atmel, providing also direct support for the programming and JTAG solutions of Atmel.
 
  
== Content of this document ==
+
== Compiler Path ==
The purpose of this document is to describe all the information needed to create, develop and modify an Erika Enterprise application for the AVR family of microcontrollers.
 
  
In particular, the document describes:
+
It is possible to choose the path of the compiler in three different ways:
* The design flow which should be used to generate an Erika Enterprise application;
 
* The configuration of the development environment;
 
* The options which are available to configure the system.
 
  
As a final note, all the settings which are explained in this document apply both to Erika Enterprise if not otherwise stated.
+
* ''Compiler specific environment variables'': '''AVR_TOOLS'''
 +
** E.g.: AVR_TOOLS=C:\WinAVR
 +
* ''RT-Druid Eclipse IDE Property''.
 +
* ''RT-Druid Configuration File Entry'': '''preference_avr8__path_for_gcc_compiler'''
 +
** E.g.: preference_avr8__path_for_gcc_compiler=C:\WinAVR
  
<pre>
+
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
Note: If you are looking for a step-by-step / quick guide tutorial on how to use Erika Enterprise and RT-Druid with AVR,
 
please read the “Erika Enterprise Tutorial for the AVR microcontrollers”, available for download on the Evidence Web site.
 
</pre>
 
 
 
 
 
== Configuration and Programming ==
 
 
 
ERIKA Enterprise is configured through [[Tutorial: RT-Druid and OIL basics | RT-Druid and an OIL file]]. Here are listed, after the information to set compiler path, the OIL fields customized for Atmel AVR8 architecture.
 
  
=== Compiler Path ===
+
== Arduino SDK Path ==
  
It is possible to choose the path of the compiler in three different ways:
+
It is possible to choose the path in three different ways:
  
* ''PATH enviornment variable'': You can put compilers bin directories in PATH and the environmet can use them from here.
+
* ''Specific environment variables'': '''ARDUINO_SDK_FILES'''
* ''Compiler specific environment variables'':
+
** E.g.: ARDUINO_SDK_FILES=C:\Program Files (x86)\Arduino
** '''AVR8 GCC toolchain''': You can specify the compiler path for AVR8 GCC with the '''AVR_TOOLS'''.
+
* ''RT-Druid Eclipse IDE Property''.
* ''RT-Druid configuration file'' see [[RT-Druid configuration#Compiler paths]]:
+
* ''RT-Druid Configuration File Entry'': '''preference_avr8__path_for_arduino_sdk'''
** '''preference_avr8__path_for_gcc_compiler''' set GCC compiler path for AVR8
+
** E.g.: preference_avr8__path_for_arduino_sdk=C:\Program Files (x86)\Arduino
  
 
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
 
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
  
=== CPU ===
+
== Arduino Serial Port ==
  
'''CPU_DATA''' must be set to '''AVR8'''.
+
It is possible to choose the Serial Port for Arduino in two different ways:
  
Example of a CPU_DATA section:
+
* ''RT-Druid Eclipse IDE Property''.
 +
* ''RT-Druid Configuration File Entry'': '''preference_avr8__serial_port_for_arduino'''
 +
** E.g.: preference_avr8__serial_port_for_arduino=COM5
  
    CPU_DATA = AVR8 {
+
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
      ...
 
    };
 
  
=== MCU ===
+
== Arduino Serial Baudrate ==
  
'''MCU_DATA''' supports for now the '''MEGA''' value only.
+
It is possible to choose the Serial Baudrate for Arduino in two different ways:
  
'''MODEL''' attribute of '''MCU_DATA''' supports for now the '''MEGA_328p''' value only.
+
* ''RT-Druid Eclipse IDE Property''.
 +
* ''RT-Druid Configuration File Entry'': '''preference_avr8__serial_baudrate_for_arduino'''
 +
** E.g.: preference_avr8__serial_baudrate_for_arduino=115200
  
  MCU_DATA = MEGA {
+
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
    MODEL = MEGA_328p;
 
  };
 
  
=== BOARD ===
+
== CPU ==
  
There is only support form TriBoard TC2x5. This board only provide debug interface and 8 leds, so the support is limited to the LEDs configuration/driving and, because standard ERIKA demos require it, an external button (''external'' means that have to be soldered by the user) mounted on pin P15.8 of (corresponding to pin 71 of PERIPHERALS (Xx02,Xx02) connector). Add the following OIL field to enable this support.
+
'''CPU_DATA''' must be set to '''AVR8'''.
  
  BOARD_DATA = TRIBOARD_TC2X5;
+
The available <tt>COMPILER</tt> is <tt>GCC</tt>.
  
=== Interrupt Handling ===
+
Example of a CPU_DATA section:
  
Due to the special implementation of the Interrupt Vector in AURIX architecture, each entry of the vector table is simply identified by it's priority value. It must be the application code that configure the service request node (''SRN''') with the right priority, assigning in this way the right handler.
+
    CPU_DATA = AVR8 {
 +
      COMPILER = GCC;
 +
      ...
 +
    };
  
  ISR IsrLow {
+
== MCU ==
    CATEGORY = 2;
 
    PRIORITY = 1;
 
    HANDLER = "isr_low";
 
  };
 
  
The mean of the fields are:
+
'''MCU_DATA''' object supports for now the '''MEGA''' value only.
*'''CATEGORY''': the type of ISR as specified by OSEK.
 
*'''PRIORITY''': The ISR priority that represent it's position inside Interrupt Vector so it has to be considered as ISR Identifier. The '''ENTRY''' field, the one usually used to declare Interrupt IDs, is still available but it's superfluous because it has to be equal to PRIORITY and, in any case, priority value take the precedence.
 
*'''HANDLER''': Declare the interrupt handler symbol. If it's not declared the the handler symbol is supposed to be equal to ISR block name (IsrLow in the example).
 
  
=== Trap Handling ===
+
Example of a MCU_DATA section:
  
With TriCore AURIX, for the first time, we support the options to register handler for TRAP/Exceptions. OSEK OIL do not provide any field for trap handling: it suppose that all the handling is done inside the Kernel. Usually that's what happens, but sometime can be useful have some mechanism to attach an handler for a particular class of TRAPs.
+
    MCU_DATA = MEGA {
 +
      ...
 +
    };
  
We decide to exetend ISR entry with the field '''TRAP''' that can be set to TRUE to enable TRAP handling. In this case you have to choose the TRAP class with the field LEVEL (or ENTRY). The only valid values for this configuration are:
+
=== MODEL ===
  
*'''TRAP_MMU''' (Actually useless because TC27x and TC26x families don't have MMU, just a place holder)
+
'''MODEL''' attribute of '''MCU_DATA''' supports for now the '''MEGA_328p''' value only.
*'''TRAP_PROT''' (Handler for protection traps)
+
Default value is '''MEGA_328p'''.
*'''TRAP_INST''' (Handler for instructions traps)
 
*'''TRAP_CONT''' (Handler for context traps)
 
*'''TRAP_BUS''' (Handler forn bus traps)
 
*'''TRAP_ASS''' (Handler for assertion traps) (please don't be silly :))
 
*'''TRAP_SYS''' (Handler for system calls)
 
*'''TRAP_NMI''' (Handler for NMI trap)
 
  
OIL TRAP configuration example:
+
Example of MODEL attribute of a MCU_DATA section:
  
   ISR trap_context {
+
   MCU_DATA = MEGA {
      LEVEL = "TRAP_CONT";
+
    MODEL = MEGA_328p;
      HANDLER = "EE_trap_context";  //Trap handler
 
      TRAP = TRUE;
 
 
   };
 
   };
  
To define the handler in your code, you have to use the following syntax:
+
== BOARD ==
  
  TRAP(EE_CLASS_TRAPCONT, EE_trap_context) {
+
For now, there is no NATIVE board support for AVR8 Architecture. The ONLY supported board is [[Arduino]] by [https://www.arduino.cc/en/Main/Software Arduino SDK 1.8.5].
    while(1) {
 
      ; /* dummy */
 
    }
 
  }
 
  
TRAP class identifiers are the following:
+
'''NOTE:''' To support a custom board, it's mandatory to install the Arduino SDK software package and correctly set the related RT-Druid properties.
  
*EE_CLASS_TRAPMMU
+
Moreover it's mandatory to set the ''F_CPU'' macro according to the ''CLOCK FREQUENCY'' set by custom AVR8 MCU Driver (e.g. 16MHz in the following example).
*EE_CLASS_TRAPPROT
 
*EE_CLASS_TRAPINST
 
*EE_CLASS_TRAPCONT
 
*EE_CLASS_TRAPBUS
 
*EE_CLASS_TRAPASS
 
*EE_CLASS_TRAPSYS
 
*EE_CLASS_TRAPNMI
 
  
Inside the TRAP handler TIN (Trap Identification Number) value can be accessed with '''EE_tc_get_TIN()''' function or, for HIGHTEC GNUC Compiler, with the local variable '''tin'''. For more information you can check the '''$(ee)/pkg/cpu/tricore/inc/ee_tc_trap.h''' file.
+
  ...
 
+
  OS myOs {
=== EEOPT ===
+
    ...
 
+
    CFLAGS = "-DF_CPU=16000000L";
EEOPT is a way to specify configuration flags to the Erika build environment.
 
EEOPTs can be specified as strings in the OS section of the OIL file. Examples:
 
 
 
EE_OPT = "EE_DEBUG";
 
EE_OPT = "__ASSERT__";
 
 
 
Please notice that spelling inside the OIL file includes an underscore: EE_OPT.
 
 
 
The only supported format for EEOPTs is a single name, which should be a valid C identifier (i.e., only Latin letters, digits, and underscore are allowed; the first character cannot be a digit). And any other format is not supported, and even if it works now, it may break in the future.
 
 
 
The following EEOPTs are specific of AURIX Architecture:
 
* '''EE_DEBUG''': Replace the often used DEBUG option (because it conflict with compilers DEBUG define). Enable debug compiler options, basically less optimization and debug symbols generation plus defualt TRAP handlers are implemented as busy loops instead of system reset.
 
* '''EE_EXECUTE_FROM_RAM''': When specified, a linker script is used that maps both code and data in the RAM space. Executables produced with this option can be used only together with a debugger that loads the program in memory. By default, code and constant data are mapped to Flash, data to RAM.
 
* '''EE_SAVE_TEMP_FILES''': Enable temporary files saving for the compiler, useful to debug build process and to inspect generate assembly code. It's useful only for HIGHTEC GCC compiler because for TASKING compiler is always active. For the GCC compiler it has been added the switch because the size of temporary files is '''huge'''.
 
* '''EE_ICACHE_ENABLED''': Enable the instruction cache in start-up code.
 
* '''EE_DCACHE_ENABLED''': Enable data cache in start-up code
 
 
 
= OSEK/VDX Extensions =
 
 
 
This Section contains information about the OSEK/VDX Extensions (or optional features) that have been implemented for the AURIX support.
 
 
 
=== 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 resource to the corrisponding ISR object as follows:
 
 
 
  TASK Task1 {
 
 
     ...
 
     ...
    RESOURCE = "ResourceA";
 
 
   };
 
   };
    
+
   ...
  ISR <SYMBOL> {
 
    PRIORITY = <PRIORITY_LEVEL>;
 
    CATEGORY = <ISR_TYPE>;
 
    RESOURCE = "ResourceA";
 
  };
 
 
 
  RESOURCE ResourceA { RESOURCEPROPERTY = STANDARD; };
 
  
=== System Timer ===
+
== LIB ==
  
The OSEK/VDX standard provides support for a '''System Counter''' (a counter that is automatically linked to a hardware timer). The System Timer is used to give a coherent timing reference across the entire application.
+
'''LIB''' object supports for now the '''ARDUINO''' value only.
  
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 '''for each core''' can be the System Timer.
+
Example of a LIB section:
  
A Counter which is not a System Counter must be incremented explicitly using the Autosar primitive '''IncrementCounter'''.
+
    LIB = ARDUINO {
 
+
      ...
The following is an example OIL definition for a System Counter:
 
 
 
  CPU_DATA = TRICORE{
 
    CPU_CLOCK = 200.0;
 
    ...
 
  };
 
 
 
  COUNTER SystemTimer {
 
    MINCYCLE = 1;
 
    MAXALLOWEDVALUE = 2147483647;
 
    TICKSPERBASE = 1;
 
    TYPE = HARDWARE {
 
      DEVICE = "STM_SR0";
 
      SYSTEM_TIMER = TRUE;
 
      PRIORITY = 1;
 
 
     };
 
     };
    SECONDSPERTICK = 0.001;
 
  };
 
  
The meaning of the various attributes is as follows:
+
=== ARDUINO ===
* '''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 TRICORE only '''STM''' (System Timer Module) MCU peripheral is a valid device for system timer. Both Interrupt source of this peripheral can be set to device and allowed values are '''STM_SR0''' and '''STM_SR1'''
 
* '''COUNTER/TYPE/PRIORITY''' By default SYSTEM_TIMER is tied to smallest ISR priority (i.e. PRIORITY = 1;), but it can be overritten. Ovveride is necessay in multicore environment because priority 1 is used by the '''Intercore Interrupt Request'''.
 
* '''COUNTER/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:
+
The following sections describe the OIL fields of the '''LIB''' object customized for the official '''ARDUINO''' SDK supports.
  
  ALARM AlarmExample {
+
==== SDK_BOARD ====
    COUNTER = SystemTimer;
 
    ACTION  = ACTIVATETASK{
 
      TASK = TaskExample;
 
    };
 
  };
 
  
= CPU MCU & BOARD API =
+
'''SDK_BOARD''' attribute of '''ARDUINO''' supports for now the '''UNO''' value only.
 +
Default value is '''UNO'''.
  
In addition to '''AUTOSAR OS Kernel Interface''', in ERIKA AURIX porting are implemented a bunch of utility functions that will be considered as part of '''ERIKA API'''. As usual they are separated in the three logical layer that compose ERIKA architecture abstraction: '''CPU, MCU & BOARD'''.
+
Example of SDK_BOARD attribute of ARDUINO:
  
=== CPU API ===
+
    LIB = ARDUINO {
 +
      SDK_BOARD = UNO;
 +
      ...
 +
    };
  
CPU layer represent all the behaviour shared between all the families of AURIX MCUs. In this layer are declared the functions to temporary disable '''ENDINIT''' and '''SAFETY_ENDINIT''' register protection (see Infineon AURIX documentation). These functions are a little bit tricky: ''declaration'' belong to CPU layer, because AURIX architecture documentation states that every AURIX implementation has some kind of '''ENDINIT''' and '''SAFETY_ENDINIT''' protection, but delegate implementation details to each AURIX family, so functions ''definitions'' has been done inside MCU files.
+
==== VARIANT ====
  
* '''void EE_tc_endint_disable( void )''': Temporary disable ENDINT protection.
+
'''VARIANT''' attribute of '''ARDUINO''' supports for now the '''CC''' value only.
* '''void EE_tc_endint_enable( void )''': Re-enable ENDINT protection.
+
Default value is '''CC'''.
  
* '''void EE_tc_safety_endinit_disable( void )''': Temporary disable SAFETY_ENDINIT protection.
+
Example of VARIANT attribute of ARDUINO:
* '''void EE_tc_safety_endinit_enable( void )''': Re-enable SAFETY_ENDINIT protection.
 
  
=== MCU API ===
+
    LIB = ARDUINO {
 +
      SDK_BOARD = UNO;
 +
      VARIANT = CC;
 +
      ...
 +
    };
  
MCU layer represent the behaviour tied to an specific AURIX family of MCUs. For now only family TC27x is supported.
+
===== VERSION =====
Most part of the utilities belong to this layer:
 
  
* '''void EE_tc2Yx_get_clock ( void )''': Return CPU clock frequency in HZ.
+
'''VERSION''' attribute of '''ARDUINO CC VARIANT''' supports for now the '''"1.8.5"''' value only.
* '''void EE_tc2Yx_configure_clock( EE_UREG fclock )''': Make the best effort to set CPU clock frequency to fclock value. It's the function used by '''StartOS''' when a '''CPU_CLOCK''' is configured in '''CPU_DATA'''.
+
Default value is '''"1.8.5"'''.
* '''void EE_tc2Yx_delay ( EE_UREG usec )''': Implement a busy loop wait of '''usec''' micorseconds.
 
* '''void EE_tc2Yx_stm_set_sr0( EE_UINT32 usec, EE_TYPEISR2PRIO intvec )''': Programs '''STM compare register 0''' to trigger an IRQ after '''usec''' microseconds. '''intvec''' is the priority tied to this source, in other words it is the Interrupt Vector Table entry that will handle STM interrupt. With intvec == 0, the correponding service request node is left unprogrammed or resetted.
 
* '''void EE_tc2Yx_stm_set_sr0_next_match( EE_UINT32 usec )''': Change '''previous programmed''' STM compare register 0 to trigger next IRQ after usec microseconds. To mantain fixed interrupt interval, it have to been called at the beginning of '''intvec''' handler.
 
* '''void EE_tc2Yx_stm_set_sr1( EE_UINT32 usec, EE_TYPEISR2PRIO intvec )''': Programs '''STM compare register 1''' to trigger an IRQ after '''usec''' microseconds. '''intvec''' is the priority tied to this source, in other words it is the Interrupt Vector Table entry that will handle STM interrupt. With intvec == 0, the correponding service request node is left unprogrammed or resetted.
 
* '''void EE_tc2Yx_stm_set_sr1_next_match( EE_UINT32 usec )''': Change '''previous programmed''' STM compare register 1 to trigger next IRQ after usec microseconds. To mantain fixed interrupt interval, it have to been called at the beginning of '''intvec''' handler.
 
  
'''SR0''' and '''SR1''' API are both available to the user if '''System Timer''' is '''not''' configured. Otherwise only the one not used by system timer will be available.
+
Example of VERSION attribute of ARDUINO CC VARIANT:
  
=== Board API ===
+
    LIB = ARDUINO {
 +
      SDK_BOARD = UNO;
 +
      VARIANT = CC {
 +
        VERSION = "1.8.5";
 +
      };
 +
      ...
 +
    };
  
BOARD layer represent the specific board support. There is only aminimal support for TriBoard TC2x5 v2.0 equiped with a TC275TE MCU:
+
==== STAND_ALONE ====
  
* '''void EE_tc2x5_leds_init( void )''': Initialize the 8 boards leds.
+
'''STAND_ALONE''' boolean attribute of '''ARDUINO''' configures the build system to generate or not '''libarduinosdk.a''' stand-alone binary library. The default value is set to '''TRUE'''.
* '''void EE_tc2x5_leds_on( void )''': Turns all the 8 leds.
+
Default value is '''TRUE'''.
* '''void EE_tc2x5_leds_off( void )''': Turns off all the 8 leds.
 
* '''void EE_tc2x5_turn_led(enum EE_tc2x5_led_id led_id, enum EE_tc2x5_led_status onoff)''': Turn the status of the led '''led_id''' (led IDs are collected in an enum in the form: '''EE_TRIBOARD_2X5_LED_{x}''' with {x}=[1..8]) on (onoff == '''EE_TRIBOARD_2X5_LED_ON''') or off (onoff == '''EE_TRIBOARD_2X5_LED_OFF''').
 
* '''EE_BIT EE_tc2x5_read_button( void ): read external button value
 
* '''void EE_tc2x5_button_irq_init( EE_TYPEISR2PRIO intvec )''': Configure the external button has an interrupt source and tie it to '''intvec''' priority handler.
 
* '''void EE_tc2x5_button_irq_clear_request( void )''': Clear external button interrupt request.
 
  
External button have to be connected to pin P15.8 on TC275TE corrisponding to pin 71 of PERIPHERALS (Xx02,Xx02) connector of TriBoard TC2x5.
+
Example of STAND_ALONE attribute of ARDUINO:
  
= Debugger support =
+
    LIB = ARDUINO {
 +
      SDK_BOARD = UNO;
 +
      VARIANT = CC {
 +
        VERSION = "1.8.5";
 +
      };
 +
      STAND_ALONE = TRUE;
 +
    };
  
* [[Lauterbach TRACE32 Support for Infineon Aurix]]
+
== Interrupt Handling ==
* [[iSYSTEM winIDEA Support for Infineon Aurix]]
 
  
= Multicore Autosar OS Support =
+
Interrupt Handling is microcontroller dependent so for each supported Atmel (now Microchip) AVR8 microcontroller family, the ISRs configuration of ERIKA Enterprise v3 is shown below.
  
For details please see the following page: [[Erika AUTOSAR OS]]
+
=== MEGA Family ===
  
=== Build Multicore Application Single ELF with HighTec GCC Compiler ===
+
The '''MEGA''' family of '''AVR8''' microcontrollers has an interrupt vector table which is stored in the flash memory. The lowest addresses of the interrupt vector table are allocated to the RESET and to the interrupt vectors. Interrupt handlers placed at lower addresses have higher hardware priorities than interrupt handlers placed at higher addresses so the '''PRIORITY''' attribute of the '''ISR''' object in the OIL is USELESS. The complete list of '''SOURCE''' entries is shown below.
  
The conventional ERIKA multicore build chain generate an ELF file for each core and the real application image is loaded on the device by Lauterbach, trought scripts. This approach is not straightforwardly portable on other programmer tools. Fortunately HighTec GCC Compiler has some peculiar features that have allowed us to change this approach, and for TriCore is possible to compile a Multicore Application contained in a single ELF.
+
* <code>RESET</code>: External Pin, Power-on Reset, Brown-out Reset and Watchdog System Reset
 +
* <code>INT0</code>: External Interrupt Request 0
 +
* <code>INT1</code>: External Interrupt Request 1
 +
* <code>PCINT0</code>: Pin Change Interrupt Request 0
 +
* <code>PCINT1</code>: Pin Change Interrupt Request 1
 +
* <code>PCINT2</code>: Pin Change Interrupt Request 2
 +
* <code>WDT</code>: Watchdog Time-out Interrupt
 +
* <code>TIMER2_COMPA</code>: Timer/Counter2 Compare Match A
 +
* <code>TIMER2_COMPB</code>: Timer/Counter2 Compare Match B
 +
* <code>TIMER2_OVF</code>: Timer/Counter2 Overflow
 +
* <code>TIMER1_CAPT</code>: Timer/Counter1 Capture Event
 +
* <code>TIMER1_COMPA</code>: Timer/Counter1 Compare Match A
 +
* <code>TIMER1_COMPB</code>: Timer/Coutner1 Compare Match B
 +
* <code>TIMER1_OVF</code>: Timer/Counter1 Overflow
 +
* <code>TIMER0_COMPA</code>: Timer/Counter0 Compare Match A
 +
* <code>TIMER0_COMPB</code>: Timer/Counter0 Compare Match B
 +
* <code>TIMER0_OVF</code>: Timer/Counter0 Overflow
 +
* <code>SPI_STC</code>: SPI Serial Transfer Complete
 +
* <code>USART_RX</code>: USART Rx Complete
 +
* <code>USART_UDRE</code>: USART, Data Register Empty
 +
* <code>USART_TX</code>: USART, Tx Complete
 +
* <code>ADC_ADC</code>: Conversion Complete
 +
* <code>EE_READY</code>: EEPROM Ready
 +
* <code>ANALOG_COMP</code>: Analog Comparator
 +
* <code>TWI</code>: 2-wire Serial Interface
 +
* <code>SPM_READY</code>: Store Program Memory Ready
  
To enable this new build method add the following '''EEOPT=EE_BUILD_SINGLE_ELF''' to the project OIL file.
+
== EEOPT ==
  
To export some symbols from a core an '''HighTec GCC export file''' is needed. An HighTec export file looks like this:
+
The following EEOPTs are specific of AVR8 Architecture:
 +
* '''__AVR8_GCC_C99__''': Enables C99 compiler option.
  
  EXPORT FUNCTION _START ;
+
= OSEK/VDX Extensions =
  EXPORT FUNCTION ErrorHook ;
 
  EXPORT FUNCTION StartupHook ;
 
  EXPORT FUNCTION ShutdownHook ;
 
 
 
  EXPORT OBJECT EE_oo_ErrorHook_ServiceID ;
 
  EXPORT OBJECT EE_oo_ErrorHook_data ;
 
 
 
  ...
 
  
To inform the build system to use an export file for a given core change the '''COMPILER_TYPE''' field of '''CPU_DATA''' OIL container, in the following way:
+
This Section contains information about the OSEK/VDX Extensions (or optional features) that have been implemented for the AVR8 support.
 
 
  CPU_DATA = TRICORE {
 
    ID = "master";
 
    ...
 
    COMPILER_TYPE = GNU {
 
      EXPORT_FILE = "<relative path to the export file>";
 
    };
 
    ...
 
  }; 
 
  
If this is done add explicitly '''EEOPT=EE_BUILD_SINGLE_ELF''' is no more needed.
+
== System Timer ==
  
'''N.B:''' When used this approach an export files for the master core have to be provided always. The file can be empty if no symbols have to be exported by master core.
+
System Timer is microcontroller dependent so for each supported Atmel (now Microchip) AVR8 microcontroller family, the System Timer configuration of ERIKA Enterprise v3 is shown below.
  
This build approach is showed on following RT-Druid TriCore templates:
+
=== MEGA Family ===
  
''tricore/infineon_TriBoard-TC2X5_V2.0/Multicore automatic tests/Multicore System StartUp test''
+
For the '''MEGA''' family of '''AVR8''' microcontrollers the System Timer is linked to TIMER1 so the '''DEVICE''' attribute MUST be se to '''TIMER1_COMPA''' as shown below.
  
''tricore/infineon_TriBoard-TC2X5_V2.0/Multicore automatic tests/Multicore Spinlocks test''
+
  COUNTER SystemTimer {
 +
    MINCYCLE = 1;
 +
    MAXALLOWEDVALUE = 65535;
 +
    TICKSPERBASE = 1;
 +
    TYPE = HARDWARE {
 +
      DEVICE = "TIMER1_COMPA";
 +
      SYSTEM_TIMER = TRUE;
 +
    };
 +
    SECONDSPERTICK = 0.001;
 +
  };
  
 
= Additional Notes =
 
= Additional Notes =
  
Since ERIKA 2.4.0 full AUTOSAR SC4 OS support for AURIX is publically released: you can find all the information about the implemented features and how to configure them at this page: [[Erika AUTOSAR OS]].
+
T.B.D.
 +
 
 +
[[Category:Architectures]]

Latest revision as of 10:27, 26 September 2018

introduction

This manual describes the porting details of the ERIKA Enterprise v3 kernel(s) for the Atmel (now Microchip) families of microcontrollers which support 8/16-bit RISC AVR cores (aka AVR8).

AVR8 Features Supported

The following are the main features of the currently implemented support:

Tutorials

The following tutorials are available for this architecture:

Configuration and Programming

ERIKA Enterprise is configured through RT-Druid and an OIL file and some other properties.

The following sections describe the properties and OIL fields customized for Atmel (now Microchip) AVR8 architecture.

Compiler Path

It is possible to choose the path of the compiler in three different ways:

  • Compiler specific environment variables: AVR_TOOLS
    • E.g.: AVR_TOOLS=C:\WinAVR
  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_avr8__path_for_gcc_compiler
    • E.g.: preference_avr8__path_for_gcc_compiler=C:\WinAVR

Here is an example of RT-Druid configuration file.

Arduino SDK Path

It is possible to choose the path in three different ways:

  • Specific environment variables: ARDUINO_SDK_FILES
    • E.g.: ARDUINO_SDK_FILES=C:\Program Files (x86)\Arduino
  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_avr8__path_for_arduino_sdk
    • E.g.: preference_avr8__path_for_arduino_sdk=C:\Program Files (x86)\Arduino

Here is an example of RT-Druid configuration file.

Arduino Serial Port

It is possible to choose the Serial Port for Arduino in two different ways:

  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_avr8__serial_port_for_arduino
    • E.g.: preference_avr8__serial_port_for_arduino=COM5

Here is an example of RT-Druid configuration file.

Arduino Serial Baudrate

It is possible to choose the Serial Baudrate for Arduino in two different ways:

  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_avr8__serial_baudrate_for_arduino
    • E.g.: preference_avr8__serial_baudrate_for_arduino=115200

Here is an example of RT-Druid configuration file.

CPU

CPU_DATA must be set to AVR8.

The available COMPILER is GCC.

Example of a CPU_DATA section:

   CPU_DATA = AVR8 {
     COMPILER = GCC;
     ...
   };

MCU

MCU_DATA object supports for now the MEGA value only.

Example of a MCU_DATA section:

   MCU_DATA = MEGA {
     ...
   };

MODEL

MODEL attribute of MCU_DATA supports for now the MEGA_328p value only. Default value is MEGA_328p.

Example of MODEL attribute of a MCU_DATA section:

 MCU_DATA = MEGA {
   MODEL = MEGA_328p;
 };

BOARD

For now, there is no NATIVE board support for AVR8 Architecture. The ONLY supported board is Arduino by Arduino SDK 1.8.5.

NOTE: To support a custom board, it's mandatory to install the Arduino SDK software package and correctly set the related RT-Druid properties.

Moreover it's mandatory to set the F_CPU macro according to the CLOCK FREQUENCY set by custom AVR8 MCU Driver (e.g. 16MHz in the following example).

 ...
 OS myOs {
   ...
   CFLAGS = "-DF_CPU=16000000L";
   ...
 };
 ...

LIB

LIB object supports for now the ARDUINO value only.

Example of a LIB section:

   LIB = ARDUINO {
     ...
   };

ARDUINO

The following sections describe the OIL fields of the LIB object customized for the official ARDUINO SDK supports.

SDK_BOARD

SDK_BOARD attribute of ARDUINO supports for now the UNO value only. Default value is UNO.

Example of SDK_BOARD attribute of ARDUINO:

   LIB = ARDUINO {
     SDK_BOARD = UNO;
     ...
   };

VARIANT

VARIANT attribute of ARDUINO supports for now the CC value only. Default value is CC.

Example of VARIANT attribute of ARDUINO:

   LIB = ARDUINO {
     SDK_BOARD = UNO;
     VARIANT = CC;
     ...
   };
VERSION

VERSION attribute of ARDUINO CC VARIANT supports for now the "1.8.5" value only. Default value is "1.8.5".

Example of VERSION attribute of ARDUINO CC VARIANT:

   LIB = ARDUINO {
     SDK_BOARD = UNO;
     VARIANT = CC {
       VERSION = "1.8.5";
     };
     ...
   };

STAND_ALONE

STAND_ALONE boolean attribute of ARDUINO configures the build system to generate or not libarduinosdk.a stand-alone binary library. The default value is set to TRUE. Default value is TRUE.

Example of STAND_ALONE attribute of ARDUINO:

   LIB = ARDUINO {
     SDK_BOARD = UNO;
     VARIANT = CC {
       VERSION = "1.8.5";
     };
     STAND_ALONE = TRUE;
   };

Interrupt Handling

Interrupt Handling is microcontroller dependent so for each supported Atmel (now Microchip) AVR8 microcontroller family, the ISRs configuration of ERIKA Enterprise v3 is shown below.

MEGA Family

The MEGA family of AVR8 microcontrollers has an interrupt vector table which is stored in the flash memory. The lowest addresses of the interrupt vector table are allocated to the RESET and to the interrupt vectors. Interrupt handlers placed at lower addresses have higher hardware priorities than interrupt handlers placed at higher addresses so the PRIORITY attribute of the ISR object in the OIL is USELESS. The complete list of SOURCE entries is shown below.

  • RESET: External Pin, Power-on Reset, Brown-out Reset and Watchdog System Reset
  • INT0: External Interrupt Request 0
  • INT1: External Interrupt Request 1
  • PCINT0: Pin Change Interrupt Request 0
  • PCINT1: Pin Change Interrupt Request 1
  • PCINT2: Pin Change Interrupt Request 2
  • WDT: Watchdog Time-out Interrupt
  • TIMER2_COMPA: Timer/Counter2 Compare Match A
  • TIMER2_COMPB: Timer/Counter2 Compare Match B
  • TIMER2_OVF: Timer/Counter2 Overflow
  • TIMER1_CAPT: Timer/Counter1 Capture Event
  • TIMER1_COMPA: Timer/Counter1 Compare Match A
  • TIMER1_COMPB: Timer/Coutner1 Compare Match B
  • TIMER1_OVF: Timer/Counter1 Overflow
  • TIMER0_COMPA: Timer/Counter0 Compare Match A
  • TIMER0_COMPB: Timer/Counter0 Compare Match B
  • TIMER0_OVF: Timer/Counter0 Overflow
  • SPI_STC: SPI Serial Transfer Complete
  • USART_RX: USART Rx Complete
  • USART_UDRE: USART, Data Register Empty
  • USART_TX: USART, Tx Complete
  • ADC_ADC: Conversion Complete
  • EE_READY: EEPROM Ready
  • ANALOG_COMP: Analog Comparator
  • TWI: 2-wire Serial Interface
  • SPM_READY: Store Program Memory Ready

EEOPT

The following EEOPTs are specific of AVR8 Architecture:

  • __AVR8_GCC_C99__: Enables C99 compiler option.

OSEK/VDX Extensions

This Section contains information about the OSEK/VDX Extensions (or optional features) that have been implemented for the AVR8 support.

System Timer

System Timer is microcontroller dependent so for each supported Atmel (now Microchip) AVR8 microcontroller family, the System Timer configuration of ERIKA Enterprise v3 is shown below.

MEGA Family

For the MEGA family of AVR8 microcontrollers the System Timer is linked to TIMER1 so the DEVICE attribute MUST be se to TIMER1_COMPA as shown below.

 COUNTER SystemTimer {
   MINCYCLE = 1;
   MAXALLOWEDVALUE = 65535;
   TICKSPERBASE = 1;
   TYPE = HARDWARE {
     DEVICE = "TIMER1_COMPA";
     SYSTEM_TIMER = TRUE;
   };
   SECONDSPERTICK = 0.001;
 };

Additional Notes

T.B.D.