CHAPTER 2 SYSTEM BUILDING


This chapter describes how to build a system (load module) that uses the functions provided by the RI600PX.

2.1 Outline

System building consists in the creation of a load module using the files (kernel library, etc.) installed on the user development environment (host machine) from the RI600PX's supply media.

Figure 2-1 shows the procedure of system building.

Figure 2-1 Example of System Building



The RI600PX provides a sample program with the files necessary for generating a load module.

The sample programs are stored in the following folder. The source files are stored in "appli" sub-folder.

<ri_sample> = <CubeSuite+_root>\SampleProjects\RX\device_name_RI600PX

- <CubeSuite+_root>

Indicates the installation folder of CubeSuite+.

The default folder is "C:\Program Files\Renesas Electronics\CubeSuite+\".

- SampleProjects

Indicates the sample project folder of CubeSuite+.

- RX

Indicates the sample project folder of RX MCU.

- device_name_RI600PX

Indicates the sample project folder of the RI600PX. The project file is stored in this folder.

device_name: Indicates the device name which the sample is provided.

2.2 Coding Processing Programs

Code the processing that should be implemented in the system.

In the RI600PX, the processing program is classified into the following five types, in accordance with the types and purposes of the processing that should be implemented.

- Tasks
A task is processing program that is not executed unless it is explicitly manipulated via service calls provided by the RI600PX, unlike other processing programs (interrupt handler, cyclic handler and alarm handler).

- Task Exception Handling Routines
When task exception is requested to a task, the task exception handling routine defined for the task is invoked. The requested exception code is passed to the task exception handling routine.

- Cyclic Handlers
The cyclic handler is a routine started for every specified cycle time.
The RI600PX handles the cyclic handler as a "non-task (module independent from tasks)". Therefore, even if a task with the highest priority in the system is being executed, the processing is suspended when a specified activation cycle has come, and the control is passed to the cyclic handler.


- Alarm Handlers
The alarm handler is a routine started only once after the specified time.
The RI600PX handles the alarm handler as a "non-task (module independent from tasks)". Therefore, even if a task with the highest priority in the system is being executed, the processing is suspended when a specified activation cycle has come, and the control is passed to the cyclic handler.


- Interrupt Handlers
The interrupt handler is a routine started when an interrupt occurs.
The RI600PX handles the interrupt handler as a "non-task (module independent from tasks)". Therefore, even if a task with the highest priority in the system is being executed, the processing is suspended when an interrupt occurs, and the control is passed to the interrupt handler.


Note For details about the processing programs, refer to "CHAPTER 4 TASK MANAGEMENT FUNCTIONS", "CHAPTER 6 TASK EXCEPTION HANDLING FUNCTIONS", "CHAPTER 10 TIME MANAGEMENT FUNCTIONS", "CHAPTER 12 INTERRUPT MANAGEMENT FUNCTIONS".

2.3 Coding System Configuration File

Code the SYSTEM CONFIGURATION FILE required for creating information files that contain data to be provided for the RI600PX.

Note For details about the system configuration file, refer to "CHAPTER 20 SYSTEM CONFIGURATION FILE".

2.4 Coding User-Own Coding Module

- MEMORY PROTECTION FUNCTIONS

- Access Exception Handler (_RI_sys_access_exception( ) )
The access exception handler will be invoked when a task or task exception handling routine accesses the memory that has not been permitted.

- TIME MANAGEMENT FUNCTIONS

- Base Clock Timer Initialization Routine (_RI_init_cmt_knl( ))
The base clock timer initialization routine is called at starting the RI600PX.

- SYSTEM DOWN

- System down routine (_RI_sys_dwn__( ))
The system down routine is called when the system down occurs.

- SYSTEM INITIALIZATION

- Boot processing file
For details, refer to "17.2 Boot Processing File (User-Own Coding Module)".


- Section information file (User-Own Coding Module)
Informations for uninitialized data sections and initialized data sections are defined in the section information file.

