+ All Categories
Home > Documents > HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing...

HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing...

Date post: 01-Dec-2018
Category:
Upload: haxuyen
View: 249 times
Download: 3 times
Share this document with a friend
59
© 2016 Renesas System Design Co., Ltd. All rights reserved. HOW TO DIVIDE BOOT AND FLASH AREAS CC-RL C COMPILER FOR RL78 FAMILY Oct 10, 2016 Rev. 2.00 Software Product Marketing Department, Software Business Division Renesas System Design Co., Ltd. R20UT3475EJ0200
Transcript
Page 1: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

HOW TO DIVIDE BOOT AND FLASH AREASCC-RL C COMPILER FOR RL78 FAMILY

Oct 10, 2016 Rev. 2.00Software Product Marketing Department,Software Business DivisionRenesas System Design Co., Ltd.

R20UT3475EJ0200

Page 2: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

AGENDA

Introduction Page 3

Overview Page 4

Common Processing for Boot and Flash Areas Page 12

Boot Area Page 19

Flash Area Page 38

Debugging Tool Page 50

Sample Programs Page 53

REVISION HISTORY Page 58

Page 2

Page 3: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 3

Introduction

This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler for the RL78 family.

This document uses the following tools and versions for descriptions.

CC-RL C compiler for the RL78 family V.1.03.00

e2 studio integrated development environment V.5.2.0.020

CS+ for CC integrated development environment V.4.01.00

Page 4: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

Overview

Page 4

Dividing Boot and Flash Areas

Allocating Boot and Flash Areas

Processing for Dividing Boot and Flash Areas

Build Procedures for Boot and Flash Areas

Page 5: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 5

Dividing Boot and Flash Areas (1/4)

Divided areas on system

Boot area

(Fixed HEX code)

Flash area

(Application 1)

Flash area

(Application 2)

Update the application area using the flash memory self-programming function of the microcontroller.

Page 6: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 6

Dividing Boot and Flash Areas (2/4)

What are boot and flash areas?

Boot area: This area cannot be modified on the system.

Flash area: This area can be modified or replaced on the system.

Purpose of dividing boot and flash areas

Only the program in the flash area can be modified without reconfiguring the program in the boot area.

Page 7: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 7

Dividing Boot and Flash Areas (3/4)

Requirements for boot and flash areas

The variables and functions in the boot area can be accessed from the flash area.

− The external definition output option -FSymbol should be used in the boot area project.

− The external definition symbol file should be specified as a target of build in the flash area project.

The functions in the flash area can be called from the boot area through a function table.

− When calling functions in the flash area, the boot area project should call the address of each branch instruction for a function that is specified in the function table.

− A table of branch instructions for functions to be called from the boot area project should be created in the flash area project.

Page 8: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 8

Dividing Boot and Flash Areas (4/4)

References to variables and functions between boot and flash areas

Boot area

Flash area

RAM areaRAM for boot

RAM for flash

Branch table area ROM area

Cannot be referenced.

Manage physical addresses.

(function calls)

Use external definition

symbol output option

-FSymbol(variable

references)

Cannot be referenced.

Use external definition

symbol output option

-FSymbol(function calls)

0000H

Page 9: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 9

Allocating Boot and Flash Areas

Example: Allocate the boot and flash areas as follows.

Boot area

Flash area

RAM areaRAM for boot

RAM for flash

Branch table area ROM area

0000H

FE900H

2200H

2000H

FEA00H

Page 10: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 10

Processing for Dividing Boot and Flash Areas

Creating the boot area project

Create boot area programs in the source file.

Specify necessary linker options.

Build the boot area project before the flash area project because the boot area project is necessary when building the flash area project.

Creating the flash area project

Create flash area programs in the source file.

Specify necessary linker options.

Page 11: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 11

Overview of Build Processing for Boot and Flash Areas

Compile

-fsymbol=External variable and function section

boot.asm

boot.c

boot.abs Variables and functions.fsy

flash.asm

flash.c

