Renesas RH850

From ERIKA WIKI
Revision as of 17:17, 6 November 2018 by E.Guidieri (talk | contribs) (VERSION)
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 of the currently implemented support:

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 rely 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 that are 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 system timer is configured) are done inside the StartOS call, always relying on Embark E2x library, but 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 when Sistem Timer is configured, all other peripherals stand-by have to be handled by 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 other features: 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. We do no exclude that in future these modules will be added to ERIKA's build system. For some of these modules integration is really straightforward, I refer to CanFD, FPE and Term, but for lwip and GTM this would require more time so we opted to postpone support for everything external to RH850 low level drivers.

In case of multicore application, the application MUST NOT call directly Embark E2X R_BOOT_SetPeActive function but rely on the kernel API StartCore, failing on doing that will break the ERIKA's startup procedure.

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

Details for the Embark E2X configuration are provided here, in a specific paragraph.

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 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 by misconfiguration).

ID is a numeric value starting from 0 (default value). ID value correspond to the core physical ID, so the ID=0, that correspond to master core, MUST be configured always as is requested by 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 of 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.

The Renesas interrupt controller (INTC) is a two level interrupt controller with the first 32 entry handled privately for each core, while entry the subseguent entries are global for the systems.

So is legit to have, for examples, multiple ISR with SOURCE 18, as long as they belong to different cores. Mind that in multicore enviroment SOURCE = "0"; that correspond to Channel 0 of Inter-processor interrupt function (IPIR), 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 with a specific core (if the core to be tied to is 0, explicitly declaring CPU_ID is not necessary)
  • 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 broacast interrupt to all the cores (this is a nice feature that ensure 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.

N.B. Is very important, if multiple system timers are driven by DEVICE = 18 (OSTM0 unit) this value must be specified equal in all of them otherwise temporal misbehaviour will happen in some core. The OSTM0 unit configuration is done by the first core, with System Timer with DEVICE=18 specified, that reach the system timer initialization routine, a multicore "atomic" boolean grant 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

VERSION is a string attribute of EMBARK_E2X that would be used by the ERIKA's build system to handle multiple versoion of library, currently is not used yet. In any case "2.5" is default value

Example of VERSION attribute of S32_SDK:

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

STAND_ALONE

STAND_ALONE boolean attribute of EMBARK_E2X configures the build system to generate or not 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

RH850 boolean attribute enable EMBARK_E2X low level drivers inclusion, RH850 default vaule 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 minimalistic library needed to execute an ERIKA application. Embark E2X software is composed by different layer and modules of utilities, the lowest level is the RH850. This level is the only supported by automatic build system currently, but we prepared the environment to be extended with the support of other modules, so we collected the configuration for the low level drivers in its own container. Below all the RH850 flags with default value.

   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 */
     };
   };