The Solution – Data Flash & Record Management Use data flash and existing Flash API for low level Add layer to handle record management Flash API ???. Data Flash Block #0Data Flash B
Trang 1Using Virtual EEPROM and Flash API for Renesas MCUs
Trang 2Renesas Technology & Solution Portfolio
Trang 3Microcontroller and Microprocessor Line-up
44 DMIPS, True Low Power Embedded Security, ASSP
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
Trang 4 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’
Trang 7ROM
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
Trang 8The Problem – Storing Non-Volatile Data
Store in external EEPROM
Trang 9The 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
Trang 10The 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
Trang 11Data 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 #1 Data #2 EMPTY
Trang 12ROM 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
Trang 14Data Flash vs ROM
Typically Data Flash has:
Smaller write and erase sizes
Shorter write times
Larger number of rewrite/erase cycles
Trang 15Virtual EEPROM Features
Trang 16Background Operations (BGO)
With BGO, MCU can continue during DF erase or write
Memory area being worked on cannot be accessed
Access Violation!
Trang 17Wear Leveling
Increases longevity of the Data Flash
Records do not overwrite
Old records are ignored
VEE Memory Area
Address
0x100000
Address 0x1007FF
VEE
Record
1
VEE Record 1
VEE Record 2
VEE Record 1
VEE Record 2
Trang 18Ignore Duplicate Writes
Increases longevity of the Data Flash
Identical writes are ignored
VEE
VEE Record
1
VEE
VEE Record
VEE Record 2
Trang 19Record Caching
No seeking for records
1 cache entry per available record number
VEE Memory Area
Address
0x100000
Address 0x1007FF
VEE Record Cache
Record 1 Address
Record 2 Address
VEE Record
VEE Record
VEE Record
VEE Record
VEE Record Many More
Trang 20VEE 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
Trang 21 4 extra structure members per record
Overhead depends on write granularity
RX62N = 32 bytes per record
Trang 22How does it work?
Trang 23Virtual EEPROM Terminology
VEE Sector 0
VEE Record 0 VEE Record 1 VEE Record 1 VEE Record 0 VEE Record 2 VEE Record 2
Trang 24Virtual EEPROM Operational Overview
VEE Sector 0
VEE Record 0 VEE Record 1 VEE Record 1 VEE Record 0 VEE Record 2 VEE Record 2
Trang 25Virtual EEPROM Operational Overview
VEE Sector 0
VEE Record 0 VEE Record 1 VEE Record 1 VEE Record 0 VEE Record 2 VEE Record 2
NOT ENOUGH
ROOM
Trang 26Virtual EEPROM Operational Overview
VEE Sector 0
VEE Record 0 VEE Record 1 VEE Record 1 VEE Record 0 VEE Record 2 VEE Record 2
DEFRAG OCCURS
VEE Record 1
Trang 27Virtual EEPROM Operational Overview
VEE Sector 0
VEE Record 0 VEE Record 1 VEE Record 1 VEE Record 0 VEE Record 2 VEE Record 2
VEE Record 1 VEE Record 0 VEE Record 2
DEFRAG CONTINUES
Trang 28Virtual EEPROM Operational Overview
VEE Sector 0
VEE Record 0 VEE Record 1 VEE Record 1 VEE Record 0 VEE Record 2 VEE Record 2
VEE Record 1 VEE Record 0 VEE Record 2
DELETE OLD
BLOCK
Trang 29Virtual EEPROM Operational Overview
VEE Sector 0
VEE Record 1 VEE Record 0 VEE Record 2
Trang 30Virtual EEPROM Configuration
Trang 31Why 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
Trang 32Why 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
VEE Record
VEE Record
VEE Record
VEE Record
VEE Record
VEE Record
VEE Record
VEE Record
VEE Record
Defrag Finally!
2 Sectors
Trang 33Virtual EEPROM API
Trang 35VEE 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
Trang 36Data Flash User 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 0 VEE Record 0
VEE Record 1 VEE Record 1
Trang 37Why not have R_FlashRead() instead?
User would call this function to read data
Data would have to be copied every time
No way to prevent user from directly accessing
Trang 38Virtual EEPROM for RL78
Trang 39RL78 – EEPROM Emulation Library
Has similar features
Uses ‘pools’
Trang 40RL78 – EEL Modes
Has 3 execution modes
Trang 42Questions?
Trang 43 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’