Renesas RH850

From ERIKA WIKI
Jump to: navigation, search

Introduction

This manual describes the porting details of the ERIKA Enterprise v3 kernel(s) for Renesas RH850 E2x-FCC2 microcontroller.

RH850 features supported

The following are the main features currently supported by the RH850 port:

N.B. ERIKA currently support Floating Point Unit Coprocessor (FPU), Extended Floating Point Unit Coprocessor (FXU) is not supported yet.

Integration with Renesas Embark E2X Software

This ERIKA's porting relies on Embark E2x Software for all the low-level startup activity needed to bring up an RTOS environment, like: boot from reset vector, general purpose and special registers initialization, C data initialization, pll ramp-up (CLK), eventual FPU initialization etc. All these procedures plus most of the other low-level drivers (e.g. PORT, SCI, ADCH, CAN etc) are configured and executed in exactly the the same way as what is typically done in a native Renesas Embark E2x application (i.e. without an external RTOS).

Interrupt Controller Initialization (INTC) and OS Timer Module (OSTM) initialization (when the system timer is configured) are done inside the StartOS call, always relying on Embark E2x library. The configuration of these features is automatically generated by RT-Druid, starting from OIL file. The generated configuration file is out/ee_r_embark_e2x_cfg.c.

Module Standby for OSTM is internally handled by ERIKA3 when the System Timer is configured, all other peripherals stand-by have to be handled by the application.

Currently only the low-level drivers of the Embark E2X library are automatically supported by ERIKA's build system (i.e. those contained in Drivers/RH850 sub-folder).

The support for everything external to the RH850 low level drivers has been currently postponed. In particular the modules: CanFD driver, Ethernet Stack with Lightweight IP, Floating Point Exception driver (FPE), GTM support and Serial Terminal (Term), can be added as external sources to the application. Some of these modules (CanFD, FPE and Term) can be integrated in a straightforward way. LWIP and GTM will require more effort. We do no exclude that in future releases additional modules will be automatically added to the ERIKA3 build system.

IMPORTANT: In case of a multicore application, the application MUST NOT call directly the Embark E2X R_BOOT_SetPeActive function (this will break the ERIKA3 startup procedure), but it should rely on the standard kernel API StartCore.

Obviously, Embark E2X Scheduler Module (SCHD) is not compatible with ERIKA.

Details for the Embark E2X configuration are provided below, in the specific paragraph dedicated to the Embark library.

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 the Renesas RH850 Architecture.

Wind River Diab Compiler Path

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

  • Specific environment variable: WIND_DIAB_PATH (this is the same environment variable that Wind River configuration scripts generate and use)
    • E.g.: WIND_DIAB_PATH=C:\WindRiver\compilers\diab-5.9.6.6
  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_tricore__path_for_hightec_gcc_compiler
    • E.g.: preference_rh850__path_for_windriver_diab_compiler=C:\\WindRiver\\compilers\\diab-5.9.6.6

Here is an example of RT-Druid configuration file.

Renesas Embark E2X Software

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

  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_rh850__path_for_embark_e2x_software
    • E.g.: preference_rh850__path_for_embark_e2x_software=C:\\Renesas\\EmbarkE2x_V2.5\\EmbarkE2xFCC1

Lauterbach TRACE32 Path

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

  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_lauterbach__path_for_trace32
    • E.g.: preference_lauterbach__path_for_trace32=C:\T32

Here is an example of RT-Druid configuration file.

Lauterbach Emulator Interface

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

  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_lauterbach__emulator_usb_interface
    • E.g.: preference_lauterbach__emulator_usb_interface=true

Here is an example of RT-Druid configuration file.

CPU

CPU_DATA object must be set to RH850.

Example of a CPU_DATA section:

   CPU_DATA = RH850 {
     ...
   };

ID

On multicore systems, one CPU_DATA instance exists for each core. They must have different IDs to be considered really distinct cores (all the CPU_DATA block with the same ID are merged together during generation and this may or may not cause validation errors if this happens due to a misconfiguration).

