As an auxiliary storage medium replacing an HDD (Hard Disc Drive) of a portable PC (Personal Computer), a flash memory being a nonvolatile PROM (Programmable Read-Only Memory) to which data can be electrically written many times and data stored therein can be electrically deleted at a time has been used, since it is small and light, and enables high speed processing and low power consumption.
There is also used a memory card which is a removable flash memory. The memory card is installed to a data recording apparatus for recording data, to which picture data and music data is recorded.
Picture data and music data recorded in the memory card can be reproduced by means of a PC, a digital camera, or a music playback apparatus, etc.
Next, the configuration of the flash memory will be explained with reference to FIG. 1. The flash memory is composed of a plurality of blocks, each having data of a predetermined amount and being a unit in deleting data. Also, each block is composed of a plurality of pages, each having data of a predetermined amount and being a unit in writing and reading out data. Each page has a data area of e.g. 512 Bytes to which data is to be written, and an extra area of e.g. 16 Bytes to which parity data, etc. is to be written.
The flash memory has important information such as information for initiating the data recording apparatus, information for managing the data recording apparatus, etc., which will be referred to as management information, stored in the data area thereof, besides picture data and music data recorded by the data recording apparatus.
The management information is read out and stored to a RAM (Random Access Memory) of the data recording apparatus, and is managed, when using the flash memory. Stored management information is updated under the control of a CPU of the data recording apparatus, if necessary, in accordance with change of stored data when picture data and music data is written, and updated management information is rewritten to the data area of the flash memory.
Next, the operation of updating management information stored in a flash memory will be explained with reference to FIG. 2. It is assumed that the management information is written in a predetermined block of a flash memory.
Firstly, in step S21, a CPU retrieves a predetermined block of the flash memory to determine whether there is a vacant page in the block or not. Then, in case there is a vacant page, the process proceeds to step S22, while in case there is no vacant page, the process proceeds to step S23.
In step S22, the CPU reserves the vacant page in the block, in which also management information just before updating is written, as a new page for writing the updated management information. In case the page in which the management information just before updating is written is the last page of the block, the updated management information is written to the leading page of the next block.
In step S23, since there is no vacant page in all blocks of the flash memory, the CPU deletes all the management information before updating written in the leading block so as to prepare a block for writing the updated management information. Then, the CPU reserves the leading page of the block whose management information before updating is deleted as a new page for writing the updated management information.
In step S24, the CPU writes the updated management information to the new page reserved in step S22 or step S23. When step S24 ends, the processing of updating the management information is terminated.
When updating the management information under the steps shown in the flow chart of FIG. 2, the management information in the block of the flash memory is updated as shown in FIG. 3.
When blocks to which the management information is written are 100a and 100b, firstly, the management information is written to the block 100a from a page number 0 to a page number n. Then, the management information is written to the block 100b from a page number 0. Thus, in the block of the flash memory, the management information is updated for each block sequentially.
When updating the management information of the flash memory, in case updating processing is unsuccessfully performed, the CPU updates the management information again using the management information just before updating.
In writing data to a page of the flash memory, when there is raised an error, the error affects all data in a block to which the page belongs.
That is, as shown in FIG. 4, when there is raised an error in a bit of a page of a block, there are also raised errors in similar bits of all the other pages of the block, which damages all data in the block.
In updating the management information of the flash memory shown in the flow chart, since the management information is written to a vacant page which is next to a page of the block in which the management information before updating is written, when there is raised an error due to unsuccessful updating processing, all the management information in the block including the page with the error is damaged. Thus, the management information just before updating, which is necessary in case updating processing is unsuccessfully performed, is also damaged. So, the CPU cannot update the management information again since the management information just before updating cannot be used.
Furthermore, each of memory cells of a conventional flash memory can store information of only 1 bit, while, so as to cut costs and enlarge the capacity, there is also used a flash memory each of whose memory cells can store information of 2 bits and 4 bits. In this case, area of damaged data spreads over a wide range of bits, which cannot be coped with by error correction codes.