Вы находитесь на странице: 1из 37

Implementing Bootloaders on Renesas MCUs

Class ID: Renesas Electronics America Inc.


2012 Renesas Electronics America Inc. All rights reserved.

Renesas Technology & Solution Portfolio

2012 Renesas Electronics America Inc. All rights reserved.

Microcontroller and Microprocessor Line-up


2010
1200 DMIPS, Superscalar
Automotive & Industrial, 65nm 600A/MHz, 1.5A standby

2012
1200 DMIPS, Performance
Automotive, 40nm 500A/MHz, 35A deep standby

32-bit

500 DMIPS, Low Power


Automotive & Industrial, 90nm 600A/MHz, 1.5A standby

32-Bit High Performance DSP, FPU with High Integration

165 DMIPS, FPU, DSC


Industrial, 40nm 200A/MHz, 0.3A deep standby

165 DMIPS, FPU, DSC


Industrial, 90nm 200A/MHz, 1.6A deep standby

Embedded Security, ASSP


Industrial, 90nm 1mA/MHz, 100A standby

25 DMIPS, Low Power


8/16-bit

Industrial & Automotive, 150nm 190A/MHz, 0.3A standby

44 DMIPS, True Low Power


Industrial & Automotive, 130nm 144A/MHz, 0.2A standby

10 DMIPS, Capacitive Touch


Industrial Automotive, 130nm Wide Format&LCDs 350A/MHz, 1A standby

2012 Renesas Electronics America Inc. All rights reserved.

Enabling The Smart Society


In a smart society devices can add features and fix bugs after leaving store shelves. Having a bootloader in your system allows you to sleep better at night.

???
Firmware v1.2 v1.3 Fixed focusing bug
4 2012 Renesas Electronics America Inc. All rights reserved.

Firmware v3.0 v4.0 Added Multitasking

Agenda
Quick bootloader overview The flash loader framework Design choices RX implementation RL78 implementation Lab

2012 Renesas Electronics America Inc. All rights reserved.

Quick Bootloader Overview

2012 Renesas Electronics America Inc. All rights reserved.

Quick Bootloader Overview


What is a bootloader? What can a bootloader do?
Erase and rewrite user memory Validate user memory Communicate with the outside world Download new application in case of failure

Reset Bootloader

Application

What should a bootloader be?

2012 Renesas Electronics America Inc. All rights reserved.

Available Boot Options


Factory bootloader
Cannot be modified User code cannot run Can program/erase everything MCU Address Space RAM Factory Bootloader
P/E

User boot area


Programmed with USB from factory Uses CPU rewrite code

User Boot Area

P/E

User application
Uses CPU rewrite code

User Application Area

2012 Renesas Electronics America Inc. All rights reserved.

The Flash Loader Project

2012 Renesas Electronics America Inc. All rights reserved.

What is the Flash Loader Project? Flexible system for implementing in-field-reprogramming in your own project Communications medium agnostic Modify to fit your system Retries & error checking built in Does not interfere with user application

10

2012 Renesas Electronics America Inc. All rights reserved.

Terms

Load Image

v4.2

Host

Device Storage

11

2012 Renesas Electronics America Inc. All rights reserved.

Parts of the Flash Loader Project? Flexible system that can be split into 2 parts:
Downloader Bootloader

Host
Reprogramming Downloading Checking Storing
12 2012 Renesas Electronics America Inc. All rights reserved.

Device Storage

1: Using Flash Loader With Your Project

13

2012 Renesas Electronics America Inc. All rights reserved.

Add Flash Loader to your HEW Project Add flash loader project files

Users Project

User Application

Flash Loader

Enables future updates Flash loader bootloader is separate project

14

2012 Renesas Electronics America Inc. All rights reserved.

Configure Flash Loader for Your System r_fl_app_header.c r_fl_comm_*type*.c r_fl_downloader.c r_fl_store_manager.c r_fl_memory_*type*.c r_fl_utilities.c
= Edit for your configuration

v4.2 Device Storage

Host
15 2012 Renesas Electronics America Inc. All rights reserved.

2: Making a Load Image

16

2012 Renesas Electronics America Inc. All rights reserved.

Making a Load Image


S-Record (MOT) files are inefficient
S-Record Converter

60KB

20KB

MOT

S-Record Converter

Load Image

Load image information:


