Home
EEPROM Emulation Library EEL
Contents
1. 88 EEPROM Emulation Library Introduction Chapter 1 Caution Introduction This user s manual describes the internal structure the functionality and software interfaces API of the RENESAS V850 EEPROM Emulation Library EEL type 06 designed for V850 based Flash devices with Data Flash based on the RCOSF Flash technology such as V850E2S Fx4 L 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 behaviour 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 implementations 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 libraries are delivered together with device dependent applicati
2. 23 27 3 Block overlapping DS s periere bete tut die einen 24 2 7 4 Storage structure details 25 Chapter3 EEL Design 27 3 1 Asynchronous architecture 27 3 2 Flash interrupt Support inii ince U u 27 3 3 EEL user operations priority 44 4 21 11 1 27 3 4 Background operations 28 3 5 Error and warning levels 29 3 6 Data Set search and read 29 3 0 1 1D L and IDX tables LLL L 29 3 7 Start up processing u uu 31 3 8 Function amp command execution times amp latencies 33 3 9 1 Library startup phase elenco cte rece Pinot De deri yas rnnt 33 3 8 2 Normal operation phase J U u u u u 35 Chapter4 Implementation 37 FEil str ct revoc nu uu ua usata sasata sasata
3. ou peo SC uBiu o eng esneo 100 y pue 43 dois jou s inse ji 10 uoge1edo esneo 1001 y pue uolle nu INO3d33 dois pejoedxe jou si jjnse1 y ji 10 uoneJedo BuoJM eq Sjuejuoo peay Ajuo euoN 1olABu q Jo uu qoid e1ewpueu Jo esneo 1001 eq 1 Aq ejepdn Buunp uoneuuojur ulB5u l 1019410 ejuepiooe episeg jou seop jeg ejeq y jo 991 Jo ees ueeq seu 10 PUNO ql eui sq ou esneo Jool y pue uone nuie WOU dois 51 uano 10 nq 2 Jamo pue mau S490 pue eAissed oj fueJqi y Joe ue Z e 10 1e dn peuej
4. bi bd bd Dd Pd Bd Bj bd bd R POOL EXHAUSTED zj Bd Ed Ed Ed Ed td Bd E E E Dd Ed Dd bd td pd Ed R POOL INCONSISTENT R COMMAND R R R R R RR FLASH ERROR R R R R typedef volatile struct EEL REQUEST T eel u08 address pu08 eel 016 identifier 116 eel u16 length 416 eel 116 offset 016 eel command t command enu eel status t status enu eel request t eel status t 5 3 3 Driver status The EEL supervision process collects and signals all background operations processes errors Furthermore the process controls two driver status values which describe the status of the EEL background operations These are the operation status and access status e Operational status Defining the status of the state machine according to the following RO1AN1035ED0100 Rev 1 0 Application Note EEL OPERATION PASSIVE The state machine can handle neither internal nor user initiated processes This state is set before EEL startup after EEL shutdown is finished after fatal EEL operations errors EEL OPERATION IDLE No process active except supervision doing margin checks No Refresh or Prepare necessary and no user process Read Write Format active EEL OPERATION BUSY This status is set if either a background process e g Refresh or Prepare is active or a user process Read or Write is being processed As Flash operati
5. 11 2 4 Flash nfrastructure u uuu 11 2 1 1 Complementary Read Flash U 11 2 1 2 Dual operatlon u k cheese ee eile 11 21 3 _ Flash granularity eissir inneasan irienna Karanane tierce ccu siete dee Deu a aww s Esse 12 2 2 Layered software architecture 12 2 3 Data Flash Pools u uy au ipn cepi DRE tetas ERR 13 2 4 Safety Considerations eere ee ee ee EIE E ER ceu 14 2 9 Feat r OV OF VICW lt 2 uuu WORTEN 14 26 EEL Flash managemernt 15 2 6 1 Physical vs virtual address range U U U uuu u Q 15 2 6 2 Physical vs virtual Flash blocks I I U U 15 2 0 2 Virt al block structu re yu au ree Ep u u asawa a D 15 2 6 4 Block lifecycle eere rere eret peter eer tree reden iore dues 17 2 6 5 Internal block struct re riecht Rhe rien aasawa asa 18 2 7 EEL Data Sets Management 23 274 M 23 rd DP and RPuuu
6. Example 2 Data Flash size is 32kB The EEL shall use blocks 2 to 9 for the EEL pool while blocks 0 to 1 and 10 to 15 can be used as user pool define FAL EEL VIRTUALBLOCKSIZE 64u define FAL FAL POOL SIZE 16u FAL EEL VIRTUALBLOCKSIZE define FAL EEL POOL START 2 FAL EEL VIR BLOCKSIZE define FAL EEL POOL SIZE 8u FAL EEL VIRTUALBLOCKSIZE Example 3 Data Flash size is 32kB the EEL shall not be used at all The complete Data Flash shall be used as user pool define FAL EEL VIRTUALBLOCKSIZE 64u define FAL FAL POOL SIZE l6u FAL EEL VIRTUALBLOCKSIZE define FAL EEL POOL START Ou FAL EEL VIRTUALBLOCKSIZE define FAL EEL POOL SIZE Ou FAL EEL VIRTUALBLOCKSIZE 5 2 2 EEL run time configuration elements The descriptor contains the following elements 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 OXFE00000 44 EEPROM Emulation Library User Interface API blkRefreshThreshold Defines the number of virtual blocks that shall be prepared in the ring buffer by default In case of threshold underflow the EEL supervision will
7. Oxbbbb 0x0018 P Et MU 0 Oxceco 02x0033 Application Note 2 N SAS User Interface API 5 3 Data Types 5 3 1 Error Codes EEPROM Emulation Library asneo 1001 pue WOzId33 0015 osneo 1001 y u pue uonejnue WOd33 dojs jou s jjnseu y ji 10 VINHOJ 193 uogejedo 133 pojoefe1 jueuno poxoo 9 eq 4 eu Jo uu qoid 10 nq SI pejnoexe oj eu lyse peneuuojun yuejq eseo peuunjei ose lt SIY L eugno dnyejs y Aouejsisuoour ue punoj eurnoi dnyejs y JO Kouejsisuoo eu L uonejedo nunuoo luo euoN pexy eue spez Jemod uo s 1 q 6 pesneo sj oo usel4 ejejduiooul suie qoud Aouejsisuoo 1ejnq Bury Ajjeuuou enuguoo ued pue ju9jsisuo5 suomnoes 941 Jaye dnyeyg uo enjeA Jeuuou e s siu uoneJedo xy fouejsisuoo e euop seu dnueis uonejedo Ajuo M euoN JOU si se xoolq e
8. uoneJ do v SNEI 1001 y Ul ejyeBnseaur pue WO3d33 dois 1001 ejeBnseaur pue dois poxoo SM se peJepisuoo eq pinous use J u L s sseooe peuyepun s jeuun eu wajqoud uoneorddy use J 94 enp SI 10119 941 suonejedo 10 syoolq ou uoisnioxe 0014 uselJ Keme uns 6 3 uonnoexe jeuuou ui ueddeu jou pjnoo yoiym v esneo 001 y pue uone nuie WONd33 dois dnuejs peuunooo 10113 eju M 9 jeuuou Buunp peunooo 10113 pe oo sessoooe au se eq pinous 941 Jo w jqosd uiejqoud usej4 enp parie 733 Aq perjeo 744 eui jo uone1edo v eoeds jood uBnoue eJedeud euin peu eui Inun Anu nb u jejpued 133 1nq ejepijeAu e3u M 4euuny Buinssi 015 pojoefe1 juano peojiano uu ls s 133 Meu 10 eoeds pasedaid eq
9. 4 2 EEL Linker sections The following sections are EEPROM emulation library related e FAL Text FDL code section containing the hardware interface and user interface e FAL Const FDL data section containing library internal constant data FAL Data FDL Data section containing all FDL internal variables e EEL Text EEL code section containing the state machine user interface and FAL interface EEL Const EEL data section containing library internal constant data EEL Data EEL Data section containing all EEL internal variables ROIAN1035ED0100Rev 1 0 40 Application Note AS EEPROM Emulation Library Implementation 4 3 MISRA Compliance RO1AN1035ED0100 Rev 1 0 2 N SAS Application Note The EEL and FDL have been tested regarding MISRA compliance The used tool is the QAC Source Code Analyzer which tests against the MISRA 2004 standard rules All MISRA related rules have been enabled Findings are commented in the code while the QAC checker machine is set to silent mode in the concerning code lines 41 EEPROM Emulation Library User Interface API Chapter 5 User Interface 5 1 Pre compile configuration The pre compile configuration of the EEL may be located in the EEL_cfg h user has to configure all parameters and attributes by adapting the related constant definition in that header file The configuration for Fx4 L contains the following element EE
10. 5 2 1 FDL run time configuration elements The descriptor contains the following elements falFrequencyCpuMHz u16 Defines the device CPU frequency The Flash hardware frequency is device internally derived from the CPU frequency Note The define requires the CPU frequency not the crystal frequency The CPU frequency must be set correctly If not malfunction may occur such as unstable Flash data without data retention programming failure operation blocking Application Note 2 NE SAS EEPROM Emulation Library User Interface API falPoolSize Defines the number of physical Flash 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 physical Data Flash block number used as EEL pool The block number must be aligned to the virtual block size 2kB used by the EEL Following that the block number must be a multiple of 64 2kB 64 32Byte Value range Min FAL Pool start block Max eelPoolStart eelPoolSize falPoolSize eelPoolSize Defines the number of blocks used for the EEL pool The block number must be aligned to the virtual block size 2kB used by the EEL Following that the block number must be a multiple of 64 2kB 64 32Byte Value range Min 64 4 Blocks required for proper EEL operation Max FAL
11. EEL CMD WRITE IMM INC EEL EMD INVALIDATE IMM EEL CMD FORMAT EEL CMD CLEANUP Buffer address for the Read and Write operation 16bit ID identifying the DS to read or write Only required for Read operation Number of bytes to read from the DS Only required for Read operation Read offset from the DS bottom Together with length the parameter is used to read only a fraction of the DS Status Error codes returned by the library see next page Type definition in EEL Types h o 5 typedef EEL d MD READ D WRITE INVA EEL COMMAND T D WRITE INC D D WRITE IMM D WRITE INC IMM INVA IDA E IMM bi bd bd bd Dd B El Oo OQ cO rj E Ed EJ D Ej Ej Uj FORMAT CMD C E eel command t j EANUP R01AN1035ED0100 Rev 1 0 Application Note typedef enum EEL STATUS T Normal operation EEL OK EEL BUSY Warnings EEL ERR ERASESUSPEND OVERFLOW EEL ERR WRONG CHECKSUM EEL ERR BLOCK EXCLUDED EEL ERR FIX DONE Errors EEL ERR CONFIGURATION 50 RENESAS EEPROM Emulation Library User Interface R PARAMETER R REJECTED R ACCESS LOCKED R NO INSTANCE R POOL FULL R INTERNAL
12. Request to update the EEL_OPERATION_MODE_NORMAL application Full EEPROM Emulation Execute BL including EEPROM emulation Stop EEL by no longer calling the EEL Handler and EEL Execute Poo No EEPROM Update Application including Emulation ID L table in ROM possible Start EEL with operation mode EEL_OPERATION_MODE_NORMAL E Full EEPROM Emulation Execute BL including EEPROM emulation Application update concept with timely stopping EEPROM emulation Application Note 41 NE SAS EEPROM Emulation Library EEL Implementation into the user application Application update flow proposal Boot loader with independent ID L table and limited Write 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 ought to be defragmented cleaned See Cleanup command The emulation is started in limited operation mode using the parameter EEL OPERATION MODE LIMITED when calling the function EEL Init Start EEL with operation mode EEL OPERATION MODE NORMAL Request to update the application Full EEPROM Emulation Execute BL including EEPROM emulation Execute EEL operation EEL CMD CLEANUP Cleanup of the active blocks to gain as r much as possible free space for DS Write Wait until the state machine finished c
13. eyep uoneunBuuoo uj pereo sem uonoun 133 941 enuguo 9uoN Aiinjsseoons popes ueeq seu 99 uonejedo enuguo SuoN Ajinjsseoons peusiuy 991 Figure 5 1 uonoeaM pepueuiuio28s uonejedo 133 1003 uoneue dx3 EEL status amp error codes 48 RENESAS R01AN1035ED0100 Rev 1 0 Application Note EEPROM Emulation Library User Interface API The error code table shows quite some severe error messages which lead to the situation that the EEL cannot continue operation It needs to be considered carefully how to deal with the error fro application side The following options are worth to discussing e Stop and permanently disable emulation emulation is dead This mostly lead to complete application failure and the system need to be changed This allows a certain kind of post mortem analysis but lower availability rates e Format Data Flash and re start the emulation This will destroy all data and prevent any kind of post mortem analysis but increase the availability rates of the system if data loss can be accepted e Reinitialize and re start the EEL a certain number of times before permanently disable emulation emulation is dead This allows potentially to recover from some failures e g EEL ERR INTERNAL While increasing the availability rates
14. ret ret EEL Startup if EEL OK ret error treatment else EEL Handler EEL GetDriverStatus amp dStat Wait until early read write is possible or error while EEL OPERATION STARTUP dStat operationStatus enu amp amp EEL ACCESS LOCKED dStat accessStatus enu Error check if EEL OK dStat errorStatus enu Error handler 5 4 1 3 EEL ShutDown Description This function initiates deactivation of the EEL state machine After this function the EEL Handler need to be continuously executed in order to finish eventually executed processes and to set the state machine status passive Effect on the processes e Startup The process is stopped after a sub process execution e Refresh A ongoing DS Write is finished then the Refresh is stopped e Prepare The Prepare is finished in order not to waste a Flash erase cycle Application Note 21 NE SAS EEPROM Emulation Library User Interface API e User DS Write A ongoing DS Write is finished e User DS Read A ongoing DS Read is finished Interface eel status t EEL ShutDown void Arguments None Return types values Type Argument Description Result of the function Possible eel status t None valles ale EEL OK EEL ERR ACCESS LOCKED Pre conditions e library must be active Call EEL St
15. ID to write o address u32 source buffer address o command enu EEL CMD WRITE INC IMM for the Write operation Parameter checks resulting in return value EEL ERR PARAMETER o Unknown ID e Invalidate Immediate Writing a DS instance invalid identified by an ID This is done with high priority resulting in suspending an eventually ongoing DS write invalidate with normal priority Later on the normal priority operation is resumed Required parameters from the request structure o identifier u16 ID to invalidate Application Note 2 NE SAS EEPROM Emulation Library User Interface API Note Note Note o command enu EEL INVALIDATE for the Invalidation operation Parameter checks resulting in return value EEL ERR PARAMETER o Unknown ID e 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 Required parameters from the request structure o command enu Set to EEL CMD FORMAT for the Format operation After successful Format the EEL must be restarted with EEL Init EEL Startup gt e Clean up This operation initiates that the active blocks are defragmented cleaned up in order to achieve as much as possible prepared blocks for new data This command is recommended before the EEL is started without a complete reference list ID L table As in this case the Refresh cannot b
16. Library Architecture Note 2 3 EEPROM Emulation Library EEL The functional block EEPROM Emulation library is the subject of this document It offers all functions and commands the Application can use in order to handle its EEPROM data Data Flash Access Library FDL The Data Flash Access Library offers an interface to access any user defined flash area so called FDL pool described in next chapter Beside the initialization function the FDL allows the execution of access commands like write as well as a suspend able erase command General requirement is to be able to deliver pre compiled EEL libraries which can be linked to either Data Flash Access Libraries FDL or Code Flash Access Libraries FCL To support this a unique API towards the EEL must be provided by these libraries Following that the standard API prefix FDL which would usually be provided by the FDL library will be replaced by a standard Flash Access Layer prefix FAL All functions type definitions enumerations etc will be prefixed by FAL or fal_ Independent from the API the module names will be prefixed with FLD in order to distinguish the source object modules for Code and Data Flash Data Flash Pools The FDL pool defines the Flash blocks which may be accessed by any FDL operation e g write erase The limits of the FDL pool are taken into consideration by any of the FDL flash access commands The user can define the siz
17. Z NC SAS gt ES o gt 2 et EEPROM Emulation Library N EEL T06 EEPROM Emulation Library for RC03F Flash based V850 devices 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 Renesas Electronics RO1AN1035ED0100 Rev 1 0 WWW renesas com Mar 21 2012 Notice All information included in this document is current as of the date this document is issued Such information however is subject to change without any prior notice Before purchasing or using any Renesas Electronics products listed herein please confirm the latest product information with a Renesas Electronics sales office Also please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or othe
18. 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 OxFFFF Implementation The descriptor structure is defined in the module EEL Types h typedef struct EEL DESCRIPTOR T eel u32 addDF u32 eel ulg blkRefreshThreshold u16 const eel 1116 IDBETab pawl6 I2 eel 116 IDXTab paul6 eel 116 IDLTabIdxCnt 1116 eel ul6 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 Descriptor c can be kept unchanged Example variable definition and filling in EEL Descriptor c
19. 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 EEPROM Emulation Library Architecture 2 EEL Data Sets Management 2 7 1 Basic Concept Differing from real EEPROM where user data is referenced by the address information the user data in the RENESAS EEPROM emulation is referenced by an identifier ID An ID is unique for a certain set of data with a dedicated length Differing from EEPROM the data is stored somewhere in the Flash memory but not on a fix address Figure 2 10 Data Data Zone Overview Entry in the REF zone pointing to the user data in the 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 HWd the data is stored HWd 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 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 e Data Pointer DP The DP is the po
20. ongoing So in the next sub chapters this time is not mentioned again 3 8 1 Library startup phase Note The library needs to execute various process steps according to the implementation concept see startup phase description The EEL Handler execution time during steps will be partially gt gt 100us which need to be considered in the library implementation concept From EEL 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 RO1AN1035ED0100 Rev 1 0 RENESAS 33 Application Note EEPROM Emulation Library EEL Design 3 8 1 1 Early Read command Operation invocation latency The maximum latency of the Read operation invocation by the EEL Execute function is defined by the EEL Handler execution time see comments above Furthermore after invocation of the read start of the Read process need to wait for the end of a possibly started 4 HWd Data Flash write up to 4 half words can be written by the Flash hardware in sequence without software interaction caused by a Write command or by the startup process
21. pool size condition eelPoolStart eelPoolSize lt falPoolSize Implementation The descriptor structure is defined in the module FDL Types h typedef struct FAL DESCRIPTOR T fal 016 falFrequencyCpuMHz ul6 fal 016 falPoolSize 1116 fal 116 eelPoolStart 116 fal 016 eelPoolSize 116 fal descriptor t The descriptor variable definition and filling is part of the user application The files 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 Descriptor c be kept unchanged Example variable definition and filling in Descriptor c const fal descriptor t eelApp falConfig enu FAL CPU FREQUENCY MHZ FAL FAL POOL START POOL SIZE FAL FAL POOL SIZE E E i Ej RO1AN1035ED0100 Rev 1 0 RENESAS 43 Application Note EEPROM Emulation Library RO1AN1035ED0100 Rev 1 0 41 NE SAS Application Note User Interface API Example configuration in Descriptor h Example 1 Data Flash size is 32kB The EEL shall use the complete Data Flash for the EEL pool define FAL EEL VIRTUALBLOCKSIZE 64u define FAL 1 POOL SIZE l6u FAL EEL VIRTUALBLOCKSIZE define FAL EEL POOL START Ou FAL EEL VIRTUALBLOCKSIZE define FAL EEL POOL SIZE 16u FAL EEL VIRTUALBLOCKSIZE
22. programming tool or the debugger e 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 RO1AN1035ED0100 Rev 1 0 RENESAS 79 Application Note EEPROM Emulation Library Figure 6 3 EEL Implementation into the user application Create and edit an xml description file Containing reference Data ID amp lenth is taken from the xml file or configured new Read out the reference Data Flash contents and store to a hex file RO1AN1035ED0100 Rev 1 0 Application Note Customer application with EEL using format and data set write Data Flash initialization tool chain 2 NE SAS 80 EEPROM Emulation Library EEL Implementation into the user application 6 3 3 Library handling by the user application 6 3 3 1 6 3 3 2 6 3 3 3 Function reentrancy All functions are not re entrant So re entrant calls of any EEL or FDL functions must be avoided Task switches context changes and synchronization between EEL functions 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 anoth
23. 0100 Rev 1 0 Application Note RENESAS 31 EEL Design EEPROM Emulation Library NOILVH3dO 133 ASN 133 dNLYVLS NOlLVH3dO 133 I A9 Ieuonei do Q334201Nn SS32SV 133 31lHM QvdH 55300 133 Q33201 55300 133 J9 9 Sso22y oe L 0 X7CYCUY L 4 add 9 6 Snjels x2o g 199 ejejs ueJqi x sI 3 ouejsisuo2 Bury 49945 IIn jood yoayo l3 S3 1eynq yul SJojuiod Buunsue Ka 5 uoisiAJedns jueueulag Figure 3 2 Start up processing steps 32 RENESAS R01AN1035ED0100 Rev 1 0 Application Note EEPROM Emulation Library EEL Design 3 8 Function amp command execution times amp latencies Basically three important times need to be considered when implementing the EEL into a user application e Operation invocation latency This is the time from calling EEL Execute to issue the command and start an operation e g Read Write up to the point where the process of the operation is really started This latency is determined by execution of higher priority operations but also by the delay to suspend a lower priority operation Some process steps of lower priority operations cannot be suspended because they started Flash Write operations erase can immediately be suspended E g the D
24. 08 req str identifier 116 10u req str command enu EEL CMD WRITE Execute amp reqg str Wait until operation end while EEL BUSY req str status enu EEL Handler Error check if EEL OK req str status enu Error handler El EL Handler EEL GetDriverStatus amp 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 Application Note 2 NE SAS EEPROM Emulation Library EEL Implementation into the user application 6 2 2 Device normal operation When the device has passed the startup phase and is in normal operation the complete functionality is available The example code below reads and writes data sets address u32 U dentifrer ule length 1116 Offset 1416 command enu EEL Execute amp req str while EEL BUSY EEL Handler req str address u32 req str identifier ute req str command enu EEL Execute amp req str while EEL BUSY EEL Handler Error check Error handler E 432 amp buffer au08 10u Oxl0u 021311 EEL CMD READ Wait until operation end req str status enu Error check if EEL OK req s
25. 2 User operation request structure Return types values Type Argument Description request t The value is returned in the request structure error variable EEL BUSY request str EEL ERR REJECTED status enu EEL ERR ACCESS LOCKED EEL ERR PARAMETER EEL ERR COMMAND EEL ERR POOL FULL Note Application 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 e Call EEL Init to initialize the library e Call EEL Startup and call EEL Handler cyclically to bring the library into operational status Post conditions Call EEL Handler to complete the initiated operation Example See EEL Handler function 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 e Asynchronous to EEL operation invocation by EEL Execute in an operating system idle task In a normal system the CPU load is balanced in a way that a sufficient idle time is available By calling from the idle task loop the handler can be called frequently and the EEPROM Emulation performance is quite high However as the idle time is not always de
26. 5ED0100 Rev 1 0 RENESAS 83 Application Note EEPROM Emulation Library EEL Implementation into the user application e Flash block erase or Flash block header operation was interrupted Eventually it is necessary to fix a block status e g block activation or block erase was interrupted In this case additionally Flash write operations might take some more time and so slightly enlarge the time until the driver leaves the state EEL OPERATION STARTUP Furthermore the driver will return the warning EEL ERR FIX DONE as an indication that a fix was done The library operation continues normal the application need not react on the warning e DS Write was interrupted If the DS write proceeded up to writing the DCS the DS is valid If the EOR has not been written the DS will automatically be refreshed In this case additionally Flash write operations might take some more time and so enlarge the time until the driver leaves the state EEL OPERATION STARTUP e DS Write was interrupted If the DS write did not proceed up to writing the DCS the DS is invalid The start up process does no special action but this DS instance is not considered on DS read 6 3 7 Application update issues 6 3 7 1 Change DS length Note When a user application shall be updated but the EEPROM emulation data shall be used also further on different constraints need to be considered with respect to the ROM ID L table On application update it might be requ
27. E E 37 4411 OverviQW usu us S ee E eee d eere eene 37 41 2 Delivery package directory structure and 11 38 4 2 BEL ie eser Deep ro De sasa sasa 40 4 3 MISRA Compliance u uuu 41 Chapter 5 User Interface 42 5 1 Pre compile configuration 42 5 2 Run time configuration 42 5 2 1 FDL run time configuration elements u u uu nnn 42 5 2 2 EEL run time configuration elements U U U U uu uu u 44 5 3 Data Type eS e 48 5 3 T Error Codes enregistre rele cde Eo 48 5 3 2 User operation request structure l U u u u 49 5 3 3 Driver status u hiw SN a Q y 51 54 EEL Functions uir a a DE qawapasun 54 541 Initialization Shut down l u nnn nenne 54 5 4 2 7 Suspend Resume eerie nicer niece Pene reete een ee 59 5 4 3 Operational fUNCtONS LL I I NS dede neis 61 5 4 4 Administrative functions J U u u u u 68 Chapter6 EEL Im
28. EEL Handler execution time A Read command executed in the library startup phase while the RAM table is not completely filled is called early read The data of a DS with a certain ID to be read is found as follows e fthe ID X RAM table entry belonging to the ID is already filled the entry addresses the data and the data can be read quickly e fthe ID X RAM table entry belonging to the ID is not yet filled the DS is searched by parsing the REF entries from the youngest one backwards until a valid DS with the ID is found According to the possibly necessary REF entry parsing the early Read may last longer time gt gt 100us and requires 100 CPU load Furthermore the data read from Flash itself together with the checksum calculation need some time So the time can increase 100us already by DS sizes 32 Bytes 3 8 1 2 Early Immediate Write Immediate Incremental Write Immediate Invalidation command The early Immediate Write sequence does not differ to the normal Immediate Write Generally a Write operation needs to wait for the end of a preceding Write or Invalidation operation Trying to invoke a Write before will be rejected Operation invocation latency The maximum latency of the Write operation invocation by the EEL Execute function is defined by the EEL Handler execution time see comments above Furthermore after invocation of the write starting of the Write Invalidation process need to wait for e Thee en
29. F OFFFF ongoing 5555 5555 FFFF FFFF FFFF FFFF FFFF FFFF RN ongoing 5555 5555 Set L9ngoing FFFF EFFF Frrr FFFF 5555 5555 FFFF rrr rere rer FEFE 200 E EES FFFF Set Excluded ongoing 5555 5555 gt fi S 55 ongoing 7777 FFEF EA I a Set Invalid FFFF ee normal i L EFFF P Ner RT Set Invalid FFFF special case NETTEN WEIT Set Invalid seset f sass special 2 finished SE Set Invalid masc cene ipee ee special 3 fe 2979 a 22s osoo FFFF Flash word Pattern 0x5555 Pattern 0x00000000 Erase counter reference write pointer data Data write in progress gt Data is undefined Datais irrelevant and or undefined Data on 0 1 is any data 0x5555 0x5555 Block header data transitions The block header information is read on library startup and
30. L FLINT SET SW Basically each Flash operation end triggers the Flash interrupt However quite some EEL state machine internal states don t issue a Flash operation If the handler function shall be executed in the Flash interrupt context these states must issue the Flash interrupt by SW The define basically is a macro to request the Flash interrupt by SW If set it is called within the handler function at the end of each process state when no Flash operation was started Implementation in EEL Cfg h define EEL FLINT SET SW eel ui6 0xffff60feuL eel u16 Oxffff60feuL 1000 5 2 Run time configuration The overall EEL run time configuration is defined by an EEL specific part EEL run time configuration and by the FDL run time configuration Background of the splitting is that the FDL requires either common by EEL and FDL used information e g block size or EEL related information e g about the EEL pool size So this information is part of the FDL run time configuration Both configurations of FDL and EEL are stored in descriptor structures which are declared FDL Types h EEL Types h and defined in FDL Descriptor c Descriptor c with header files FDL Descriptor h EEL Descriptor h The descriptor files c and h are considered as part of the user application The defined descriptor structures are passed to the libraries as reference by the functions FDL Init and Init
31. LOCKED Pointer to the space calculation result storage location u32 space pu32 Pre conditions e The library must be unlocked o Call EEL Init to initialize the library o Call EEL Startup and EEL Handler cyclically to unlock the access status access status EEL ACCESS LOCKED o Donotcall EEL ShutDown or EEL Suspend before Post conditions None RO1AN1035ED0100 Rev 1 0 RENESAS 71 Application Note EEPROM Emulation Library User Interface API Example eel u32 space egel status t rot ret EEL GetSpace amp space if EEL OK ret Error treatment 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 const eel u08 EEL GetVersionString void Arguments None Return types values The library version is returned as string value in the following style EV850T06xxxxyZabcd with x supported compiler y compiler option Z E for engineering versions V for final versions abcd Library version numbers according to version Va bc or E1 00a d optional on E versions Pre conditions None Post conditions None Example eel 1108 vstr pu08 vstr pu08 EL GetVersionString Application Note 41 NE SAS EEPROM Emulation Library EEL Implementation into the user applicatio
32. S Write process cannot be suspended until the user data write has started After SOR DRP EOP write and potential new block activation because otherwise the data consistency would be endangered So these process steps must be finished and by this determine the invocation latency of a higher priority operation Handler EEL Execute execution time The execution time should be typically below 100us on a 100MHz device in order to realize a system with reliable timing During normal operation this can be reached but in the startup phase the execution times will be longer as complex calculations and searches are executed In the startup phase this time is affected by many conditions and so can only be measured for a reference system whereas the real timing needs to be evaluated by the customer in the user application Issues affecting this time are e g DS Size higher priority operations ongoing pool size Overall operation execution time This is the time to execute a complete operation like user DS write user DS Read from operation invocation to operation finish This time is affected by many conditions and so can only be measured for a reference system whereas the real timing needs to be evaluated by the customer in the user application Issues affecting this time are e g Flash Write time in the evaluations also the worst case time need to be considered DS Size operation invocation latency higher priority operations
33. ace eel status t EEL GetDriverStatus eel driver status t driverStatus str Arguments None Return types values Type Argument Description Result of the function Possible sal statusi values are EEL OK EEL ERR ACCESS LOCKED Pointer to the driver status structure to update eel driver status t driverStatus str See chapter Chapter 15 3 3 Driver status Pre conditions e Call EEL Init to initialize the library Post conditions None Example eel driver status t dStat eel status t ret EEL GetDriverStatus amp dStat if EEL OK ret Error treatment Application Note 41 NE SAS EEPROM Emulation Library User Interface 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 HWd remaining space in the active block Interface eel status t EEL GetSpace eel u32 space pu32 Arguments None Return types values Type Argument Description Result of the function Possible values EEL OK ERR ACCESS
34. against accidental overwriting due to application failures Blank Data Zone Data Z eau Data Zone Occupied Occupied Active Reference Write Pointer RDP The Read Data Pointer is used for special treatment of the situation that only one block is left for refresh The RDP is not related to the block status and so need not be considered in the power fail FMEA considerations regarding block status management Reserved areas Reserved header areas are unused These areas result from the fact that 11 and E1 have to be placed into another physical Flash block RO1AN1035ED0100 Rev 1 0 RENESAS 21 Application Note EEPROM Emulation Library Architecture 2 6 5 2 Block header data transitions Application Note During EEPROM emulation block header information changes according to the block status The following table shows the data change process and the resulting block header data As the RDP word see last sub chapter is not block status related it is not mentioned here Figure 2 9 Operation Status PIGCK TIERS WES ERES RESO erased ongoing FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 5 going FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF Set Prepared FFFF FFFF mcm FFFF fi aaie nF ongoing 5555 FFFF FFFF FFFF FFFF 77077 FFF
35. artup before On violation the function ends with EEL ERR ACCESS LOCKED Post conditions e Continuously call the EEL Handler function to forward the state machine to the shut down status e Continuously call EEL GetDriverStatus to detect when the state machine is shut down Example eel driver status t dStat IE 2x Ret EEL ShutDown if EEL OK ret Wait until operation end do Error treatment Ed EL Handler EEL GetDriverStatus amp dStat RO1AN1035ED0100 Rev 1 0 RENESAS 58 Application Note EEPROM Emulation Library User Interface ud while EEL OPERATION PASSIVE Error check af 5 4 2 Su EEL OK dStat errorSt Error handler spend Resume dStat operationStatus enu atus enu The library provides the functionality to suspend and resume the library operation in order to provide the possibility to synchronize the EEL Flash operations with possible user application Flash operations e g write erase by using the FDL library directly or read by direct Data Flash read access 5 4 2 1 EEL Suspend Description This function initiates the suspend mechanism for EEL operations to put the EEL in a passive state Interface eel status t EEL Suspend void Arguments None Return types values Type Argument Description Result of the function Possib
36. ash the EEL is the only master on the EEL pool accesses to this pool shall be done via the EEL API only Access to the user pool is done by using the FDL API functions for all accesses except read e g FDL Erase FDL Write while Data Flash read is directly done by the CPU The configuration of FDL pool and EEL pool and resulting user pool is done in the FDL descriptor 6 3 4 1 User Data Flash access during active EEPROM emulation While the EEL is active any direct Data Flash access like Data Flash Read by the CPU or execution of FLD functions are not allowed at all The EEL can at each time erase or write Data Flash During these operations Data Flash is not accessible for Read operations even not on other address ranges Furthermore execution of FDL operations like Flash Erase or Write would be blocked Following that EEL operations and user accesses to Data Flash must be synchronized This has to be done by the application considering the EEL as the default master If the user application wants to get access rights the EEL need to be suspended beforehand The API contains the functions EEL Suspend and EEL Resume for this The following flow chart shows the correct handling Application Note 2 NE SAS EEPROM Emulation Library EEL Implementation into the user application Figure 6 4 Start y Ongoing EEL operations function and operation errors handled by user application 1 4 Y Call EEL_Susp
37. ata is copied to the destination buffer in order to have the possibility to check the content Additionally on Format e EEL ERR BLOCK EXCLUDED e EEL ERR FLASH ERROR e EEL ERR POOL EXHAUSTED Pre conditions e Call EEL Init to initialize the library e Call EEL Startup and call EEL Handler cyclically to bring the library into operational status e Call EEL Execute to initiate an EEL operation Application Note 21 NE SAS EEPROM Emulation Library Post conditions None Example User Interface API eel u08 req str hile 5 req str el request t reg Str buffer 0x100 address u32 identifier ul6 length 1116 Offset uls command enu Execute r g str EEL Handler Error check If EEL OK req str status Error handler 1 0 0 E Start the read operation req str req str req str 132 amp buffer Set receive buffer Qus cT Ou zizu EL CMD READ Wait until operation end EEL BUSY req str status enu 5 4 4 Administrative functions 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 buff
38. cked e Cleanup operation Requires that the system executes no user or background operations If this is not the case the command will be rejected After being started other operations can be executed the cleanup operation will be suspended and later on resumed automatically Background operations The EEL operations are based on independent processes for the different user operations such as Read Write Immediate Write Furthermore background processes are to be executed in order to manage the EEL pool and to manage the startup flow The following background operations and their processes are available e Refresh This process manages copying any potential DS instances from the EEL pool active tail to the head before invalidating a virtual block The copy process itself is done by the Write Refresh process After invalidation the block can be prepared again e Write Refresh This process is triggered by Refresh to copy one DS e Prepare Erase invalid Flash blocks and mark them prepared This process provides new space for the active pool e Supervision This process manages the complete startup processing See 3 7 Start up processing When the library is up and in normal operation it controls the background processes o When the refresh threshold is underrun the process triggers first the Refresh process then the Prepare process to provide enough prepared pool space to store new DS instances o When no further po
39. const eel 1116 IDLTab 16 2 EEL CONFIG IDL TABLE eel 116 IDXTab aul6 sizeof IDLTab aule gt gt 21 const eel descriptor t 1 eelConfig EL CONFIG DF BASE ADDRESS EL CONFIG BLOCK CNT REFRESH THRESHOLD DLTab 16 IDXTab au16 0 sizeof IDLTab aul6 gt gt 2 EL CONFIG ERASE SUSPEND THRESHOLD H B EJ Example configuration in EEL Descriptor h Data Flash size is 32kB Application Note 21 NE SAS EEPROM Emulation Library User Interface API The EEL shall use the complete Data Flash for the EEL pool blkRefreshThreshold is set to 1 3 of 16 Flash blocks 5 the erase shall be suspend able up to 10 times until the erase suspend warning is issued define EEL CONFIG DF BASE ADDRESS 000000 define CONFIG BLOCK CNT REFRESH THRESHOLD 0x05 define EEL CONFIG ERASE SUSPEND THRESHOLD 10 See eee eee eee eee eee eee eee ee Oe eS EEL CONFIG IDL TABLE Descriptor table containing data set identifier and data set length as 16 bit ID lt 16 bit length in bytes a ea ee sas define EEL CONFIG IDL TABLE 0 1111 0 0005 0x2222 0x0006 0x3333 0x0007 0x4444 0x0008 0x5555 0x0009 0x6666 0x000a 0x7777 0x000b 0 8888 0 000 0 9999 0x000d 0xaaaa 0 0015
40. criptor 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 e structure of the descriptor is passed to the user application by FDL EEL Types h e The value definition should be done in the file FDL EEL Descriptor h e The constant variable definition and value assignment should be done in the file FDL EEL Descriptor c If overtaking the files FDL EEL Descriptor c h into the user application only the file FDL EEL Descriptor h need to be adapted by the user while FDL EEL Descriptor c may remain unchanged 4 1 2 Delivery package directory structure and files The following table contains all files installed by the library installer e Files in red belong to the build environment controlling the compile link and target build process e Files in blue belong to the sample application e Files in green are description files only e Files in black belong to the FDL and EEL in the separate directories for EEL and FDL 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 lt device name gt compiler Build bat Batch file to build the application sample RO1AN1035ED0100 Rev 1 0 RENESAS 38 A
41. criptor 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 m ss s aa s S a Wait until we read write 1st data sets EE EM eit rra nA cetus t ess cm tbi 35 irs do EEL Handler EEL GetDriverStatus amp dStat Wait until early read write is possible or error while EEL OPERATION STARTUP dStat operationStatus enu amp amp EEL ACCESS LOCKED dStat accessStatus enu k Error check if EEL OK dStat errorStatus enu Error handler nmm Em Early read write operation req str address u32 u32 amp buffer au08 req str identifier u16 10u req str length 1116 0 10 req str offset 1116 Oxl3u req str command enu EEL CMD READ Execute amp req str Wait until operation end while EEL BUSY req str status enu Error check EEL Handler RO1AN1035ED0100 Rev 1 0 RENESAS 75 Application Note EEPROM Emulation Library EEL Implementation into the user application if EEL OK req str status enu Error handler str address u32 432 amp buffer au
42. d of a higher priority Read command e end of blocking by a lower priority DS Write process invoked by user DS Write Invalidation command or background Refresh process In order to ensure data and ring buffer consistency any DS Write process need to block higher priority Write commands until the process step to write the user data is reached Blocking time is defined by 8 times a 1 word Data Flash Write 4 times to write SOR DRP EOP amp 4 times to possibly activate a new block EEL Handler execution time The execution time should be 100us on a 100MHz device Application Note 2 NE SAS EEPROM Emulation Library EEL Design 3 8 1 3 Early Write Incremental Write Invalidation command The early Write sequence does not differ to the normal Write Generally a Write operation needs to wait for the end of a preceding Write or Invalidation operation Trying to invoke a Write before will be rejected Operation invocation latency The maximum latency of the Write operation invocation by the EEL Execute function is defined by the EEL Handler execution time see comments above Furthermore after invocation of the write starting of the Write process need to wait for e The end of a higher priority Read Immediate Write or Immediate Invalidation command end of blocking by a lower priority DS Write process invoked by user DS Write Invalidation command or background Refresh process In order to ensure data an
43. d ring buffer consistency any DS Write process need to block higher priority Write commands until the process step to write the user data is reached Blocking time is defined by 6 times a 1 HWd Data Flash Write 4 times to write SOR DRP EOP amp 4 times to possibly activate a new block EEL Handler execution time The execution time should be 100us on a 100MHz device 3 8 2 Normal operation phase If not mentioned otherwise in the normal operation phase the EEL Handler function execution time should always below 100us on a 100MHz device An ongoing Flash erase will not block any user command The erase will be suspended and later on resumed Anyhow after a configurable number of times suspending the warning EEL ERR ERASESUSPEND OVERFLOW is returned in order to inform the user to give sufficient time to complete the erase operation rather than extremely frequently invoking Read Write Invalidation operations 3 8 2 1 Read command Operation invocation latency The maximum latency of the Read operation invocation by the EEL Execute function is defined by the EEL Handler execution time see comments above Furthermore after invocation of the read start of the Read process need to wait for the end of a possibly started 4 HWd Data Flash write up to 4 half words can be written by the Flash hardware in sequence without software interaction caused by a Write command or by the background process EEL Handler execution time Typicall
44. date DS Read Format Cleanup These commands have partially been mentioned before and are described in the API description The Read and Write operations are considered to be prioritized according to the following scheme e Priority 1 Read can interrupt Write Incremental Write Invalidation Immediate Write Immediate Incremental Write and Immediate Invalidation Priority 2 Immediate Write Immediate Incremental Write and Immediate Invalidation can interrupt Write Incremental Write and Invalidation Priority 3 Write Incremental Write and Invalidation cannot interrupt any other user operation The following rules apply to these operations All of the above operations can interrupt ongoing background operations A command invoking an operation when an operation of the same priority is ongoing will be rejected When an operation of a higher priority is invoked a possibly ongoing operation of a lower priority will be suspended Application Note 21 NE SAS EEPROM Emulation Library EEL Design 3 4 Note When invoking an operation of a lower priority a possibly ongoing operation of a higher priority is will be finished first then the lower priority operation is executed Furthermore special conditions apply for the other operations e Format operation Requires that the system executes no user or background operations If this is not the case the command will be rejected When started all other operations are blo
45. der file with definitions for library setup at compile time root device name gt lt compiler gt sample FDL lib FDL Env h Library internal defines for accessing the Flash programming hardware and Data Flash related definitions FDL Global h R01AN1035ED0100 Rev 1 0 Application Note Library internal defines function prototypes and variables RENESAS 39 EEPROM Emulation Library Implementation FDL HWAccess c Source code for the library Hardware interface FDL UserlF c Source code for the library user interface and z service functions root lt device name gt lt compiler gt sample EEL EEL h Header file containing all function prototypes of the library user interface Header file containing calling structures and EEL_Types h error enumerations of the library user interface EEL Cfg h Header file with definitions for library setup at compile time Descriptor file with the run time EEL configuration Using the defines of EEL Descriptor h and should not be edited by the user EEL Descriptor c Descriptor file header with the run time EEL BEL aka ci configuration To be edited by the user root lt device name gt lt compiler gt sample EEL lib Library internal defines function prototypes and variables EEL BasicFct c EEL internal functions amp state machine EEL UserlF c EEL user interface functions
46. e driver status will indicate why and allow the user application to decide how to react Furthermore when the handler is called to execute background operations the driver status will indicate the operations result The driver status can be checked by the function EEL GetDriverStatus Application Note 2 NE SAS EEPROM Emulation Library User Interface API Type definition typedef enum EEL ACCESS STATUS T read amp write access disabled EEL ACCESS LOCKED read only access set in case of write error EEL ACCESS READ ONLY read amp write access enabled limited performance EEL ACCESS READ WRITE full read and write access enabled EEL ACCESS UNLOCKED eel access status t typedef enum EEL OPERATION STATUS T all operations locked EEL OPERATION PASSIVE after Startup maintainance passive full operation possible EEL OPERATION IDLE any user request under processing EEL OPERATION BUSY x While startup processes are running EEL OPERATION STARTUP User suspend EEL OPERATION SUSPENDED eel operation status t typedef struct EEL DRIVER STATUS T eel operation status t operationStatus enu eel access status t accessStatus enu eel request status t error enu eel driver status t Application Note 41 NE SAS EEPROM Emulation Library Us
47. e 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 entry written afterwards in the preparation process If the P entry 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 Figure 2 7 Physical Flash EC 121 Under erasing undefined 120 120 EEL pool lt 120 120 120 120 120 Erase Counter example 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 Application Note 21 NE SAS EEPROM Emulation Library Architecture Figure 2 8 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 entry written afterwards in the activation process If the A 1 entry is valid the RWP is electrically stable Additionally the RWP is checksum protected in order to be robust
48. e executed as much free space as possible for DS Write should be available 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 amp 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 Required parameters from the request structure o command enu Set to EEL CLEANUP for the Clean up operation Clean up requires at least one DS entry in the EEL pool If not the operation is not accepted resulting in access locked error 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 e Read e Normal priority write invalidate e High priority write invalidate In order to do so the application needs to provide separate request structures for these operations Interface void EEL Execute eel request t request str RO1AN1035ED0100 Rev 1 0 RENESAS 64 Application Note EEPROM Emulation Library User Interface Arguments Type Argument Description eel request t request str See chapter 9 3
49. e of the FDL pool freely at project compilation time while usually the complete Data Flash is selected The FDL pool provides the space for the EEL pool which is allocated by the EEL inside the FDL pool The EEL pool provides the Flash space for the EEL to store the emulation data and management information All FDL pool space not allocated by the EEL pool is freely usable by the user application so is called the User pool Pools details e 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 Oxfe000000 0xfeO0FFFF are transformed into a linear address room 0x0000 0xFFFF used by the FDL e 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 e 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 RO1AN1035ED0100 Rev 1 0 RENESAS 13 Application Note EEPROM Emulation Library Architecture Figure 2 2 24 2 5 Data Flash FDL Pool Data Flash FDL Pool Sa
50. e 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 After this exercise it might be easier to understand and follow the recommendations and considerations of this document 6 2 Standard EEL life cycle The following flow chart represents the recommended EEL life cycle during device operation including the API functions to be used RO1AN1035ED0100 Rev 1 0 RENESAS 73 EEPROM Emulation Library Figure 6 1 6 2 1 RO1AN1035ED0100 Rev 1 0 Application Note EEL Implementation into the user application 7 4 Device Start Start up phase Y EEL Init EEL Startup P Normal Application operation Y EEL Execute EEL Frequent call of Service functions Write EEL Handler Format EEL Handler After user operation Read Write finish background operations ring buffer space Function serves preparation bit error check user operations are executed and background operations Device power down re
51. ed and vice versa This allows implementation of EEPROM emulation concepts with Data storage on Data Flash while all program code is executed from Code Flash If not mentioned otherwise in the device users manuals the devices with Data Flash are designed according to this standard approach It is not possible to modify Code Flash and Data Flash in parallel RO1AN1035ED0100 Rev 1 0 RENESAS 11 Application Note EEPROM Emulation Library Architecture 2 1 3 Flash granularity The Data Flash can be erased in 32 Byte units The Data Flash can be written and read in 2 Byte units As the CPU is able to handle 4 Byte units as one Word this document often refers to the Half Word HWd as 2 Byte units 2 2 Layered software architecture This chapter describes the function of all blocks belonging to the EEPROM Emulation System Even though this specification describes the functional block EEL a short description of all concerned functional blocks and their relationship can be beneficial for the general understanding Figure 2 1 Code Flash Rough symbolic relationship between the functional blocks 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 Application Note 41 NE SAS EEPROM Emulation
52. end Function error return Check the driver status with Y EEL GeiDriverStatus 7 Call Handler until the EEL driver status is passive Function error return S ____ Do direct Data flash accesses via FDL functions FDL Erase FDL Write direct Data Flash read by the CPU FDL operations processing errors y Call EEL Resume Function error return y Continue with EEL operations EEL Suspend Resume 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 6 3 5 Entering power safe mode Entering power safe modes is delayed by the device hardware until eventually ongoing Data Flash operations are finished In order to gain a proper synchronisation between EEL and Power safe mode entering the library operations must be suspended before entering the mode Please check EEL Suspend API description 6 3 6 Library behaviour after operation interruption Library operation might be suddenly interrupted e g by a power fail Depending on the interrupted operation E g Flash erase write the behaviour of the library on the next start up might differ e Library was idle or at the end of a operation Normal library start up RO1AN103
53. er EEL function while the last one has not finished Example of not allowed sequence e Task1 Start an EEL operation with EEL Execute e Interrupt the function execution and switch to task 2 executing Handler function e 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 EEL operation performance The performance of the EEL operations strongly depends on the frequency of the handler calls This especially affects operations which require many Flash write operations until the operation is finished such as DS Write and background operations such as Startup processing or Refresh As the typical Flash write operation needs between 200 and 700us a slower handler call frequency significantly reduces the operation performance The following user application implementations are judged regarding advantages and disadvantages also mixtures are possible if the synchronization of the function calls is ensured e Call in a timed task In order to archive a reasonable emulation operation performance the time slice should not be selected too big A 500us interval would not significantly reduce the EEL performance and so seems to be a reasonable compromise between library performance and CPU load e Call in the idle task If it is ensured that the idle task
54. er Interface API 5 4 EEL Functions Functions represent the functional interface to the EEL which other SW can use 5 4 1 Initialization Shut down 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 eel status t EEL Init const eel descriptor t descriptor pstr eel operation mode t opMode enu Arguments Type Argument Description EEL OPERATION MODE NORMAL Full operation of the library eel opMode opMode enu e EEL OPERATION MODE LIMITED Operation with limited ID L table in ROM containing not all IDs gt no Refresh possible Pointer to the EEL run time configuration descriptor structure in ROM eel descriptor t descriptor pstr Return types values Type Argument Description Result of the function Possible values are status t None EEL OK EEL ERR ACCESS LOCKED EEL ERR CONFIGURATION The function checks the configuration in the descriptor variable for consistency If a problem i
55. er 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 eel status t Arguments None RO1AN1035ED0100 Rev 1 0 EEL GetEraseCounter eel u32 counter pu32 RENESAS 68 Application Note EEPROM Emulation Library Return types values User Interface API Type Argument Description eel status t Result of the function Possible values are EEL OK EEL ERR ACCESS LOCKED u32 Pre conditions counter pu32 Pointer to the erase counter storage location e library must be unlocked o Call EEL Init to initialize the library o Call EEL Startup and call EEL Handler cyclically to unlock the access status access status EEL ACCESS LOCKED o Donotcall EEL ShutDown or EEL Suspend before Post conditions None Example eel 132 eraseCounter eel status t ret ret EEL GetEras if EEL OK ret eCounter Error treatment RO1AN1035ED0100 Rev 1 0 Application Note amp EraseCounter RENESAS 69 EEPROM Emulation Library User Interface 5 4 4 2 EEL GetDriverStatus Description This function returns the state machine status into the driver status structure Interf
56. er with the ID statically in ROM the pointers to the latest DS instances are evaluated on library startup and stored in RAM Application Note 2 NE SAS EEPROM Emulation Library Figure 3 1 3 6 1 1 RO1AN1035ED0100 Rev 1 0 Application Note EEL Design Data Flash Under erasing ROM ID L Table RAM IDX Table 16bit 16bit Data Flash pointer Length Data Flash pointer Length EEL 5 Pool Data Flash pointer Length Data Flash pointer Length Data Flash pointer Length Data Flash pointer Length Data Flash pointer Length Data Flash pointer Length Library ID Tables 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 Data Read Mechanisms ROM table search Whenever a DS with a dedicated ID shall be read the requested ID is searched in the ROM table The index of the ROM table entry with the fitting ID is then used to get the data pointer to the Data Flash from the RAM table This ROM table search is fast but the RAM table must be initialized on startup which requires some time The Rom table is used for Read as well as for the Refresh
57. erface Return types values Type Argument Description Result of the function Possible eel status t None vales ales E EEL OK EEL ERR ACCESS LOCKED Pre conditions e The library must be initialized Call EEL_Init before e The library may not already be active function EEL Startup already called On violation the function ends with EEL ERR ACCESS LOCKED In case of re initialization the function EEL ShutDown must be called before EEL Init and EEL Startup Post conditions e Continuously call the EEL Handler function to forward the state machine to come to normal operation Example Option Wait after Startup until the library is completely and running eel driver status t dStat ret EEL Init if EEL OK ret ret EEL Startup if EEL OK ret error treatment EEL Handler EEL GetDriverStatus amp 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 RO1AN1035ED0100 Rev 1 0 RENESAS 56 Application Note EEPROM Emulation Library User Interface API 2 Option Wait after EEL_Startup until the library at least partially unlocked eel driver status t dStat ret EEL Init ret EEL Init if EEL OK
58. fety Considerations EEPROM emulation in the automotive market is not only operated under normal conditions where stable function execution can be guaranteed In fact several failure scenarios should be considered Most important issue to be considered is the interruption of a function e g by power fail or Reset Differing from a normal digital system where the operation is re started from a defined entry point e g Reset vector the EEPROM emulation modifies Flash cells which is an analogue process with permanent impact on the cells Such an interruption may lead to instable electrical cell conditions of affected cells This might be visible by undefined read values read value write value but also to defined read values blank or read value 7 write value In each case the read margin of these cells is not given The value may change by time into any direction This is considered in the emulation design Safety relevant considerations and concepts are mentioned in dedicated sup chapters in this document Feature Overview The new EEL concept improves quite some features known from today s V850 MF2 UX4 EEELib Beside the same kind of user data management based on data sets DS identified with certain IDs many new or extended features are implemented The old V850 MF2 UX4 EEELib searches DSs in the Flash memory on every Read access as well as during the Refresh process Even though being executed in background the read latenc
59. for the later Prepare process Furthermore the invalidation flags are written during execution of the startup process when a block status is detected as invalid but the flags are not valid This ought to result from an interrupted invalidation of the virtual block e By writing 0x5555 the block is marked invalid e startup the half 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 e f on startup the entries are blank the other header entries determine the block status E 0 E 1 The flags are written to 0x5555 to mark a virtual block excluded This is done when the Flash erase returns an erase error The blocks are then judged defect P The prepare marker is set by the preparation process With the pattern 0x5555 the block is marked prepared Application Note 2 NE SAS EEPROM Emulation Library Architecture 0 The activation flag 0 is written 1st in the block activation process with the pattern 0x5555 It locks the block for activation to indicate the started activation process In case of a power fail during activation the next block is used A 1 The activation flag 1 is written last in the activation process with the pattern 0x5555 EC The erase counter is written as the 1st entry in the preparation process Rule for counter calculation is if the block is th
60. g EEL ERR BLOCK EXCLUDED These warnings are signalled to the user application but don t result in a emulation system reaction e Errors resulting in complete system lock e g EEL ERR POOL INCONSISTENT The error is signalled to the user application and the complete system is locked o Nouser commands accepted o All ongoing user operations are stopped and return with error EEL ERR ACCESS LOCKED o All background processes are stopped e Errors resulting in read only mode e g EEL ERR FLASH ERROR during data set write The error is signalled to the user application and the complete system is in read only mode o Only further user read command accepted write and format are locked o ongoing user operations are stopped and return with error EEL ERR ACCESS LOCKED a read operation cannot be ongoing as this has the highest priority o All background processes are stopped The errors warnings are returned to the user application on two different ways e 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 e Errors on user commands Write Read Format will be returned as command answer 3 6 Data Set search and read 3 6 1 ID L and IDX tables The library uses internal tables to store the DS size information and latest DS location While the DS size is stored togeth
61. hanged length e Protect DSs with a checksum Calculating the checksum from data with a different length result in a checksum differing from the stored one not 100 safe 6 3 7 2 ID L ROM table temporarily not available The boot loader as well as the application needs to access EEPROM emulation data with Read as well as Write While the application requires frequent data write the boot loader will only store a very limited amount of data e g to store the application update process state The ROM ID L table containing all IDs available in the emulation belongs to the application On application update it needs to be removed together with the application After removal of the ID L table normal operation of the EEPROM emulation cannot continue In order to continue at least with limited functionality the library provides operation modes to survive at least with limited functionality The mode configuration is done by the initialization function EEL Init In order to change the mode EEL Init need to be called again e EEL OPERATION MODE NORMAL Full normal operation of the library requires the complete ID L table in ROM e EEL OPERATION MODE LIMITED Operation with limited ID L table in ROM containing only the IDs required by the boot loader The DS Read and Write work on the ID L table The Refresh process is not possible as this would require a list of all available IDs Following this Data Sets can only be written unt
62. ighest performance Disadvantages function execution time in interrupt context Synchronization between handler call in interrupt context and other EEL function in tasks handler must be called in other timed tasks to do bit error checks See 3 2 Flash interrupt support Interface void EEL Handler void Arguments None RO1AN1035ED0100 Rev 1 0 RENESAS 66 Application Note EEPROM Emulation Library User Interface API Return types values Type Argument Description The value is returned in the request structure error variable passed to the EEL Execute function The possible return values depend on the operation that was started as well as on the errors of background operations This table describes not the errors set by operation invocation with the EEL Execute function but the errors additionally set during operation execution All operations e EEL OK e EEL BUSY e EEL ERR REJECTED EEL ERR COMMAND e EEL ERR ERASESUSPEND OVERFLOW e EEL ERR INTERNAL Additionally on Write and Invalidate e EEL ERR FLASH ERROR e EEL ERR POOL FULL request str e EEL ERR ACCESS LOCKED eel request t m status enu Additionally on immediate Write and immediate Invalidate EEL ERR FLASH ERROR e EEL ERR POOL FULL e EEL ERR ACCESS LOCKED Additionally on Read e EEL ERR WRONG CHECKSUM e EEL ERR NO INSTANCE Note Even when the error EEL ERR WRONG CHECKSUM is returned the d
63. il the passive Flash space of the Data Flash prepared and invalid blocks is consumed Then the library must switch to read only As the size of data to be written by the boot loader is very limited it is considered that the passive space should be sufficient even in case of frequent interruptions of the application update process Additionally the library provides a function to defragment the active space activated blocks in the Flash by Refreshing all activated blocks By that all DS instances which are not the latest ones are removed and as much as possible passive space is provided 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 explanations describe the different application update strategies which we consider to be reasonable The different strategies use the different operation modes Application Note 21 NE SAS EEPROM Emulation Library EEL Implementation into the user application Application update flow proposal Stop EEPROM emulation until ROM ID L table is available The following flow chart explains the application update idea Timely no EEPROM emulation is possible The emulation is started in normal operation mode using the parameter EEL OPERATION MODE NORMAL when calling the function EEL Init BL start Figure 6 5 Start EEL with operation mode
64. il valid data is written again A Read command on a ID which last DS instance is invalidated will return the error invalidated instead of returning data 2 7 4 1 DS containing normal data The DSs are stored according to the following picture Figure 2 13 RO1AN1035ED0100 Rev 1 0 Application Note byte 1 byte 0 REF entry Data n 2 REF entry Data n 1 REF Zone REF entry Data n Data n 14 Bytes Data Zone Data n 1 4 Bytes Data n 2 3 Bytes DS Data and management information in Flash RENESAS 25 EEPROM Emulation Library Architecture e SOR Start of reference entry It is written 1st in order to block one REF zone list entry e DRP Data Reference Pointer Is written after SOR and contains 16 bit lower half word ID 16 bit upper half word word index a pointer to the data Note DRP can address 64k indexes This is sufficient to cover 128kB Flash with HWd addressing indexing e EOP End of DRP Is written immediately after the DRP When written the read margin of the DRP word is ensured by the write sequence e DCS Data Check Sum This is a simple 16bit checksum calculated over the user data and DRP It ensures higher robustness detection on accidental overwriting of data or DRP 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
65. initiate Refresh Prepare operations to cleanup the active EEL pool range and provide more prepared blocks 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 GetSpace provides a tool to trace the available free space in the ring buffer during run time
66. inter to the next write location for the user data e Reference Pointer RP The RP is the pointer to the next location for a REF zone entry Application Note 2 NE SAS EEPROM Emulation Library Architecture Figure 2 11 Block bottom address Blank DP Data Zone Block top address DP and RP RP and DP grow together When the pointers match only one blank HWd is between the zones The Flash block is considered as full and the next block must be activated 2 7 3 Block overlapping DS s In order not to waste Flash space when a DS does not completely fit into a Flash block the DS is partly written into the block and finished in the next block or blocks in case of DS bigger than one block Figure 2 12 Active Prepared Occupied Active New DS part 1 DS Write Blank sss Data Zone Data Zone New DS part 2 Block Overlapping DS normal size DS 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 Application Note 21 NE SAS EEPROM Emulation Library Architecture 2 7 4 Storage structure details The following 2 sub chapters describe the Data Sets DS storage structure details The structures differ depending on e The DS contains valid user data e The DS contains the information that the user data of a certain ID is invalid and so may not be read unt
67. ired to change the DS length of some IDs Differing from the MF2 UX4 EEELib this is automatically done when the ID L table in ROM is updated After that update all DS s are read written with the new length and also the Refresh process copies the data with the new length e Old length lt new length Data is extended by any data stored after the DS data of the next DS undefined e Old length gt new length Data is cut to new length 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 Possible options to store the DS lengths are e Store the length of the DS in the DS itself RO1AN1035ED0100 Rev 1 0 RENESAS 84 Application Note EEPROM Emulation Library EEL Implementation into the user application If the length is stored in the 1st Bytes a read operation on the 1st Bytes only can be done e Reserve a special DS only containing all available DS IDs and the length information A comparison with the ROM ID L table will identify the IDs with c
68. is called often enough that method might result in the good performance as the handler can be called continuously However as this method is not deterministic in case of higher CPU load by the application it might be combined with calls in a timed task RO1AN1035ED0100 Rev 1 0 RENESAS 81 Application Note EEPROM Emulation Library EEL Implementation into the user application 6 3 3 4 EEL Start up time optimization The duration from EEL initialization up to EEL full operation is usually a critical value for the application This time is largely defined by the process step to fill the RAM ID L table for fast DS search and read The complete active part of the EEL pool is parsed DS to DS and on each found DS the library checks if the appropriate RAM table entry is already filled Therefore the ROM table is searched for the correct ID from the last entry table end to the first entry If all IDs of often written Data Sets are placed to the ID L table end and all rarely written DS IDs are placed to the ID L Table begin the EEL Start up performance is significantly increased 6 3 4 Concurrent Data Flash accesses Depending on the user application scenario the Data Flash might be used for different purposes e g one part is reserved for direct access by the user application and one part is reserved for EEPROM emulation by the Renesas EEL The FDL is prepared to split the Data Flash into an EEL Pool and a User Pool On splitted Data Fl
69. ked without latency as no other operations are ongoing EEL Handler execution time The Cleanup command only sets a variable to more often call the Refresh process and Prepare process in background The handler execution time will be below 100us Application Note 21 NE SAS EEPROM Emulation Library Implementation Chapter 4 4 1 Note Application Note Implementation File structure The library is delivered as a complete compile able sample project which contains the EEL and FDL libraries and in addition to an application sample to show the library implementation and usage in the target application The application sample initializes the EEL and does some dummy data set Write and Read operations 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 make files 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 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 function
70. l presents the software manual for the concerned libraries This document describes the following sections e Architecture e Implementation and Usage Additional remark or tip Item deserving extra attention Binary or xxxB Decimal XXXX Hexadecimal XxxxH or Ox representing powers of 2 address space memory capacity K kilo 219 1024 2 10242 1 048 576 G giga 27 1024 1 073 741 824 X x don t care Block diagrams do not necessarily show the exact software flow but the functional structure Timing diagrams are for functional explanation purposes only without any relevance to the real hardware implementation How to Use This Manual Purpose and Target Readers This manual is designed to provide the user with an understanding of the library itself and the functionality provided by the library It is intended for users designing applications using libraries provided by Renesas A basic knowledge of software systems as well as Renesas microcontrollers is necessary in order to use this manual The manual comprises an overview of the library its functionality and its structure how to use it and restrictions in using the library Particular attention should be paid to the precautionary notes when using the manual These notes occur within the body of the text at the end of each section and in the Special Considerations section The revision history summarizes the locati
71. le eel status t None ara n EEL OK EEL ERR ACCESS LOCKED Pre conditions RO1AN1035ED0100 Rev 1 0 Application Note The library must be initialized Call EEL Init before The Library may not already be suspended On violation the function ends with EEL ERR ACCESS LOCKED RENESAS 59 EEPROM Emulation Library User Interface API Post conditions e Call EEL Handler until the library is suspended status EEL OPERATION SUSPENDED If the function returned successfully no further error check of the suspend procedure is necessary as a potential error is saved This is restored on EEL Resume Example eel driver status t dStat P ret EEL Suspend if EEL OK ret Error treatment Wait until operation end do EEL Handler EEL GetDriverStatus amp dStat while EEL OPERATION SUSPENDED dStat operationStatus enu Do other Flash operations or bring the device in power safe mode ret EEL Resume if EEL OK ret Error treatment Continue with EEL operations 5 4 2 2 EEL_Resume Description This function resumes the EEL operations after suspend Interface ret EEL Resume void R01AN1035ED0100 Rev 1 0 RENESAS 60 Application Note EEPROM Emulation Library User Interface Arguments None Return types values T
72. leanup operation j Re start EEL with operation mode EEL OPERATION MODE LIMITED r gt Limited EEPROM Update Application including ID L Emulation without Q table in ROM J Refresh process Start EEL with operation mode EEL_OPERATION_MODE_NORMAL Execute BL including EEPROM emulation Application update concept with timely limited EEPROM emulation Full EEPROM Emulation Application Note 21 NE SAS EEPROM Emulation Library EEL Implementation into the user application 6 3 8 Device performance during active Flash operations Based on the devices system architecture the APB bus access by the application is affected by active Flash operations During the Flash operations the APB bus access is delayed by up to 32 wait states RO1AN1035ED0100 Rev 1 0 RENESAS 88 Application Note EEPROM Emulation Library EEL Implementation into the user application Revision History Chapter Page Description new version ROIANIGSEDUTRev 10 Application Note QEN AS EEPROM Emulation Library 2 NESAS Renesas Electronics Corporation
73. lfunctions under certain use conditions Further Renesas Electronics products are not subject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or system manufactured by you Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this docume
74. mory The difference to 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 Flash Macro A certain number of Flash blocks is grouped together in a Flash macro HWd Half Word 16bit data HWIdx Half Word Index index to HWd data ID Identifier of a Data Set instance in the Renesas EEPROM Emulation Non volatile memory All memories that hold the NVM value even when the power is cut off E g Flash memory EEPROM MRAM Random access memory volatile memory with RAM random access REE Renesas Electronics Europe GmbH REL Renesas Electronics Japan ROM Read only memory nonvolatile memory The content of that memory can not be changed Segment Section Segment of Flash is a part of the flash that might consist of several blocks Important is that this segment can be protected against manipulation Serial programming The onboard programming mode is used to program the device with an external programmer tool Virtual Flash blocks The EEL merges together small physical Flash blocks to bigger virtual Flash blocks which are then managed in the ring buffer All trademarks and registered trademarks are the property of their respective owners Table of Contents Chapter 1 Introduction erit P Eee i eoi 10 Chapter2 Architecture
75. n Chapter 6 EEL Implementation into the user application Application Note 6 1 First steps There are several ways to approach the EEPROM emulation concept and the implementation into the user application It is for sure worth knowing the basics of the RENESAS EEPROM emulation concept and the library architecture design and implementation By that you most probably get a feeling of the EEPROM emulation complexity at all and might consider that the implementation into the user s application is not done in a few days but requires careful consideration of the libraries features and requirements and the users application requirements A few things worth mentioning here are e Start up time until 1st data read and write e CPU load by the EEL during library start up and during normal operation e Where to call the EEL Handler function e Where to call the EEL Execute function e How to map application variables to the EEL IDs 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 6 1 1 Application sample After a first compile run it will be worth playing around with the library in the debugger By that you will get a feeling for the source code files the request structure mechanism and the library startup behavior Note Before the first compile run the compiler path must be configured in the application sample file makefile Set th
76. nd the next block must be activated when only 1 3 blank half words depending on different conditions as delimiter remain between the two zones e Block header The header contains the block status information e Data Zone Contains the pure user data to be stored without any management information e Reference REF zone This is a table with entries containing the references pointers to the data Figure 2 5 Block bottom address Growing Blank Data Zone Growing Block top address Basic Block structure 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 Application Note 42 NE SAS EEPROM Emulation Library Architecture 2 6 5 1 Block Header The block header contains the block status half words Figure 2 6 HW idx byte 0 byte 1 0 invalid flag O 1 exclude flag 0 2 prepare flag 3 Jactive flag 0 4 Jactive flag 1 5 reserved 6 32bit erase counter 8bit CS protected 8 32bit reference write pointer 8 bit CS protected 10 Pool full read data pointer 8 bit CS protected 12 reserved 16 invalid flag 1 17 exclude flag 1 Block header half words 1 0 1 1 The flags are written by the Refresh process when a block does not contain any more valid DSs with relevant data and shall be marked
77. nt or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Electronics product s means any product developed or manufactured by or for Renesas Electronics Regional Information Some information contained in this document may vary from country to country Before using any Renesas Electronics product in your application please contact the Renesas Electronics office in your country to obtain a list of authorized representatives and distributors They will verify 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 Awww renesas com to get in contact with your regional representatives and distributors Readers Purpose Organisation Note Caution Numeric notation Numeric prefixes Register contents Diagrams Preface This manual is intended for users who want to understand the functions of the concerned libraries This manua
78. o address u32 Destination buffer address o length 16 Number of bytes to read o Offset u16 Offset from DS begin to start reading o command enu EEL READ for the Read operation Parameter checks resulting in return value EEL ERR PARAMETER o Offset length DS size o Unknown ID Write Writing data from a user defined address buffer into a new DS instance identified by a given ID This is done with normal priority Required parameters from the request structure o identifier u16 ID to write o address u32 source buffer address o command enu WRITE for the Write operation Parameter checks resulting in return value EEL ERR PARAMETER o Unknown ID Write Incremental Writing data from a user defined address buffer into a new DS instance identified by a given ID The data write is only executed when the given data in the write buffer differs from the data of the last DS instance in the EEL pool If the data equals the operation is successfully finished without data write operation This is done with normal priority Required parameters from the request structure o identifier u16 ID to write o address u32 source buffer address o command enu EEL WRITE for the Write operation Parameter checks resulting in return value EEL ERR PARAMETER o Unknown ID Invalidate Writing a DS instance identified by an ID invalid This is done with normal p
79. ocesses are finished and the Supervision gets passive Handler GetDriverStatus amp dStat xj mj while EEL OPERATION PASSIVE dStat operationStatus enu Error check if EEL OK dStat errorStatus enu Error handler Application Note 41 NE SAS EEPROM Emulation Library EEL Implementation into the user application 6 3 Special considerations 6 3 1 Endurance calculations Note Every write operation of a new data set instance occupies space in the Data Flash When a certain amount of Data Flash is filled new space is created by Refresh and Prepare processes where the Refresh process copies data which is still valid from the ring buffers active zone tail block to the active zone head block When finished the Prepare operation can erase the tail block This is repeated many times over device lifetime However the endurance of the Data Flash blocks regarding number of erase cycles is limited So it is necessary to calculate the number of erase cycles required over device life time and to judge if this does not exceed the specified Data Flash endurance 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 The endurance calculation sheet is a very helpful tool but still the re
80. of the system a post mortem analysis will get much more difficult or impossible as the Flash contents may change since appearance of the problem root cause While in the debugging phase the emulation should be stopped immediately for problem analysis the system reaction in field should be carefully judged depending on the application requirements to the system availability and failure analysis options 5 3 2 User operation request structure All different user operations are initiated by a central initiation function EEL Execute All information required for the execution is passes to the EEL by a central request structure Also the error is returned by the same structure Application Write access Figure 5 2 Read access Request structure handling Application Note 41 NE SAS EEPROM Emulation Library The following request elements are defined e command User operation to execute EEL CMD READ EEL CMD WRITE EEL CMD WRITE INC EEL CMD INVALIDATE EEL CMD WRITE IMM User Interface Read a DS Write a DS Incremental Write a DS Write a DS data invalid Write a DS with high e address u32 e identifier u16 e length u16 e Offset u16 e status enu priority Incremental Write a DS with high priority Write a DS data invalid with high priority Format the Data Flash for EEPROM Clean up ring buffer to provide as much as possible prepared ring buffer space
81. ol handling is required the process checks the EEL pool for bit errors To do so the complete pool address range only active and prepared virtual blocks is checked HWd by HWd using the FDL bit error check function On detection of a bit error further Refresh and Prepare operations are triggered and by that sequentially all blocks are refreshed This is continued until the bit error is gone On invocation of a user operation the background processes are interrupted at the next possible state in order to execute the user processes After user process termination the background processes are continued When the Supervision process need not execute any pool operations beside bit error check the EEL driver status is set to idle Nevertheless the handler function shall be called regularly even with lower frequency e g 10ms task in order to execute the bit error checks This need to be considered too when the library is executed in the Flash interrupt context RO1AN1035ED0100 Rev 1 0 RENESAS 28 Application Note EEPROM Emulation Library EEL Design 3 5 Error and warning levels Due to the case that errors may happen in cause of user activated processes e g write read format or automatic handled background processes prepare refresh supervision the error return to the user and the complete system reaction on the errors must be clearly defined The error reaction is classified in the 5 3 1 Error Codes e Warnings e
82. on programs showing the implementation of the libraries and the usage of the library functions The different options of setup and usage of the libraries are explained in detail in this document 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 www renesas eu update RO1AN1035ED0100 Rev 1 0 RENESAS 10 Application Note EEPROM Emulation Library Architecture Chapter 2 Architecture 2 1 Flash Infrastructure 2 1 1 Complementary Read Flash Based on the different application needs the Flash implementation used for Data Flash differs from the Code Flash implementation In order to achieve the required high endurance erase cycles Renesas decided for a Complementary Read CR Flash implementation on Data Flash Each data bit is realized by two Flash cells which are programmed to the opposite direction da
83. ons may be processed the device should not be switched off in this status in order to avoid repair operations to be executed on EEL startup 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 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 RENESAS al EEPROM Emulation Library User Interface API done immediately the application need to wait until the suspend status is set Access status During Startup the full functionality of the EEPROM emulation is not given It is increased step by step depending on the proceeding of the Startup flow 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 ACCESS LOCKED During Startup The state machine is in an early startup phase and so does not accept any user operation During normal operation Due to a failure no more data access is possible ACCESS READ WRITE During Startup only The state machine proceeded further in the start
84. ons of revisions and additions It does not list all revisions Refer to the text of the manual for details List of Abbreviations and Acronyms Abbreviation Full Form API Application Programming Interface Area of Flash consists of several coherent Flash Flash Area Blocks Code Flash Embedded Flash where the application code or constant data is stored CR Complementary Read Data Flash Embedded Flash where mainly the data of the EEPROM emulation are stored Data Set Instance of data written to the Flash by the EEPROM Emulation Library EEL identified by the Data Set ID DS Short for Data Set Dual Operation Dual operation is the capability to access flash memory during reprogramming another flash memory range Dual operation is available between Code Flash and Data Flash Between different Code Flash macros dual operation depends on the device implementation ECC Error Correction Code EEL EEPROM Emulation Library EEPROM Electrically erasable programmable read only memory EEPROM emulation In distinction to a real EEPROM the EEPROM emulation uses some portion of the flash memory to emulate the EEPROM behaviour To gain a similar behaviour some side parameters have to be taken in account FAL Flash Access Library Flash access layer FDL Data Flash Library Data Flash access layer Electrically erasable and programmable nonvolatile Flash me
85. plementation into the user application 73 6 1 Fifst Sau ut 73 6 1 7 Application sample 1 ctc ceesseececte cove cues seccctereevensssteuececesevdvesssunseatecereess 73 6 2 Standard EEL life cycle uuu u 73 6 2 1 Device start p idee Ete Ite S gaa 74 6 2 2 Device normal 77 6 2 3 Device DoWet A Sa uq ass aAa 78 6 3 Special considerations 2 22 2228 79 6 31 calculations i tien nce reden reo ui eet eere a IEEE ra 79 6 3 2 Data Flash initialization 1 eicere C ener D nen nena 79 6 3 3 Library handling by the user application eee 81 6 3 4 Concurrent Data Flash 82 6 3 5 Entering power safe mode U U nennen nennen nenne nennen nn 83 6 3 6 Library behaviour after operation 83 6 3 7 Application update u nennen nnne t 84 6 3 8 Device performance during active Flash
86. pplication Note EEPROM Emulation Library Clean bat Implementation Batch file to clean the application sample Makefile Makefile that controls the build and clean process root device name gt lt compiler gt sample EELApp Main c Main source code EELApp Control c EEPROM emulation sample code target h target device and application related definitions device header files df lt device number gt h GHS df device number gt _irq h io macros v2 h io 70f device number gt h io macros h Ixx h cfi h start up file GHS DF dev num startup 850 107 585 cstartup s85 IAR REC cstart asm linker directive file GHS df lt dev num gt ld IAR Ink70f lt dev num gt xcl REC df lt dev num gt dir root lt device name gt lt compiler gt sample FDL FDL h Header file containing function prototypes of the library user interface FDL_Types h Header file containing calling structures and error enumerations of the library user interface FDL_Descriptor h Descriptor file header with the run time FDL configuration To be edited by the user FDL_Descriptor c Descriptor file with the run time FDL configuration Using the defines of FDL_Descriptor h Should not be edited by the user FDL_User c Library related functions which may be edited by the user FDL Cfg h Hea
87. process REF zone search In order to be able to read data without initialized RAM table the library provides another read data search mechanism The library can parse the REF zone of the blocks and read the entries sequentially until an entry with the requested ID is found It needs to be considered that the REF zone parsing requires some time and 10096 CPU load This search mechanism is called REF zone search The REF zone search is used in the library startup phase when the RAM table is not yet initialized and also in special library operation modes see next sub chapter RENESAS 30 EEPROM Emulation Library 3 7 Start up processing EEL Design The start up processing is controlled by the EEL state machine After library initialization and start up invocation see EEL Startup function API several start up process steps are executed until the system is in normal operation Along with the start up progress the access rights to the data and the library features are unlocked and the full performance of the EEL is reached The start up progress can be checked by the user application with the function EEL GetDriverStatus which returns the access status and the operational status Please check the next figure for the status values depending on the progress Start up access status operational status comment progress EEL Initialized EEL ACCESS EEL_OPERATION All library operations LOCKED _PASSIVE are pre
88. quest N E Y Power Y down EEL ShutDown phase a System Passive p TW 4 Device Power Down k EEL life cycle 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 Device start up The device boots and the application start up Usually very soon some data sets need to be read Then the EEPROM emulation has some time to come up completely before the rest of the data need to be read e g build up a RAM mirror and written RENESAS ra EEPROM Emulation Library EEL Implementation into the user application The example code below reads and writes data as soon as possible and then waits until the EEL is fully operational and unlocked u08 buffer au08 0x100 eel request t Stry eel driver status t dStat eel status t res Initialize the EEL eel RTConfiguration str should have been set in EEL Des
89. rd Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems safety equipment and medical equipment not specifically designed for life support Specific Aircraft aerospace equipment submersible repeaters nuclear reactor control systems medical equipment or systems for life support e g artificial life support devices or systems surgical implantations or healthcare intervention e g excision etc and any other applications or purposes that pose a direct threat to human life You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and ma
90. riority Required parameters from the request structure o identifier u16 ID to invalidate 0 RENESAS 62 EEPROM Emulation Library User Interface API o command enu EEL CMD INVALIDATE for the Invalidation operation Parameter checks resulting in return value EEL ERR PARAMETER o Unknown ID e Write Immediate Writing data from a user defined address into a new DS instance identified by an ID This is done with high priority resulting in suspending an eventually ongoing DS write invalidate with normal priority Later on the normal priority operation is resumed Required parameters from the request structure o identifier u16 ID to write o address u32 source buffer address o command enu EEL WRITE for the Write operation Parameter checks resulting in return value EEL ERR PARAMETER o Unknown ID e Write Incremental Immediate Writing data from a user defined address buffer into a new DS instance identified by a given ID The data write is only executed when the given data in the write buffer differs from the data of the last DS instance in the EEL pool If the data equals the operation is successfully finished without data write operation This is done with high priority resulting in suspending an eventually ongoing DS write invalidate with normal priority Later on the normal priority operation is resumed Required parameters from the request structure o identifier u16
91. rwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information When exporting the products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations You should not use Renesas Electronics products or the technology described in this document for any purpose relating to military applications or use by the military including but not limited to the development of weapons of mass destruction Renesas Electronics products and technology may not be used for or incorporated into any products or Systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations Renesas Electronics has used reasonable care in preparing the information included in
92. s DSs As the concept is derived from the EEL 05 used for UX6LF Flash based devices with 2kB Flash block size also the 06 library merges the physical Flash blocks together to virtual Flash blocks of 2kB which are managed by the EEL The transition from physical to virtual blocks is done within the EEL near to the FDL interface As the FDL API handles physical blocks an EEL internal low level routine converts the virtual blocks to physical blocks before calling the FDL to execute Flash erase The complete EEL works on virtual blocks 2 6 3 Virtual block structure The virtual Flash blocks are used as a kind of ring buffer The below picture considers a write pointer staying fix while the ring buffer rotates clockwise Every block reaching the write pointer gets activated This block is called the active zone head When a block reaches the end of the active zone it is called the active zone tail Before getting activated again the block is prepared Each virtual block will pass a complete life cycle on every ring buffer loop RO1AN1035ED0100 Rev 1 0 RENESAS 15 Application Note EEPROM Emulation Library Architecture Figure 2 3 Logical ring Under erasing Y Y Active pool Passive pool containing actual and old data Write pointer waiting for new data last I physical Physical 125 Flash erasing 1 51 physical block Basic ring buffer structure R01AN1035ED0100 Rev 1 0 RENESAS 16 Applica
93. s calls the usage of the FDL functions can be derived from that Overview The following picture contains the library and application related files F 9 ure 4 1 Libray API declaration Describtors User Passed to the library Source Code Application Precompiled Library Source Code Library Library Configuration Library Files Fix may not be touched by the user Library pre compile configuration Only on souce code delivery File name fix File content user configurable Ems Application User Code Completely in the hand of the user Library and application file structure 22 7 EEPROM Emulation Library Implementation 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 des
94. s found in the configuration the error EEL ERR CONFIGURATION is returned RO1AN1035ED0100 Rev 1 0 RENESAS 54 Application Note EEPROM Emulation Library User Interface API e RAMor ROM table pointer pointing to 0 e AnyID entry 0 or OXFFFF e Max DS length exceeded Threshold must be gt 2 blocks and at least 2 blocks must remain between threshold and EEL pool size e Max DS size must be lt PFct Calc BlkSpace REF entry size On check fail the startup processing is locked and user operations will never be unlocked Pre conditions EEL initialization is not possible when Flash operations are active So FAL Init need to be called before EEL Init may be called In between no Flash operations may be started On violation the function ends with EEL ERR ACCESS LOCKED Post conditions None Example eel rtConfiguration is configured globally in EEL Descriptor c ret EEL Init eel rtConfiguration EEL OPMODE FULL if EEL OK ret Error treatment 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 eel status t EEL Startup void Arguments None RO1AN1035ED0100 Rev 1 0 RENESAS 55 Application Note EEPROM Emulation Library User Int
95. s jou si eu 1 20 sew 51 uoiuw v eun seu eser use eur jeu os 143 eui Ajuo M euoN 133 ayy q s ay Inun jejunoo 241 se IIeus sIUL e 10 peyejduuoo eq jou pjnoo esee Jey ueyjo puedsns ese13 puadsns uonejedo eseje e oj pue 5 s pee V peusiuy seu jueunouoo y jeedes 1001 pue WOHd33 dois juang Juang Jo 133 lt 133 joujnq Qvas 133 lt 133 uone1edo jueunouoo e sng 15 s ejejs eq pjnous uonejedo y 1s nb 1 y u uoneorddy gt 133 eui passed ueeq suajawesed esneo 001 y pue uone nuie WONd33 9015 pezyjeniui you uei 941
96. sh the upper application can continue operation while frequently invoking the state machine handler function 3 2 Flash interrupt support The EEL is prepared to support the Flash interrupt This means that the EEL triggers the Flash interrupt when the handler function shall be called in order to process a next EEL process state By that the handler function can be executed in the Flash interrupt context or in an interrupt triggered task which means as few as possible handler function calls no polling by achieving the best EEL performance Basically each Flash operation end triggers the Flash interrupt However quite some EEL state machine internal states User operations as well as background processes don t issue a Flash operation In order to support the Flash interrupt in a sufficient way these states must issue the Flash interrupt by SW This can be achieved by the EEL configuration See 5 1 Pre compile configuration Note Even when the EEL is idle the handler function shall be called regularly in order to execute idle time supervision tasks like bit error check See 3 4 Background operations As for that the handler shall not be called with high frequency e g 10ms 100ms task the user application need to trigger the interrupt by SW 3 3 EEL user operations priority The EEL provides the following user operations which are invoked by appropriate commands Immediate DS Write Immediate DS Invalidate DS Write DS Invali
97. sult 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 be requested at the RENESAS Flash support under mailto application support flash eu Im renesas com 6 3 2 Data Flash initialization Before being able to normally use the Data Flash for EEPROM emulation the Flash must be formatted and depending on the application be filled with initial data set instances This can be done using different approaches Often used ones are e 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 Aserial 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 e naself 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 e Dumping the Flash content of an already formatted Data Flash to a hex file using a serial
98. ta bit The cell value difference is read to judge the data value Data bit Flash cell 1level Flash cell 2 level 0 high low 1 low high Resulting from the implementation erased Flash both Flash cells with same similar level has a very small differential level The resulting data bit judgement has an undefined result but with a tendency to formerly written data This need to be considered on interpretation of the read values e The lower level library FDL provides a blank check to distinguish between erased and written Flash on read level not exact electrical margins please refer to the FDL UM e The EEL handles this CR behaviour of erased cells in the library concept e When inspecting the Data Flash contents e g using a debugger the debugger need to provide the information on the Flash status erased written 2 1 2 Dual operation Note Common for all Flash implementations is that during Flash modification operations Erase Write a certain amount of Flash memory is not accessible for any read operation e g program execution or data read This does not only concern the modified Flash range but a certain part of the complete Flash system The amount of not accessible Flash depends on the device architecture A standard architectural approach is the separation of the Flash into Code Flash and Data Flash By that it is possible to read from the Code Flash to execute program code or read data while Data Flash is modifi
99. terministic also the emulation performance might not be deterministic enough RO1AN1035ED0100 Rev 1 0 RENESAS 65 EEPROM Emulation Library User Interface e Advantages Usually high emulation performance No blocking of other user application operations Disadvantages Not always deterministic e Asynchronous to EEL operation invocation by EEL Execute in a timed task By calling in a timed task a deterministic performance can be reached However as the Flash operations execution Flash Write usually require less than 500us for best possible performance the handler should be called in very short time slices As these are usually not available the performance of the emulation decreases Advantages Deterministic Disadvantages Lower emulation performance e Synchronous with EEL operation invocation by EEL Execute The handler is called in the same function context as EEL Execute The handler call is repeated in this function in a loop until the EEL operation has finished Advantages Highest performance Disadvantages function execution time is high and not deterministic e Inthe Flash interrupt context The handler is called in the Flash intrrupt context In that case the function is not polled but exactly called when required to finish a user or background operation Therefore the library must be configured to support the Flash interrupt See 5 1 Pre compile configuration Advantages H
100. this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein Renesas Electronics products are classified according to the following three quality grades Standard High Quality and Specific The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application categorized as Specific without the prior written consent of Renesas Electronics Further you may not use any Renesas Electronics product for any application for which it is not intended without the prior written consent of Renesas Electronics Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as Specific or for which the product is not intended where you have failed to obtain the prior written consent of Renesas Electronics 10 11 12 13 The quality grade of each Renesas Electronics product is Standard unless otherwise expressly specified in a Renesas Electronics data sheets or data books etc Standa
101. tion Note Architecture EEPROM Emulation Library 2 6 4 Block lifecycle The life cycle of a block passes different steps which are largely marked inside the block header in specific half words The active state and the occupied state are not explicitly distinguished by block header information They all have the active marker set Anyhow inside the library only the latest block containing required data not full the write pointer points into this block contains the active status All other blocks containing required data are full and so are treated internally occupied The consumed blocks blocks under erasing or other blocks with undefined state due to power fail are considered as invalid and are all treated in the same way by the library They enter the preparation phase in the next life cycle and are then prepared In case of an erase fail the affected Flash block is considered to be defect and is so marked excluded This block will not enter the lifecycle again Section header Figure 2 4 Block Lifecycle 1 Active Em Invalid Under erasing Excluded Block Lifecycle RO1AN1035ED0100 Rev 1 0 RENESAS 17 Application Note EEPROM Emulation Library Architecture 2 6 5 Internal block structure Every Flash block of the logical ring buffer contains 3 areas While the block header size is fix the data zone and the Reference REF zone grow towards each other A block is full a
102. tr status enu Error handler u32 amp buffer au08 10u EEL CMD WRITE Wait until operation end req str status enu if EEL OK req str status enu 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 RO1AN1035ED0100 Rev 1 0 Application Note RENESAS 77 EEPROM Emulation Library EEL Implementation into the user application Figure 6 2 Request state 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 Operations state diagram The handler call frequency significantly determines the EEL performance As long as the driver or request state is busy the handler should be called with higher frequency When the driver state is idle the call frequency can be reduced as then only cyclical bit error checks are done by the EEL Then on each handler call one Flash HWd is checked 6 2 3 Device power down On power down the user application should give the library time to finish background operations which are under progress This can be reached by using the service functions in the following way Wait until all background pr
103. up 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 10096 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 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 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 e State machine errors Error values of the state machine are returned Only background process errors are considered Please refer to the error description 5 3 1 Error Codes and the handler function description 5 4 3 Operational functions for details Note The user application needs to check the driver status and react on it when necessary When a user operation ends with EEL ERR ACCESS LOCKED th
104. update the DCS indicates a possible DS length change to the user application e EORO End of Reference 0 are the last written HWds of a DS When EORO pattern is correct it is ensured that the previously written REF entry part and data are written correct e EOR1 End of Reference 1 Additional safety for the case of data set write interruptions At the end of the startup phase EOR1 is checked for each DS and on not available or invalid EOR1 the DS is refreshed to ensure the electrical margin of the complete DS 2 7 4 2 Invalidated DS One requirement is to provide a possibility to invalidate the last DS instance of a certain ID Sample use case When activating a window lifter the last stored window position is invalidated then the lifter is turned on At the end when the lifter stops the new position is written Invalidation is realized by a special kind of REF entry The widx entry is set to zero and no data is written in the data zone A later on Read on this ID will return an error EEL ERR INSTANCE to indicate this non existing data Application Note 21 NE SAS EEPROM Emulation Library EEL Design Chapter 3 EEL Design 3 1 Asynchronous architecture 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 Fla
105. vented EEL startup EEL ACCESS EEL_OPERATION All library operations started _LOCKED _STARTUP are prevented DS Read is possible with limited EEL startup EEL ACCESS performance REF ongoing READ WRIT EEL OPERATION zone search basic startup E _ STARTUP n finished DS Write is possible until the prepared blocks are full DS Read is possible with full performance EEL startup ROM table search ongoing EEL ACCESS OPERATION WE RAM table UNLOCKED STARTUP DS Write is possible filled and supervision processing is active to manage the ring buffer EEL OPERATION BUSY or DLE pe Read and DS EEL startup EEL ACCESS depending if Electrical in of end UNLOCKED Refresh Prepare 7 0188 Margin o the latest DS instances operations are to is ehsured be done Note Startup process progress steps 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 The last startup processing step Ensure the electrical margin of the latest DS instances checks if the valid DS instances have been completely written Therefore it checks if the last step of a DS write was executed EOR1 is written If not redundant information valid EORO ensures that the DS data is valid On detection of such cases the DS is refreshed copied to active zone head R01AN1035ED
106. which allows threshold optimization during run time IDLTab pau16 Pointer to ROM ID L table See chapter 3 6 1 ID L and IDX tables The ID L table need to be defined as a 2 dimensional array of 16bit values as follows 1D1 size 1 102 size 2 103 size 3 Value range ID Min 1 ID Max OxFFFE Size min 1Byte Size max Block size Block header size REF zone size 2 2048 36 14 2 1996 Bytes this is caused by the EEL implementation Bigger data size would require significant overhead in the power fail and supervision concepts IDXTab pau16 Pointer to ROM ID X table See chapter 3 6 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 Application Note 2 NE SAS EEPROM Emulation Library User Interface IDLTabldxCnt u16 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 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
107. y is very big In order to overcome this situation the new EEL concept uses a RAM table to store the latest DS instance So the read access performance will be significantly increased The startup worst case performance is significantly improved regarding the V850 MF2 UXA implementation as the DS management does no longer need to overwrite data and refresh complete sections 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 RO1AN1035ED0100 Rev 1 0 RENESAS 14 Application Note EEPROM Emulation Library Architecture 2 6 2 6 1 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 EEL Flash management Physical vs virtual address range To simplify function parameter passing between the FAL and the EEL the physical space used to directly access the device is transformed into a linear address room starting from 0x00000000 FDL address range This should save space in the reference area of the EEPROM driver when writing new instance references Also the protection mechanisms can be implemented in a more effective way 2 6 2 Physical vs virtual Flash blocks The EEL concept relies on Flash blocks of a reasonable size to store block management data and Data Set
108. y the handler execution time will be below 100us However the data read from Flash itself together with the checksum calculation need some time So the time can increase 100us by DS sizes gt 32 Bytes Application Note 2 NE SAS EEPROM Emulation Library EEL Design 3 8 2 2 Immediate Write Immediate Incremental Write Immediate Invalidation command The normal operation Immediate Write and Immediate Invalidation sequence does not differ to the early Immediate Write Invalidation So please refer to this description 3 8 2 3 Write Incremental Write Invalidation command The normal operation Write Invalidation sequence does not differ to the early Write Invalidation So please refer to this description 3 8 2 4 Format command The Format command is considered as an exclusive command and can only be executed if the background state machine is EEL OPERATION IDLE or EEL OPERATION PASSIVE So invocation by EEL Execute is rejected until this state is reached Operation invocation latency The operation is invoked without latency as no other operations are ongoing EEL Handler execution time The handler execution time will be below 100us 3 8 2 5 Cleanup command The Cleanup command is considered as an exclusive command and can only be executed if the background state machine is EEL OPERATION IDLE So invocation by EEL Execute is rejected until this state is reached Operation invocation latency The operation is invo
109. ype Argument Description Result of the function Possible eel status t None ale EEL OK EEL ERR ACCESS LOCKED Pre conditions e library must be suspended 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 Operational functions 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 e Read Read a DS or a fraction of the DS from the Data Flash to a user defined buffer address The DS is identified by the ID The offset from the DS start and the number of bytes to read can be specified Required parameters from the request structure RO1AN1035ED0100 Rev 1 0 RENESAS 61 Application Note EEPROM Emulation Library RO1AN1035ED0100 Rev 1 Application Note User Interface o identifier u16 ID to read
Download Pdf Manuals
Related Search
Related Contents
KitchenAid 30" Electric Freestanding Range User's Manual DBR-S400F Liebherr FK 2642 Da-Lite Advantage Deluxe Electrol Philips SPF5010 digital photo frame Guide d`instruction (30 ko, PDF) ERSSTOCK INVENTORY SOFTWARE FOR PC USER GUIDE OPERATING MANUAL Copyright © All rights reserved.
Failed to retrieve file