Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using Virtual EEPROM and Flash API for Renesas MCUs CL08I Brandon Hussey, Applications Engineer
© 2012 Renesas Electronics America Inc. All rights reserved.2 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
© 2012 Renesas Electronics America Inc. All rights reserved.3 Renesas Technology & Solution Portfolio
© 2012 Renesas Electronics America Inc. All rights reserved.4 Microcontroller and Microprocessor Line-up Wide Format LCDs Industrial & Automotive, 130nm 350µA/MHz, 1µA standby 44 DMIPS, True Low Power Embedded Security, ASSP 165 DMIPS, FPU, DSC 1200 DMIPS, Performance 1200 DMIPS, Superscalar 500 DMIPS, Low Power 165 DMIPS, FPU, DSC 25 DMIPS, Low Power 10 DMIPS, Capacitive Touch Industrial & Automotive, 150nm 190µA/MHz, 0.3µA standby Industrial, 90nm 200µA/MHz, 1.6µA deep standby Automotive & Industrial, 90nm 600µA/MHz, 1.5µA standby Automotive & Industrial, 65nm 600µA/MHz, 1.5µA standby Automotive, 40nm 500µA/MHz, 35µA deep standby Industrial, 40nm 200µA/MHz, 0.3µA deep standby Industrial, 90nm 1mA/MHz, 100µA standby Industrial & Automotive, 130nm 144µA/MHz, 0.2µA standby bit 8/16-bit
© 2012 Renesas Electronics America Inc. All rights reserved.5 Devices in a smart society must efficiently use their available resources. Eliminating the need for external components when they can be incorporated inside the MCU is vital. ‘Enabling The Smart Society’
© 2012 Renesas Electronics America Inc. All rights reserved.6 Agenda Introduction to Virtual EEPROM Features How does it work? Configuration API Lab
© 2012 Renesas Electronics America Inc. All rights reserved.7 Terminology Non-volatile Data Record EEPROM Erase and write sizes (or granularity)
© 2012 Renesas Electronics America Inc. All rights reserved.8 MCU ROM The Problem – Storing Non-Volatile Data Store in internal ROM Advantages: Stored internally to MCU; no extra cost Disadvantages: Must halt MCU or run from RAM Possibility of corrupting application Relatively large minimum write and erase sizes Complex to implement
© 2012 Renesas Electronics America Inc. All rights reserved.9 The Problem – Storing Non-Volatile Data Store in external EEPROM Advantages: Self-contained Easy to use Usually 1 byte writable Disadvantages: $$$ Uses HW No record management
© 2012 Renesas Electronics America Inc. All rights reserved.10 The Problem – Storing Non-Volatile Data Store in internal data flash Advantages: Stored internally to MCU; no extra cost Can continue to execute from ROM Relatively small minimum write and erase sizes No possibility of corrupting ROM Disadvantages: No record management Write granularity might not be 1-byte MCU ROM Data Flash MCU
© 2012 Renesas Electronics America Inc. All rights reserved.11 The Solution – Data Flash & Record Management Use data flash and existing Flash API for low level Add layer to handle record management Flash API???Virtual EEPROM
© 2012 Renesas Electronics America Inc. All rights reserved.12 Data Flash Block #0 Data Flash Block #1 EMPTY Why is Virtual EEPROM Needed? Many data flashes do not have 1-byte writes Maintaining multiple records Statically allocating addresses can wear out DF faster Using advanced features of MCU Data #1Data #2 EMPTY
© 2012 Renesas Electronics America Inc. All rights reserved.13 MCU ROM Data Flash What is the Virtual EEPROM Project? The Virtual EEPROM Project allows you to use the Data Flash on your MCU as you would an EEPROM while adding other record management features MCU ROM Data Flash/VEE I2C
© 2012 Renesas Electronics America Inc. All rights reserved.14 Simple API User Application R_VEE_Write(my_record)... R_VEE_Read(my_record)... MCU ROM Data Flash
© 2012 Renesas Electronics America Inc. All rights reserved.15 Data Flash vs ROM Typically Data Flash has: Smaller write and erase sizes Shorter write times Larger number of rewrite/erase cycles MCU – Memory Area Write Size Erase Size Write Time Erase Time Erase/ Write Cycles RX62N - DF8B2KB0.4ms70ms30,000 RX62N - ROM256B4KB2.0ms25ms1,000 RX63N – DF2B32B0.25ms2ms100,000 RX63N – ROM128B4KB1.0ms25ms1,000 MCU – Memory Area Write Size Erase Size Write Time Erase Time Erase/ Write Cycles RX62N - DF8B2KB0.4ms70ms30,000 RX62N - ROM256B4KB2.0ms25ms1,000
© 2012 Renesas Electronics America Inc. All rights reserved.16 Virtual EEPROM Features
© 2012 Renesas Electronics America Inc. All rights reserved.17 Background Operations (BGO) With BGO, MCU can continue during DF erase or write Memory area being worked on cannot be accessed Access Violation!
© 2012 Renesas Electronics America Inc. All rights reserved.18 Wear Leveling Increases longevity of the Data Flash Records do not overwrite Old records are ignored VEE Memory Area Address 0x Address 0x1007FF VEE Record 1 VEE Record 1 VEE Record 2 VEE Record 1 VEE Record 2
© 2012 Renesas Electronics America Inc. All rights reserved.19 Ignore Duplicate Writes Increases longevity of the Data Flash Identical writes are ignored Time trade-off VEE Memory Area Address 0x Address 0x1007FF VEE Record 1 VEE Record 1 VEE Record 2 VEE Record 1 CHECKING… VEE Record 2
© 2012 Renesas Electronics America Inc. All rights reserved.20 Record Caching No seeking for records 1 cache entry per available record number VEE Memory Area Address 0x Address 0x1007FF VEE Record Cache Record 1 Address Record 2 Address VEE Record 1 VEE Record 1 VEE Record 2 VEE Record 1 VEE Record 2 Many More Records
© 2012 Renesas Electronics America Inc. All rights reserved.21 VEE Memory Area VEE Record 2 Error Detection Each record has its own error detection field Virtual EEPROM recovers automatically from errors Recovery measures are only taken on writes VEE Record 1 ID Size Data Check
© 2012 Renesas Electronics America Inc. All rights reserved.22 Overhead 4 extra structure members per record Overhead depends on write granularity RX62N = 32 bytes per record RX63N = 8 bytes per record
© 2012 Renesas Electronics America Inc. All rights reserved.23 How does it work?
© 2012 Renesas Electronics America Inc. All rights reserved.24 Virtual EEPROM Terminology VEE Sector 0 VEE Block 0VEE Block 1 VEE Record 0VEE Record 1 VEE Record 0 VEE Record 2
© 2012 Renesas Electronics America Inc. All rights reserved.25 Virtual EEPROM Operational Overview VEE Sector 0 VEE Block 0VEE Block 1 VEE Record 0VEE Record 1 VEE Record 0VEE Record 2
© 2012 Renesas Electronics America Inc. All rights reserved.26 Virtual EEPROM Operational Overview VEE Sector 0 VEE Block 0VEE Block 1 VEE Record 0VEE Record 1 VEE Record 0VEE Record 2 VEE Record 1 NOT ENOUGH ROOM
© 2012 Renesas Electronics America Inc. All rights reserved.27 Virtual EEPROM Operational Overview VEE Sector 0 VEE Block 0VEE Block 1 VEE Record 0VEE Record 1 VEE Record 0VEE Record 2 DEFRAG OCCURS VEE Record 1
© 2012 Renesas Electronics America Inc. All rights reserved.28 Virtual EEPROM Operational Overview VEE Sector 0 VEE Block 0VEE Block 1 VEE Record 0VEE Record 1 VEE Record 0VEE Record 2 VEE Record 1VEE Record 0VEE Record 2 DEFRAG CONTINUES
© 2012 Renesas Electronics America Inc. All rights reserved.29 Virtual EEPROM Operational Overview VEE Sector 0 VEE Block 0VEE Block 1 VEE Record 0VEE Record 1 VEE Record 0VEE Record 2 VEE Record 1VEE Record 0VEE Record 2 DELETE OLD BLOCK
© 2012 Renesas Electronics America Inc. All rights reserved.30 Virtual EEPROM Operational Overview VEE Sector 0 VEE Block 0VEE Block 1 VEE Record 1VEE Record 0VEE Record 2
© 2012 Renesas Electronics America Inc. All rights reserved.31 Virtual EEPROM Configuration
© 2012 Renesas Electronics America Inc. All rights reserved.32 Why would I need more than 1 VEE Sector? Optimize (lower) the number of defrags VEE Sector #0 – Block #0 VEE Record 1 VEE Record 2 VEE Sector #0 – Block #1 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 1 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 2 Defrag Again! 1 Sector
© 2012 Renesas Electronics America Inc. All rights reserved.33 Why would I need more than 1 VEE Sector? Optimize (lower) the number of defrags VEE Sector #0 – Block #0 VEE Record 1 VEE Sector #1 – Block #0 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 2 VEE Record 2 Defrag Finally! 2 Sectors
© 2012 Renesas Electronics America Inc. All rights reserved.34 Virtual EEPROM API
© 2012 Renesas Electronics America Inc. All rights reserved.35 API Functions R_VEE_Read() R_VEE_Write() R_VEE_Defrag() R_VEE_Erase() R_VEE_GetState() R_VEE_ReleaseState()
© 2012 Renesas Electronics America Inc. All rights reserved.36 VEE Operation Completion Can use polling or interrupt driven Polling: Use R_VEE_GetState() Will return current state of VEE Interrupt Driven: User defined callback in r_vee_config.h Warning: Callback is called from interrupt #define VEE_CALLBACK_FUNCTION VEE_OperationDone_Callback
© 2012 Renesas Electronics America Inc. All rights reserved.37 Data FlashUser Application Why do we need R_VEE_ReleaseState()? Used to prevent data flash access violations R_VEE_Read(ID=0) to read VEE Record 0 R_VEE_Write(ID=1) to write VEE Record 1 User reads data from pointer in step 1 while write is still on-going Multiple reads are allowed Pointer to Record 0VEE Record 0VEE Record 1
© 2012 Renesas Electronics America Inc. All rights reserved.38 Why not have R_FlashRead() instead? User would call this function to read data Advantages: This would eliminate need for releasing state Disadvantages: RX can directly read data flash Large overhead Data would have to be copied every time No way to prevent user from directly accessing
© 2012 Renesas Electronics America Inc. All rights reserved.39 Virtual EEPROM for RL78
© 2012 Renesas Electronics America Inc. All rights reserved.40 RL78 – EEPROM Emulation Library Has similar features Uses ‘pools’
© 2012 Renesas Electronics America Inc. All rights reserved.41 RL78 – EEL Modes Has 3 execution modes
© 2012 Renesas Electronics America Inc. All rights reserved.42 Summary Why do you need it? Features How it works How to use it Available on RX and RL78 MCUs
© 2012 Renesas Electronics America Inc. All rights reserved.43 Questions?
© 2012 Renesas Electronics America Inc. All rights reserved.44 Devices in a smart society must efficiently use their available resources. Eliminating the need for external components when they can be incorporated inside the MCU is vital. ‘Enabling The Smart Society’
© 2012 Renesas Electronics America Inc. All rights reserved.45 Please utilize the ‘Guidebook’ application to leave feedback or Ask me for the paper feedback form for you to use… Please Provide Your Feedback…
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved.