REN - U20280EE1V2UM00 - MAT - 20140206 EEPROM Emulation Library
REN - U20280EE1V2UM00 - MAT - 20140206 EEPROM Emulation Library
All information contained in these materials, including products and product specifications,
represents information on the product at the time of publication and is subject to change by
Renesas Electronics Corp. without notice. Please review the latest information published by
Renesas Electronics Corp. through various means, including the Renesas Technology Corp.
website (http://www.renesas.com).
• Device availability
• Ordering information
• Product release schedule
• Availability of related technical literature
• Development environment specifications (for example, specifications for
third-party tools and components, host computers, power plugs, AC
supply voltages, and so forth)
• Network requirements
In addition, trademarks, registered trademarks, export restrictions, and other legal issues may also
vary from country to country.
Visit
http://www.renesas.com
to get in contact with your regional representatives and distributors.
Chapter 1 Introduction
This user’s manual describes the internal structure, the functionality and
software interfaces (API) of the Renesas V850 EEPROM Emulation Library
(EEL) type T05, designed for V850 based Flash devices with Data Flash
based on the UX6LF Flash technology
The device features differ depending on the used Flash implementation and
basic technology node. Therefore, pre-compile and run-time configuration
options allow adaptation of the library to the device features and to the
application needs.
The libraries are delivered in source code. However it has to be considered
carefully to do any changes, as not intended behavior and programming faults
might be the result.
The development environments of the companies Green Hills (GHS), IAR and
Renesas are supported. Due to the different compiler and assembler features,
especially the assembler files differ between the environments. So, the library
and application programs are distributed using an installer tool that allows
selecting the appropriate environment.
For support of other development environments, additional development effort
may be necessary. Especially, but maybe not only, the calling conventions to
the assembler code and compiler dependent section defines differ
significantly.
The different options of setup and usage of the libraries are explained in detail
in this document.
Caution:
Please read all chapters of the application note carefully.
Much attention has been put to proper conditions and limitations description.
Anyhow, it can never be ensured completely that all not allowed concepts of
library implementation into the user application are explicitly forbidden. So,
please follow exactly the given sequences and recommendations in this
document in order to make full use of the libraries functionality and features
and in order to avoid any possible problems caused by libraries misuse.
The EEPROM emulation libraries together with the application samples, this
application note and other device dependent information can be downloaded
from the following URL:
http://www.eu.renesas.com/update
Abbreviations /
Description
Acronyms
Block Smallest erasable unit of a flash macro
Embedded Flash where the application code is stored.
For devices without Data Flash EEPROM emulation
Code Flash
might be implemented on that flash in the so called data
area.
Embedded Flash where mainly the data of the EEPROM
Data Flash emulation are stored. Beside that also code operation
might be possible.
Dual operation is the capability to fetch code during
reprogramming of the flash memory. Current limitation is
Dual Operation that dual operation is only available between different
flash macros. Within the same flash macro it is not
possible!
EEL EEPROM Emulation Library
In distinction to a real EEPROM the EEPROM emulation
EEPROM uses some portion of the flash memory to emulate the
emulation EEPROM behavior. To gain a similar behavior some
side parameters have to be taken in account.
FAL Flash Access Library (Flash access layer)
FCL Code Flash Library (Code Flash access layer)
FDL Data Flash Library (Data Flash access layer)
“Flash EPROM” - Electrically erasable and
programmable nonvolatile memory. The difference to
Flash
ROM is, that this type of memory can be re-programmed
several times.
A flash block is the smallest erasable unit of the flash
Flash Block
memory.
A flash comprises of the cell array, the sense amplifier
Flash Macro and the charge pump (CP). For address decoding and
access some additional logic is needed.
Non volatile memory. All memories that hold the value,
NVM even when the power is cut off. E.g. Flash memory,
EEPROM, MRAM...
“Random access memory” - volatile memory with
RAM
random access
“Read only memory” - nonvolatile memory. The content
ROM
of that memory can not be changed.
The onboard programming mode is used to program the
Serial programming
device with an external programmer tool.
For the reprogramming of single voltage flashes the
voltage needed for erasing and programming are
Single Voltage
generated onboard of the microcontroller. No external
voltage needed like for dual- voltage flash types.
Note:
It is not possible to modify Code Flash and Data Flash in parallel!
Code Flash
Code Flash
User Application
or User Application
EEL
FDL FDL
Application
The functional block “Application” should not use the functions offered by the
FDL directly. FDL functions are reserved for EEL only. Exception is when the
user implements a proprietary EEPROM emulation, it has to use functions
provided by the FDL only.
Pools details:
FDL-pool is just a place holder for the EEL-pool. It does not allocate any
flash memory. The FDL-pool descriptor defines the valid address space
for FDL access to protect all flash outside the FDL-pool against
destructive access (write/erase) by a simple address check in the library.
To simplify function parameter passing between FDL and the higher layer
the physical Flash addresses (e.g. 0x02000000….0x0200FFFF) are
transformed into a linear address room 0x0000….0xFFFF used by the
FDL.
EEL-pool allocates and formats (virgin initialization) all flash blocks
belonging to the EEL-pool. The header data are generated in proper way
to be directly usable by the application.
User Pool is completely in the hands of the user application. It can be
used to build up an own user EEPROM emulation or to simply store
constants.
User Pool
User Application
EEL Pool
EEL
User Pool
DS write abort is handled very simple by stopping the write process. Writing
closing management data as for the V850 MF2 EEELib is no longer required
due to the new data management method.
The startup performance is significantly improved regarding the V850
MF2/UX4 implementation as the DS management does no longer need to
overwrite data in order to ensure the data consistency.
Ring buffer style Flash block management reaches better Flash endurance
usage. While the old concept required a constant “copy zone” in order to
execute Refresh section operations, the new concept requires copy space only
if the data at the ring buffer tail (eldest part of the ring buffer) is not already
written new in the ring buffer.
Each block will pass a complete life cycle on every ring buffer loop.
consumed prepared
Logical
ring active active
active prepared prepared
(full) (full)
last
physical
Physical prepared block
Flash prepared
Under
erasing
consumed
consumed
active
(full)
active
(full)
active
prepared
1'st
physical
block
Section header
Block Lifecycle
information
prepared Prepared
active
Active
occupied
consumed
Invalid
Under
erasing
Excluded Excluded
Block header:
The header contains the block status information.
Data Zone:
Contains the pure user data to be stored without any management information.
Block bottom
address
Block Header
REF Zone
Growing
Blank
Data Zone
Growing
Block top
address
While the block management (including the block header) is described in the
next sub-chapters, the data management within the blocks (including REF
Zone and Data Zone) is described in the main chapter EEL Data Sets
Management.
I – 0, I – 1:
These words together build a 64bit word containing the information, if a block
is invalid or excluded.
By writing 0x5555555555555555, the block is marked excluded.
By writing 0x0000000000000000, the block is marked invalid.
If on startup the words are not blank and not matching one of the above
patterns, the block is judged invalid. This is the block default state which may
result from a power fail during block status change operations.
If on startup the words are blank, the other header words determine the block
status.
P:
The prepare marker is set by the preparation process. With the pattern
0x55555555, the block is marked prepared.
A – 0:
The activation flag 0 is written 1st in the block activation process with the
pattern 0x55555555.
It locks the block for the activation, so that in case of a power fail in this
process, a later activation after restart will not lock this block again, but will use
the next one.
A – 1:
The activation flag 1 is written last in the activation process with the pattern
0x55555555.
EC:
The erase counter is written as the 1st word in the preparation process.
Rule for counter calculation is:
if the block is the 1st physical block
EC = ( previous block EC ) + 1
otherwise
EC = ( previous block EC )
By that rule, on each ring buffer turn around the erase counter in each block is
increased by 1.
The erase counter stability is ensured by the P word, written afterwards in the
preparation process. If the P word is valid, the EC is electrically stable.
Additionally, the EC is checksum protected in order to be robust against
accidental overwriting due to application failures.
Physical Flash
EC
prepared 121
prepared 121
Under undefined
erasing
consumed 120
occupied 120
occupied 120
active 120
prepared 120
Note:
The erase counter does not necessarily match the real Flash block erase
cycles, but only the erase cycles since the EEPROM emulation has been set
up last time. The erase counter is affected by Data Flash complete erase or
manual Flash modification (programmer or debugger).
RWP:
The reference write pointer is written in the activation process after A – 0 and
before A – 1.
It points to the previous block separator between REF zone and Data zone. By
that, the EEL knows for each occupied block the last REF zone entry.
The RWP stability is ensured by the A - 1 word, written afterwards in the
activation process. If the A - 1 word is valid, the RWP is electrically stable.
Additionally, the RWP is checksum protected in order to be robust against
accidental overwriting due to application failures.
REF Zone
REF Zone
REF Zone
Blank Blank
Blank
Data Zone
Data Zone
Data Zone
RDP:
The Read Data Pointer is used for treatment of the special situation that only
one passive block is left (“Pool full situation”).
The block header information is read on library startup and maintained library
internal during run-time.
The block header data is modified during run-time by the block management
processes (see next chapter) and during startup in case of detected
inconsistencies.
Figure 10 Overview - Entry in the REF zone pointing to the user data in the Data zone
Block Header
REF entry
REF Zone
Blank
Data
Data Zone
The user data is stored in the Data Zone sequentially according to the write
sequence. Based on the Flash write size of 1 word, the data is stored word
aligned.
In order to find the data later on in the Flash, the REF zone contains the DS
management information, which is basically the ID and the pointer to the data.
Further information is required in the REF-zone to ensure data consistency in
case of write interruption and in order to improve the robustness against user
application fails resulting in Flash words overwrite.
2.7.2 DP and RP
The emulation library requires two pointers in the active section in order to
write new DS instances to the Flash
Data Pointer (DP)
The DP is the pointer to the next write location for the user data.
Reference Pointer (RP)
The RP is the pointer to the next location for a REF zone entry.
Figure 11 DP and RP
Block bottom
address
Block Header
REF Zone
RP
Blank
DP
Data Zone
Block top
address
RP and DP grow together. When the pointers match, only one blank word is
between the zones. The Flash block is considered as full and the next block
must be activated.
Blank – part 1
Blank
New DS
DS Write
Blank Blank
New DS – part 2
Note:
Based on the EEL implementation it is not allowed that the DS size exceeds
more than one Data Flash block. So, overlapping multiple blocks is not
possible.
Blank
Data n (7 Bytes)
EOR
Data n-1 (14 Bytes)
Data
Zone EOR
Data n-2 (8 Bytes)
EOR
EOR Data n-3 (1 Byte)
NOTE:
The DRP widx is excluded from the checksum as it is
updated in case of a Refresh, where the DCS is not re-
calculated (may not be recalculated as in case of an
application update combined with IDL table update, the DCS
indicates a possible DS length change to the user
application).
EOR End of Reference (1-bit Tag)
Additional safety for the case of data set write interruptions.
In order not to waste an additional Flash word for this, the last
data words Tag is used for EOR.
2.7.3.2 Invalidated DS
The Invalidated DS’s are stored according to the following picture (data n-1
and data n-2):
Blank
Data n (7 Bytes)
Data EOR
Zone EOR Data n-3 (1 Byte)
Note:
Widx = 0 identifies that the DS is invalidated and no data
zone contents is addressed by this REF entry
EOP/EOR End of Reference (1-bit Tag)
Is written immediately after the DCS. When written, the read
margin of the DRP word is ensured by the write sequence.
NOTE:
The DRP widx is excluded from the checksum as it is
updated in case of a Refresh, where the DCS is not re-
calculated (may not be recalculated as in case of an
application update combined with IDL table update, the DCS
indicates a possible DS length change to the user application.
The process scheduler judges the priority of the main processes and
suspends/resumes the processes accordingly.
The following rules are considered:
The startup process prohibits Read operations until DP and RP are
calculated.
The startup process prohibits Write operations until all DS margins are
ensured.
Process states need to be finished before a process can be suspended.
This includes all Flash operations except Erase.
If a process state containing a Flash erase is active:
o The Flash erase is suspended.
o The process step is finished.
o A Flash erase resume process step is set as next step.
Furthermore, the Format process immediately locks all other processes except
Preparation, which is required for the Format.
Note:
All Write/Invalidation processes are based on one source code. The
differentiation in the processes is done by the process local variables.
Highest Priority
READ process
suspend resume
DS WRITE process
Set active sub-process
(Immediate User)
suspend resume
DS WRITE process
(User)
suspend resume
DS WRITE process
(REFRESH)
suspend resume
Set invalide
REFRESH process
sub-process
suspend resume
Set prepared
PREPARATION process
sub-process
Set exclude
suspend resume sub-process
FORMAT process
suspend resume
Startup sub-process:
- Check ring buffer
- Check pool full
- Get block pointers
- Ensure DS margin
- Build RAM table
Process
selection
Active
flag
0 READ process
DS WRITE process
1 (Immediate User)
0 DS WRITE process
(User)
DS WRITE process
1 (REFRESH)
0 PREPARATION process
0 REFRESH process
0 FORMAT process
1 SUPERVISION process
S1
Process activation
S1
Process execution S2
1 WRITE process
S3
S5
S4
Process deactivation
S5
After finishing one state, the next state within this (sub) process is stored and
the control is given back to the state machine, which then again selects the
highest priority active process to execute.
All processes except the lowest priority supervision process have an exit or
exception state, which result in deactivation of the process, so that other lower
priority processes can be executed.
Each state has a strictly limited execution time. Based on that, the library
function controlling the state machine (EEL_Handler, see API description) will
immediately return to the user application. Due to dual operation between
Code Flash and Data Flash the upper application can continue operation while
frequently invoking the state machine handler function.
The errors/warnings are returned to the user application on two different ways:
Errors on background operations are returned by a special function
returning the driver status. Independently, in case of errors, ongoing and
future user commands will be answered with
EEL_ERR_ACCESS_LOCKED.
Errors on user commands (Write, Read, Format) will be returned as
command answer.
On errors the process error status is set and the affected process is
finished. The error reaction is taken over by the higher level process when
execution is continued there.
Background process Supervision
This top level background process activates the background processes.
After finish of these processes, the supervision checks the error status of
these processes and depending on the result, the system reaction is
handled (see 3.1.5.1, “Error reaction and return”).
This also includes the startup sub-process functions which are also
handled by the supervision.
User command processes (Read, Write, Format)
These processes may activate other processes (e.g. Format activates
prepare). After finish of these processes, the user command processes
check the error status of the activated processes and depending on the
result, the system reaction is handled (see 3.1.5.1, “Error reaction and
return”).
Data Flash
prepared
prepared
consumed
16bit 16bit 16bit
Data Flash pointer ID 0 Length
EEL consumed Data Flash pointer ID 1 Length
Pool Data Flash pointer ID 2 Length
Data Flash pointer ID 3 Length
Data Flash pointer ID 4 Length
occupied
active
prepared
The ID-L table (ROM table) contains one entry for each ID available in the
system, together with its DS length information. This table is configured at
compile time.
IDX table (RAM table) contains for each ID available in the system the pointer
to the latest data instance. On EEL startup the IDX table is filled and
continuously updated on each DS Write access.
Start-up
access status operational status comment
progress
All library
EEL_ACCESS_ EEL_OPERATION
EEL Initialized operations are
LOCKED _PASSIVE
prevented.
All library
EEL startup EEL_ACCESS_ EEL_OPERATION
operations are
started LOCKED _STARTUP
prevented.
DS Read is
possible with limited
EEL startup performance (REF
ongoing - EEL_ACCESS_ EEL_OPERATION zone search).
basic startup READ_WRITE _STARTUP
finished DS Write is possible
until the prepared
blocks are full.
DS Read is
possible with full
performance (ROM
EEL startup table search).
ongoing - EEL_ACCESS_ EEL_OPERATION
RAM table UNLOCKED _STARTUP DS Write is possible
filled and supervision
processing is active
to manage the ring
buffer.
EEL_OPERATION - DS Read and DS
_BUSY or _IDLE Write as before
EEL startup EEL_ACCESS_ (depending if - Electrical margin
end UNLOCKED Refresh/Prepare of the latest DS
operations are to instances is
be done) ensured.
In case of a fatal error during any start-up step, the library switches to
EEL_ACCESS_LOCKED and EEL_OPERATION_PASSIVE and the function
EEL_GetDriverStatus will additionally return an appropriate error.
Note:
The last step (Ensure the electrical margin of the latest DS instances) checks if
the last DS instances have been completely written. Therefore it checks if the
last step of a DS write was executed (EOR is written). If not, redundant
information (valid DCS) ensures that the DS data is valid. On detection of such
cases, the DS is refreshed (copied to active zone head).
User’s Manual U20280EE1V2UM00 34
Fully operational
(after DS margins ensured)
Permanent
supervision
Build RAM
(starting with
table ensuring DS margin)
Get pointers
0 1 2 3 30
Access level
EEL_ACCESS_LOCKED EEL_ACCESS_READ_WRITE EEL_ACCESS_UNLOCKED
Operational
level
35
EEL_OPERATION_STARTUP EEL_OPERATION_BUSY
EEL_OPERATION_IDLE
EEPROM Emulation Library
Note:
From implementation point of view the startup phase will end when the
operational status changes from EEL_OPERATION_STARTUP to
EEL_OPERATION_BUSY/IDLE. Then all startup operations are finished.
From timing point of view, the startup phase will end when the access status
changes from EEL_ACCESS_READ_WRITE to EEL_ACCESS_UNLOCKED.
The remaining startup operations are executed in background and transparent
for the user. Also the early Read (see below) ends on
EEL_ACCESS_UNLOCKED.
Please refer to chapter 5.3.3, “Driver status” for the defines.
Chapter 4 Implementation
Differing from former EEPROM emulation libraries, this one is realized not as a
graphical IDE related specific sample project, but as a standard sample project
which is controlled by makefiles.
Following that, the sample project can be built in a command line interface and
the resulting elf-file can be run in the debugger.
The FDL and EEL files are strictly separated, so that the FDL can be used
without the EEL. However, using EEL without FDL is not possible.
The delivery package contains dedicated directories for both libraries
containing the source and the header files.
Note:
The application sample does not contain sample code for the FDL interface
usage, but only for the EEL interface. Anyhow, as the EEL contains FDL
functions calls, the usage of the FDL functions can be derived from that.
4.1.1 Overview
The following picture contains the library and application related files.
API declaration
Libray Describtors User
Passed to the
FDL.h library
FDL_Types.h
FDL.a
EEL.h FDL_Descriptor.h Source Code
EEL.a EEL_Types.h Application
EEL_Descriptor.h
EEL_...c
EEL_...c FDL_Cfg.h EEL_...c
Precompiled FDL_Descriptor.c
Library EEL_...c EEL_Cfg.h App....c
FDL_...c
EEL_Descriptor.c
Source Code EEL_...c
Library Library
Configuration
Library pre-compile configuration (Only on souce code delivery) – File name fix, File content user configurable
The library code consists of different source files, starting with FDL/EEL_...
The files may not be touched by the user, independently, if the library is
distributed as source code or pre-compiled.
The file FDL/EEL.h is the library interface functions header file.
The file FDL/EEL_Types.h is the library interface parameters and types header
file.
In case of source code delivery, the library must be configured for compilation.
The file FDL/EEL_Cfg.h contains defines for that. As it is included by the
library source files, the file contents may be modified by the user, but the file
name may not.
FDL/EEL_Descriptor.c and FDL/EEL_Descriptor.h do not belong to the
libraries themselves, but to the user application. These files reflect an
example, how the library descriptor ROM variables can be built up which need
to be passed with the functions FDL/EEL_Init to the FDL/EEL for run-time
configuration (see FDL user manual and 5.4.1.1, “EEL_Init”).
The structure of the descriptor is passed to the user application by
FDL/EEL_Types.h.
The value definition should be done in the file FDL/EEL_Descriptor.h.
The constant variable definition and value assignment should be done in
the file FDL/EEL_Descriptor.c.
[root]
Release.txt Installer package release notes
[root]\[make]
GNUPublicLicense.txt Make utility license file
libiconv2.dll DLL-File required by make.exe
libintl3.dll DLL-File required by make.exe
make.exe Make utility
[root]\[<device name>]\[compiler]
Build.bat Batch file to build the application sample
Clean.bat Batch file to clean the application sample
Makefile Makefile that controls the build and clean process
[root]\[<device name>]\[<compiler>]\[sample]
EELApp.h Application sample header with function prototypes
and collecting all includes
EELApp_Main.c Main source code
EELApp_Control.c Source code of the control program for EEEPROM
emulation
target.h Target device and application related definitions.
... device header files ... ( GHS: df<device number>.h,
io_macros.h, ...
IAR: io_70f3xxx.h
REC: - )
... startup file ... ( GHS: Startup_df<dev. num.>.850
IAR: DF3xxx_HWInit.s85
User’s Manual U20280EE1V2UM00 41
EEPROM Emulation Library
REC: cstart.asm)
... linker directive file ... ( GHS: Df<device number>.ld
IAR: lnk70f3xxx.xcl
REC: df3xxx.dir )
[root]\[<device name>]\[<compiler>]\[sample]\[EEL]
EEL_Cfg.h Header file with definitions for library setup at
compile time
EEL.h Header file containing function prototypes
EEL_Types.h Header file containing calling structures and error
definitions
EEL_Descriptor.h Descriptor file header with the run-time EEL
configuration. To be edited by the user.
EEL_Descriptor.c Descriptor file with the run-time EEL configuration.
Should not be edited by the user.
[root]\[<device name>]\[<compiler>]\[sample]\[EEL]\[lib]
EEL_Global.h Library internal defines, function prototypes and
variables
EEL_UserIF.c Source code for the EEL internal state machine,
service routines and initialization
EEL_BasicFct.c Source code of functions called by the state machine
[root]\[<device name>]\[<compiler>]\[sample]\[FDL]
FDL_Cfg.h Header file with definitions for library setup at
compile time
FDL.h Header file containing function prototypes
FDL_Types.h Header file containing calling structures and error
definitions
FDL_Descriptor.h Descriptor file header with the run-time FDL
configuration. To be edited by the user.
FDL_Descriptor.c Descriptorfile with the run-time EEL configuration.
Should not be edited by the user.
[root]\[<device name>]\[<compiler>]\[sample]\[FDL]\[lib]
FDL_Env.h Library internal defines for the Flash programming
hardware
FDL_Global.h Library internal defines, function prototypes and
variables
FDL_UserIF.c Source code for the library user interface and service
functions
FDL_HWAccess.c Source code for the libraries HW interface
EEL_CFG_TAG_READ_OFFSET:
Defines the read address offset of the Data Flash Tags regarding the Data
Flash base address.
This define is reserved for future use and must be set to 0x100000 for the
current devices.
Implementation in EEL_Cfg.h:
#define EEL_CFG_MAX_DATA_FLASH_SIZE EEL_CFG_MAX_DATA_FLASH_SIZE_256K
blkSize:
Defines the Data Flash block size in Bytes. This is just a configuration option
reserved for future use. In all current Devices the Data Flash size is fixed to
2kB=0x800Bytes.
Value range: Currently fixed to 0x800
falPoolSize:
Defines the number of blocks used for the FAL pool, which means the User
Pool + EEL Pool. Usually, the FAL pool size equals the total number of Flash
blocks.
Value range: Min: EEL pool size
Max: Physical number of Data Flash blocks
eelPoolStart:
Defines the first Data Flash block number used as EEL pool.
Value range: Min: FAL Pool start block
Max: eelPoolStart + eelPoolSize <= falPoolSize
eelPoolSize:
Defines the number of blocks used for the EEL pool.
Value range: Min: 4 Blocks (required for proper EEL operation)
Max: FAL pool size, condition:
eelPoolStart + eelPoolSize <= falPoolSize
Implementation:
typedef struct {
fal_u16 blkSize_u16;
fal_u16 falPoolSize_u16;
fal_u16 eelPoolStart_u16;
fal_u16 eelPoolSize_u16;
} fal_descriptor_t;
The descriptor variable definition and filling is part of the user application. The
files FDL_Descriptor.h/.c give an example which shall be used by the user
application. Only FDL_Descriptor.h need to be modified for proper
configuration while FDL_Descriptor.c can be kept unchanged.
Example 1)
Data Flash size is 32kB, separated into blocks of 2kB.
The EEL shall use the complete Data Flash for the EEL pool:
#define FAL_CONFIG_DATAFLASH_SIZE 16
#define FAL_CONFIG_BLOCK_SIZE 0x800
#define EEL_CONFIG_BLOCK_START 0
#define EEL_CONFIG_BLOCK_CNT 16
Example 2)
Data Flash size is 32kB, separated into blocks of 2kB.
The EEL shall use blocks 2 to 11 for the EEL pool, while blocks 0 to 1 and 12
to 15 can be used as user pool:
#define FAL_CONFIG_DATAFLASH_SIZE 16
#define FAL_CONFIG_BLOCK_SIZE 0x800
#define EEL_CONFIG_BLOCK_START 2
#define EEL_CONFIG_BLOCK_CNT 10
Example 3)
Data Flash size is 32kB, separated into blocks of 2kB; the EEL shall not be
used at all. The complete Data Flash shall be used as user pool:
#define FAL_CONFIG_DATAFLASH_SIZE 16
#define FAL_CONFIG_BLOCK_SIZE 0x800
#define EEL_CONFIG_BLOCK_START 0
#define EEL_CONFIG_BLOCK_CNT 0
addDF
Defines the Data Flash start address in the physical address room. The
definition is required for EEL internal calculations.
This is just a configuration option reserved for future use. In all current Devices
the Data Flash address is fixed.
Value range: Fixed to 0x2000000
blkRefreshThreshold
Defines the number of blocks that shall be prepared in the ring buffer by
default. In case of threshold underflow, the EEL supervision will initiate
Refresh / Prepare operations by time until the threshold is exceeded again.
Increasing the threshold allows fast sequences of data write without having to
give the EEL time to do the Refresh/Prepare operations. Reducing the
threshold improves the Flash usage as written data sets stay longer in the ring
buffer and need less Refresh copy operations. When the threshold is set too
low and the ring buffer gets full due to continuous data set write, the library will
return error Pool Full and block further write operations until the supervision
had enough time to prepare at least one additional Flash block.
Value range: Min: 2 Blocks (required for proper EEL operation)
Max: EEL pool size – 2
Example:
On a threshold of 6 the EEL will always try to have 6 prepared blocks as
passive pool in the ring buffer. This means that the user application could write
10kB data in sequence without giving the EEL time to do background
operations to prepare new space again (one block must remain prepared for
pool full situation handling).
~1/3 of the total available Flash blocks might be a reasonable starting point to
evaluate the balance between the possibility to write fast data sequences (big
threshold) and reducing the data copy effort on refresh (low threshold). The
service function EEL_GetSpace provides a tool to trace the available free
space in the ring buffer during run-time which allows threshold optimization
during run-time.
*IDLTab
Pointer to ROM ID-L table, see chapter 3.2.1, “ID-L and IDX tables”.
The ID-L table need to be defined as a 2-dimensional array of 16bit values as
follows:
{ { ID1, size 1 }, { ID2, size 2 }, { ID3, size 3 }, ..... }
Value range: ID Min: 1
ID Max: 0xFFFE
Size min: 1Byte (is adjusted library internal to word
boundary)
Size max: Block size – Block header size - 12Bytes
= 2048 – 32 - 12
= 2004Bytes
(this is caused by the EEL implementation.
Bigger data size would require significant
overhead in the power fail and supervision
concepts).
*IDXTab
Pointer to ROM ID-X table, see chapter 3.2.1, “ID-L and IDX tables”.
The ID-X table is a 1-dimensional array of 16bit values. The ID-X table RAM is
provided by the user application and filled and handled by the EEL.
IDLTabIdxCnt
Defines the size of the ID-L/X table in “number of entries”.
eraseSuspendThreshold_u16
When the EEL background operation executes the Prepare process, the Data
Flash block is erased. Any user Read or Write operation will suspend the
Flash Erase and after the operation resume the Erase again. Based on the
UX6LF Flash implementation, this Erase Suspend/Resume flow is restricted.
The Erase operation might not finish, if it is interrupted continuously. The user
application must be realized in a way that the erase operation once gets the
time to complete, which means that the user application must provide a time
frame as long as the worst case Flash block erase time in which the erase
operation is not suspended. As long as the erase is not finished, the EEL
cannot continue to provide new free passive pool space for further write
operations. In order to signal too often Erase suspends to the user application,
the eraseSuspendThreshold_u16 can be configured. A user operation
resulting in exceeding the threshold will return a warning “erase suspend
overflow”. This is no hard error resulting in EEL reaction but just a signal to the
user application to provide enough time to the EEL to finish the background
operation.
Value range: Min: 0 (On every erase suspend the warning is returned)
Max: 0xFFFF
Implementation:
The descriptor structure is defined in the module EEL_Types.h
typedef struct {
eel_u32 addDF_u32;
eel_u16 blkRefreshThreshold_u16;
const eel_u16 (*idlTab_pau16)[2];
eel_u16 *idxTab_pau16;
eel_u32 idlTabIdxCnt_u32;
eel_u16 eraseSuspendThreshold_u16;
} eel_descriptor_t;
The descriptor variable definition and filling is part of the user application. The
files EEL_Descriptor.h/.c give an example which shall be used by the user
application. Only EEL_Descriptor.h need to be modified for proper
configuration while EEL_Descriptor.c can be kept unchanged.
/*------------------------------------------------------------*\
EEL_CONFIG_IDL_TABLE
Descriptor table containing data set identifier and data set
length as:
{ { <16-bit ID>, <16-bit length in bytes> }, {...},
{...}, .... }
/*------------------------------------------------------------*\
#define EEL_CONFIG_IDL_TABLE { \
{ 0x1111, 0x0005 }, \
{ 0x2222, 0x0006 }, \
{ 0x3333, 0x0007 }, \
{ 0x4444, 0x0008 }, \
{ 0x5555, 0x0009 }, \
{ 0x6666, 0x000a }, \
{ 0x7777, 0x000b }, \
{ 0x8888, 0x000c }, \
{ 0x9999, 0x000d }, \
{ 0xaaaa, 0x0015 }, \
{ 0xbbbb, 0x0018 }, \
{ 0xcccc, 0x0033 } \
}
EEL_BUSY The operation has been started successfully None Continue operation
EEL_ERR_CONFIGURATION The EEL_Init function was called with wrong configuration data Application bug The library is not initialized Stop EEPROM emulation and investigate in the root cause
Wrong parameters have been passed to the EEL, e.g.: Wrong
EEE_ERR_PARAMETER Application bug Current command rejected Stop EEPROM emulation and investigate in the root cause
parameter in the request structure
A new operation should be initiated although the
state machine is still busy with a concurrent operation (e.g. Application bug or intended
EEE_ERR_REJECTED Current command rejected Repeat the command when concurrent operation has finished
EEL_CMD_READ --> EEL_CMD_READ, but not EEL_CMD_WRITE -- behaviour
> EEL_CMD_READ)
Read/Write operations are executed and lead to a background erase
Error Codes
operation suspend. The Erase suspend took place so often, that the
Data Types
Continue operation - or -
Either no DS corresponding to the ID could be found or the data has Application bug or intended
EEL_ERR_NO_INSTANCE None / Warning only if the result is not expected, stop EEPROM emulation and
been invalidated explicitely (See Invalidation API) behaviour
investigate in the root cause
The checksum of the Data Set does not match. Beside accidental data Application bug, hardware Continue operation - or -
EEL_ERR_WRONG_CHECKSUM overwrite, also a change of the IDL ROM table (data length information) problem or intended Read returns data, but it might be wrong if the result is not expected, stop EEPROM emulation and
during allplication update by a boot loader might be the root cause behaviour investigate in the root cause
Due to high DS Write load, no more blocks could be prepared to gain Stop further Write operations but call EEL_Handler frequently,
EEL_ERR_POOL_FULL EEL System overload Current command rejected
space for new data until the EEL had time to prepare enough passive pool space
EEPROM Emulation Library
50
EEPROM Emulation Library
Application
*address_pu08
identifier_u16
length_u16
offset_u16
command_enu
status_enu
Write access
EEL
Read access
typedef enum {
/* Normal operation */
EEL_OK,
EEL_BUSY,
/* Warnings */
EEL_ERR_BLOCK_EXCLUDED,
EEL_ERR_FIX_DONE,
EEL_ERR_WRONG_CHECKSUM,
/* Errors */
EEL_ERR_CONFIGURATION
EEL_ERR_PARAMETER,
EEL_ERR_ACCESS_LOCKED
EEL_ERR_FLASH_ERROR,
EEL_ERR_POOL_EXHAUSTED,
EEL_ERR_POOL_FULL,
EEL_ERR_POOL_INCONSISTENT,
EEL_ERR_REJECTED,
EEL_ERR_NO_INSTANCE,
EEL_ERR_COMMAND,
EEL_ERR_ERASESUSPEND_OVERFLOW,
EEL_ERR_INTERNAL
} eel_request_status_t;
typedef struct {
eel_u32 *address_pu08;
eel_u16 identifier_u16;
eel_u16 length_u16;
eel_u16 offset_u16;
eel_command_t command_enu;
eel_request_status_t status_enu;
} eel_request_t;
o EEL_OPERATION_PASSIVE
The state machine can handle neither internal nor user initiated
processes.
o EEL_OPERATION_STARTUP
This status is set as long as the startup background process is
executed. This indicates that the EEL is not completely up and
running. As long as this operational status is returned, EEL
functionality is possibly limited. Please see emulation access status
below and chapter 6.2.1, “Device start-up”.
o EEL_OPERATION_SUSPENDED
When the suspend request is issued to the EEL by the EEL_Suspend
function, the state machine enters the suspend mode. As this cannot
be done immediately, the application need to wait until the suspend
status is set.
Emulation access status
It is important, that not only Startup affects the access level, but also EEL
failures resulting in loss of functionality. Depending on the failure, either
Write is prohibited or no access is possible. See also error codes of the
request structure in chapter 5.3.1, “Error Codes”.
o EEL_ACCESS_LOCKED
During Startup:
The state machine is in an early startup phase and so, does not
accept any user operation.
During normal operation:
o EEL_ACCESS_ READ_WRITE
During Startup only:
The state machine proceeded further in the startup phase and so,
accepts DS read and write operations.
- The read operations require REF table search as the RAM table is
not yet available. So, the Read requires longer execution time at
100% CPU load.
- The DS write capability is limited to the available passive blocks
(prepared and invalid) as due to the missing RAM table no Refresh
operation is possible.
o EEL_ACCESS_ READ_ONLY
During normal operation only:
A user DS Write operation resulted in a Flash Write error, either
caused by a hardware or a software problem. In order to preserve the
remaining Flash contents the library forbids any further Flash
modification operations. Read operations are still possible, however a
certain risk is given, that the read data may be wrong if the write
operation caused damage to the read data. This should be detected
by the DCS check.
o EEL_ACCESS_UNLOCK
The state machine is up and running. All user and background
operations should be possible, if no error occurred. The RAM table is
built up, so Read operations are executed fast from now on.
Error values of the state machine are returned. As only process errors are
considered (no errors on EEL_Execute resulting in not starting a
process), the error range is limited to:
o EEL_ERR_FIX_DONE
o EEL_ERR_FLASH_ERROR
o EEL_ERR_POOL_INCONSISTENT
o EEL_ERR_POOL_EXHAUSTED
o EEL_ERR_BLOCK_EXCLUDED
o EEL_ERR_INTERNAL
o EEL_ERR_ACCESS_LOCKED
Type definition:
typedef enum {
/* read- & write access disabled*/
EEL_ACCESS_LOCKED,
} eel_access_status_t;
typedef enum {
/* all operations locked */
EEL_OPERATION_PASSIVE,
/* User suspend */
EEL_OPERATION_SUSPENDED
} eel_operation_status_t;
typedef struct {
eel_operation_status_t operationStatus_enu;
eel_access_status_t accessStatus_enu;
eel_request_status_t error_enu;
} eel_driver_status_t;
5.4.1.1 EEL_Init
Description
The EEL_Init() function is executed before any execution of other EEL
functions. It initializes the basic EEL variables, but the state machine is not
started.
This function also defines the operation mode of the library. While in the
normal application the full operation must be enabled, in case of a boot loader
not all information required for full operation might be available. Especially the
ROM ID–table might be not present or not completely present if the application
is being updated.
Interface
Arguments
Return types/values
On check fail, the startup processing is locked and user operations will never
be unlocked.
Pre-conditions
The library may not already be active (function EEL_Startup already called). In
case of re-initialization, the function EEL_ShutDown must be called before
EEL_Init. On violation the function ends with EEL_ERR_ACCESS_LOCKED.
Post-conditions
None
Example
5.4.1.2 EEL_Startup
Description
This function starts the EEL state machine and initiates execution of the
startup process.
By this function and continuous EEL_Handler calls, the library passes the
startup status and enters the operational status.
Interface
Arguments
Return types/values
Pre-conditions
Post-conditions
Example
Option: Wait after EEL_Startup until the library is completely up and running
eel_driver_status_t dStat;
ret = EEL_Init();
do
{
EEL_Handler();
EEL_GetDriverStatus( &dStat );
}
/* Wait until the system is up and running (or error) */
while(EEL_OPERATION_STARTUP ==
dStat.operationStatus_enu );
/* Error check */
if( EEL_OK != dStat.errorStatus_enu )
{
/* Error handler */
. . .
}
Option: Wait after EEL_Startup until the library at least partially unlocked
eel_driver_status_t dStat;
ret = EEL_Init();
do
{
EEL_Handler();
EEL_GetDriverStatus( &dStat );
}
/* Wait until early read/write is possible (or error) */
while( ( EEL_OPERATION_STARTUP == dStat.operationStatus_enu )
&&( EEL_ACCESS_LOCKED == dStat.accessStatus_enu ) );
/* Error check */
if( EEL_OK != dStat.errorStatus_enu )
{
/* Error handler */
. . .
}
5.4.1.3 EEL_ShutDown
Description
Interface
Arguments
Return types/values
Pre-conditions
Post-conditions
Example
eel_driver_status_t dStat;
/* ... */
Ret = EEL_ShutDown();
if( EEL_OK != ret )
{
/* Error treatment */
}
/* Error check */
if( EEL_OK != dStat.errorStatus_enu )
{
/* Error handler */
. . .
}
5.4.2.1 EEL_Suspend
Description
This function suspends the EEL operations and puts the EEL in a passive
state.
Interface
Arguments
None
Return types/values
Pre-conditions
Post-conditions
Example
eel_driver_status_t dStat;
/* ... */
ret = EEL_Suspend();
if( EEL_OK != ret )
{
/* Error treatment */
}
ret = EEL_Resume();
if( EEL_OK != ret )
{
/* Error treatment */
}
5.4.2.2 EEL_Resume
Description
Interface
Arguments
None
Return types/values
Pre-conditions
The library must be suspended. Call EEL_Suspend before and wait until
the suspend process finished.
On violation the function ends with EEL_ERR_ACCESS_LOCKED.
Post-conditions
None
Example
See EEL_Suspend
5.4.3.1 EEL_Execute
Description
This function initiates an EEL user operation. The operation type and operation
parameters are passed to the EEL by a request structure, the status and the
result of the operation are returned to the user application also by the same
structure. The required parameters as well as the possible return values
depend on the operation to be started.
This function only starts a process according to the operation to be executed.
The processes must be controlled and stepped forward by the state machine
handler function EEL_Handler (explained later on).
Possible user operations are:
Read
Write
Invalidate
Write Immediate
Invalidate Immediate
Format
Format the Data Flash block structure, so that DS can be written. Format
erases all Flash blocks and so deletes all eventually existing DS
instances:
Clean-up
Cleanup concept:
This command sets an indication flag for cleaning to the supervision. The
cleaning itself is handled by the supervision process by executing Refresh
& Prepare operations over all active/occupied blocks. Cleaning is finished
when the driver status changes from busy to idle again. The cleanup
request structure immediately returns with EEL_OK.
Note:
Format is executed as exclusive operation, Cleanup is started as exclusive
operation (finished in background). Exclusive operations require that no other
operation (except supervision) is ongoing. All other functions can be
prioritized.
This priorization allows executing up to three operations in parallel:
Read
Normal priority write/invalidate
High priority write/invalidate
In order to do so, the application needs to provide separate request structures
for these operations.
Interface
Arguments
Return types/values
Note:
The user application can either react directly on the errors returned by the
EEL_Execute function or call the handler function EEL_Handler and react on
errors then. The errors set on EEL_Execute are not reset and the handler
execution does not do additional operations in case of an error already set.
Pre-conditions
Post-conditions
Example
5.4.3.2 EEL_Handler
Description
This function handles the complete state machine. It shall be called frequently,
but the calling style depends on the user application. Possible solutions are:
Asynchronous to EEL operation invocation by EEL_Execute in an
operating system idle task
Advantages:
+ Usually high emulation performance
+ No blocking of other user application operations
Disadvantages:
- Not always deterministic
Asynchronous to EEL operation invocation by EEL_Execute in a
timed task
Advantages:
+ Deterministic
Disadvantages:
- Lower emulation performance
Synchronous with EEL operation invocation by EEL_Execute
Advantages:
+ Highest performance
Disadvantages:
- function execution time is high and not deterministic
Interface
Arguments
-
Return types/values
Note:
Even when the error
EEL_ERR_WRONG_CHECKSUM is returned,
the data is copied to the destination buffer in
order to have the possibility to check the
content.
Additionally on Format:
EEL_ERR_BLOCK_EXCLUDED
EEL_ERR_FLASH_ERROR
EEL_ERR_POOL_EXHAUSTED
Pre-conditions
Post-conditions
None
Example
eel_request_t req_str;
eel_u08 buffer[0x100];
EEL_Execute( &req_str );
/* Error check */
If( EEL_OK != req_str. status )
{
/* Error handler */
. . .
}
5.4.4.1 EEL_GetEraseCounter
Description
This function reads the current erase counter at the active Flash block of the
ring buffer. Except potentially excluded blocks, the erase counter of all other
blocks only differs from the active block in the range of +-1.
Note:
The erase counter is counting the ring buffer loops. As long as the ring buffer
is normally handled by the library, the erase counter is counted up. Of cause,
the erase counter is as reliable as all EEPROM emulation data. It is handled
by the library and any mistreatment outside the library (e.g. manual erase of
the Flash) will destroy the erase counter.
Interface
Arguments
Return types/values
Pre-conditions
The library must be unlocked:
Post-conditions
None
Example
eel_u32 eraseCounter;
eel_status_t ret;
5.4.4.2 EEL_GetDriverStatus
Description
This function returns the state machine status into the driver status structure.
Interface
Arguments
Return types/values
Pre-conditions
Post-conditions
None
Example
eel_driver_status_t dStat;
eel_status_t ret;
5.4.4.3 EEL_GetSpace
Description
This function returns the current free space in the EEL ring buffer (prepared
space for new data).
As the library always need to reserve one block for refreshing data sets (copy
from the ring buffer tail to the front), the function reduces the prepared space
by one block.
Calculation base:
Free space = ( (no. of prepared blocks – 1) *
(block size – block header – 1 word) ) +
remaining space in the active block
Interface
Arguments
Return types/values
Pre-conditions
The library must be unlocked:
- Call EEL_Init to initialize the library
- Call EEL_Startup and call EEL_Handler cyclically to unlock the access
status ( access status != EEL_ACCESS_LOCKED )
- Do not call EEL_ShutDown or EEL_Suspend before
Post-conditions
None
Example
eel_u32 space;
eel_status_t ret;
5.4.4.4 EEL_GetVersionString
Description
This function returns the pointer to the library version string. The version string
is the zero terminated string identifying the library.
Interface
Arguments
-
Return types/values
Pre-conditions
None
Post-conditions
None
Example
eel_u08 *vstr_pu08;
vstr_pu08 = EEL_GetVersionString();
All these questions require some hands on experience with the EEL.
The best way after initial reading the user manual will be testing the EEL
application sample.
Note:
Before the first compile run, the compiler path must be configured in the
application sample file “makefile”:
Set the variable COMPILER_INSTALL_DIR to the correct compiler
directory
Later on the sample might be extended by further IDs and different data read
and write sequences in order to come nearer to the later application
requirements (data set amount and size) and to get a feeling of the CPU load
and execution time during start-up and normal operation.
Start-up
phase
EEL_Init
EEL_Startup
Background
Normal
operation
Application
operation
EEL_Execute
EEL_... - Read Frequent call of
(Service functions) - Write EEL_Handler
(- Format)
EEL_Handler
Device power
down request?
N
Y
Power
down EEL_ShutDown
phase
System Passive?
In the startup phase, the EEL is initialized by EEL_Init and the background
operation is started by EEL_StartUp
During normal operation, the foreground operations (user operations) are
initiated synchronous to the application, while the background handler task
ought to be executed in a task, asynchronous to the application (idle task,
interrupt task, timed task)
In the power down phase the EEL is shut down. EEL_Handler need to be
executed until the library status is passive. This is required in order to finalize
ongoing EEL processes.
u08 buffer_au08[0x100];
eel_request_t req_str;
eel_driver_status_t dStat;
eel_status_t res;
/* ----------------------------------------------------------
Initialize the EEL
- eel_RTConfiguration_str should have been set in
EEL_Descriptor.c
---------------------------------------------------------- *\
res = EEL_Init( eel_RTConfiguration_str,
EEL_OPERATION_MODE_NORMAL );
if( EEL_OK != res )
{
/* Error handler */
. . .
}
res = EEL_Startup();
if( EEL_OK != res )
{
/* Error handler */
. . .
}
/* ----------------------------------------------------------
Wait until we can read/write 1st data sets
---------------------------------------------------------- *\
do
{
EEL_Handler();
EEL_GetDriverStatus( &dStat );
}
/* Wait until early read/write is possible (or error) */
while( ( EEL_OPERATION_STARTUP == dStat.operationStatus_enu )
&&( EEL_ACCESS_LOCKED == dStat. accessStatus_enu) );
/* Error check */
if( EEL_OK != dStat.errorStatus_enu)
{
/* Error handler */
. . .
}
/* ----------------------------------------------------------
Early read/write operation
---------------------------------------------------------- *\
req_str.address_pu08 = (&buffer[0]);
req_str.identifier_u16 = 10u;
req_str.length_u16 = 0x10u;
req_str.offset_u16 = 0x13u;
req_str.command_enu = EEL_CMD_READ;
EEL_Execute( &req_str );
/* Error check */
if( EEL_OK != req_str.status_enu )
{
/* Error handler */
. . .
}
req_str.address_pu08 = (&buffer[0]);
req_str.identifier_u16 = 10u;
req_str.command_enu = EEL_CMD_WRITE;
EEL_Execute( &req_str );
/* Error check */
if( EEL_OK != req_str.status_enu )
{
/* Error handler */
. . .
}
/* ----------------------------------------------------------
Wait for fully operational and access unlock
---------------------------------------------------------- *\
do
{
EEL_Handler();
EEL_GetDriverStatus( &dStat );
}
/* Wait until the system is completely up and running
(or error) */
while(EEL_OPERATION_STARTUP == dStat.operationStatus_enu );
/* Error check */
if( EEL_OK != dStat.errorStatus_enu)
{
/* Error handler */
. . .
}
/* ----------------------------------------------------------
Now the EEL is fully operational
---------------------------------------------------------- *\
/* ----------------------------------------------------------
Normal operations
---------------------------------------------------------- *\
req_str.address_pu08 = (&buffer[0]);
req_str.identifier_u16 = 10u;
req_str.length_u16 = 0x10u;
req_str.offset_u16 = 0x13u;
req_str.command_enu = EEL_CMD_READ;
EEL_Execute( &req_str );
/* Error check */
if( EEL_OK != req_str.status_enu )
{
/* Error handler */
. . .
}
req_str.address_pu08 = (&buffer[0]);
req_str.identifier_u16 = 10u;
req_str.command_enu = EEL_CMD_WRITE;
EEL_Execute( &req_str );
/* Error check */
if( EEL_OK != req_str.status_enu )
{
/* Error handler */
. . .
}
Most important operation control signals are the status of a requested user
operation and the driver status. The following diagram shows the relationship
between a request and execution of background operations.
EEL_BUSY
EEL_OK
Driver state
EEL_OPERATION_BUSY
EEL_OPERATION_IDLE
User operations request User operations finished, starting Background operations finished,
background operations. nothing to do except bit error
New user operation can be checking
requested
/* ----------------------------------------------------------
Request Library shutdown
---------------------------------------------------------- *\
EEL_Shutdown();
/* ----------------------------------------------------------
Wait until all background processes are finished and the
supervision gets passive
---------------------------------------------------------- *\
do
{
EEL_Handler();
EEL_GetDriverStatus( &dStat );
}
while(EEL_OPERATION_PASSIVE != dStat.operationStatus_enu );
/* Error check */
if( EEL_OK != dStat.errorStatus_enu)
{
/* Error handler */
. . .
}
Renesas provides an endurance calculation sheet which can be filled with the
different data sets sizes and the required write cycles. That sheet can estimate
the expected number of Flash erase cycles and judge if this exceeds the
specification.
Note:
The endurance calculation sheet is a very helpful tool, but still the result
is just an estimation and cannot be absolute accurate because the result
depends on different conditions like e.g. the sequence of the written Data
sets. So, the result must be confirmed in the real user application.
The calculation sheet can either be loaded from the Renesas download page
mentioned in the “Introduction” chapter or be requested at the Renesas Flash
support under:
[email protected]
This can be done using different approaches. Often used ones are:
The application itself executes the Format operation and then writes initial
instances of the data sets.
As the format operation deletes all data, it shall be carefully considered
how to prevent accidental formatting by the application!
A serial programming tool (e.g. PG-FP5) or debugger is used to program
the Data Flash in the same flow, that also programmes the Code Flash.
In a self-programming flow a boot loader normally updates the application
code in the Code Flash. During this flow, also the Data Flash can be filled
using the FDL directly.
For the later solution with the programming tool or debugger a hex file is
required which contains the Data Flash contents (complete EEL pool content).
This content can be gained by:
Dumping the Flash content of an already formatted Data Flash to a hex
file using a serial programming tool or the debugger.
Using a tool chain called Data Flash Converter and Data Flash Editor to
convert a raw data description in an xml file into a hex file. This tool chain
will be provided by Renesas on request when available.
User’s Manual U20280EE1V2UM00 83
EEPROM Emulation Library
Hex File
6.3.3.2 Task switches, context changes and synchronization between EEL functions
All EEL functions depend on EEL global available information and are able to
modify this. In order to avoid synchronization problems, it is necessary that at
any time only one EEL function is executed. So, it is not allowed to start an
EEL function, then switch to another task context and execute another EEL
function while the last one has not finished.
Example of not allowed sequence:
- Task1: Start an EEL operation with EEL_Execute
- Interrupt the function execution and switch to task 2, executing EEL_Handler
function
- Return to task 1 and finish EEL_Execute function
As the EEL may not define critical sections which disable interrupts in order to
avoid context changes and task switches, this synchronization need to be
done by the user application.
Start
6.3.4.2 Direct access to the Data Flash by the user application by DMA
Basically, DMA transfers from Data Flash are permitted, but need to be
synchronized with the EEL. Same considerations apply as mentioned in the
last sub-chapter for accesses by the user application.
Note:
After DS length change, a Read operation will always return a checksum error
(EEL_ERR_WRONG_CHECKSUM) as the checksum does not match to the
DS data (see above) anymore. To fix this, the DS must be written once more
by the application.
Anyhow, differing from the EEELib, the DS length is no longer stored within the
DS, but in the ID-L table. When the table is updated, the information of the
former DS size get lost. So, the library provides no measure to get the length
of the last stored DS instance. This information must be provided otherwise.
The limited mode is realized by simply stopping the EEL start-up process
before it could complete. The resulting access state is
EEL_ACCESS_READ_WRITE (see chapter 5.3.3, “Driver status”)
The following flow chart explains the application update idea. Timely no
EEPROM emulation is possible.
EEL_OPERATION_MODE_NORMAL is set by the EEL initialization function
EEL_Init (see chapter 6.2.1, “Device start-up”).
BL start
Full EEPROM
Emulation
Execute BL including
EEPROM emulation
No EEPROM
Update Application including Emulation
ID-L table in ROM possible
Full EEPROM
Execute BL including Emulation
EEPROM emulation
The following flow chart explains the application update idea. Timely only
limited EEPROM emulation is possible.
In order to overcome the situation of no Refresh during the limited emulation
period, the active blocks may be are defragmented/cleaned (see
chapter5.4.3.1, “EEL_Execute”).
EEL_OPERATION_MODE_LIMITED is set by the EEL initialization function
EEL_Init (see chapter 6.2.1, “Device start-up”).
BL start
Full EEPROM
Emulation
Execute BL including EEPROM
emulation
Cleanup of the
active blocks to gain as
much as possible free
space for DS Write
Wait until the state machine finished
cleanup operation
Limited EEPROM
Update Application including ID-L Emulation without
table in ROM Refresh process
Full EEPROM
Execute BL including EEPROM Emulation
emulation