flash.obj

flash.abs

Variables and functions.fsy

Variables and functions.obj

Compile

Assemble

Link

Assemble

boot.obj

Link

Boot area load module

Symbol information for external variables and functions

Boot area Flash area

Flash area load module

Function branch instruction table resolution.asm

Function branch instruction table resolution.obj

Function table.asm

Function table.obj

Page 12: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

Common Processing for Boot and Flash Areas

Page 12

Creating projects

e2 studio

CS+

Creating a common program for the boot and flash areas

Address definition file for the branch table (assembly language)

Hex files for the boot and flash areas

Initialization procedure

Page 13: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 13

Creating Projects (e2 studio)

Create projects. *

Flash area project

Boot area project

Add target files for build.

* Remarks(1) Set up the flash area project so that the

boot area project is referenced when the flash area project is built.

(2) As the *.fsy file cannot be assembled, change the extension to *.asm before registration.

Page 14: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 14

Creating Projects (CS+)

Create projects. *

Main project

− Flash area project

Sub-project

− Boot area project

Exclude the automatically generated files from the target of build.

Add target files for build.* Remarks(1) The build order in CS+ should be

[Sub-project] → [Main project].(2) The boot area program will not be modified once it is created.

Therefore, when creating the second- or a later generation flash area project, the sub-project can be deleted.

Page 15: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 15

Creating a Common Program for Boot and Flash Areas

Address definition file for the branch table (assembly language)

Include the file in the assembly source files for the boot and flash areas.

− FLASH_TABLE: Start address of the branch table

− INTERRUPT_OFFSET: Size of the interrupt area in the branch table

Example: ftable.inc

FLASH_TABLE .EQU 0x2000INTERRUPT_OFFSET .EQU 0x100

Page 16: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 16

Hex Files for Boot and Flash Areas

File names used in this document (output procedures are described later)

0000H

2000HHex file for the boot area

(boot0000_1fff.mot)

Hex file for the flash area(flash2000_ffff.mot)

Combined hex file(boot_flash.mot)

Boot area

Flash area

RAM area

Note: A load module file (*.abs) is separately generated for each of the boot and flash areas.

Page 17: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 17

Initialization Procedure (1/2)

0000H

Boot area (ROM)

_start:

Vector area…

VECT02VECT01RESET

boot_main()

2

1

.data.sdata

.dataR.sdataR

RAM area

Flash area

Boot area

Copy the initial values in _start.

Jump to the startup processing in the flash area from the end of

_start.

3

Page 18: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 18

Initialization Procedure (2/2)

_start

main()

Branch table areaBR !func…BR !! VECT02BR !! VECT01BR !! _start

.data.sbata

3

4

5

For interrupts

For functions

func()

RAM area

.dataR.sdataR

Flash area

Boot area

Flash area (ROM)

Copy the initial values in _start.

Page 19: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

Boot Area

Page 19

Creating boot area programs

Modifying the startup routine (cstart.asm)

Modifying hdwinit.asm and stkinit.asm

Creating a program for allocating the on-chip debug area

Creating a file for solving the function addresses in the branch table

Specifying boot area options

Outputting a file for the external definition symbols

Specifying section allocation

Specifying a vector for branching to the interrupt function in the flash area

Making necessary settings for the on-chip debug function

Specifying hex file output only to the boot area addresses

Page 20: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 20

Creating Boot Area Programs (1/9)

Modifying the startup routine (cstart.asm) (1/6)

Add inclusion of the address definition file for the branch table.

Example:

$IFNDEF __RENESAS_VERSION____RENESAS_VERSION__ .EQU 0x01000000$ENDIF

$INCLUDE "ftable.inc"

Page 21: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 21

Creating Boot Area Programs (2/9)

Modifying the startup routine (cstart.asm) (2/6)

Explicitly allocate the stack area.

− Comment out the conditional assembly control instructions to make the definition of the .stack_bss section valid.

Example:

;$IF (__RENESAS_VERSION__ < 0x01010000) ; for CC-RL V1.00;-------------------------------------------------------------------; stack area;-------------------------------------------------------------------; !!! [CAUTION] !!!; Set up stack size suitable for a project..SECTION .stack_bss, BSS_stackend:

.DS 0x200_stacktop:;$ENDIF

Page 22: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 22

Creating Boot Area Programs (3/9)

Modifying the startup routine (cstart.asm) (3/6)

Modify the section name.

− Modify the section name to exclude it from the target of the external definition symbol output option -FSymbol.

Example:

;-----------------------------------------------------------------------------; startup;-----------------------------------------------------------------------------.SECTION .btext, TEXT_start:

Page 23: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 23

Creating Boot Area Programs (4/9)

Modifying the startup routine (cstart.asm) (4/6)

Specify the stack pointer.

− Comment out the conditional assembly control instructions to specify the explicitly allocated .stack_bss section as the stack pointer.

Example:

;$IF (__RENESAS_VERSION__ >= 0x01010000); MOVW SP,#LOWW(__STACK_ADDR_START);$ELSE ; for CC-RL V1.00

MOVW SP,#LOWW(_stacktop);$ENDIF

Page 24: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 24

Creating Boot Area Programs (5/9)

Modifying the startup routine (cstart.asm) (5/6)

Modify the main function call to the call to the main function for the boot area, and add a branch instruction to the flash area startup routine.

Example:

;--------------------------------------------------; call main function;--------------------------------------------------CALL !!_boot_main ; main();BR !!FLASH_TABLE

Page 25: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 25

Creating Boot Area Programs (6/9)

Modifying the startup routine (cstart.asm) (6/6)

Comment out the definition of the .const section when no mirror source area is included in the boot area.

Example:; section;-----------------------------------------------------------------------------$IF (__RENESAS_VERSION__ >= 0x01010000).SECTION .RLIB, TEXTF.L_section_RLIB:.SECTION .SLIB, TEXTF.L_section_SLIB:$ENDIF.SECTION .textf, TEXTF.L_section_textf:;.SECTION .const, CONST;.L_section_const:

Page 26: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 26

Creating Boot Area Programs (7/9)

Modifying hdwinit.asm and stkinit.asm

Modify the section name.

− Modify the section name to exclude it from the target of the external definition symbol output option -FSymbol.

Example:

.btextf .CSEG TEXTF

Page 27: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 27

Creating Boot Area Programs (8/9)

Creating a program for allocating the on-chip debug area

To use the on-chip debug function, the following memory areas should be emptied (filled with 0xff).

− Addresses 0x0002 to 0x0003

− Specify 0xffff with the linker option -VECTN.

− Addresses 0x00ce to 0x00d7

− Make definitions in the assembly source (see the following program).

− Last 512 bytes of ROM

− Allocate this area through the flash area project.

Example: ocdrom_ce.asmMON_CE .CSEG AT 0x00ce

.DB8 0xffffffffffffffff

.DB2 0xffff

Page 28: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 28

Creating Boot Area Programs (9/9)

Creating a file for solving the function addresses in the branch table (assembler)

Define symbols for solving the addresses for the branch table to be used to call functions in the flash area from the C source.

Register this file in the project.

Example: extern_ftable.asm

$INCLUDE "ftable.inc".public _f1

_f1 .equ (FLASH_TABLE + INTERRUPT_OFFSET + (0 * 4)).public _f2

_f2 .equ (FLASH_TABLE + INTERRUPT_OFFSET + (1 * 4))

Page 29: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 29

Specifying Boot Area Options (1/9)

Outputting the external definition symbols to a file so that the flash area project can access the variables and functions in the boot area.

Register all target sections with the -FSymbol option.

Example: e2 studio

Page 30: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 30

Specifying Boot Area Options (2/9)

Example: CS+

Page 31: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 31

Specifying Boot Area Options (3/9)

Specifying section allocation

Specify section allocation in the boot area with the linker option -start.Make sure that the sections do not overlap those in the flash area.