2.5 Creating Load Module

Run a build on CubeSuite+ for files created in sections from "2.2 Coding Processing Programs" to "2.4 Coding User-Own Coding Module", and library files provided by the RI600PX and C compiler package, to create a load module.

1 ) Create or load a project

Create a new project, or load an existing one.

Note See "RI Series Start", "CubeSuite+ Start" and the Release Notes of this product for details about creating a new project or loading an existing one.

2 ) Set a build target project

When making settings for or running a build, set the active project.

If there is no subproject, the project is always active.

Note See "CubeSuite+ RX Build" for details about setting the active project.

3 ) Confirm the version

Select the Realtime OS node on the project tree to open the Property panel.

Confirm the version of RI600PX to be used in the [Kernel version] property on the [ RI600PX ] tab.

Figure 2-2 Property Panel: [RI600PX] Tab



4 ) Set build target files

For the project, add or remove build target files and update the dependencies.

Note See "CubeSuite+ RX Build" for details about adding or removing build target files for the project and updating the dependencies.

The following lists the files required for creating a load module.

- Source files created in "2.2 Coding Processing Programs"

- Processing programs (tasks, cyclic handlers, alarm handlers, interrupt handlers)

- System configuration file created in "2.3 Coding System Configuration File"

- SYSTEM CONFIGURATION FILE

Note Specify "cfg" as the extension of the system configuration file name. If the extension is different, "cfg" is automatically added (for example, if you designate "aaa.c" as a file name, the file is named as "aaa.c.cfg").

- Source files created in "2.4 Coding User-Own Coding Module"

- User-own coding module (system down routine, boot processing)

- Library files provided by the RI600PX

- Kernel library (refer to "2.6.3 Kernel library")

- Library files provided by the C compiler package

- Standard library, runtime library, etc.

Note 1 If the system configuration file is added to the Project Tree panel, the Realtime OS generated files node is appeared.
The following information files are appeared under the Realtime OS generated files node. However, these files are not generated at this point in time.


- System information header file (kernel_id.h)

- Service call definition file (kernel_sysint.h)

- ROM definition file (kernel_rom.h)

- RAM definition file (kernel_ram.h)

- System definition file (ri600.inc)

- CMT timer definition file (ri_cmt.h)

- Table file (ritable.src)

Figure 2-3 Project Tree Panel



Note 2 When replacing the system configuration file, first remove the added system configuration file from the project, then add another one again.

Note 3 Although it is possible to add more than one system configuration files to a project, only the first file added is enabled. Note that if you remove the enabled file from the project, the remaining additional files will not be enabled; you must therefore add them again.

5 ) Set the output of Realtime OS generation files

Select the system configuration file on the project tree to open the Property panel.

On the [System Configuration File Related Information] tab, set the output of realtime OS generation files, etc.

Figure 2-4 Property Panel: [System Configuration File Related Information] Tab



6 ) Specify the output of a load module file

Set the output of a load module file as the product of the build.

Note See "CubeSuite+ RX Build" for details about specifying the output of a load module file.

7 ) Set build options

Set the options for the compiler, assembler, linker, and the like.
Please be sure to refer to "2.6 Build Options".


Note See "CubeSuite+ RX Build" for details about setting build options.

8 ) Run a build

Run a build to create a load module.

Note See "CubeSuite+ RX Build" for details about running a build.

Figure 2-5 Project Tree Panel (After Running Build)



9 ) Save the project

Save the setting information of the project to the project file.

Note See "CubeSuite+ Start" for details about saving the project.

2.6 Build Options

This section explains the build options that should be especially noted.

2.6.1 Service call information files and "-ri600_preinit_mrc" compiler option

The service call information file (mrc files) are generated to the same folder as object files at compilation of the source files that includes kernel.h file.

