CHAPTER 2 SYSTEM CONSTRUCTION
This chapter describes how to build a system (load module) that uses the functions provided by the RI78V4.
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 RI78V4's supply media.
The following shows the procedure for organizing the system.
Figure 2-1 Example of System Construction
2.2 Coding of Processing Program
Code the processing that should be implemented in the system.
In the RI78V4, the processing program is classified into the following three 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 RI78V4, unlike other processing programs (cyclic handler and interrupt handler).
Note For details about the task, refer to "
3.2 Tasks".
-
Cyclic Handlers
The cyclic handler is a routine dedicated to cycle processing that is activated periodically at a constant interval (activation cycle).
The RI78V4 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.
-
Interrupt Handlers
The interrupt handler is a routine dedicated to interrupt servicing that is activated when an interrupt occurs.
The RI78V4 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 2 The user must code the interrupt handlers that calls the
Timer Handler.
2.3 Coding of System Configuration File
Code the
SYSTEM CONFIGURATION FILE required for creating information files (system information table file, system information header file, Interrupt information definition file) that contain data to be provided for the RI78V4.
2.4 Coding of User-Own Coding Module
Code the user-own coding modules that are extracted to allow the RI78V4 to be supported in various execution environments.
In the RI78V4, the user-own coding module is classified into the following four types, in accordance with the types and purposes of the processing that should be implemented.
Note 2 When the interrupt handler is described by C language (the TA_HLNG attribute is specified in a interrupt handler definition of the system configuration file(DEF_INH)), the user does not have to describe interrupt entry processing because of the C compiler outputing "interrupt entry processing which corresponds to an interrupt request name" automatically.
-
Boot Processing
A routine dedicated to initialization processing that is extracted from the
SYSTEM CONFIGURATION MANAGEMENT FUNCTIONS as a user-own coding module to initialize the minimum required hardware for the RI78V4 to perform processing. It is called from
Interrupt Entry Processing that is assigned to the vector table address to which the CPU forcibly passes the control when a reset interrupt occurs.
-
Idle Routine
A routine dedicated to idle processing that is extracted from the
SCHEDULER as a user-own coding module to utilize the standby function provided by the CPU (to achieve the low-power consumption system), and is called from the scheduler when there no longer remains a task subject to scheduling by the RI78V4 (task in the RUNNING or READY state) in the system.
2.5 Start address of section
Specifies the start address of section by the user to fix the address allocation done by the linker. In the RI78V4, the allocation destinations (section names) of management objects modularized for each function are specified.
The following lists the section names prescribed in the RI78V4.
|
|
|
|
|
|
|
Area where the RI78V4's core processing part and main processing part of service calls provided by the RI78V4 are to be allocated.
The start can be aligned at an even address in the area from 0x000c0 to 0xeffff.
|
|
|
|
Area where the interrupt for system timer and information of FAR branch are to be allocated.
The start can be aligned at an even address in the area from 0x000c0 to 0x0ffff.
|
|
|
|
Area where information items such as the RI78V4 version are to be allocated.
The start can be aligned at an even address that does not span a 64K-1 boundary.
|
|
|
|
Area where initial information items related to OS resources that do not change dynamically are allocated as system information tables and Interrupt infomation definition file.
The start can be aligned at an even address that does not span a 64K-1 boundary.
|
|
|
|
Area where the system stack and the task stack are to be allocated.
The start can be aligned at an even address in the built-in RAM area from 0xf0000 to 0xfffff and that does not span a 64K-1 boundary.
|
|
|
|
Area where information items required to implement the functionalities provided by the RI78V4 and information items related to OS resources that change dynamically are allocated as management objects.
The start can be aligned at an even address in the built-in RAM area from 0xf0000 to 0xfffff and that does not span a 64K-1 boundary.
|
|
|
|
Area where initial information items of RI78V4 are to be allocated.
The start can be aligned at an even address in the built-in RAM area from 0xf0000 to 0xfffff and that does not span a 64K-1 boundary.
|
|
|
|
Area where data queues and fixed-sized memory pools are to be allocated.
The start can be aligned at an even address in the built-in RAM area from 0xf0000 to 0xfffff and that does not span a 64K-1 boundary.
|
|
|
|
Area where the trace data are to be allocated.
The start can be aligned at an even address in the built-in RAM area from 0xf0000 to 0xfffff and that does not span a 64K-1 boundary.
|
|
|
|
Area where information items to get trace data are to be allocated.
The start can be aligned at an even address that does not span a 64K-1 boundary.
|
|
|
|
Area where the processing part to get trace data are to be allocated.
The start can be aligned at an even address in the area from 0x000c0 to 0xeffff.
|
|
|
|
SADDR area where the RI78V4's core processing are to be allocated.
The start can be aligned at an even address in the saddr area.
|
Note 2 The RI78V4 occupies the 8-byte area from the saddr area (0xffe20 to 0xfff1f). Therefore, the available saddr area for the user is up to 247 bytes.
Note 3 The section for RI78V4 is set automatically on CS+. When you want to change the start address of section, changes in the linker setting. For details about the directive file, refer to "CS+ RL78 Building".
Note 4 For details about the directive file, refer to "CS+ RL78 Coding".
2.5.1 .kernel_system section
The size of the .kernel_system section is approximately 1 KB to 9 KB depends on the service calls used in the processing program.
2.5.2 .kernel_system_timer_n section
The following shows an expression required for estimating the .kernel_system_timer_n section size (unit: bytes).
system_timer_n = 16 + (
inthnum_FAR * 8)
2.5.3 .kernel_system_trace_f section
The following shows an expression required for estimating the .kernel_system_trace_f section size (unit: bytes).
[ When the trace mode is "Not tracing" ]
[ When the trace mode is "Takes in trace chart by hardware trace mode" ]
[ When the trace mode is "Takes in trace chart by software trace mode" ]
[ When the trace mode is "Takes in long-statistics by software trace mode" ]
2.5.4 .kernel_info section
The size of the .kernel_info section is approximately 16 bytes.
2.5.5 .kernel_const section
The following shows an expression required for estimating the .kernel_const section size (unit: bytes).
const = (
tsknum * 10 ) +
semnum +
flgnum + (
dtqnum * 5 ) + (
mpfnum * 8 ) + (
cycnum * 12 ) + (
kindnum * 4 ) + 16
2.5.6 .kernel_const_f section
The following shows an expression required for estimating the .kernel_const_f section size (unit: bytes).
[ When the trace mode is "Not tracing" ]
[ When the trace mode is "Takes in trace chart by hardware trace mode" ]
[ When the trace mode is "Takes in trace chart by software trace mode" ]
[ When the trace mode is "Takes in long-statistics by software trace mode" ]
2.5.7 .kernel_stack section
The following shows an expression required for estimating the .kernel_stack section size (unit: bytes).
stack = (
stksz k + 20 ) + (
sys_stksz + 2 )
sys_stksz: Stack size specified in
System stack information. When multiple interrupt occurs, adds 18 bytes every one time.
2.5.8 .kernel_data section
The following shows an expression required for estimating the .kernel_data section size (unit: bytes).
The expression varies depending on whether or not
Semaphore information is defined in the system configuration file.
[ When semaphore information is defined ]
data = align2 (
maxtpri + 1 ) + align2 { (
tsknum * 24 ) + (
semnum * 2 ) + 1 } + align2 (
flgnum * 3 ) + align2 { (
dtqnum * 4 ) + 1} + (
mbxnum * 8 ) + align2 (
primbx ) + (
mpfnum * 4 ) + (
cycnum * 8 ) + 20
[ When semaphore information is not defined ]
data = align2 (
maxtpri + 1 ) + (
tsknum * 24 ) + align2 (
flgnum * 3 ) + align2 { (
dtqnum * 4 ) + 1} + (
mbxnum * 8 ) + align2 (
primbx ) + (
mpfnum * 4 ) + (
cycnum * 8 ) + 20
primbx: Total amount of
Mailbox information for which the priority is specified for the attribute (message queuing method)
2.5.9 .kernel_data_init section
The size of the .kernel_data_init section is approximately 2 bytes.
2.5.10 .kernel_work0, .kernel_work1, .kernel_work2, .kernel_work3 section
The following shows an expression required for estimating the size of the .kernel_work0, .kernel_work1, .kernel_work2, and .kernel_work3 section (unit: bytes).
work
X = (
blkcnt kblksz k ) (
dtqcnt k4 )
2.5.11 .kernel_data_trace_n section
The following shows an expression required for estimating the .kernel_data_trace_n section size (unit: bytes).
[ When the trace mode is "Not tracing" ]
[ When the trace mode is "Takes in trace chart by hardware trace mode" ]
[ When the trace mode is "Takes in trace chart by software trace mode" ]
data_trace_n = 8 +
bufsize
bufsize: Trace buffer size
[ When the trace mode is "Takes in long-statistics by software trace mode" ]
data_trace_n = { (
tsknum + 1) * 20 ) } + { (
inhnum + 1)
* 8 ) }34
2.5.12 .kernel_const_trace_f section
The following shows an expression required for estimating the .kernel_const_trace_f section size (unit: bytes).
[ When the trace mode is "Not tracing" ]
[ When the trace mode is "Takes in trace chart by hardware trace mode" ]
[ When the trace mode is "Takes in trace chart by software trace mode" ]
[ When the trace mode is "Takes in long-statistics by software trace mode" ]
The following lists the files required for creating load modules.
1 ) Create or load a project
Create a new project, or load an existing one.
Note See "RI Series Start" or "CS+ Start" 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 "CS+ Build" for details about setting the active project.
3 ) Set build target files
For the project, add or remove build target files and update the dependencies.
Note See "CS+ 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.
Note Specify "cfg" as the extention 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").
- Files provided by the RI78V4
- Library files provided by the RI78V4
- Library files provided by the C compiler/assembler 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 table file
- System information header file (for C language)
- System information header file (for assembly language)
- Interrupt Information definition file
Figure 2-2 Project Tree Panel (After Adding sys.cfg)
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.
4 ) Set the output of information files
Select the system configuration file on the project tree to open the
Property panel.
Figure 2-3 Property Panel: [System Configuration File Related Information] Tab
5 ) Specify the output of a load module file
Set the output of a load module file as the product of the build.
Note See "CS+ RL78 Build" for details about specifying the output of a load module file.
6 ) Set trace information
Set the detailed information on the using task analyzer in RI78V4 package.
Figure 2-4 [Task Analyzer] Tab
Set the options for the compiler, assembler, linker, and the like.
Note See "CS+ RL78 Build" for details about setting build options.
Run a build to create a load module.
Note See "CS+ RL78 Build" for details about runnig a build.
Figure 2-5 Project Tree Panel (After Running Build)
Save the setting information of the project to the project file.
Note See "CS+ Start" for details about saving the project.
After that, embed the modules to the system by using a flash programmer.