In addition, specify the stack area section.

Example: e2 studio Example: CS+

Page 32: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 32

Specifying Boot Area Options (4/9)

Specifying a vector for branching to the interrupt function in the flash area

Specify the address in the branch table with the linker option -VECTN.

Example: e2 studio To specify 0x2010 for address 8.

Page 33: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 33

Specifying Boot Area Options (5/9)

Example: CS+ To specify 0x2010 for address 8.

Page 34: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 34

Specifying Boot Area Options (6/9)

Making necessary settings for the on-chip debug function

Allocate the area of addresses 0x0002 and 0x0003 with the linker option -VECTN (in e2 studio, this area is automatically allocated).

Set the linker option –OCDBG to be enabled and specify the value for the on-chip debug option byte.

Example: e2 studio

Page 35: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 35

Specifying Boot Area Options (7/9)

Example: CS+

Page 36: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 36

Specifying Boot Area Options (8/9)

Specifying hex file output only to the boot area addresses

Specify the output file name and output addresses.

Example: e2 studio

Page 37: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 37

Specifying Boot Area Options (9/9)

Example: CS+

Page 38: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

Flash Area

Page 38

Creating flash area programs

Modifying the startup routine (cstart.asm)

Creating a branch table program

Defining an interrupt function

Specifying flash area options

Registering the external definition symbol file to the project

Specifying section allocation

Specifying hex file output only to the flash area addresses

Combining the hex files for the boot and flash areas

Page 39: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 39

Creating Flash Area Programs (1/3)

Modifying the startup routine (cstart.asm)

Comment out the stack pointer settings.

− The stack pointer specified in the boot area startup routine should be used; a stack pointer must not be specified again in the flash area.

Example:;--------------------------------------------------; setting the stack pointer;--------------------------------------------------

;$IF (__RENESAS_VERSION__ >= 0x01010000); MOVW SP,#LOWW(__STACK_ADDR_START);$ELSE ; for CC-RL V1.00; MOVW SP,#LOWW(_stacktop);$ENDIF

Page 40: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 40

Creating Flash Area Programs (2/3)

Creating a branch table program

At the addresses called from the boot area, write instructions for branching to the function addresses in the flash area.

Example: ftable.asm$INCLUDE "ftable.inc"

.EXTERN _start

.EXTERN _f1

.EXTERN _f2.jtext .CSEG AT FLASH_TABLE

br !!_start ; RESET.DB4 0xffffffff ;.DB4 0xffffffff ; INTWDTI.DB4 0xffffffff ; INTLVIbr !!_int_INTP0 ; INTP0.DB4 0xffffffff ; INTP1.DB4 0xffffffff ; INTP2

~ 省略 ~.jtext2 .CSEG AT FLASH_TABLE+INTERRUPT_OFFSET

br !!_f1br !!_f2

For interrupts

For functions

Page 41: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 41

Creating Flash Area Programs (3/3)

Defining an interrupt function

The interrupt vector should be defined in the boot area project.

Do not specify the vector address (vect) with the #pragma interrupt directive in the flash area.

Example:

#include "iodefine.h"#pragma interrupt int_INTP0volatile char f;void int_INTP0(void){

f = 1;}

Page 42: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 42

Specifying Flash Area Options (1/8)

Registering the external definition symbol file to the project

Register the external definition symbol file created in the boot area to the project so that the variables and functions in the boot area can be accessed.

Example: e2 studio Example: CS+

*Remarks: e2 studioAs the *.fsy file cannot be assembled, change the extension to *.asm before registration

Page 43: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 43

Specifying Flash Area Options (2/8)

Specifying section allocation

Specify section allocation in the flash area with the linker option -start.

− Make sure that the sections do not overlap those in the boot area.

− Do not allocate anything to the branch table area.

Example: e2 studio Example: CS+

Page 44: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 44

Specifying Flash Area Options (3/8)

Specifying hex file output only to the flash area addresses

Specify the output file name and output addresses.

Example: e2 studio