ID is a numeric value starting from 0 (default value). The ID value correspond to the core physical ID, so the ID=0 (corresponding to the master core), MUST be configured always as it is requested by the AUTOSAR specifications, the other ID values are free to be configured or not.

In RH850 E2X-FCC2 MCU family this number can be 5 at most, since this family is equipped with 6 cores.

COMPILER

COMPILER attribute of CPU_DATA supports for now the DIAB value only. Deafult value is DIAB.

Example of a COMPILER attribute of CPU_DATA section:

   CPU_DATA = RH850 {
     COMPILER = DIAB;
     ...
   };

MINIMAL_OPTS

MINIMAL_OPTS boolean property of COMPILER attribute of CPU_DATA configures the build system with minimal compiling and linking options. The default value is set to FALSE.

Example of a MINIMAL_OPTS property of COMPILER attribute of CPU_DATA section:

   CPU_DATA = RH850 {
     COMPILER = DIAB {
          MINIMAL_OPTS = TRUE;
     };
     ...
   };

MCU

The MCUs support for the RH850 is configured correctly by simply specifying the MCU_DATA item without additional options.

In case you are debugging with Lauterbach TRACE32, you may specify the DERIVATIVE and in order for the .cmm scripts to be generated correctly.

Valid configurations

The following are valid configurations for the MCU_DATA setting:

  • E2X-FCC2
   MCU_DATA = E2X_FCC2 {
     DERIVATIVE = "R7F702Z17";
   };

MCU_DATA

MCU_DATA currently supports E2X_FCC2 value only.

Example of a MCU_DATA section:

   MCU_DATA = E2X_FCC2 {
     ...
   };

DERIVATIVE

DERIVATIVE attribute of MCU_DATA is an OIL attribute of type String. This field is used to generate Lauterbach scripts, its value has to be a valid system.cpu value for Lauterbach scripts, belonging to the selected RH850 family.

Please note that if you configure MCU_DATA = E2X_FCC2, the DERIVATIVE string has to point to a MCU belonging to the E2X-FCC2 family. Please note that no consistency checks have been implemented (you will notice it because Lauterbach TRACE32 will not start).

Example of DERIVATIVE attribute of a MCU_DATA section:

   MCU_DATA = E2X_FCC2 {
     DERIVATIVE = "R7F702Z17";
     ...
   };

"R7F702Z17" is the default value for the attribute DERIVATIVE if MCU_DATA E2X_FCC2 is configured

Interrupt Handling

Since there is no naming convention enforced by Renesas to identify a specific external interrupt source, the numeric approach have been chosen for this porting, mimicking what is done in native Embark E2X application. Valid values for the SOURCE field are strings representing numbers from "0" to "695" for a MCU_DATA E2X_FCC2.

Additional details:

  • The Renesas interrupt controller (INTC) is a two level interrupt controller.
  • The first 32 entries are handled privately for each core, while all the entries after 32 are global for the entire system.
  • It is legal to have multiple ISR with SOURCE 18 as long as they belong to different cores.
  • IMPORTANT: in multicore enviroment, SOURCE = "0"; correspond to Channel 0, mapped to the Inter-processor interrupt function (IPIR). This source is reserverd for Kernel internal communication.

System Timer

The OSEK/VDX standard provides support for a System Counter (a counter that is automatically linked to a hardware timer).

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.

A Counter which is not a System Counter must be incremented explicitly using the Autosar primitive IncrementCounter.

The following is an example OIL definition for a System Counter:

 COUNTER SystemTimer {
   CPU_ID = 0;
   MINCYCLE = 1;
   MAXALLOWEDVALUE = 2147483647;
   TICKSPERBASE = 1;
   TYPE = HARDWARE {
     DEVICE = "18";
     SYSTEM_TIMER = TRUE;
     PRIORITY = 1;
   };
   SECONDSPERTICK = 0.001;
 };

