Implementing Bootloaders on Renesas MCUs Brandon Hussey, Applications Engineer Class ID: CL09I Renesas Electronics America Inc.
Brandon Hussey Applications Engineer RX support Flash API Virtual EEPROM Flash Loader Firmware Integration Technology (FIT) PREVIOUS EXPERIENCE: Interned at Renesas for 3 years Joined on full-time after graduation I hold an MSCPE from North Carolina State University 2
Renesas Technology & Solution Portfolio 3
8/16-bit 32-bit Microcontroller and Microprocessor Line-up 2010 2012 1200 DMIPS, Superscalar Automotive & Industrial, 65nm 600µA/MHz, 1.5µA standby 500 DMIPS, Low Power 32-Bit High Performance DSP, FPU with High Integration Automotive & Industrial, 90nm 600µA/MHz, 1.5µA standby 165 DMIPS, FPU, DSC Industrial, 90nm 200µA/MHz, 1.6µA deep standby 25 DMIPS, Low Power Industrial & Automotive, 150nm 190µA/MHz, 0.3µA standby 10 DMIPS, Capacitive Touch Wide Industrial Format & LCDs Automotive, 130nm 350µA/MHz, 1µA standby 1200 DMIPS, Performance Automotive, 40nm 500µA/MHz, 35µA deep standby 165 DMIPS, FPU, DSC Industrial, 40nm 200µA/MHz, 0.3µA deep standby Embedded Security, ASSP Industrial, 90nm 1mA/MHz, 100µA standby 44 DMIPS, True Low Power Industrial & Automotive, 130nm 144µA/MHz, 0.2µA standby 4
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 Firmware v3.0 v4.0 Added Multitasking 5
Agenda Quick bootloader overview The flash loader framework Design choices RX implementation RL78 implementation Lab 6
Quick Bootloader Overview 7
Quick Bootloader Overview Reset What is a bootloader? What can a bootloader do? Erase and rewrite user memory Bootloader Validate user memory Communicate with the outside world Download new application in case of failure Application What should a bootloader be? 8
Available Boot Options Factory bootloader Cannot be modified User code cannot run Can program/erase everything User boot area Programmed with USB from factory Uses CPU rewrite code User application Uses CPU rewrite code P/E P/E MCU Address Space RAM Factory Bootloader User Boot Area User Application Area 9
The Flash Loader Project 10
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 11
Terms Load Image v4.2 Host Device Storage 12
Parts of the Flash Loader Project? Flexible system that can be split into 2 parts: Downloader Bootloader Host Device Storage Checking Downloading Storing Reprogramming 13
1: Using Flash Loader With Your Project 14
Add Flash Loader to your HEW Project Add flash loader project files User s Project User Application + Flash Loader Enables future updates Flash loader bootloader is separate project 15
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 Host Device Storage 16
2: Making a Load Image 17
Making a Load Image 60KB 20KB S-Record ( MOT ) files are inefficient MOT S-Record Converter Load Image S-Record Converter Load image information: Binary Starts with header Has N blocks Load Image... Header Block 1 Block 2 Block N 18 2012 2010 Renesas Renesas Electronics Electronics America America Inc. Inc. All rights reserved. All rights reserved.
Load Image Header Field Size in Bytes Valid mask 1 Image ID 1 Version number 1 Size of load image 4 Max block data size 4 Load image CRC 2 Raw CRC 2 Address of 1 st data block 4 Successfully stored? 4 19 2012 2010 Renesas Renesas Electronics Electronics America America Inc. Inc. All rights reserved. All rights reserved.
3: Obtaining the Load Image 20
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 Device Storage 21
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 Device Storage 22
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 23
4: Using the Load Image 24
Reboot & Flash Reboot when convenient Check for new load image If valid, reflash MCU Jump to user application and execute Load Image Host Device Storage 25
Design Choices 26
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 27
RX Implementation 28
Flash Loader Bootloader Separate workspace Separate memory areas Can use same or different communications as FL downloader User Boot is special M C User Application & Flash Loader Downloader Flash Loader Bootloader U User ROM User Boot Area 29
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 30
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 It s so much easier! 31
RL78 Implementation 32
Dual Boot Blocks Has 2 independent boot blocks Can swap which one is used Removes problem of losing everything Still recommend external SPI flash 33
Using Boot Swap Download new image Swap to bootloader block Program in image Swap to application block 34
Summary Quick bootloader overview The flash loader framework Design choices RX implementation RL78 implementation Lab 35
Questions? 36
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 Firmware v3.0 v4.0 Added Multitasking 37
Please Provide Your Feedback Please utilize the Guidebook application to leave feedback or Ask me for the paper feedback form for you to use 38
Renesas Electronics America Inc.