Renesas FSL-T06 User Manual
Renesas FSL-T06 User Manual

Renesas FSL-T06 User Manual

Flash self-programming library

Advertisement

Quick Links

Flash Self-Programming
Library
32
FSL - T06
Flash Self-Programming 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).
www.renesas.com
R01US0046ED, Rev. 1.01
Mar 19, 2013

Advertisement

Table of Contents
loading

Summary of Contents for Renesas FSL-T06

  • Page 1 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.
  • Page 2 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.
  • Page 3 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.
  • Page 4 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: ...
  • Page 5 Preface Readers This manual is intended for users who want to understand the functions of the concerned libraries. Purpose This manual presents the software manual for the concerned libraries. Organization This document describes the following sections:  Architecture  Implementation and Usage ...
  • Page 6 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.
  • Page 7 E.g. Flash memory, EEPROM, MRAM... “Random access memory” - volatile memory with random access Renesas Electronics Europe GmbH Renesas Electronics Japan “Read only memory” - nonvolatile memory. The content of that memory can not be changed.
  • Page 8: Table Of Contents

    Table of Contents Chapter 1 Introduction ................. 9 Flash versus EEPROM .................. 10 Dual Operation ....................10 Chapter 2 FSL Architecture..............11 Chapter 3 FSL Implementation ............12 File structure ....................12 3.1.1 Overview ..........................12 3.1.2 Delivery package directory structure and files ..............13 FSL Linker sections ..................
  • Page 9: Chapter 1 Introduction

    This user’s manual describes the internal structure, the functionality and software interface (API) of the Renesas V850 Flash Self-Programming Library (FSL) type T06. The library type T06 is suitable for all Renesas V850 Flash based on the RC03F Flash technology.
  • Page 10: Flash Versus Eeprom

    Flash Self-Programming Library Introduction 1.1 Flash versus EEPROM Major difference between Flash and EEPROM (or E PROM) is the reprogramming granularity. EEPROM can be reprogrammed wordwise, where the size of one word depends on the organization and interface. It can vary in the wide range between 8 bit and 256 bytes.
  • Page 11: Chapter 2 Fsl Architecture

    Flash Self-Programming Library FSL Architecture Chapter 2 FSL Architecture This chapter describes the function of all blocks belonging to the Flash Self- Programming System. Even though this manual describes the functional block FSL, a short description of all concerned functional blocks and their relationship can be beneficial for the general understanding.
  • Page 12: Chapter 3 Fsl Implementation

    Flash Self-Programming Library FSL Implementation Chapter 3 FSL Implementation 3.1 File structure The library is delivered as a complete compilable sample project which contains the FSL and in addition an application sample to show the library implementation and usage in the target application. The application sample initializes the FSL and does some dummy data set Erase and Write operations.
  • Page 13: Delivery Package Directory Structure And Files

    Flash Self-Programming Library FSL Implementation In case of source code delivery, the library must be configured for compilation. The file FSL_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. Caution Wrong configuration of the FSL might lead to undefined results.
  • Page 14 Flash Self-Programming Library FSL Implementation [root]\ [<device name>]\[<compiler>]\[sample] Main.c Main source code target device and application related target.h definitions df<device number>.h df<device number>_irq.h io_macros_v2.h device header files io_70f< device number>.h io_macros.h lxx.h cfi.h startup file l07.s85 cstartup.s85 df<dev. num.>.ld linker directive file lnk70f<dev.
  • Page 15: Fsl Linker Sections

    Flash Self-Programming Library FSL Implementation 3.2 FSL Linker sections The following sections are Flash Self-Programming Library related. FSL data sections  FSL_DATA This section contains the variables required for FSL. It can be located either in internal or in external RAM. FSL code sections ...
  • Page 16: Chapter 4 Fsl Usage

    In most cases application software contains important intellectual property and/or data that may not be distributed to others or manipulated by others. In order to ensure Flash data integrity and to prevent unintended data read-out, Renesas implements a set of features and mechanisms into Flash devices.
  • Page 17: Configuration Options

    Flash Self-Programming Library FSL Usage By the programmer interface In order to disable this feature, the commands Flash Write and Flash Block Erase can be disabled (see chapter 4.1.2 Configuration options for details). By doing so, Flash writing via this interface is only possible after erasing the complete Flash. Illegal or accidental reprogramming of Flash For many applications protection against the illegal Flash read-out is already sufficient.
  • Page 18: Flash Safety

    Flash Self-Programming Library FSL Usage  Program command disable (Programmer interface) Writing to the Flash via programming interface is disabled. It does not affect Self-Programming (see FSL_SetWriteProtectFlag).  Block Erase command disable (Programmer interface) Erasing single blocks via programming interface is disabled. It does not affect Self-Programming.
  • Page 19: Hardware Protection

    Flash Self-Programming Library FSL Usage 4.2.1 Hardware Protection Device Reprogramming is disabled if FLMD0 Pin is low. By using a port pin or an external logic FLMD0 must be set to “1” to allow Self-Programming. Additionally reprogramming can be enabled by a register if supported by the device. Please refer to the device user manual for further details.
  • Page 20 Flash Self-Programming Library FSL Usage  Safe Self-Programming without bootloader update  Safe Self-Programming with bootloader update Safe Self-Programming without bootloader update The easiest way of safe Self-Programming is to occupy some complete Flash blocks for the bootloader and do not reprogram them again. By that it never happens, that an interruption of the reprogramming (e.g.
  • Page 21: Code Execution In Ram

    Flash Self-Programming Library FSL Usage Two methods are implemented in the Library to swap the boot cluster. 1. Swap the boot cluster only temporary. The boot cluster will be unswapped again after a device reset. For details, please refer to FSL_ChangeSwapState.
  • Page 22: User Code Execution During Self-Programming

    Flash Self-Programming Library FSL Usage Internal mode  FSL_CODE_RAM_USRINT  FSL_CODE_RAM_USR  FSL_CODE_RAM  FSL_CODE_EX_PROT For further information regarding the linker sections please refer to chapter 3.2 “FSL Linker sections” Caution Beside the mentioned sections, Self-Programming needs additional 4kByte of RAM located on the top of the RAM. These RAM addresses are reserved for the internal firmware.
  • Page 23: Interrupts In Ram

    Flash Self-Programming Library FSL Usage This sequence is best for devices with sufficient internal RAM. User code execution is always possible during Self-Programming, because a Flash operation is just initiated by the FSL command. While the FSL returns control to the user application, the Flash operation is executed in background.
  • Page 24: Dual Cpu Operation

    Flash Self-Programming Library FSL Usage Regardless which method is used, interrupt service routines have to be executed from and therefore copied to RAM. For details how to copy the routines to RAM, please refer to chapter 4.3 “Code execution in RAM”. Note Further information about interrupt handling from RAM can be found in the device user manual and in the CPU architecture description (see “V850E2R-V3...
  • Page 25: User Interface (Api)

    Flash Self-Programming Library User Interface (API) Chapter 5 User Interface (API) 5.1 Pre-compile configuration The pre-compile configuration of the FSL is located in the FSL_cfg.h. The user has to configure all parameters and attributes by adapting the related constant definition in that header-file. This file may also contain device or application specific defines.
  • Page 26: Data Types

    Flash Self-Programming Library User Interface (API) Internal mode (FSL_STATUS_CHECK_INTERNAL) Advantages:  no polling necessary  less RAM consumption Disadvantages:  more activation / deactivation time  no return to the application during Self-Programming  user code execution during Self-Programming only by interrupts For details refer to chapter 4.4 User code execution during Self-Programming.
  • Page 27: Library Functions

    Flash Self-Programming Library User Interface (API) 5.3 Library Functions Functions represent the application interface to the FSL which the user SW can use. Following list is an overview of all available functions (in alphabetic order).  FSL_CalcFctAddr  FSL_ChangeSwapFlag  FSL_ChangeSwapState ...
  • Page 28: Initialization

    Flash Self-Programming Library User Interface (API) 5.3.1 Initialization 5.3.1.1 FSL_Init Description Function is executed before any execution of other FSL function. It initializes internal Self-Programming environment and internal variables. Interface void FSL_Init( void ) Arguments None Return types / values None Pre-conditions None...
  • Page 29 Flash Self-Programming Library User Interface (API) Pre-conditions Library must be initialized (call function FSL_Init). Post-conditions None Example /* Copy FSL to internal RAM address 0xffff7000 */ FSL_CopySections( 0xffff7000 ); 5.3.1.3 FSL_CalcFctAddr Description Function calculates the new address of a function copied from ROM to RAM. To locate the new address of the function, the copied function must be located in on of the FSL linker segments (see chapter 3.2 “FSL Linker sections”).
  • Page 30 Flash Self-Programming Library User Interface (API) 5.3.1.4 FSL_FlashEnv_Activate Description Function initializes the Flash control macro and activates and prepares the Flash environment. Interface fsl_status_t FSL_FlashEnv_Activate( void ) Arguments None Return types / values Type Argument Description fsl_status_t Operation status when returned from function call: ...
  • Page 31 Flash Self-Programming Library User Interface (API) Interface fsl_status_t FSL_FlashEnv_Deactivate( void ) Arguments None Return types / values Type Argument Description fsl_status_t Operation status when returned from function call:  FSL_OK  FSL_BUSY  FSL_ERR_FLOW  FSL_ERR_FLMD0  FSL_ERR_INTERNAL Status check is performed internally by the firmware Status check is performed by the user Pre-conditions Library must be initialized (call function FSL_Init), copied (call function...
  • Page 32 Flash Self-Programming Library User Interface (API) E.g.: Fx4-L, Px4-L: Flash hardware  16MHz <= f <= mimimum of <100MHz> or <maximum device frequency> Caution: The CPU frequency must be set correctly. If not, malfunction may occur such as unstable Flash data without data retention, programming failure, operation blocking.
  • Page 33: Operation

    Flash Self-Programming Library User Interface (API) 5.3.2 Operation 5.3.2.1 FSL_Erase Description Function erases a range of blocks. Interface fsl_status_t FSL_Erase( fsl_u32 blockNoStart_u32, fsl_u32 blockNoEnd_u32 ) Arguments Type Argument Description fsl_u32 blockNoStart_u32 First block number to be erased. (It is not the block address, but the number of the Flash block.) fsl_u32 blockNoEnd_u32...
  • Page 34 Flash Self-Programming Library User Interface (API) Example /* Erase check block 3 to 20 */ fsl_status_t status_enu; status_enu = FSL_Erase( 3, 20 ); #if FSL_STATUS_CHECK == FSL_STATUS_CHECK_USER while( status_enu == FSL_BUSY ) status_enu = FSL_StatusCheck( ); #endif /* Error treatment */ 5.3.2.2 FSL_Write Description Function writes the specified number of words from a buffer to consecutive Flash...
  • Page 35 Flash Self-Programming Library User Interface (API) Pre-conditions Library must be initialized (call function FSL_Init), copied (call function FSL_CopySections) and active (call function FSL_FlashEnv_Activate). Additionally the library must be informed about FBUS clock by using function FSL_SetFrequency. Post-conditions In case of user mode call FSL_StatusCheck till function return value is different from FSL_BUSY.
  • Page 36 Flash Self-Programming Library User Interface (API)  FSL_ERR_FLOW  FSL_ERR_PARAMETER  FSL_ERR_INTERNAL fsl_u32 pDest Pointer to buffer filled with read data Status check is performed internally by the firmware Status check is performed by the user Pre-conditions Library must be initialized (call function FSL_Init), copied (call function FSL_CopySections) and active (call function FSL_FlashEnv_Activate).
  • Page 37: Security

    Flash Self-Programming Library User Interface (API)  FSL_BUSY  FSL_ERR_FLOW  FSL_ERR_ERASE  FSL_ERR_WRITE  FSL_ERR_INTERNAL Pre-conditions Library must be initialized (call function FSL_Init), copied (call function FSL_CopySections) and active (call function FSL_FlashEnv_Activate). Additionally the library must be informed about FBUS clock by using function FSL_SetFrequency.
  • Page 38 Flash Self-Programming Library User Interface (API) Return types / values Type Argument Description Function return values:  FSL_OK fsl_status_t  FSL_ERR_FLOW  FSL_ERR_PARAMETER Pointer to buffer filled with bit coded security information  x1xxxx : Read permission  x0xxxx : Read prohibition ...
  • Page 39 Flash Self-Programming Library User Interface (API) Return types / values Type Argument Description Function return values:  FSL_OK fsl_status_t  FSL_ERR_FLMD0  FSL_ERR_FLOW Pre-conditions Library must be initialized (call function FSL_Init), copied (call function FSL_CopySections) and active (call function FSL_FlashEnv_Activate). Additionally the library must be informed about FBUS clock by using function FSL_SetFrequency.
  • Page 40 Flash Self-Programming Library User Interface (API) Pre-conditions Library must be initialized (call function FSL_Init), copied (call function FSL_CopySections) and active (call function FSL_FlashEnv_Activate). Additionally the library must be informed about FBUS clock by using function FSL_SetFrequency. Post-conditions In case of user mode call FSL_StatusCheck till function return value is different from FSL_BUSY.
  • Page 41 Flash Self-Programming Library User Interface (API) Post-conditions In case of user mode call FSL_StatusCheck till function return value is different from FSL_BUSY. Example /* Set write protection */ fsl_status_t status_enu; status_enu = FSL_SetWriteProtectFlag( ); #if FSL_STATUS_CHECK == FSL_STATUS_CHECK_USER while( status_enu == FSL_BUSY ) status_enu = FSL_StatusCheck( );...
  • Page 42 Flash Self-Programming Library User Interface (API) Example /* Set boot cluster protection */ fsl_status_t status_enu; status_enu = FSL_SetBootClusterProtectFlag( ); #if FSL_STATUS_CHECK == FSL_STATUS_CHECK_USER while( status_enu == FSL_BUSY ) status_enu = FSL_StatusCheck( ); #endif /* Error treatment */ 5.3.3.6 FSL_SetReadProtectFlag Description Function enables read protection by setting the according protection flag.
  • Page 43 Flash Self-Programming Library User Interface (API) Example /* Set read protection */ fsl_status_t status_enu; status_enu = FSL_SetReadProtectFlag( ); #if FSL_STATUS_CHECK == FSL_STATUS_CHECK_USER while( status_enu == FSL_BUSY ) status_enu = FSL_StatusCheck( ); #endif /* Error treatment */ 5.3.3.7 FSL_GetFSW Description Function returns the start and the end block of the actual Flash shield window. Interface fsl_status_t FSL_GetFSW( fsl_u32 *pBlockNoStart_pu32, fsl_u32 *pBlockNoEnd_pu32 )
  • Page 44 Flash Self-Programming Library User Interface (API) Example /* Read Flash Shield Window range */ fsl_status_t status_enu; fsl_u32 blockStart_u32; fsl_u32 blockEnd_u32; status_enu = FSL_GetFSW( &blockStart_u32, &blockEnd_u32 ); /* Error treatment */ 5.3.3.8 FSL_SetFSW Description Function sets a new Flash shield window to protect the range of blocks from unwanted Flash operations.
  • Page 45: Administration

    Flash Self-Programming Library User Interface (API) Post-conditions In case of user mode call FSL_StatusCheck till function return value is different from FSL_BUSY. Example /* Set Flash Shield Window for block 2 up to block 3 */ fsl_status_t status_enu; status_enu = FSL_SetFSW( 2, 3 ); #if FSL_STATUS_CHECK == FSL_STATUS_CHECK_USER while( status_enu == FSL_BUSY ) status_enu = FSL_StatusCheck( );...
  • Page 46 Flash Self-Programming Library User Interface (API) customer specific version information Pre-conditions None Post-conditions None Example /* Read library version */ fsl_u08 *version_pu08; version_pu08 = FSL_GetVersionString( ); 5.3.4.2 FSL_GetDevice Description Function returns the device number to identify the used device. Interface fsl_status_t FSL_GetDevice( fsl_u32 *pDeviceNo_pu32 ) Arguments Type...
  • Page 47 Flash Self-Programming Library User Interface (API) Pre-conditions Library must be initialized (call function FSL_Init), copied (call function FSL_CopySections) and active (call function FSL_FlashEnv_Activate). Additionally the library must be informed about FBUS clock by using function FSL_SetFrequency. Post-conditions None Example /* Read device name */ fsl_u32 device_u32;...
  • Page 48 Flash Self-Programming Library User Interface (API) Example /* Read block count */ fsl_u32 cnt_u32; fsl_status_t status_enu; status_enu = FSL_GetBlockCnt( &cnt_u32 ); /* Error treatment */ 5.3.4.4 FSL_GetBlockEndAdd Description Function returns the end address of the specified block. Interface fsl_status_t FSL_GetBlockEndAdd( fsl_u32 blockNo_u32, fsl_u32 *pBlockEndAddr_pu32) Arguments Type...
  • Page 49 Flash Self-Programming Library User Interface (API) Example /* Read block end address of block 3*/ fsl_u32 addr_u32; fsl_status_t status_enu; status_enu = FSL_GetBlockEndAdd( 3, &addr_u32 ); /* Error treatment */ 5.3.4.5 FSL_GetSwapState Description Function reads the current swap status. Interface fsl_status_t FSL_GetSwapState ( fsl_u32 *pSwapState_pu32 ) Arguments Type Argument...
  • Page 50 Flash Self-Programming Library User Interface (API) 5.3.4.6 FSL_ChangeSwapState Description Function swaps the boot cluster 0 and boot cluster 1 physically without setting the boot flag. After reset the boot cluster will be activated regarding the boot flag. Interface fsl_status_t FSL_ChangeSwapState( void ) Arguments None Return types / values...
  • Page 51 Flash Self-Programming Library User Interface (API) Arguments Type Argument Description fsl_u32 pSwapFlag_pu32 Pointer to buffer of read swap flag Return types / values Type Argument Description Function return values:  FSL_OK fsl_status_t  FSL_ERR_FLOW  FSL_ERR_PARAMETER Pointer to buffer filled with current value of the boot swap flag: fsl_u32 pSwapFlag_pu32...
  • Page 52 Flash Self-Programming Library User Interface (API) Return types / values Type Argument Description fsl_status_t Operation status when returned from function call:  FSL_OK  FSL_BUSY  FSL_ERR_PROTECTION  FSL_ERR_FLOW  FSL_ERR_INTERNAL  FSL_ERR_WRITE Status check is performed internally by the firmware Status check is performed by the user Pre-conditions Library must be initialized (call function FSL_Init), copied (call function...
  • Page 53 Flash Self-Programming Library User Interface (API) Return types / values Type Argument Description Function return values:  FSL_OK fsl_status_t  FSL_ERR_FLOW  FSL_ERR_PARAMETER Pointer to buffer filled with boot cluster size in number of blocks. size_u32 Boot Boot Block Swap Cluster size Cluster fsl_u32...
  • Page 54 Flash Self-Programming Library User Interface (API) Arguments Type Argument Description fsl_u32 size_u32 Boot cluster size (range: 0x00-0xE3) size_u32 Boot Boot Block Swap Cluster size Cluster size 0x00 32KB 32KB 0x01 64KB 64KB 0x02-0x03 96-128KB 128KB 0x04-0xE3 160-7296KB 256KB Return types / values Type Argument Description...
  • Page 55 Flash Self-Programming Library User Interface (API) 5.3.4.11 FSL_GetID Description Function reads the current ID data information (12 bytes). Interface fsl_status_t FSL_GetID( fsl_u08 *pID_pu08 ) Arguments Type Argument Description fsl_u08 pID_pu08 Pointer to buffer of read ID Return types / values Type Argument Description...
  • Page 56 Flash Self-Programming Library User Interface (API) Arguments Type Argument Description fsl_u32 pID_pu32 Pointer to source data of ID Return types / values Type Argument Description fsl_status_t Operation status when returned from function call:  FSL_OK  FSL_BUSY  FSL_ERR_PARAMETER  FSL_ERR_FLOW ...
  • Page 57 Flash Self-Programming Library User Interface (API) Interface fsl_status_t FSL_GetOPB( fsl_u08 *pOPB_pu08 ) Arguments Type Argument Description fsl_u08 pOPB_pu08 Pointer to buffer of read option byte Return types / values Type Argument Description Function return values:  FSL_OK fsl_status_t  FSL_ERR_FLOW ...
  • Page 58 Flash Self-Programming Library User Interface (API) Return types / values Type Argument Description fsl_status_t Operation status when returned from function call:  FSL_OK  FSL_BUSY  FSL_ERR_PARAMETER  FSL_ERR_FLOW  FSL_ERR_INTERNAL  FSL_ERR_WRITE Status check is performed internally by the firmware Status check is performed by the user Pre-conditions Library must be initialized (call function FSL_Init), copied (call function...
  • Page 59: Chapter 6 Integration Into The User Application

    Flash Self-Programming Library Integration into the user application Chapter 6 Integration into the user application 6.1 First steps It is very important to have theoretic background about the Code Flash and the FSL in order to successfully implement the library into the user application. Therefore it is important to read this user manual in advance.
  • Page 60 Flash Self-Programming Library Integration into the user application Device reprogramming in user mode Figure 6-1 Start reprogramming FSL_Init Initialization phase FSL_CopySections FSL_FlashEnv_Activate FSL_SetFrequency FSL_StatusCheck == FSL_BUSY ? FSL_Erase Normal operation FSL_StatusCheck == FSL_BUSY ? Error == FSL_OK ? Error treatment Fill buffer FSL_Write FSL_StatusCheck ==...
  • Page 61: Special Considerations

    Flash Self-Programming Library Integration into the user application Device reprogramming in internal mode Figure 6-2 Start reprogramming FSL_Init Initialization phase FSL_CopySections FSL_SetFrequency Normal FSL_Erase operation Error == FSL_OK ? Error treatment Fill buffer FSL_Write Error == FSL_OK ? Error treatment All data written ? Deactivation FSL_FlashEnv_Deactivate...
  • Page 62 Flash Self-Programming Library Integration into the user application Code Flash access during Self-Programming Code Flash accesses during an active Self-Programming Environment are not possible at all. The user application needs to be executed from other memory during that time. Please refer to chapter 4.4 “User code execution during Self- Programming”...
  • Page 63 Flash Self-Programming Library Integration into the user application Revision History Chapter Page Description Rev 1.00 Initial version Rev 1.01 Updated frequency setting description R01US0046ED Rev. 1.01 User Manual...
  • Page 64 Flash Self-Programming Library R01US0046ED...

Table of Contents