The meaning of the various attributes is as follows:

  • COUNTER/CPU_ID is used to tie the counter to a specific core (you do not need to declare the CPU_ID in case the value is 0)
  • 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 as system timer. Currently, for RH850 only 18 and 19 (OS Timer Module) MCU peripheral are valid devices for system timer. DEVICE = "18" correspond to OSTM0 peripheral, that can broadcast its interrupt to all the cores (this is a nice feature which ensures a synchronized timebase for all cores). DEVICE = "19" correspond to a core private OSTM unit, from OSTM1 for Core0 to OSTM6 for Core5.
  • COUNTER/TYPE/PRIORITY By default SYSTEM_TIMER is tied to smallest ISR priority (i.e. PRIORITY = 1;), but it can be overwritten.
  • COUNTER/SECONDSPERTICK is used to declare the wanted time duration of one hardware tick in seconds.
    IMPORTANT: SECONDSPERTICK needs to have the same value for all system timers are driven by DEVICE = 18 (OSTM0 unit), otherwise some temporal misbehaviour will happen in some core. The OSTM0 unit configuration is physically done by the first core reaching the system timer initialization routine. A multicore "atomic" boolean grants a single initialization.

The System Timer can be attached to ALARMs as usual, as in the following example:

 ALARM AlarmExample {
   COUNTER = SystemTimer;
   ACTION  = ACTIVATETASK{
      TASK = TaskExample;
   };
 };

LIB

LIB object supports for now the EMBARK_E2X value only.

Example of a LIB section:

   LIB = EMBARK_E2X {
     ...
   };


EMBARK_E2X

The following sections describe the OIL fields of the LIB object customized for the official Renesas EMBARK E2X software support.

VERSION

The VERSION attribute is a string attribute of EMBARK_E2X that would be used by the ERIKA's build system to handle multiple version of the library.

  • "2.5" is default value
  • this value is present in the OIL, but currently not used

Example of the VERSION attribute:

   LIB = EMBARK_E2X {
     VERSION = "2.5";
     ...
   };

STAND_ALONE

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

Example of STAND_ALONE attribute of EMBARK_E2X:

   LIB = EMBARK_E2X  {
     VERSION = "2.5";
     STAND_ALONE = TRUE;
   };


RH850

  • The RH850 boolean attribute enables the EMBARK_E2X low level drivers inclusion.
  • The RH850 default value is TRUE.
  • RH850 contains a set of boolean flag to switch on/off inclusion of various low level drivers. Each flag has it's own default value so if you just declare LIB = EMBARK_E2x; you will get the minimal library needed to execute an ERIKA3 application.
  • The Embark E2X software is composed by different layers and modules of utilities. The lowest level is the RH850, and is the only level currently supported by the automatic build system.

Below we describe all the RH850 flags with their respective default values.

   LIB = EMBARK_E2X {
     RH850 = TRUE {
       ADCH    = FALSE; /* Analog to Digital Converter */
       BARR    = FALSE; /* BARR synchronization API for multicore applications */
       BOOT    = TRUE;  /* Startup code */
       CADC    = FALSE; /* Cyclic Analog to Digital Converter */
       CAN     = FALSE; /* Low Level Driver for RS-CANFD */
       CLK     = TRUE;  /* low level driver for Clock Controller (CLKC) */
       DFL     = FALSE; /* Data Flash */
       DSADC   = FALSE; /* Delta Sigma Analog to Digital Converter */
       DTS     = FALSE; /* Data Transfer Service (Renesas DMA) */
       ECM     = FALSE; /* Error Control Module */
       ETNC    = FALSE; /* Ethernet controller driver */
       FPU     = TRUE;  /* Floating Point Unit (ERIKA support FPU coprocessor context, not FXU yet) */
       MSTB    = TRUE;  /* Module Standby */
       OSTM    = TRUE;  /* OS Timer Module (Even deactivated can be implicitly used by ERIKA) */
       PBG     = FALSE; /* Peripheral Bus Guard (Peripheral access protection) */
       PIC2    = FALSE; /* Peripheral Interconnection module 2 */
       PORT    = FALSE; /* Port Configuration driver */
       SCI     = FALSE; /* Serial Communication Interface */
       WDTB    = FALSE; /* Window Watchdog Timer */
     };
   };