The name of service calls used in the source files are outputted in the mrc files. It is necessary to input all files to the table generation utility mkritblpx. If there is a leaking in the input file, service call modules that application uses might not be linked. In this case, the system down will occur when the service call is issued.

On the other hand, if the mrc files which are generated in the past and which is invalid in now are input to the mkritblpx, the service call modules that are not used in the application may be linked. In this case, there is no problem in the operation of the RI600PX but the module size uselessly grows.

Specify "-ri600_preinit_mrc" compiler option for the source file that includes kernel.h file even if this option is not specified, there is no problem in the operation of the RI600PX but the service call module that is not used in the application may be linked.

When application libraries are used, the mrc files that is generated at compilation of the library source should be inputted to the mkritblpx. If this way is difficult for you, make mrc file where name of using service calls is described (see belows), and input the mrc file to the mkritblpx.

Note, the system down will occur when the service call that is not linked is called.

 sta_tsk
 snd_mbx
 rcv_mbx
 prcv_mbx


2.6.2 Compiler option for the boot processing file

It is necessary to set "-nostuff" option for the boot processing file ("resetprg.c" in the sample project) like a mention in "17.2.3 Compiler option for boot processing file". If not, the RI600PX does not work correctly.

To set "-nostuff" option only for the boot processing file, please set any of the following in the [Individual Compile Options] tab of [Property] panel for the boot processing file. To set "-nostuff" option for all, please set any of the following in the [Compiler Options] tab of [Property] panel for [CC-RX (Build Tool)].

1 ) Set in the [Object] category
Like Figure 2-6, set "Yes" in [Allocates uninitialized variables to 4-byte boundary alignment sections], [Allocates initialized variables to 4-byte boundary alignment sections] and [Allocates const qualified variables to 4-byte boundary alignment sections].


Figure 2-6 [Object] category

2 ) Set in the [Others] category
Like Figure 2-7, add "-nostuff" to [Other additional options].


Figure 2-7 [Others] category

2.6.3 Kernel library

The kernel libraries are stored in the folders described in Table 2-1. Note, CubeSuite+ links the appropriate kernel library automatically, you need not consider the kernel libraries.

Table 2-1 Kernel libraries
Folder

Compiler version corresponding to the library

Corresponding CPU core

File name

Description

1

<ri_root>\library\rxv1

V1.02.01 or later

RXv1 architecture

ri600lit.lib

For little endian

ri600big.lib

For big endian

2

<ri_root>\library\rxv2

V2.01.00 or later

RXv1 architecture and RXv2 architecture

ri600lit.lib

For little endian

ri600big.lib

For big endian



Note 1 <ri_root> indicates the installation folder of RI600PX.
The default folder is "C:\Program Files\Renesas Electronics\CubeSuite+\RI600PX".


Note 2 The kernel described in item-2 of Table 2-1 is linked when compiler V2.01.00 or later is used. In the case of others, the kernel library described in item-1 of Table 2-1 is linked.

2.6.4 Arrangement of section

1 ) Naming convention of sections
In order to arrange sections to suitable memory objects, defining the naming convention of sections like the following examples is recommended.


- The 1st character : Section type

- P : Program area

- C : Constant area

- B : Uninitialized data area

- D : Initialized data area (ROM)

- R : Variables area for initialized data (RAM) (generated by linker)

- W : Switch statement branch table area (generated by compiler)

- L : Literal area (generated by compiler)

- The 2nd character or subsequent ones

- RI* : Reserved by the RI600PX
This area is never accessed from user mode ( = task context).


- U* : Memory object or user stack
This area is accessed from user mode ( = task context).


- S* : Excluding the above-mentioned
This area is never accessed from user mode ( = task context).


2 ) RI600PX sections
Table 2-2 shows RI600PX sections.
The application must not use the RI600PX except SURI_STACK and BURI_HEAP.



Table 2-2 RI600PX sections

Section name

Attribute

Boundary alignment

ROM/RAM

Description

PRI_KERNEL