Page 45: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 45

Specifying Flash Area Options (4/8)

Example: CS+

Page 46: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 46

Specifying Flash Area Options (5/8)

Combining the hex files for the boot and flash areas

To combine the hex files for the boot and flash areas into one file, add the linker execution step after the build processing.

Example: e2 studio

Page 47: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 47

Specifying Flash Area Options (6/8)

Example: CS+

Page 48: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 48

Specifying Flash Area Options (7/8)

Combining the hex files for the boot and flash areas

Specify the input hex files, their format, and output file name in the subcommand file to be input to the linker.

Example: sub_mot.txt (e2 studio)

-input=..¥..¥boot¥HardwareDebug¥boot0000_1fff.mot-input=flash2000_ffff.mot-form=stype-output=boot_flash.mot

Page 49: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 49

Specifying Flash Area Options (8/8)

Example: sub_mot.txt (CS+)

-input=..¥boot¥DefaultBuild¥boot0000_1fff.mot-input=.¥DefaultBuild¥flash2000_ffff.mot-form=stype-output=.¥DefaultBuild¥boot_flash.mot

Page 50: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

Debugging Tool

Page 50

Page 51: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 51

Downloading to Debugging Tool (1/2)

Two load module files (*.abs) are generated; one for each of the boot and flash areas. Download both load module files.

Example: To add the load module file for the boot area to the flash areaproject (e2 studio)

*Remarks: e2 studioSet boot.x to "No" when connecting the debugging tool. Download it after connection.

Page 52: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 52

Downloading to Debugging Tool (2/2)

Example: To add the load module file for the boot area to the flash area project (CS+)

Page 53: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

Sample Programs

Page 53

Page 54: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 54

Sample Programs

The following pages show examples of boot and flash area programs that use the programs created through the procedures described before.

Page 55: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 55

Sample Program for Boot Area#include “iodefine.h“ /* SFR definition file */#pragma interrupt int_INTP1 (vect=INTP1) /* Interrupt definition in the boot area */int boot_a = 0x12;int boot_b = 0x34;extern int f1 ( int ) ; /* Prototype declaration of a function in the flash area */extern int f2 ( int ) ; /* Prototype declaration of a function in the flash area */void boot_main (void ) /* Main function in the boot area */{

/* Main processing in the boot area */}void boot_func(void){

boot_a = f1 ( boot_a ) ; /* Call of a function in the flash area */boot_b = f2 ( boot_b ) ; /* Call of a function in the flash area */

}void int_INTP1 (void) /* Interrupt processing in the boot area */{

boot_a = 1;}

Page 56: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 56

Sample Program for Flash Area (1/2)#include "iodefine.h“ /* SFR definition file */int flash_a, b;extern int boot_a, boot_b; /* Function defined in the boot area */extern void boot_func(void); /* Function defined in the boot area */int f1 ( int a){

return (++a);}int f2 ( int b){

return (--b);}void main(void) /* Main function in the flash area */{

boot_a++; /* Access to a variable in the boot area */boot_b++; /* Access to a variable in the boot area */boot_func(); /* Access to a function in the boot area */

}

Page 57: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 57

Sample Program for Flash Area (2/2)#include "iodefine.h" /* SFR definition file */#pragma interrupt int_INTP0 /* Interrupt definition in the flash area */volatile char f;void int_INTP0(void) /* Interrupt processing in the flash area */{

f = 1;}

Page 58: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved. Page 58

REVISION HISTORYRevision Description PageRev.1.00 First versionRev.2.00 Changed template of material All

Changed the version of tools P3, P29, P32, P47Corrected specified value of -VECTN option P32, P33Corrected instruction of jumping to _int_INTP0 label P40

Page 59: HOW TO DIVIDE BOOT AND FLASH AREAS - Renesas … · This document describes the processing necessary to divide a program into boot and flash areas when using the CC-RL C compiler

© 2016 Renesas System Design Co., Ltd. All rights reserved.

Renesas System Design Co., Ltd.


Recommended