Binary Starts with header Has N blocks

Load Image

Header

Block 1

Block 2

...

Block N

17

2010 Renesas Electronics America Inc. 2012 Renesas Electronics America Inc. All rights reserved. All rights reserved.

Load Image Header


Field Valid mask Image ID Version number Size of load image Max block data size Load image CRC Raw CRC Address of 1st data block Successfully stored? Size in Bytes 1 1 1 4 4 2 2 4 4

18

2010 Renesas Electronics America Inc. 2012 Renesas Electronics America Inc. All rights reserved. All rights reserved.

3: Obtaining the Load Image

19

2012 Renesas Electronics America Inc. All rights reserved.

Transferring the Load Image Flash loader is medium agnostic Communications protocol is supplied Supported commands
Information request Erase image from storage Load image download

Host
20 2012 Renesas Electronics America Inc. All rights reserved.

Device Storage

Storing the Load Image As Load blocks come in:


Check for errors Store

Storage area partitioned for load images If error occurs, retry is possible

Load Block

Host
21 2012 Renesas Electronics America Inc. All rights reserved.

Device Storage

What the Storage Area Looks Like Load images are in different partitions
Storage Load Image #1 Address 0x00100000 Header Block 1 Block 2 Block 3

Block 512

Load Image #2 Address 0x00200000 Header Block 1 Block 2 Block 3

Block 656

Load Image #3 Address 0x00300000

EMPTY
22 2012 Renesas Electronics America Inc. All rights reserved.

4: Using the Load Image

23

2012 Renesas Electronics America Inc. All rights reserved.

Reboot & Flash Reboot when convenient Check for new load image If valid, reflash MCU Jump to user application and execute

Load Image

Host
24 2012 Renesas Electronics America Inc. All rights reserved.

Device Storage

Design Choices

25

2012 Renesas Electronics America Inc. All rights reserved.

Bootloader Decisions
Why not store bootloader in same memory area as user application?
Bug in control code could erase everything Application must be aware of bootloader

Why not store load images in MCU memory?


Hard to make bootloader not interfere with user application Bug in control code could erase currently running application Limit application size or pay more Move code to RAM May have to use PIC and PID Keep safe older revisions
26 2012 Renesas Electronics America Inc. All rights reserved.

RX Implementation

27

2012 Renesas Electronics America Inc. All rights reserved.

Flash Loader Bootloader Separate workspace Separate memory areas Can use same or different communications as FL downloader User Boot is special

M C U
28

User Application
&

Flash Loader Downloader


User ROM

Flash Loader Bootloader

User Boot Area

2012 Renesas Electronics America Inc. All rights reserved.

Why is User Boot Special? Can execute from either reset vector on start-up Cannot accidentally erase Should have one and done attitude No indirection tables!

User Boot Mode Reset Vector

Single-Chip Mode Reset Vector


29 2012 Renesas Electronics America Inc. All rights reserved.

Storing Load Images


By default stored in external SPI flash RX cannot read from ROM while writing or erasing ROM Large stalls in user application or move to RAM No chance of losing image Cost of SPI flash is usually lower than doubling MCU ROM Its so much easier!

30

2012 Renesas Electronics America Inc. All rights reserved.

RL78 Implementation

31

2012 Renesas Electronics America Inc. All rights reserved.

Dual Boot Blocks


Has 2 independent boot blocks Can swap which one is used Removes problem of losing everything Still recommend external SPI flash

32

2012 Renesas Electronics America Inc. All rights reserved.

Using Boot Swap


Download new image Swap to bootloader block Program in image Swap to application block

33

2012 Renesas Electronics America Inc. All rights reserved.

Summary
Quick bootloader overview The flash loader framework Design choices RX implementation RL78 implementation Lab

34

2012 Renesas Electronics America Inc. All rights reserved.

Questions?

35

2012 Renesas Electronics America Inc. All rights reserved.

Enabling The Smart Society


In a smart society devices can add features and fix bugs after leaving store shelves. Have a bootloader in your system allows you to sleep better at night.

???
Firmware v1.2 v1.3 Fixed focusing bug
36 2012 Renesas Electronics America Inc. All rights reserved.

Firmware v3.0 v4.0 Added Multitasking

Renesas Electronics America Inc.


2012 Renesas Electronics America Inc. All rights reserved.

Вам также может понравиться