Renesas Technology America, Inc. Flash!. CPU Rewrite CPU-rewrite is a term that refers to an Renesas MCU’s ability to erase/program its own internal Flash.

Slides:



Advertisements
Similar presentations
Part IV: Memory Management
Advertisements

Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Memory Management Unit
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
Memory Management (II)
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
FreeRTOS.
Renesas Technology America Inc. 1 M16C/Tiny SKP Tutorial 2 Creating A New Project Using HEW4.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose:  This training module provides a technical description of Renesas.
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
Chapter 1: Introduction. 1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 1: Introduction What Operating Systems Do (previous.
1-1 NET+OS Software Group Flash API Multiple flash memory bank support New Flash API introduction Detailed Flash API Function presentation Supporting.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This course provides an overview of the CPU architecture.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Interrupts By Ryan Morris. Overview ● I/O Paradigm ● Synchronization ● Polling ● Control and Status Registers ● Interrupt Driven I/O ● Importance of Interrupts.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using Virtual EEPROM and Flash API for.
CE Operating Systems Lecture 14 Memory management.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Implementing Bootloaders on Renesas MCUs.
S4525A Peripherals & Enhanced FLASH 1 © 1999 Microchip Technology Incorporated. All Rights Reserved. S4525A Peripherals & Enhanced FLASH 1 Peripherals.
RL78 Code & Dataflash.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
PLC ARCHITECTURE – Memory 1 by Dr. Amin Danial Asham.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
Renesas Technology America Inc. 1 M16C Seminars Lab 3 Creating Projects Using HEW4 14 March 2005 M16C Seminars Lab 3 Creating Projects Using HEW4 Last.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
EFLAG Register of The The only new flag bit is the AC alignment check, used to indicate that the microprocessor has accessed a word at an odd.
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This course provides an introduction to the peripheral functions.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course demonstrates the Project Generator function.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Chapter 11 System Performance Enhancement. Basic Operation of a Computer l Program is loaded into memory l Instruction is fetched from memory l Operands.
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
Fundamentals of Computer Engineering
Chapter Objectives In this chapter, you will learn:
Chapter 2 Memory and process management
Memory COMPUTER ARCHITECTURE
Process Management Process Concept Why only the global variables?
Background on the need for Synchronization
Chapter 2: System Structures
Chapter 8: Main Memory.
Memory chips Memory chips have two main properties that determine their application, storage capacity (size) and access time(speed). A memory chip contains.
Flash EEPROM Emulation Concepts
Paging and Segmentation
Chapter 8: Main Memory.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Memory Management-I 1.
Main Memory Background Swapping Contiguous Allocation Paging
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
CSE 451: Operating Systems Autumn 2005 Memory Management
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Chapter 8: Memory Management strategies
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Renesas Technology America, Inc. Flash!

CPU Rewrite CPU-rewrite is a term that refers to an Renesas MCU’s ability to erase/program its own internal Flash in circuit. R8C is BYTE programmable, where current M16C and M32C devices are WORD programmable. Old M16C/M32C devices were 256byte programmable. In order to erase any data, the ENTIRE block must be erase.

Renesas Technology America, Inc. EW0 vs. EW1 Mode HNDc Flash devices can perform Flash operations using either EW0 or EW1 Mode. EW0 Mode: CPU-rewrite Code must be executed out of RAM and the Flash register polled for operation completion. EW1 Mode: CPU-rewrite Code is run out of Flash (just not in the same block as target block) and the CPU is kept in HOLD state until operation completion.

Renesas Technology America, Inc. Block LOCK bit Hardware mechanism to protect Flash blocks from accidentally be erased/programmed. Only on older DINOR, HNDa,b Flash devices (M16C/62P,/6N, M32C/83,/85) Once a block is locked, it remains that way (even through resets) until it is erased. To erase a locked block requires and extra step in software which disables ALL lock bit settings. There are 2 Flash erase commands for this type of Flash: –Erase Block (can be used to override lock bit settings) –Erase All unlocked blocks. (can never erase a locked block)

Renesas Technology America, Inc. Block PROTECT bits Hardware mechanism to protect Flash blocks from accidentally be erased/programmed. Will be used for all new devices (R8C, M16C, M32C) Typically, there are only 2 bits (4 settings) for all the Flash Blocks in the device. Therefore, blocks are grouped (ie, Block 0&1, All other user blocks) Data Flash is never protected. Since the protect bits are SET every time you enter CPU-rewrite mode, an extra software step is required to remove protection to certain blocks. The Protect bits reside in the Flash registers.

Renesas Technology America, Inc. ROM Code Protect Disables Flash memory from being read out by a parallel programmer. The ROMCP register always resides in the last byte of Flash (0xFFFFF or 0xFFFFFF) Once set, user can only access flash via serial boot mode (which has a 7-byte ID code protection – next page)

Renesas Technology America, Inc. ROM Code Protect *Taken from the M16C/26 Hardware Manual! ROM Code Protect Register ROMCP

Renesas Technology America, Inc..

Flash Suspend Flash writes are fast, erases are slow. The bigger the Flash block, the longer the operation will take. Some newer devices have an Erase Suspend option that will allow you to postpone an erase operation and leave CPU-rewrite mode before it has completed (for example in order to service an interrupt). You can then go back into CPU-rewrite mode later and continue the erase. The HNDe Flash type improves the flash suspend response time (from 8ms to 90us). The first device to have HNDe will be R8C/20 Series.

Renesas Technology America, Inc. R8C Flash R8C/ has a Watchdog register at address 0xFFFF. If that address programmed to 00 (by default of NC30 compiler startup file), then the watchdog will start firing automatically after reset and interfere with CPU-rewrite operations that don’t account for this. The FlashAPI source code does not “pet” the watchdog. Therefore, you must set address FFFF to FF in your R8C startup file.

Renesas Technology America, Inc. Flash Lookup Table MCUTYPEWriteData FlashLock/ProtectSuspendNotes R8C/10,11,14,16HNDcBYTE-ProtectYesW-Dog INTR R8C/12,13HNDcBYTEA,B (2k each)ProtectYesW-Dog INTR R8C/15,17HNDcBYTEA,B (1k each)ProtectYesW-Dog INTR M16C/26HNDcWORDA,B (2k each)ProtectYesonly 1 protect bit M16C/26A,28,29HNDcWORDA,B (2k each)ProtectYes M16C/62P,6NHNDcWORDA,1 (4k each)Lock- M32C/83DINOR256 BYTE-Lock-EW0 only M32C/85,/87HNDcWORDA,1 (4k each)Lock- EW0 and EW1 Mode 7 Byte Serial ID code ALL: ROM Code Protection FoUSB Programming

Renesas Technology America, Inc. Simple Flash API R8C, M16C and M32C MCUs with HNDc type Flash are similar enough to create one API source file for all of them. Current supported devices are listed to the right. R8CM16CM32C R8C/10M16C/1N2M32C/83 R8C/11M16C/26M32C/84 R8C/12M16C/26AM32C/85 R8C/13M16C/28 R8C/14M16C/29 R8C/15M16C/62P R8C/16M16C/6N4 R8C/17M16C/6N5

Renesas Technology America, Inc. Flash API Files There are only 2 files for the API: Flash_API.c Flash_API.h There is a very simple sample program that works with all the supported MCU: FlashAPI_Sample.c There is an appnote for using this API: REU05B0058-2_Simple_Flash_API.pdf A Hew project using these files comes with the SKP’s.

Renesas Technology America, Inc. Flash API Functions There are only 2 functions in the API unsigned char FlashErase( unsigned char block ); unsigned char FlashWrite( FLASH_PTR_TYPE flash_addr, BUF_PTR_TYPE buffer_addr, unsigned int bytes) The acceptable values for “block” in FlashErase are listed in FlashAPI.h (BLOCK_0, BLOCK_1, etc…) The types FLASH_PTR_TYPE and BUF_PTR_TYPE in FlashWrite are memory pointers. The have to be defined this way in order to deal with the different memory models between the R8C, M16C and M32C. success = FlashErase( BLOCK_A ); Success = FlashWrite((FLASH_PTR_TYPE)0xF000, (BUF_PTR_TYPE) “hello”, 6);

Renesas Technology America, Inc. Flash API Setup You must define the MCU you are using. The list of valid devices are at the top of the file Flash_API.h. #define M16C_62P 1 #define R8C_13 0 You must define the Flash Mode you want to use. Mode 0 sends flash command while running from RAM. Mode 1 sends command while running in Flash. #define EW_MODE 0 #define EW_MODE 1 You must define the Bus Clock Frequncy (BCLK) you are running at. This is used to determine how much to slow the MCU down when sending commands to the flash controller. #define BCLK_FREQUENCY

Renesas Technology America, Inc. Flash API Setup You can also set up the #defines within HEW.

Renesas Technology America, Inc. Flash API Setup There are 3 things that must be #defined before using API. They are all listed in the file Flash_API.h. If something is not defined, the compiler will stop and print out a message. C:\FlashAPI\Flash_API.h 179 Error "You must specify your device in Flash_API.h first!!" C:\FlashAPI\Flash_API.c Phase M16C C Compiler finished

Renesas Technology America, Inc. New Virtual EEPROM APIs The Virtual EEPROM software was created to: –Fix design bugs in the initial release –Use the new Flash API code –Account for writing into a Flash space that wasn’t blank. –Improve reliability in loss of power situations –Allow for multiple and uniquely sized data to be stored

Renesas Technology America, Inc. Virtual EEPROM The concept is not to erase a flash block every time stored data needs to be changed. Instead, write the new data to another un-programmed location within that flash block until the entire block has been filled. Reducing the number of erase cycles of a block better utilizes and extends the life of the Flash. The Renesas Virtual EEPROM solution is a software implementation utilizing the two high Erase-Write cycle Flash blocks.

Renesas Technology America, Inc. Virtual EEPROM The virtual EEPROM API uses the Flash API in order to erase/program the Data Flash areas of the MCU Data Flash Flash API Virtual EEPROM API User Code

Renesas Technology America, Inc. Virtual EEPROM M16C/62PBLOCKS A & 14KB each M16C/Tiny Series (2x)BLOCKS A & B2KB each R8C 12,13BLOCKS A & B2KB each R8C 15,17BLOCKS A & B1KB each M32C/85BLOCKS A & 14KB each All new R8C, M16C and M32C MCUs come with two Flash blocks with 10,000 erase/write cycle. 10,000 E/W versions have special Option codes (#D7,#D9)

Renesas Technology America, Inc. Virtual EEPROM Virtual EEPROM (Fixed Method) The user has a single fixed amount of data that can be stored referred to a a SEGMENT. All the bytes in the SEGMENT must be modified at the same time. SEGMENT SIZE = 5 5 WORD array

Renesas Technology America, Inc. Virtual EEPROM (Fixed Method) To change one or more bytes, user application must read the SEGMENT array into a RAM buffer, modify, then write back VirEE Read VirEE Write Buffer in RAM Virtual EEPROM 5 WORD array

Renesas Technology America, Inc. Virtual EEPROM (Multiple/Variable Method) The user may have multiple records (segments) of variable length that may be modified individually. Virtual EEPROM User assigned record label (0-254) 24 data 17 data 50 data 10 data Size in WORDs -1 (1-255) User data for that record

Renesas Technology America, Inc. Virtual EEPROM Example #include “virtEE_Variable.h” typedef struct { unsigned char record_label; /* 0x00 to 0xFE */ unsigned char data_size; /* number of WORDS - 1*/ unsigned int NV_FAR *pData; /* pointer to data */ } NV_type; void main(void) { NV_type EE_data; /* Read Record 1 */ EE_data.record_label = 1; NV_Read( &EE_data ); value = EE_data.pData[0]; /* Write Record 5 */ EE_data.record_label = 5; EE_data.pData[0] = 55; EE_data.pData[1] = 22; EE_data.data_size = 2; NV_Write( &EE_data );

Renesas Technology America, Inc. Continue in Lab 5