Abstract:
A backup method includes the following processes. Backup data is temporarily stored in a volatile memory. An erased area is saved in a flash memory for the backup data. The erased area is free of data. The backup data is written in the erased area.

Description:
BACKGROUND OF THE INVENTION 
       [0001]    1. Field of the Invention 
         [0002]    The present invention relates to a backup method, a backup device, and a vehicle controller. 
         [0003]    Priority is claimed on Japanese Patent Application No. 2008-286466, filed on Nov. 7, 2008, the content of which is incorporated herein by reference. 
         [0004]    2. Description of the Related Art 
         [0005]    All patents, patent applications, patent publications, scientific articles, and the like, which will hereinafter be cited or identified in the present application, are incorporated by reference in their entirety in order to describe more fully the state of the art to which the present invention pertains. 
         [0006]    Generally, an SRS (Supplemental Restraint System) air-bag system is known as a system for occupant protection upon a vehicle collision. In the SRS air-bag system, a collision is detected based on acceleration data obtained from acceleration sensors provided in a vehicle to activate an occupant protection device, such as an air-bag or a seatbelt pretensioner. An ECU (Electronic Control Unit) that controls the entire SRS air-bag system is called an SRS unit, and is usually provided separately from other ECUs, such as ECUs for an engine and an ABS (Anti-Brake System). 
         [0007]    For example, Japanese Unexamined Patent, First Publication No. 2003-252256 discloses a technology for analyzing vehicle information (such as velocity, acceleration, braking information, or acceleration information) upon a collision to investigate the causes of the collision. According to the technology, vehicle information obtained from various sensors or other ECUs is sequentially updated and stored while a vehicle is running, and the vehicle information stored in a RAM is read upon detecting a vehicle collision and stored in an EEPROM (Electronically Erasable and Programmable Read Only Memory). 
         [0008]    Conventionally, an EEPROM has been used as a backup memory for storing nonvolatile data (backup data), such as the vehicle information. On the other hand, cheaper and faster-writable flash memory has been recently required to be used in lieu of the EEPROM with an increasing amount of data to be stored as backup data. However, there are the following problems in using a flash memory. 
         [0009]      FIG. 13  is a performance comparison chart between a flash memory and an EEPROM. The flash memory is superior to the EEPROM in “byte unit price” and “writing speed,” but is inferior in “writing unit,” “erasing speed,” “erasing unit,” “retention (the number of years for storing data),” and “the rewritable number of times.” In other words, the flash memory has problems in that the rewritable number of times is small and a writing time is long (several hundred msec is required for rewriting 1 byte of data if a simple rewriting operation including erasing of data and writing of data is executed). 
       SUMMARY OF THE INVENTION 
       [0010]    To solve the above problems, a backup method according to a first aspect of the present invention includes the following processes. Backup data is temporarily stored in a volatile memory. An erased area is saved in a flash memory for the backup data. The erased area is free of data. The backup data is written in the erased area. 
         [0011]    The process of saving the erased area includes the following processes. A total size of the erased area is detected. All data written in a block of the flash memory is erased when the total size becomes a predetermined size or less. Erasing data written in part of the block is inhibited. The block has a start address next to an end address of the erased area. The end address is determined when the total size becomes the predetermined size or less. 
         [0012]    In the process of erasing all the data written in the block, if the backup data most-recently written is included in the block to be erased, the backup data most-recently written is moved to the start address of the erased area before all the data in the block are erased. 
         [0013]    The backup method further includes the following process. The backup data most-recently written in an area of the flash memory which is different from the erased area, and a destination address of the flash memory in which the backup data most-recently written is present are stored in the volatile memory. 
         [0014]    The backup method further includes the following processes. The backup data newly-stored in the volatile memory is compared to the backup data most-recently written in the destination address. The backup data newly-stored is newer than the backup data most-recently written. The backup data newly-stored is written in the erased area from a start address of the erased area if the backup data most-recently written in the destination address is not identical to the backup data newly-stored. The destination address and the start address of the erased area are updated. 
         [0015]    The process of writing the backup data is executed by the sector defined as a recording unit. The flash memory is divided into a plurality of sectors. 
         [0016]    A backup device according to a second aspect of the present invention includes: a volatile memory; a flash memory; and a controller. The controller temporarily stores backup data in the volatile memory, saves an erased area in the flash memory for the backup data, the erased area being free of data, and writes the backup data in the erased area. 
         [0017]    In the backup device, the controller detects a total size of the erased area, and erases all data written in a block of the flash memory when the total size becomes a predetermined size or less. Erasing data written in part of the block being inhibited. The block has a start address next to an end address of the erased area. The end address is determined when the total size becomes the predetermined size or less. 
         [0018]    In the backup device, if the backup data most-recently written is included in the block to be erased, the controller moves the backup data most-recently written to the start address of the erased area before erasing all the data in the block. 
         [0019]    In the backup device, the controller stores, in the volatile memory, the backup data most-recently written in an area of the flash memory which is different from the erased area, and a destination address of the flash memory in which the backup data most-recently written is present. 
         [0020]    In the backup device, the controller compares the backup data newly-stored in the volatile memory to the backup data most-recently written in the destination address. The backup data newly-stored is newer than the backup memory most-recently written. The controller writes the backup data newly-stored in the erased area from a start address of the erased area if the backup data most-recently written in the destination address is not identical to the backup data newly-stored. The controller updates the destination address and the start address of the erased area. 
         [0021]    In the backup device, the controller writes the backup data by the sector defined as a recording unit. The flash memory is divided into a plurality of sectors. 
         [0022]    A vehicle controller according to a third aspect of the present invention comprises a backup device comprising: a volatile memory; a flash memory; and a controller. The controller temporarily stores backup data in the volatile memory, saves an erased area in the flash memory for the backup data, the erased area being free of data, and writes the backup data in the erased area. 
         [0023]    In the present invention, an erased area is always saved in a flash memory, instead of simply executing a rewriting operation including erasing of data and writing of data stored in the flash memory. In other words, erasing of data is preliminarily executed in a different timing from the timing of writing of data. Accordingly, a time for rewriting backup data stored in the flash memory can be reduced since only a writing operation which is not time-consuming is required for updating backup data. 
         [0024]    Additionally, although the rewritable number of times per cell in the flash memory is the same, the wear level per cell can be reduced by writing backup data in the erased area sequentially from the start address of the erased area. Consequently, the upper limit of the rewritable number of times of the flash memory can be increased. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0025]    Objects, features, aspects, and advantages of the present invention will become apparent to those skilled in the art from the following detailed descriptions taken in conjunction with the accompanying drawings, illustrating the embodiments of the present invention, in which: 
           [0026]      FIG. 1  is a schematic block diagram illustrating an SRS unit  1  including a backup device according to an embodiment of the present invention; 
           [0027]      FIG. 2  illustrates a storage area of a flash memory  1   h;    
           [0028]      FIG. 3  is a flowchart illustrating an initialization process when a CPU  1   d  included in the SRS unit  1  is powered-on; 
           [0029]      FIGS. 4 and 5  illustrate a blank check process included in the initialization process; 
           [0030]      FIG. 6  illustrates a data mounting process included in the initialization process; 
           [0031]      FIG. 7  is a flowchart illustrating a backup process in a normal operation performed by the CPU  1   d;    
           [0032]      FIGS. 8 and 9  illustrate a data writing process included in the backup process; 
           [0033]      FIGS. 10 to 12  illustrate a garbage collection process included in the backup process; and 
           [0034]      FIG. 13  is a performance comparison chart between a flash memory and an EEPROM. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0035]    The present invention will now be described herein with reference to illustrative embodiments. 
         [0036]    Those skilled in the art will recognize that many alternative embodiments can be accomplished using the teachings of the present invention and that the present invention is not limited to the embodiments illustrated herein for explanatory purposes. 
         [0037]      FIG. 1  is a schematic block diagram illustrating a vehicle ECU including a backup device according to an embodiment of the present invention. An SRS unit  1  that controls an entire SRS air-bag system for occupant protection is taken as an example of the vehicle ECU. 
         [0038]    The SRS unit  1  includes: a power circuit  1   a;  a unit sensor  1   b;  a communication I/F  1   c;  a CPU (Central Processing Unit)  1   d;  an ignition circuit  1   e;  a ROM (Read Only Memory)  1   f;  a RAM (Random Access Memory)  1   g;  and a flash memory  1   h.  The CPU  1   d  and the RAM  1   g  correspond to a memory controller and a volatile memory, respectively. In other words, the CPU  1   d,  the RAM  1   g,  and the flash memory  1   h  form a backup device. 
         [0039]    The power circuit la is connected to an external power source  3 , such as a battery, through an ignition switch  2 . When the ignition switch  2  changes to an on-state, the power circuit  1   a  receives power voltage supply from the external power source  3 , converts the power voltage into a predetermined internal power voltage, and supplies the converted power voltage to the unit sensor  1   b,  the communication I/F  1   c,  the CPU  1   d,  the ignition circuit  1   e,  the ROM  1   f,  the RAM  1   g,  and the flash memory  1   h.  The power circuit  1   a  is provided with a backup power source (such as a backup capacitor) so that the SRS unit  1  can operate even when power supply from the external power source  3  is blocked due to a vehicle collision. 
         [0040]    The unit sensor  1   b  is an acceleration sensor that detects acceleration in the running direction and/or the lateral direction, and outputs acceleration data based on the detected acceleration to the CPU  1   d.  The communication I/F  1   c  is an interface circuit to relay data communication between the CPU  1   d  and an engine ECU  4 , an ABS ECU  5 , a satellite sensor  6 , and a velocity sensor  7 , which are externally provided. 
         [0041]    The engine ECU  4  controls an engine and transmits information concerning a condition of the engine (engine data) to the CPU  1   d  through the communication I/F  1   c.  The ABS ECU  5  controls the entire anti-brake system and transmits information concerning braking (braking data) to the CPU  1   d  through the communication I/F  1   c.  The satellite sensor  6  is an acceleration sensor provided at a predetermined position of a vehicle (such as at the front or either side of the vehicle), detects an acceleration at the provided portion, and transmits acceleration data based on the detected acceleration to the CPU  1   d  through the communication I/F  1   c.  The velocity sensor  7  detects the velocity of the vehicle and transmits velocity data based on the detected velocity to the CPU  1   d  through the communication I/F  1   c.    
         [0042]    The CPU  1   d  operates based on control programs stored in the ROM  1   f.  The CPU  1   d  determines whether or not a vehicle collision has occurred based on the acceleration data obtained from the unit sensor  1   b  and the acceleration data obtained from the satellite sensor  6  through the communication I/F  1   c.  Based on the determination result, the CPU  1   d  controls the ignition circuit  1   e,  and thereby controls activation of the air-bag  8  that is an occupant protection device. A method similar to the conventional methods can be used for the collision determination based on the acceleration data, and therefore explanations thereof are omitted hereinafter. 
         [0043]    The CPU  1   d  has a function of counting the number of times the ignition switch  2  has turned on (number of times activated), and a fault diagnosis function. The CPU  1   d  temporally stores, in the RAM  1   g,  the number of times activated, the fault diagnosis history, the collision determination history, the activation history of the air-bag  8 , the engine data, the braking data, the velocity data, or the like, as backup data. Further, the CPU  1   d  has a backup function of storing the backup data stored in the RAM  1   g  in the flash memory  1   h  with a fulfillment of a predetermined condition as a trigger. The details of the backup function will be explained later. 
         [0044]    Under control of the CPU  1   d,  the ignition circuit  1   e  inflates the air-bag  8  by supplying current to a scriber included in an inflator of the air-bag  8  for ignition. The air-bag  8  includes air-bags for driver&#39;s and passenger&#39;s seats, a side air-bag, a curtain air-bag, and the like. In addition to the air-bag  8 , a seatbelt pretensioner may be provided as a passenger protection device. 
         [0045]    The ROM  1   f  is a nonvolatile read-only memory that preliminarily stores nonvolatile data required for the control programs and the activation control of the air-bag  8  executed by the CPU  1   d.  The RAM  1   g  is a rewritable volatile memory to be used for temporally storing the aforementioned backup data or volatile data required for the CPU  1   d  to execute various processing. The flash memory  1   h  is a nonvolatile rewritable memory to be used as a backup memory for storing, after the predetermined condition is fulfilled, the backup data temporally stored in the RAM  1   g.    
         [0046]    In the embodiment, the entire size of the flash memory  1   h  is assumed to be 64 kbytes, as shown in  FIG. 2 . A storage area of the flash memory  1   h  is divided into sectors, each of which is a unit of a data record. A writing of backup data is executed by the sector. In the embodiment, one sector is assumed to have 16 bytes. Therefore, the storage area of the flash memory  1   h  is divided into 4000 sectors (sectors “ 0 ” to “ 3999 ”). 
         [0047]    15 bytes of the 16 bytes are assigned to an actual data area (storage area for storing backup data), and the remaining 1 byte is assigned to a management data area (storage area for storing management data indicative of the type of backup data stored in the actual data area). For example, if velocity data is stored as backup data in a sector, the velocity data is stored in the actual data area, and management data indicating that the velocity data is stored in the actual data area is stored in the management data area. If all the backup data to be stored cannot be stored in one sector, multiple sectors are assigned to store the backup data. 
         [0048]    In the flash memory  1   h  of the embodiment, erasing of the stored backup data is executed by the block that is the minimum erasable unit. Since a block is assumed to have 16 kbytes in the embodiment, the storage area of the flash memory  1   h  is divided into four blocks (“ 1 ” to “ 4 ”), and 1000 pieces of sector data are collectively erased for each block. 
         [0049]    It is assumed in the embodiment that an address of the sector “ 0 ” is the minimum address, an address of the sector “ 3999 ” is the maximum address, the address of the sector “ 0 ” is a start address of the entire storage area, and the address of the sector “ 3999 ” is an end address of the entire storage area. 
         [0050]    Hereinafter, an operation of the SRS unit  1  according to the embodiment is explained. An activation control of the air-bag  8  in the embodiment is the same as the conventional one. Therefore, explanations of the activation control are omitted here, and only backup of backup data is explained in detail, hereinafter. 
         [0051]      FIG. 3  is a flowchart illustrating an initialization process executed by the CPU  1   d  when the ignition switch  2  turns on. In the initialization process, the CPU  1   d  executes a blank check process on the flash memory  1   h  (step S 1 ). In the blank check process, all the sectors from the start to end addresses of the storage area of the flash memory  1   h  are scanned to find an erased area and to extract start and end addresses of the erased area. The erased area is an area in which data has been erased. 
         [0052]    For example, if all the sectors included in the block “ 1 ”, the sectors “ 2002 ” to “ 2999 ” included in the block “ 3 ”, and all the sectors included in the block “ 4 ” are erased areas, the address of the sector “ 2002 ” is the start address of the erased area, and the address of the sector “ 999 ” is the end address of the erased area. As explained layer, the reason is that writing of backup data is executed sequentially from the start address of the erased area (smaller address), and that the writing continues from the sector “ 0 ” if the writing up to the sector “ 3999 ” ends. If the backup data is erased (an erased area is saved), the backup data are erased by the block sequentially from the block having a start address next to the end address of the erased area. 
         [0053]    For this reason, a state in which only one sector having the smallest address of one block is the erased area as shown in  FIG. 5A  or a state in which discrete areas are the erased areas as shown in  FIG. 5B  cannot occur. Therefore, if the first sector having the start address of one block is the erased area, the block must be the erased block. Then, the block is subjected to the blank check. If an unerased sector is present in the block, the CPU  1   d  preferably outputs a fault indicating signal. Similarly, the CPU  1   d  preferably outputs a fault indicating signal if discrete erased areas are present as shown in  FIG. 5B . 
         [0054]    After the blank check process, the CPU  1   d  executes a data mounting process (step S 2 ). In the data mounting process, latest backup data most-recently stored in an area other than the erased area detected in the blank cheek process (i.e., an area storing backup data) and a latest-data destination address in which the latest backup data is stored are read out to be stored as a table in the common storage area of the RAM  1   g.    
         [0055]    Specifically, if the sectors “ 1000 ” to “ 2001 ” that are not the erased area are included in the flash memory  1   h,  the same type of backup data (e.g., backup data concerning velocity data) are searched based on the management data stored in the sectors “ 1000 ” to “ 2001 ” to extract the latest backup data therefrom. Since backup data is written sequentially from the smallest address, the backup data stored in the sector having the largest address is the latest backup data. 
         [0056]    Then, the extracted latest backup data (e.g., the latest velocity data) and the latest-data destination address (in which the latest backup data is stored) are correlated with the management data to be stored as a table in the common storage area of the RAM  1   g.  Similarly, regarding another type of backup data (e.g., the number of times the ignition circuit has turned on, the fault diagnosis history, or the like), the latest backup data and the latest-data destination address thereof are extracted from the sectors “ 1000 ” to “ 2001 ” to be correlated with the management data to be stored as a table in the common storage area of the RAM  1   g.  The start and end addresses of the erased area obtained in the blank check process are also stored in the RAM  1   g.    
         [0057]    After the data mounting process, the CPU  1   d  executes a lock release process (step S 3 ). Specifically, the lock release process is executed to release a lock mechanism if the lock mechanism for prohibiting writing of data into the flash memory  1   h  is provided. If a lock mechanism is not provided in the flash memory  1   h,  the process in step S 3  may be omitted. 
         [0058]    By the initialization process upon power-on as explained above, the latest backup data stored in the flash memory  1   h  and the latest-data destination address thereof are correlated with the management data to be stored as a table in the common storage area in the RAM  1   g,  as shown in  FIG. 6 . Further, the start and end addresses of the erased area are also stored in the RAM  1   g.    
         [0059]    Hereinafter, a backup process in a normal operation executed by the CPU  1   d  is explained with reference to the flowchart in  FIG. 7 . The backup process is repeatedly executed at a predetermined interval. As well as the backup process, the CPU  1   d  executes, in the normal operation, updates the backup data stored in the common storage area of the RAM  1   g  in the initialization process to newly obtained backup data at a predetermined interval. In other words, in the normal operation, the backup data stored in the common storage area of the RAM  1   g  are sequentially updated to new backup data. Hereinafter, the backup process is explained assuming the above. 
         [0060]    In the backup process, the CPU  1   d  executes a data writing process on the flash memory  1   h  (step S 10 ), as shown in  FIG. 7 . In the data writing process, the backup data stored in the common storage area of the RAM  1   g  and the backup data stored in the latest-data destination address of the flash memory  1   h  are compared. If the two backup data are not identical (i.e., a predetermined condition is fulfilled), the backup data is read out from the common storage area of the RAM  1   g,  and is sequentially written in the flash memory  1   h  from the start address of the erased area of the flash memory  1   h.    
         [0061]    Specifically, it is assumed as shown in  FIG. 8  that a latest-data destination address of the velocity data among the backup data stored in the common storage area of the RAM  1   g  is the address of the sector “ 1002 ”. In this case, the CPU  1   d  compares the velocity data stored in the common storage area of the RAM  1   g  and the velocity data stored in the sector “ 1002 ” of the flash memory  1   h.    
         [0062]    If both data are not identical, the CPU  1   d  reads the velocity data from the common storage area of the RAM  1   g,  and writes the read velocity data in the start address of the erased area (the address of the sector “ 2002 ”), as shown in  FIG. 9 . At the same time, the CPU  1   d  updates the latest-data destination address of the velocity data stored in the RAM  1   g  to the address of the sector “ 2002 ”, and also updates the start address of the erased area to the address of the sector “ 2003 ”. 
         [0063]    By the data writing process being executed for each type of backup data, new backup data is written sequentially from the start address of the erased area, and the latest-data destination address on the RAM  1   g  and the start address of the erased area are sequentially updated. In other words, the latest-data destination address on the RAM  1   g  always indicates a destination of the latest backup data belonging to the targeted type, and the start address of the erased area on the RAM  1   g  always indicates the latest start address of the erased area present in the flash memory  1   h.    
         [0064]    After the data writing process, the CPU  1   d  determines whether or not writing of data to the flash memory  1   h  has occurred (step S 11 ). If writing of data occurs (step S 11 : YES), the CPU  1   d  finishes the backup process. If the writing of data has not occurred (step S 11 : NO), the CPU  1   d  executes a garbage collection process (step S 12 ). In the garbage collection process, the CPU  1   d  monitors the total size of erased areas included in the flash memory  1   h.  If the total size becomes a predetermined size or less, the CPU  1   d  erases backup data stored in the block having the start address next to the end address of the erased area, and thereby a predetermined size of an erased area is always saved. 
         [0065]    For example, it is assumed that erasing of data in a block is executed if the total size of the erased area becomes the size corresponding to 2 blocks or less. If the blocks “ 1 ” and “ 4 ” are erased areas as shown in  FIG. 10 , backup data stored in the block “ 2 ” targeted for erasing is erased. The total size of erased areas can be calculated using the start and end addresses of the erased area stored in the RAM  1   g.    
         [0066]    If valid data (i.e., the latest backup data) is stored in the block “ 2 ” targeted for erasing, the latest backup data is written sequentially from the start address of the erased area, and then the backup data stored in the block “ 2 ” is erased. Specifically, it is assumed as shown in  FIG. 11  that the latest backup data are stored in the sectors “ 1998 ” and “ 1999 ” included in the block “ 2 ” targeted for erasing. The backup data stored in the sector “ 1998 ” is written in the sector “ 3000 ” that is the start address of the erased area. Further, backup data stored in the sector “ 1999 ” is written in the sector “ 3001 ” which is the address next to the start address of the erased area. 
         [0067]    After the backup data is moved as explained above, the backup data stored in the block “ 2 ” targeted for erasing is erased as shown in  FIG. 12 . At the same time, the start and end addresses of the erased area stored in the RAM  1   g  is updated. In other words, the start and end addresses of the new erased area become the addresses of the sectors “ 3002 ” and “ 1999 ”, respectively. 
         [0068]    By repeating the backup process explained above at a predetermined interval, a predetermined size (corresponding to at least two blocks) of the erased area is always saved in the storage area of the flash memory  1   h,  and new backup data is written sequentially from the start address of the erased area. 
         [0069]    In other words, the flash memory  1   h  is not rewritten by a simple rewriting process including erasing of data and writing of data in the embodiment. Instead, only an erasing process requiring a long processing time is executed while backup data is not updated (rewritten) so that a predetermined size of the erased area is always saved. Consequently, only a writing process which is not time consuming is executed when actually updating backup data. Therefore, the time required for rewriting backup data stored in the flash memory  1   h  can be reduced. 
         [0070]    Although the rewritable number of times defined for each cell of the flash memory  1   h  is not changed, the wear level per cell can be reduced by writing new backup data sequentially from the start address of the erased area. Consequently, the upper limit of the rewritable number of times for the flash memory  1   h  can be substantially increased. For example, if it is assumed that the total size of backup data is 2 kbyte, the rewritable number of times corresponding to the predetermined number of times multiplied by 8 can be secured for one block of 16 kbyte. Further, the rewritable number of times corresponding to the predetermined number of times multiplied by 32 can be secured for the entire 4 blocks. 
         [0071]    As explained above, according to the present embodiment, the specific problems in using a flash memory as a backup memory (i.e., a long rewriting time and the small rewritable number of times) can be solved. 
         [0072]    It has been explained in the embodiment that the SRS unit  1  that controls the entire SRS air-bag system is taken as an example of a vehicle ECU including a backup device including the CPU  1   d,  the RAM  1   g,  and the flash memory  1   h.  However, the backup device of the embodiment is applicable to any vehicle ECU requiring a backup function (for example, the engine ECU  4 ), and to any electronic device requiring a backup function. 
         [0073]    It is apparent that the present invention is not limited to the above embodiments, but may be modified and changed without departing from the scope and spirit of the invention.