CODE

1

ROM/RAM

RI600PX program

CRI_ROM

ROMDATA

4

ROM/RAM

RI600PX constant

DRI_ROM

ROMDATA

4

ROM/RAM

RI600PX initialized data (ROM)

FIX_INTERRUPT_VECTOR

ROMDATA

4

ROM

Fixed vector table/Exception vector table

INTERRUPT_VECTOR

ROMDATA

4

ROM/RAM

Relocatable vector table (1kB)

SI

DATA

4

RAM

System stack

SURI_STACK

DATA

4

RAM

Default section for user stack area

BRI_RAM

DATA

4

RAM

- RI600PX variable

- Data queue area created by the system configuration file

- Message buffer area created by the system configuration file (when the section is omitted)

RRI_RAM

DATA

4

RAM

RI600PX initialized data (RAM)

BURI_HEAP

DATA

4

RAM

- Fixed-sized memory pool area created by the system configuration file (when the section is omitted)

- variable-sized memory pool area created by the system configuration file (when the section is omitted)

Usually, this section should be arranged to memory object.



3 ) FIX_INTERRUPT_VECTOR section

The configurator cfg600px generates fixed vector table/exception vector table as FIX_INTERRUPT_VECTOR section according to the contents of definitions of "interrupt_fvector[]" in the system configuration file.

- At the time of RXv1 architecture use
In the RXv1 architecture, fixed vector table is being fixed to address 0xFFFFFF80. It is necessary to arrange the FIX_INTERRUPT_VECTOR section at address 0xFFFFFF80.
When the FIX_INTERRUPT_VECTOR section is not arranged to address 0xFFFFFF80, RI600PX does not operate correctly.



- At the time of RXv2 architecture use
In the RXv2 architecture, the name of fixed vector table is changed into exception vector table, and can set up the start address by EXTB register. The initial value of EXTB register at the time of reset is 0xFFFFFF80, it is same as fixed interrupt vector table in RXv1 architecture.
Usually, please arrange the FIX_INTERRUPT_VECTOR section to address 0xFFFFFF80.
When the FIX_INTERRUPT_VECTOR section is not arranged to address 0xFFFFFF80, "interrupt_fvector[31]" (reset vector) in the system configuration file is ignored. Please generate the reset vector (address 0xFFFFFFFC) by the user side. And initialize EXTB register to the start address of FIX_INTERRUPT_VECTOR section in Boot processing function (PowerON_Reset_PC( ))




4 ) "aligned_section" linker option
The "aligned_section" linker option must be specified for following sections.


- The section specified as "memory_object[].start_address" in the system configuration file

- The section specified as "task[].stack_section" in the system configuration file

- SURI_STACK section

5 ) Attention concerning L and W section
The L section is literal area, and the W section is switch statement branch table area. These section are generated by the compiler.
The name of these section cannot be changed by using "#pragma section" directive.
Please note it as follows when a function executes as a task and the L and W section may be generated by compiling the source file.




A ) All functions in the source file executes only as tasks which belong to same domain
Especially, there are no points of concern. The L and W section should be a memory object to be able to read from the domain.


B ) Functions in the source file executes as tasks which belong to separate domains
Because a different name cannot be given to literal area and switch table area of each function, it is impossible to divide these area to separate memory object. Therefore, separate functions in order to the domain at running to individual source file and apply (A), or the L and W section should be a memory object to be able to read from all domain.


2.6.5 Initialized data section

About sections described in DTBL of the Section information file (User-Own Coding Module), it is necessary to perform setting to map sections placed on ROM to sections placed on RAM by using "-rom" linker option. Set [Link Options] tab of [Property] panel for [CC-RX (Build Tool)] like Figure 2-8.

Figure 2-8 ROM to RAM mapped section

Note In sample projects provided by RI600PX, it is already set up that the "DRI_ROM" section of RI600PX is mapped to "RRI_RAM" section.