JP2011175428A - Storage device - Google Patents

Storage device Download PDF

Info

Publication number
JP2011175428A
JP2011175428A JP2010038639A JP2010038639A JP2011175428A JP 2011175428 A JP2011175428 A JP 2011175428A JP 2010038639 A JP2010038639 A JP 2010038639A JP 2010038639 A JP2010038639 A JP 2010038639A JP 2011175428 A JP2011175428 A JP 2011175428A
Authority
JP
Japan
Prior art keywords
user data
written
page
block
flag
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2010038639A
Other languages
Japanese (ja)
Inventor
Yukio Ueno
幸男 上野
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kyocera Corp
Original Assignee
Kyocera Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kyocera Corp filed Critical Kyocera Corp
Priority to JP2010038639A priority Critical patent/JP2011175428A/en
Publication of JP2011175428A publication Critical patent/JP2011175428A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a storage device allowing load reduction of a memory. <P>SOLUTION: A control unit 46 writes a first flag into a first page of a managing block when starting writing of user data into a block for the user data, and writes a second flag into a second page different from the first page when the writing of the user data ends. The control unit 46 decides that the user data corresponding to the first flag is normally written in the block for the user data when the first flag and the second flag are written in the first page and the second page, respectively, does not perform erasure processing to the block written with the user data, and estimates that the user data corresponding to the first flag is not normally written in the block for the user data when the second flag is not written in the second page though the first flag is written in the first page. <P>COPYRIGHT: (C)2011,JPO&INPIT

Description

本発明は、書き換え可能なメモリを有する記憶装置に関する。   The present invention relates to a storage device having a rewritable memory.

近年、電子機器の不揮発性メモリとしてフラッシュメモリが市場に流通している。このフラッシュメモリは、近年大容量化が著しく進み、例えば、携帯電話機等に用いられている(例えば、特許文献1を参照)。   In recent years, flash memories have been distributed on the market as nonvolatile memories of electronic devices. The flash memory has been remarkably increased in capacity in recent years, and is used in, for example, a cellular phone (see, for example, Patent Document 1).

ところで、フラッシュメモリは、ページという単位でデータの書き込み及び読み出しが行われ、また、複数のページから構成されるブロックという単位でデータの消去が行われる。ところで、フラッシュメモリは、物理的な不良等によって、一部のページが使用できなくなることがある。具体的には、フラッシュメモリは、ページの一部がビット化けを起こしてしまうと、正確なデータの読み出し及び書き込みができなくなる問題がある。   In the flash memory, data is written and read in units of pages, and data is erased in units of blocks composed of a plurality of pages. By the way, in the flash memory, some pages may become unusable due to a physical defect or the like. Specifically, the flash memory has a problem that accurate data reading and writing cannot be performed if a part of a page is garbled.

この問題に対して、例えば、ビット化けを起こしたページが生じた場合、当該ページを有するブロックのデータを予備ブロックへコピーして、コピー元のブロックをリセット消去する技術等が広く知られている。   To deal with this problem, for example, when a bit-garbled page is generated, a technique for copying the block data having the page to a spare block and resetting and erasing the copy source block is widely known. .

特開平6−161867号公報JP-A-6-161867

しかしながら、前述した技術では、ビット化けを起こしたページを有するブロックのデータは、全て予備ブロックへコピーされてしまい、予備ブロックを大量に消費してしまう問題がある。   However, the above-described technique has a problem in that all the data of the block having the page that is garbled is copied to the spare block and consumes a large amount of the spare block.

本発明では、メモリの負担軽減化を図ることができる記憶装置を提供することを一つの目的とする。   An object of the present invention is to provide a storage device that can reduce the burden on the memory.

本発明に係る記憶装置は、上記課題を解決するために、所定数のページからなるブロックを複数個有し、データの読み出し及び書き込みをページ単位で受け付け、データの消去をブロック単位で受け付ける不揮発性メモリと、前記不揮発性メモリに対して、データの読み出し、書き込み及び消去を行う制御部を備え、前記不揮発性メモリのブロックは、ユーザデータを記憶する複数のユーザデータ用ブロックと、当該ユーザデータ用ブロックを管理する複数の管理用ブロックによって構成され、前記制御部は、ユーザデータを前記ユーザデータ用ブロックに書き込みを開始する時、前記管理用ブロックの第1ページに前記ユーザデータに対応する第1フラグを書き込み、当該ユーザデータの書き込みが終了した場合に、前記第1ページとは異なる前記管理用ブロックの第2ページに当該ユーザデータに対応する第2フラグを書き込み、前記第1ページ及び前記第2ページにそれぞれ第1フラグと第2フラグが書き込まれている場合には、当該ユーザデータが前記ユーザデータ用ブロックに正常に書き込まれていると判断して、当該ユーザデータが書き込まれているブロックに対して消去処理を行わず、前記第1ページには第1フラグが書き込まれているものの、前記第2ページには第2フラグが書き込まれていない場合には、当該ユーザデータが前記ユーザデータ用ブロックに正常に書き込まれていないと推定する。   In order to solve the above-described problem, the storage device according to the present invention has a plurality of blocks each including a predetermined number of pages, accepts reading and writing of data in units of pages, and accepts erasing of data in units of blocks. A control unit for reading, writing, and erasing data from and to the nonvolatile memory, wherein the block of the nonvolatile memory includes a plurality of user data blocks for storing user data and the user data When the control unit starts writing user data to the user data block, a first page corresponding to the user data is displayed on the first page of the management block. When the flag is written and the writing of the user data is completed, it is different from the first page. When the second flag corresponding to the user data is written in the second page of the management block, and the first flag and the second flag are written in the first page and the second page, respectively, It is determined that the user data is normally written in the user data block, and the erase process is not performed on the block in which the user data is written, and the first flag is written in the first page. However, when the second flag is not written in the second page, it is estimated that the user data is not normally written in the user data block.

また、記憶装置では、前記第2ページは、前記第1ページの次のページであることが好ましい。   In the storage device, it is preferable that the second page is a page next to the first page.

また、記憶装置では、前記制御部は、所定の期間又は前記不揮発性メモリの各ブロックの使用頻度に基づいて、一のブロックに書き込まれているデータを他のブロックに移動する処理を行うことが好ましい。   In the storage device, the control unit may perform a process of moving data written in one block to another block based on a predetermined period or a use frequency of each block of the nonvolatile memory. preferable.

また、記憶装置では、前記第2ページには、データが書き込まれる前においては、予め規定値が書き込まれており、前記制御部は、前記第2ページの一部に前記第2フラグを書き込む場合、当該第2フラグが書き込まれる領域以外の領域に前記規定値以外の値を書き込み、前記第1ページには第1フラグが書き込まれているものの、前記第2ページには第2フラグが書き込まれていない場合には、当該第1フラグに対応するユーザデータが前記ユーザデータ用ブロックに正常に書き込まれていないと推定した上で、前記第2ページの第2フラグが書き込まれる領域以外の所定領域に前記規定値が書き込まれているかどうかを判定し、前記所定領域に前記規定値が書き込まれていると判定した場合には、前記第1フラグに対応するユーザデータが正常に書き込まれていないと判断し、前記所定領域に前記規定値が書き込まれていないと判定した場合には、前記第1フラグに対応するユーザデータが正常に書き込まれていると判断し、当該ユーザデータが書き込まれているブロックに対して消去処理を行わないことが好ましい。   In the storage device, a predetermined value is written in advance in the second page before data is written, and the control unit writes the second flag in a part of the second page. A value other than the specified value is written in an area other than the area where the second flag is written, and the first flag is written in the first page, but the second flag is written in the second page. If not, it is estimated that the user data corresponding to the first flag is not normally written in the user data block, and then a predetermined area other than the area where the second flag of the second page is written. If the specified value is written in the predetermined area, and if it is determined that the specified value is written in the predetermined area, the user data corresponding to the first flag If it is determined that the normal value is not written, and it is determined that the specified value is not written in the predetermined area, it is determined that the user data corresponding to the first flag is normally written, It is preferable not to perform an erasing process on a block in which user data is written.

また、記憶装置では、前記制御部は、前記第2ページに前記規定値が書き込まれていると判定した場合には、前記第1フラグに対応するユーザデータが正常に書き込まれていないと判断し、その後、ユーザデータ用ブロックに対して所定回数前記ユーザデータの読み出しを行い、前記所定回数以内に前記ユーザデータを有意なデータとして読み出せた場合には、当該ユーザデータが書き込まれているブロックに対して消去処理を行わず、前記所定回数以内に前記ユーザデータを有意なデータとして読み出せない場合には、当該ユーザデータが書き込まれているブロックに対して消去処理を行うことが好ましい。   In the storage device, when the control unit determines that the specified value is written in the second page, the control unit determines that the user data corresponding to the first flag is not normally written. Then, when the user data is read out from the user data block a predetermined number of times and the user data can be read as significant data within the predetermined number of times, the user data is written to the block in which the user data is written. On the other hand, when the user data cannot be read as significant data within the predetermined number of times without performing the erase process, it is preferable to perform the erase process on the block in which the user data is written.

本発明によれば、メモリの負担軽減化を図ることができる。   According to the present invention, it is possible to reduce the memory load.

携帯電話装置の外観斜視図である。1 is an external perspective view of a mobile phone device. 携帯電話装置の機能を示す機能ブロック図である。It is a functional block diagram which shows the function of a mobile telephone apparatus. 携帯電話装置が有するメモリの構成を示す図である。It is a figure which shows the structure of the memory which a mobile telephone apparatus has. 管理用ブロックとスペアブロックを入れ替える処理についての説明に供する図である。It is a figure with which it uses for description about the process which replaces a management block and a spare block. ガベージコレクション機能とウェアレベリング機能を利用してブロックを入れ替える処理についての説明に供する図である。It is a figure with which it uses for the description about the process which replaces a block using a garbage collection function and a wear leveling function. データの書き込み処理についての説明に供するフローチャートである。It is a flowchart with which it uses for description about the writing process of data. ページのデータを読み出す処理についての説明に供するフローチャートである。It is a flowchart with which it uses for description about the process which reads the data of a page. ページの破棄(ディスカード)処理についての説明に供するフローチャートである。It is a flowchart with which it uses for description about the discard (discard) process of a page. 電源投入後の処理についての説明に供するフローチャートである。It is a flowchart with which it uses for description about the process after power activation. エラーページが属するブロックに対して消去処理を行うか否かについて示す図である。It is a figure which shows whether the erasure | elimination process is performed with respect to the block to which an error page belongs.

以下、本発明の実施の形態について説明する。図1は、本発明に係る記憶装置5を内蔵する携帯電話装置1の外観斜視図を示す。なお、図1は、いわゆる折り畳み型の携帯電話装置の形態を示しているが、本発明に係る携帯電話装置の形態としては特にこれに限られない。例えば、両筐体を重ね合わせた状態から一方の筐体を一方向にスライドさせるようにしたスライド式や、重ね合せ方向に沿う軸線を中心に一方の筐体を回転させるようにした回転式(ターンタイプ)や、操作部と表示部とが一つの筐体に配置され、連結部を有さない形式(ストレートタイプ)でも良い。   Embodiments of the present invention will be described below. FIG. 1 is an external perspective view of a mobile phone device 1 incorporating a storage device 5 according to the present invention. 1 shows a form of a so-called foldable mobile phone device, the form of the mobile phone device according to the present invention is not particularly limited to this. For example, a sliding type in which one casing is slid in one direction from a state in which both casings are overlapped, or a rotary type in which one casing is rotated around an axis along the overlapping direction ( Turn type), or a type (straight type) in which the operation unit and the display unit are arranged in one housing and does not have a connecting unit.

携帯電話装置1は、操作部側筐体部2と、表示部側筐体部3を備えて構成される。操作部側筐体部2は、表面部10に、操作部11と、携帯電話装置1の使用者が通話時に発した音声が入力されるマイク12を備えて構成される。操作部11は、各種設定や電話帳機能やメール機能等の各種機能を作動させるための機能設定操作キー13と、電話番号の数字やメール等の文字等を入力するための入力操作キー14と、各種操作における決定やスクロール等を行う決定操作キー15から構成されている。
また、表示部側筐体部3は、表面部20に、各種情報を表示するためのLCD(Liquid Crystal Display)表示部21と、通話の相手側の音声を出力するスピーカ22を備えて構成されている。
The mobile phone device 1 includes an operation unit side body 2 and a display unit side body 3. The operation unit side body unit 2 includes an operation unit 11 and a microphone 12 to which a voice uttered by a user of the mobile phone device 1 is input on the surface unit 10. The operation unit 11 includes a function setting operation key 13 for operating various functions such as various settings, a telephone book function, a mail function, and the like, and an input operation key 14 for inputting a telephone number and characters such as mail. The operation key 15 includes a determination operation key 15 for performing determination and scrolling in various operations.
Further, the display unit side body unit 3 includes an LCD (Liquid Crystal Display) display unit 21 for displaying various types of information on the surface unit 20 and a speaker 22 for outputting the voice of the other party of the call. ing.

また、操作部側筐体部2の上端部と表示部側筐体部3の下端部とは、ヒンジ機構4を介して連結されている。また、携帯電話装置1は、ヒンジ機構4を介して連結された操作部側筐体部2と表示部側筐体部3とを相対的に回転することにより、操作部側筐体部2と表示部側筐体部3とを互いに開いた状態(開放状態)にしたり、操作部側筐体部2と表示部側筐体部3とを折り畳んだ状態(折畳み状態)にしたりできる。   Further, the upper end of the operation unit side body 2 and the lower end of the display unit side body 3 are connected via a hinge mechanism 4. In addition, the cellular phone device 1 relatively rotates the operation unit side body 2 and the display unit side body 3 connected via the hinge mechanism 4, thereby The display unit side body 3 can be opened (opened) with each other, or the operation unit side 2 and the display unit 3 can be folded (folded).

また、図2は、携帯電話装置1の機能を示す機能ブロック図である。携帯電話装置1は、図2に示すように、操作部11と、マイク12と、メインアンテナ40と、RF回路部41と、LCD制御部42と、音声処理部43と、メモリドライバ44と、メモリ45と、制御部46が操作部側筐体部2に備えられ、LCD表示部21と、スピーカ22と、LCDドライバ23が表示部側筐体部3に備えられている。なお、以下では、メモリドライバ44と、メモリ45と、制御部46を包括して、記憶装置5という。   FIG. 2 is a functional block diagram showing functions of the mobile phone device 1. As shown in FIG. 2, the mobile phone device 1 includes an operation unit 11, a microphone 12, a main antenna 40, an RF circuit unit 41, an LCD control unit 42, an audio processing unit 43, a memory driver 44, The memory 45 and the control unit 46 are provided in the operation unit side body 2, and the LCD display unit 21, the speaker 22, and the LCD driver 23 are provided in the display unit side body 3. Hereinafter, the memory driver 44, the memory 45, and the control unit 46 are collectively referred to as the storage device 5.

メインアンテナ40は、第1の使用周波数帯(例えば、800MHz)で基地局等と通信を行い、GPS通信のための第2の使用周波数帯(例えば、1.5GHz)に対応できるデュアルバンド対応構成である。なお、本実施の形態では、第1の使用周波数帯として、800MHzとしたが、これ以外の周波数帯であっても良い。また、メインアンテナ40は、第1の使用周波数帯で外部装置と通信を行い、GPS通信のための第2の使用周波数帯に対応できるアンテナを別途設けても良い。   The main antenna 40 communicates with a base station or the like in a first use frequency band (for example, 800 MHz), and can support a second use frequency band (for example, 1.5 GHz) for GPS communication. It is. In the present embodiment, the first frequency band used is 800 MHz, but other frequency bands may be used. Further, the main antenna 40 may be separately provided with an antenna that communicates with an external device in the first use frequency band and can correspond to the second use frequency band for GPS communication.

RF回路部41は、メインアンテナ40によって受信した信号を復調処理し、処理後の信号を制御部46に供給する。そして、制御部46から供給された信号を変調処理し、メインアンテナ40を介して外部装置(基地局)に送信する。また、その一方で、メインアンテナ40によって受信している信号の強度を制御部46に通知する。   The RF circuit unit 41 demodulates the signal received by the main antenna 40 and supplies the processed signal to the control unit 46. Then, the signal supplied from the control unit 46 is modulated and transmitted to an external device (base station) via the main antenna 40. On the other hand, the control unit 46 is notified of the strength of the signal received by the main antenna 40.

LCD制御部42は、制御部46の制御にしたがって、所定の画像処理を行い、処理後の画像データをLCDドライバ23に出力する。LCDドライバ23は、LCD制御部42から供給された画像データをフレームメモリに蓄え、所定のタイミングでLCD表示部21又はサブLCD表示部30に出力する。   The LCD control unit 42 performs predetermined image processing under the control of the control unit 46, and outputs the processed image data to the LCD driver 23. The LCD driver 23 stores the image data supplied from the LCD control unit 42 in the frame memory and outputs it to the LCD display unit 21 or the sub LCD display unit 30 at a predetermined timing.

音声処理部43は、制御部46の制御にしたがって、RF回路部41から供給された信号に対して所定の音声処理を行い、処理後の信号をスピーカ22に出力する。スピーカ22は、音声処理部43から供給された信号を外部に出力する。   The sound processing unit 43 performs predetermined sound processing on the signal supplied from the RF circuit unit 41 under the control of the control unit 46, and outputs the processed signal to the speaker 22. The speaker 22 outputs the signal supplied from the sound processing unit 43 to the outside.

また、音声処理部43は、制御部46の制御にしたがって、マイク12から入力された信号を処理し、処理後の信号をRF回路部41に出力する。RF回路部41は、音声処理部43から供給された信号に所定の処理を行い、処理後の信号をメインアンテナ40に出力する。   In addition, the audio processing unit 43 processes the signal input from the microphone 12 according to the control of the control unit 46, and outputs the processed signal to the RF circuit unit 41. The RF circuit unit 41 performs a predetermined process on the signal supplied from the sound processing unit 43 and outputs the processed signal to the main antenna 40.

メモリドライバ44は、メモリ45に対するアクセス(データの書き込み、読み出し及び消去)を行う。
メモリ45は、不揮発性メモリ(例えば、NAND型フラッシュメモリである。)により構成されている。メモリ45は、メモリドライバ44によってアクセスされ、画像データや文書データ等のユーザデータが格納される。
制御部46は、携帯電話装置1の全体を制御しており、中央処理装置(CPU)等を用いて構成される。
The memory driver 44 performs access (data writing, reading, and erasing) to the memory 45.
The memory 45 is composed of a nonvolatile memory (for example, a NAND flash memory). The memory 45 is accessed by the memory driver 44 and stores user data such as image data and document data.
The control unit 46 controls the entire mobile phone device 1 and is configured using a central processing unit (CPU) or the like.

ここで、NAND型フラッシュメモリ(以下、NAND型という。)とNOR型フラッシュメモリ(以下、NOR型という。)の違いについて説明する。
NOR型とNAND型の共通点は、(1)データの書き込み時において、ビット「1」からビット「0」の書き換えのみが行われること、(2)データの消去時において、決められたブロック単位でしか消去ができないこと等である。
Here, a difference between a NAND flash memory (hereinafter referred to as a NAND type) and a NOR flash memory (hereinafter referred to as a NOR type) will be described.
The common points of the NOR type and the NAND type are (1) only rewriting from bit “1” to bit “0” is performed at the time of data writing, and (2) block unit determined at the time of erasing data. It can only be erased.

(1)については、フラッシュメモリは、データが書き込まれていない状態において、規定値としてビット「1」が書き込まれており、データを書き込むときに、ビット「1」を書き込む場合には、規定値を維持し、ビット「0」を書き込む場合には、ビット「1」をビット「0」に書き換える処理が行われる。   As for (1), the bit “1” is written as a specified value in the flash memory in a state where no data is written, and when writing the bit “1” when writing data, the specified value is used. Is maintained and bit “0” is written, a process of rewriting bit “1” to bit “0” is performed.

(2)については、フラッシュメモリの回路構成上、消去処理は、ブロック単位での可能になっている。なお、フラッシュメモリでは、データが消去されるということは、ビットが全て「1」(規定値)になるということを意味している。   Regarding (2), due to the circuit configuration of the flash memory, the erasing process can be performed in units of blocks. In the flash memory, erasing data means that all bits are “1” (specified value).

また、NAND型には、ページの概念があり、基本的にページ単位でデータの書き込みを行う。また、ページには、データを書き込む回数に制限(数千回乃至数十万回程度)がある。NAND型は、複数のページから構成されるブロックが複数個で構成されている。例えば、1ページは、2kバイトであり、1ブロックは、64ページ(128kバイト)で構成されている。   The NAND type has a concept of pages, and data is basically written in units of pages. Further, a page has a limit on the number of times data is written (several thousands to several hundred thousand times). The NAND type includes a plurality of blocks each including a plurality of pages. For example, one page is 2 kbytes, and one block is composed of 64 pages (128 kbytes).

また、NOR型は、データの書き込み中の電源断対策として、フラグを使用している。NOR型は、回路構成上ビット単位までデータの書き込みが可能であるので、例えば、データを書き込む際に、初期状態の所定のビット(管理エリア)を「0」から「1」に書き換え、データの書き込み終了時に、当該所定のビットを「1」から「0」に書き換える処理を行う。また、NOR型は、所定のビットの状態を確認し、所定のビットが「1」であれば、データの書き込み中に電源断が生じ、データが正常に書き込めなかったと判断を行っている。   Further, the NOR type uses a flag as a countermeasure against power interruption during data writing. In the NOR type, data can be written up to a bit unit because of the circuit configuration. For example, when data is written, a predetermined bit (management area) in an initial state is rewritten from “0” to “1”. At the end of writing, a process of rewriting the predetermined bit from “1” to “0” is performed. In the NOR type, the state of the predetermined bit is confirmed, and if the predetermined bit is “1”, it is determined that the data could not be normally written because the power was cut off during the data writing.

しかし、NAND型は、上述したように、ページ単位でデータの書き込みが可能であるため、単純に、NOR型の処理方法を採用すると、管理エリアがページ単位になってしまい、ユーザデータエリアが不足してしまうおそれがある。   However, since the NAND type can write data in units of pages as described above, simply adopting the NOR type processing method causes the management area to be in units of pages, and the user data area is insufficient. There is a risk of it.

また、NOR型は、管理エリアとユーザデータエリアが一対一に固定で対応している。したがって、NAND型は、例えば、管理エリアに書き込むフラグの数が物理的なブロックサイズの制限によりm個(mページ)までとすれば、ユーザデータの個数も制限されてしまうおそれがある。   In the NOR type, the management area and the user data area are fixed in one-to-one correspondence. Therefore, in the NAND type, for example, if the number of flags to be written in the management area is set to m (m pages) due to a physical block size limitation, the number of user data may be limited.

また、NAND型において、単純にNOR型の処理方法を採用してしまうと、データを書き込み始める時に管理エリアの所定のページに対して書き換えを行い、データの書き込みが終了した場合に、当該所定のページが属するブロック全体の消去処理を行うことになる。NAND型は、上述したように書き換え回数に制限があるため、データの書き込みの度にブロック全体の消去処理を行ってしまうと、寿命が短くなるおそれがある。   In addition, in the NAND type, if the NOR type processing method is simply adopted, when the data writing is completed after rewriting the predetermined page in the management area when the data writing is started, the predetermined processing is performed. The entire block to which the page belongs is erased. Since the NAND type has a limit on the number of rewrites as described above, the lifetime may be shortened if the entire block is erased each time data is written.

また、NAND型は、NOR型の処理方法のように、ユーザデータをユーザデータエリアから読み出す直前に管理エリアからフラグを読み出し、電源断により不正なデータの書き込みが発生しているか否かの処理を、ユーザデータにアクセスする度にチェックするのは処理速度的に不利となる。   In the NAND type, as in the NOR type processing method, the flag is read from the management area immediately before the user data is read from the user data area, and whether or not illegal data is written due to the power-off is determined. Checking every time user data is accessed is disadvantageous in terms of processing speed.

また、NAND型は、回路構成上、ビットエラーの起こりやすいデバイスであるため、一般的に、ECC(Error Check and Correct)コードが付加される。また、ECCは、1ビットエラーに対しては、対応可能(訂正可能)であるが、2ビット以上のエラーに対しては、対応不可能(訂正不可能)である。なお、ECCは、2ビット以上のエラーに対しては、エラーが生じていることは検出可能である。   In addition, the NAND type is a device in which a bit error is likely to occur due to the circuit configuration, and therefore an ECC (Error Check and Correct) code is generally added. The ECC can cope with (correctable) a 1-bit error, but cannot cope with (correctable) an error of 2 bits or more. The ECC can detect that an error has occurred for an error of 2 bits or more.

また、NAND型は、あるブロックのデータを読み出す際にECCを行って、2ビット以上のエラーの発生を検出した場合には、そのブロックを消去処理(規定値の書き込み処理)しない限り再使用が禁止となる。   In the NAND type, when data of a block is read out, ECC is performed and when an error of 2 bits or more is detected, the block can be reused unless the block is erased (specified value write processing). Prohibited.

また、NAND型は、一つのブロックが複数のページから構成されており、ユーザデータの書き込みは通常、ページと呼ばれる単位で行われるが、書き込み中に電源断が発生すると、その書き込み中のページ内のデータが不定値(FFh等の規定値ではなく、ランダムな値)になることが分かっている。ここで、電源断とは、バッテリーの残量が無くなったり、携帯電話装置1を落下させる等により、電源の供給が途絶え、処理の続行ができない状態を意味する。   In the NAND type, one block is composed of a plurality of pages, and writing of user data is normally performed in units called pages. However, if a power interruption occurs during writing, the user data is written in the page being written. It is known that the data of the above becomes an indefinite value (not a specified value such as FFh but a random value). Here, the power interruption means a state in which the supply of power is interrupted due to the remaining battery level or the mobile phone device 1 being dropped, and the processing cannot be continued.

また、制御部46は、不定値が書き込まれているページ(以下、不定ページという。)のデータを読み出すと、ECCにより2ビット以上のエラーを検出することになる。しかし、システム上、不定ページは、ディスカード(破棄)して使用しない、すなわち制御部46によってアクセスされないようにする必要がある。   Further, when the control unit 46 reads data of a page in which an indefinite value is written (hereinafter referred to as an indefinite page), an error of 2 bits or more is detected by ECC. However, in the system, it is necessary to discard the undefined page and not use it, that is, not to be accessed by the control unit 46.

ここで、一般的に発生する2ビットエラーと、電源断が起因して発生する不定ページによる2ビットエラーを区別する必要がある。前者の2ビットエラーは、ブロックの再使用が物理的に不可能な場合があるが、後者の2ビットエラーは、単なる書き込み時のエラーなので、ブロックの再使用が可能である。   Here, it is necessary to distinguish between a 2-bit error that generally occurs and a 2-bit error due to an indefinite page that occurs due to a power failure. In the former 2-bit error, there is a case where the block cannot be reused physically. However, since the latter 2-bit error is an error at the time of writing, the block can be reused.

記憶装置5は、メモリ45としてNAND型を採用し、メモリ45をFFS(フラッシュファイルシステム)でデータの読み出し及び書き込みを制御する際に信頼性を確保し、メモリ45に書き込まれているユーザデータが正常に書き込まれたものか否かの判断を、メモリ45の負担を最小限にして行う機能を有している。   The storage device 5 adopts a NAND type as the memory 45, ensures reliability when the memory 45 is controlled to read and write data by FFS (flash file system), and user data written in the memory 45 is stored in the memory 45. It has a function of determining whether or not the data has been normally written with the burden on the memory 45 minimized.

以下に、上述した機能を発揮するための制御部46の動作について詳述する。
メモリ45は、所定数のページからなるブロックを複数個有し、データの読み出し及び書き込みをページ単位で受け付け、データの消去をブロック単位で受け付ける。メモリ45は、図3に示すように、ユーザデータエリアUAと、管理用エリアMAとから構成されている。ユーザデータエリアUAは、ユーザデータを記憶する複数のユーザデータ用ブロックUB1乃至UBnにより構成されている。管理用エリアMAは、ユーザデータ用ブロックUB1乃至nを管理する複数の管理用ブロックMB1乃至MBnによって構成されている。また、メモリ45は、固有のアドレスが付されている。
Hereinafter, the operation of the control unit 46 for exhibiting the above-described function will be described in detail.
The memory 45 includes a plurality of blocks each having a predetermined number of pages, receives data reading and writing in units of pages, and receives data erasing in units of blocks. As shown in FIG. 3, the memory 45 includes a user data area UA and a management area MA. The user data area UA includes a plurality of user data blocks UB1 to UBn that store user data. The management area MA includes a plurality of management blocks MB1 to MBn that manage user data blocks UB1 to UBn. The memory 45 is assigned a unique address.

また、上述したように、ブロックは、128kバイトのサイズとし、ページは、2kバイトのサイズとする。また、一つのブロックには、64個のページが含まれているものとする。また、ユーザデータエリアUAは、ユーザデータを格納するために使用する。管理用エリアMAは、ユーザデータの書き込み管理のために使用する。   As described above, the block has a size of 128 kbytes, and the page has a size of 2 kbytes. In addition, it is assumed that one block includes 64 pages. The user data area UA is used for storing user data. The management area MA is used for user data writing management.

なお、詳細は後述するが、ユーザデータエリアUA及び管理用エリアMAに属する各ブロックの物理的な位置は、固定である必要はなく、ガベージコレクション機能や、ウェアレベリング機能を利用することによって、各ブロックが適宜入れ替えられる構成であっても良い。   Although the details will be described later, the physical positions of the blocks belonging to the user data area UA and the management area MA do not need to be fixed, and by using the garbage collection function or the wear leveling function, The structure by which a block is replaced suitably may be sufficient.

制御部46は、メモリ45に対して、データの読み出し、書き込み及び消去を行う。
ここで、制御部46による具体的な処理方法について説明する。なお、ユーザデータを書き込む際には、所定の方法に基づいて所定のユーザデータ用ブロック内の所定のページが指定されるが、以下では、便宜的に、ユーザデータをユーザデータ用ブロックUB2に書き込むことを想定して説明する。
The control unit 46 reads, writes, and erases data with respect to the memory 45.
Here, a specific processing method by the control unit 46 will be described. When writing user data, a predetermined page in a predetermined user data block is designated based on a predetermined method. In the following, for convenience, the user data is written in the user data block UB2. This will be explained assuming that.

制御部46は、図3に示すように、ユーザデータをユーザデータ用ブロックUB2に書き込みを開始する時、管理用ブロックMB1の第1ページP1にユーザデータに対応する第1フラグ(書き込み中フラグ)F1を書き込む処理を行う。そして、制御部46は、ユーザデータの書き込みが終了した場合に、第1ページP1とは異なる第2ページP2にユーザデータに対応する第2フラグ(書き込み終了フラグ)F2を書き込む処理を行う。   As shown in FIG. 3, when the controller 46 starts writing user data to the user data block UB2, the first flag (during writing) corresponding to the user data in the first page P1 of the management block MB1. A process of writing F1 is performed. Then, when the writing of the user data is finished, the control unit 46 performs a process of writing a second flag (write end flag) F2 corresponding to the user data on the second page P2 different from the first page P1.

また、制御部46は、第1ページP1に第1フラグF1を書き込む際に、ユーザデータを書き込むページ(所定のユーザデータ用ブロック内の所定のページ)のアドレス(書き込みアドレス)A1を書き込む。   Further, when writing the first flag F1 to the first page P1, the control unit 46 writes the address (write address) A1 of the page to which user data is written (a predetermined page in a predetermined user data block).

制御部46は、第2ページP2に第2フラグF2を書き込む際に、ユーザデータを書き込んだページ(所定のユーザデータ用ブロック内の所定のページであって、複数ページに渡ってユーザデータが書き込まれている場合には、先頭のページ)のアドレス(書き込みアドレス)A1を書き込む。そして、詳細は後述するが、制御部46は、第2フラグF2及び書き込みアドレスA1を第2ページP2に書き込む場合、第2ページP2の残りの領域にユニーク値(例えば、55h)を書き込む。   When writing the second flag F2 to the second page P2, the control unit 46 writes the user data (a predetermined page in a predetermined user data block, and the user data is written over a plurality of pages). If it is, the address (write address) A1 of the first page) is written. As will be described in detail later, when writing the second flag F2 and the write address A1 to the second page P2, the control unit 46 writes a unique value (for example, 55h) in the remaining area of the second page P2.

また、制御部46は、第1ページP1において、書き込みアドレスA1と第1フラグF1が書き込まれた以外のエリアについては、他のデータを書き込まずに全て規定値(FFh)のままにしておく。   In addition, in the first page P1, the control unit 46 keeps the specified value (FFh) without writing other data for the areas other than the area where the write address A1 and the first flag F1 are written.

ここで、管理用エリアMAにアクセスした際に、ECCにより2ビットエラーを検出した場合においても、一般的に発生する2ビットエラーであるのか、又は、電源断が起因して発生する不定ページによる2ビットエラーであるのかを区別する必要がある。   Here, even when a 2-bit error is detected by ECC when the management area MA is accessed, it is a 2-bit error that generally occurs or due to an indefinite page that occurs due to a power failure. It is necessary to distinguish whether it is a 2-bit error.

そこで、制御部46は、図3に示すように、第2ページP2において、書き込みアドレスA1と第2フラグF2を書き込んだ以外のエリアについては、全て所定のユニーク値(例えば、55h)を書き込む処理を行う。   Therefore, as shown in FIG. 3, the control unit 46 writes a predetermined unique value (for example, 55h) for all areas other than the write address A1 and the second flag F2 in the second page P2. I do.

このような構成によれば、制御部46は、第2ページP2にアクセスし、ECCにより2ビットエラーを検出した場合には、第2ページP2に書き込まれている値を読み出し、読み出した値が所定のユニーク値と一致するか否かの処理を行う。   According to such a configuration, when the control unit 46 accesses the second page P2 and detects a 2-bit error by ECC, the control unit 46 reads the value written in the second page P2, and the read value is A process is performed to determine whether or not the value matches a predetermined unique value.

制御部46は、読み出した値にユニーク値が含まれていない、又は含まれているが少ない場合(ユニーク値に不一致が多くデータが崩れている場合)には、ユニーク値の書き込み中に電源断が生じたと判断して、当該第2ページP2を不定ページであると判定し、また、一定数以上のユニーク値が含まれている場合には、一般的に発生する2ビットエラーであると判定する。   If the read value does not contain a unique value or contains a small number of unique values (if there are many mismatches in the unique value and the data is corrupted), the control unit 46 turns off the power during the writing of the unique value. It is determined that the second page P2 is an indefinite page, and if a certain number or more of unique values are included, it is determined that a 2-bit error generally occurs. To do.

制御部46は、第2ページP2が不定ページであると判定した場合には、ユーザデータを正常に書き込んだ後、第2ページP2に第2フラグF2を書き込んだ後のユニーク値の書き込みの最中に電源断が発生したと考え、第2ページP2が属するブロックに対して消去処理を行わない。   When the control unit 46 determines that the second page P2 is an indefinite page, after writing the user data normally and then writing the second flag F2 on the second page P2, It is considered that a power interruption has occurred, and the erase process is not performed on the block to which the second page P2 belongs.

また、制御部46は、第2ページP2に一般的な2ビットエラーが生じていると判断した場合には、その管理用ブロックのページを全て破棄(ディスカード)し、ガーベッジコレクション機能の利用によって、第2ページP2が属するブロックの消去処理を行う。   If the control unit 46 determines that a general 2-bit error has occurred in the second page P2, the control unit 46 discards (discards) all the pages of the management block, and uses the garbage collection function. Then, the erasure process of the block to which the second page P2 belongs is performed.

また、一つのページが4つのセクタから構成されていると仮定した場合、制御部46は、各セクタに対してECCを行う。つまり、制御部46は、1ビットエラーの場合には訂正を行い、2ビットエラーの場合には、エラーの検出を行う。   When it is assumed that one page is composed of four sectors, the control unit 46 performs ECC for each sector. That is, the control unit 46 performs correction when a 1-bit error occurs, and detects an error when a 2-bit error occurs.

また、制御部46は、目安として、ユニーク値(55h)のパターンが2ビット不一致になっているセクタが、2セクタ以上ある場合に、不定ページと判断する。これは、1セクタだけが2ビット不一致であれば、一般的な2ビットエラーが生じている可能性があるためである。   Further, as a guideline, the control unit 46 determines that the page is an indefinite page when there are two or more sectors where the pattern of the unique value (55h) does not match 2 bits. This is because there is a possibility that a general 2-bit error has occurred if only one sector has a 2-bit mismatch.

このようにして、記憶装置5は、ユーザデータが正常にユーザデータ用ブロックに書き込んだ場合には、同一の書き込みアドレスAが書き込まれている第1ページP1と第2ページP2のペアを生成し、かつ、第2ページP2には、書き込みアドレスA1と、第2フラグF2と、所定のユニーク値を書き込む処理を行う。   In this way, when the user data is normally written in the user data block, the storage device 5 generates a pair of the first page P1 and the second page P2 in which the same write address A is written. In addition, a process of writing the write address A1, the second flag F2, and a predetermined unique value is performed on the second page P2.

また、制御部46は、電源の投入時において、管理用エリアMAにアクセスし、書き込みアドレスA1に基づいて、第1ページP1と第2ページP2のペアを検出し、第1ページP1及び第2ページP2にそれぞれ第1フラグF1と第2フラグF2が書き込まれている場合には、当該第1フラグF1に対応するユーザデータがユーザデータ用ブロックUB2に正常に書き込まれていると判断して、当該ユーザデータが書き込まれているユーザデータ用ブロックUB2に対して消去処理を行わない。   Further, when the power is turned on, the control unit 46 accesses the management area MA, detects the pair of the first page P1 and the second page P2 based on the write address A1, and detects the first page P1 and the second page P2. When the first flag F1 and the second flag F2 are respectively written in the page P2, it is determined that the user data corresponding to the first flag F1 is normally written in the user data block UB2, The erasure process is not performed on the user data block UB2 in which the user data is written.

また、制御部46は、電源の投入時において、管理用エリアMAにアクセスし、第1ページP1には第1フラグF1が書き込まれているものの、第2ページP2には第2フラグF2が書き込まれていない場合には、ユーザデータ用ブロックUB2にユーザデータを書き込み中に電源断が発生したと推定し、当該第1フラグF1に対応するユーザデータがユーザデータ用ブロックUB2に正常に書き込まれていないと推定する。   Further, the control unit 46 accesses the management area MA when the power is turned on, and the first flag F1 is written in the first page P1, but the second flag F2 is written in the second page P2. If not, it is presumed that a power interruption has occurred during the writing of user data to the user data block UB2, and the user data corresponding to the first flag F1 has been normally written to the user data block UB2. Estimated not.

なお、制御部46は、電源の投入時において、書き込みアドレスA1に基づいて、第1ページP1と第2ページP2のペアを検出し、第1ページP1には第1フラグF1が書き込まれているものの、第2ページP2にはユニーク値が書き込まれていないときでも、当該第1フラグF1に対応するユーザデータがユーザデータ用ブロックUB2に正常に書き込まれていると判断して、当該ユーザデータが書き込まれているユーザデータ用ブロックUB2に対して消去処理を行わない構成であっても良い。   When the power is turned on, the control unit 46 detects the pair of the first page P1 and the second page P2 based on the write address A1, and the first flag F1 is written in the first page P1. However, even when the unique value is not written in the second page P2, it is determined that the user data corresponding to the first flag F1 is normally written in the user data block UB2, and the user data is The configuration may be such that the erase process is not performed on the written user data block UB2.

第2ページP2に書き込みアドレスA1を書き込めたということは、ユーザデータは、正常に書き込めた状態であることを意味する。このような状態は、ユーザデータを正常に書き込み、第2ページP2に書き込みアドレスA1及び第2フラグF2を書き込んだ後のユニーク値を書き込んでいる最中に電源断が発生したものと考えられる。よって、第1フラグF1に対応するユーザデータは、ユーザデータ用ブロックUB2に正常に書き込まれていると判断される。   The fact that the write address A1 has been written to the second page P2 means that the user data has been written normally. In such a state, it is considered that the power interruption occurred while writing the user data normally and writing the unique value after writing the write address A1 and the second flag F2 to the second page P2. Therefore, it is determined that the user data corresponding to the first flag F1 is normally written in the user data block UB2.

このように構成されることによって、記憶装置5は、ユーザデータの書き込みを開始する時に、第1ページに書き込みアドレスと共に第1フラグを書き込み、ユーザデータの書き込みを終了した場合に、第2ページP2に書き込みアドレスと第2フラグを書き込むので、電源投入時に、管理用エリアMAにアクセスし、第1ページと第2ページのペアを検出し、第1フラグと第2フラグが書き込まれていることを確認した場合には、ユーザデータが正常に書き込まれていると判断でき、ユーザデータが書き込まれているユーザデータ用ブロックに対して消去処理を行わない。
したがって、記憶装置5は、メモリ45に書き込まれているユーザデータが正常に書き込まれたものか否かの判断を、メモリ45の負担を最小限にして行うことができる。
With this configuration, when starting to write user data, the storage device 5 writes the first flag together with the write address to the first page, and when the user data has been written, the second page P2 Since the write address and the second flag are written in, when the power is turned on, the management area MA is accessed, the pair of the first page and the second page is detected, and the first flag and the second flag are written. If it is confirmed, it can be determined that the user data has been normally written, and the erasure process is not performed on the user data block in which the user data is written.
Therefore, the storage device 5 can determine whether or not the user data written in the memory 45 is normally written with the burden on the memory 45 minimized.

なお、管理用ブロックMBの状態をチェックするのは、電源投入後の起動時の一回だけで良く、ユーザデータを読み出す度にチェックする必要はない。   The state of the management block MB is checked only once at the start-up after the power is turned on, and does not need to be checked every time user data is read.

また、記憶装置5は、電源断が発生したと判定されれば、その不定データが含まれているブロックを使用しないようにするために、ディスカード(破棄)処理を行っても良い。例えば、詳細は後述する、ガベージコレクション機能等の利用により、ディスカード処理したブロックの消去処理(規定値を書き込む処理)が行われ、当該ブロックの再利用が可能となる。   Further, if it is determined that a power interruption has occurred, the storage device 5 may perform a discarding (discarding) process so as not to use the block including the indefinite data. For example, by using a garbage collection function or the like, which will be described in detail later, an erase process (a process for writing a specified value) of a discarded block is performed, and the block can be reused.

また、管理用ブロックMBは、ユーザデータ用ブロックUBと一対一に対応させているわけではない。よって、記憶装置5では、ユーザデータ用ブロックUBとは独立に順次空いている下方のページに対してフラグ等の書き込みを行う。また、一度チェックされた第1フラグF1や第2フラグF2は、不要になるので、後述するガベージコレクション機能を利用することによって順次削除する。よって、記憶装置5では、管理用ブロックMBとしては見かけ上、サイズ制限はなく、全データ用ブロックのサイズにも制限はない。   Further, the management block MB does not correspond one-to-one with the user data block UB. Therefore, the storage device 5 writes a flag or the like to the lower pages that are sequentially vacant independently of the user data block UB. Further, the first flag F1 and the second flag F2 that have been checked once become unnecessary, and are sequentially deleted by using a garbage collection function described later. Therefore, in the storage device 5, the management block MB apparently has no size limitation, and there is no limitation on the size of all data blocks.

また、第2ページP2は、第1ページの次のページであることが好ましい。
このような構成によれば、制御部46は、第1ページと第2ページが連続しているので、管理用エリアMAにアクセスする際に、ペアとなるページを簡易に検索することが可能となる。
The second page P2 is preferably the next page after the first page.
According to such a configuration, since the first page and the second page are continuous, the control unit 46 can easily search for a paired page when accessing the management area MA. Become.

ここで、管理用ブロックMBにおいて、特定のブロックの使用頻度が高くなり、所定の使用回数に達すると、当該ブロックが使用不能になり、結果、メモリ45全体の容量が低減してしまう。
そこで、制御部46は、所定の期間又はメモリ45の各ブロックの使用頻度に基づいて、一のブロックに書き込まれているデータを他のブロックに移動する処理を行うことが好ましい。
Here, in the management block MB, the frequency of use of a specific block increases, and when the predetermined number of uses is reached, the block becomes unusable, and as a result, the capacity of the entire memory 45 is reduced.
Therefore, the control unit 46 preferably performs processing for moving data written in one block to another block based on a predetermined period or the use frequency of each block of the memory 45.

制御部46は、ガベージコレクション機能やウェアレベリング機能を有している。
ガベージコレクション機能とは、プログラムが使用しなくなったメモリ領域や、プログラム間の隙間のメモリ領域を集めて、連続した利用可能なメモリ領域を増やす機能である。ガベージコレクション機能によれば、有限の容量であるメモリ45を有効に活用することができる。
The control unit 46 has a garbage collection function and a wear leveling function.
The garbage collection function is a function for collecting memory areas that are no longer used by a program or memory areas in the gaps between programs to increase a continuously usable memory area. According to the garbage collection function, the memory 45 having a finite capacity can be used effectively.

また、ウェアレベリング機能とは、データの書き換えを行うブロック(ページ)を、特定のブロック(ページ)に集中させないようにできるだけ均等に分散させる機能である。ウェアレベリング機能によれば、特定のページに対する書き込みと消去の繰り返しを防ぐことができるので、メモリ45の寿命を延ばすことができる。   The wear leveling function is a function that distributes blocks (pages) for data rewriting as evenly as possible so as not to concentrate on specific blocks (pages). According to the wear leveling function, repeated writing and erasing on a specific page can be prevented, so that the life of the memory 45 can be extended.

制御部46は、所定の期間が経過したことを条件として、ガベージコレクション機能を利用して、一のブロックに書き込まれているデータを他のブロックに移動する処理を行う。また、制御部46は、メモリ45の各ブロックの使用頻度に基づいて、ウェアレベリング機能を利用して、一のブロックに書き込まれているデータを他のブロックに移動する処理を行っても良い。   The control unit 46 performs a process of moving data written in one block to another block by using the garbage collection function on condition that a predetermined period has elapsed. Further, the control unit 46 may perform a process of moving data written in one block to another block using a wear leveling function based on the frequency of use of each block in the memory 45.

このように構成されることによって、記憶装置5は、連続した利用可能なメモリ領域を増やすことができ、かつ、メモリ45の寿命を延ばすことができる。   With this configuration, the storage device 5 can increase the continuous usable memory area and can extend the life of the memory 45.

また、上述したように、管理用ブロックMBにデータの書き込みを行っていくと、そのブロックに書き込む空きスペースがなくなってくる。ここで、メモリ45は、回路構成上、ブロック単位でしか消去が行えない。
したがって、制御部46は、ガベージコレクション機能やウェアレベリング機能を利用して、管理用のブロックに管理用データを書き込み、全てのページを使い切ると、別個に存在するスペア用のブロックに必要な管理用データをコピーし、管理用のブロックを消去処理する。したがって、制御部46は、スペア用のブロックを管理用ブロックとして使用し、当初管理用として使用していたブロックをスペア用として利用する。
Further, as described above, when data is written to the management block MB, there is no free space to be written to the block. Here, the memory 45 can be erased only in block units due to the circuit configuration.
Therefore, the control unit 46 uses the garbage collection function or the wear leveling function to write management data to the management block, and when all the pages are used up, the control unit 46 is required for the spare block that exists separately. Copy the data and erase the management block. Therefore, the control unit 46 uses the spare block as a management block, and uses the block that was originally used for management as a spare block.

また、管理用ブロックMBは、頻繁にページの書き込みが行われ、使用頻度が高いブロックである。よって、制御部46は、管理用ブロックMBをウェアレベリングの対象となるように制御する。   The management block MB is a block that is frequently used and frequently used. Therefore, the control unit 46 controls the management block MB so as to be a target of wear leveling.

また、管理用ブロックMBに書き込まれる管理データは、電源投入時にユーザデータが正常に書き込まれたか否かの判断に使用された後は、利用されないため、事実上無効データとなる。したがって、厳密にいえば、制御部46は、現在の管理用ブロックMBに書き込まれている管理データをスペア用のブロックへコピーする必要はない。よって、管理データをスペア用のブロックへコピーしない場合には、スペア用のブロックは、最初から全領域が空き状態の管理用ブロックとなる。   The management data written to the management block MB is effectively invalid data because it is not used after it is used to determine whether or not user data has been normally written when the power is turned on. Therefore, strictly speaking, the control unit 46 does not need to copy the management data written in the current management block MB to the spare block. Therefore, when the management data is not copied to the spare block, the spare block is a management block whose entire area is empty from the beginning.

また、管理用ブロックMBに対して過去に書込んだページデータは、二度とアクセスする必要のないデータである。制御部46は、システムがアイドル状態(携帯電話装置1が不使用状態)になったときに、破棄(ディスカード)する。その後、制御部46は、ガベージコレクション機能を利用することによって、新しい管理用ブロックMBが再生されることになる。   The page data written in the past to the management block MB is data that does not need to be accessed again. The control unit 46 discards (discards) the system when it is in an idle state (the mobile phone device 1 is not in use). Thereafter, the control unit 46 uses the garbage collection function to reproduce a new management block MB.

なお、システムがアイドル状態になることなく、連続的なユーザデータの書き込みが行われた場合、管理用ブロックMBに空き容量がなくなってしまうことがある。制御部46は、管理用データを書き込むためのページが無くなった場合、強制的にガベージコレクション機能を利用し、仮に破棄(ディスカード)されていなくてもページデータのコピーは行わないこととする。記憶装置5は、このように強制的にガベージコレクション機能を利用して、管理用データを書き込むための空きスペースを確保する機能も有している。   Note that if continuous writing of user data is performed without the system becoming idle, the management block MB may run out of free space. When there is no page for writing management data, the control unit 46 forcibly uses the garbage collection function and does not copy the page data even if it is not discarded (discarded). The storage device 5 also has a function of ensuring a free space for writing management data by forcibly using the garbage collection function.

また、記憶装置5は、管理用ブロックのみが書き込み頻度が高く、スペア用のブロックと入替えにガベージコレクション機能を利用することも想定される。そうすると、何度もデータの入替えを繰り返すブロックは、使用頻度が高くなってしまう。   Further, it is assumed that only the management block has a high writing frequency in the storage device 5, and that the garbage collection function is used to replace the spare block. If it does so, the block which repeats replacement of data many times will become frequently used.

そこで、記憶装置5は、各ブロックに対して、消去(イレーズ)回数を数えるイレーズカウンタを設ける。制御部46は、メモリ45の全ブロックに対してイレーズカウンタのカウント値を起動時にチェックしておき、カウント値の最大と最小の差がある一定値を超えたらウェアレベリング機能を実行するものとする。このように構成することにより、記憶装置5は、カウント値の小さい静的なブロックが次のスペア用ブロックとなり、メモリ45全体を均一に使用することができる。   Therefore, the storage device 5 is provided with an erase counter that counts the number of erases for each block. The control unit 46 checks the count value of the erase counter for all blocks of the memory 45 at the time of activation, and executes the wear leveling function when the difference between the maximum and minimum count values exceeds a certain value. . With this configuration, in the storage device 5, the static block with a small count value becomes the next spare block, and the entire memory 45 can be used uniformly.

また、ガベージコレクション機能を利用した場合の模式図を図4に示す。図4では、ガベージコレクション機能を利用して、管理用ブロックMBが処理された場合を示している。メモリ45は、ガベージコレクション機能を利用した後は、図4に示すように、使用するブロック位置が相互に入れ替わるイメージとなる。   Moreover, the schematic diagram at the time of utilizing a garbage collection function is shown in FIG. FIG. 4 shows a case where the management block MB is processed using the garbage collection function. After the garbage collection function is used, the memory 45 has an image in which used block positions are interchanged as shown in FIG.

また、ガベージコレクション機能を利用するには、データを移動するためのスペア用のブロック(スペアブロックSB)が必要になる。ここで、あるブロックを新規にスペアブロックSBにするためには、当該ブロックに対して消去の処理を行う必要がある。よって、制御部46は、あるブロックを新規にスペアブロックSBにする場合には、当該ブロックのビットを全て規定値(ビット「1」)にする。   In order to use the garbage collection function, a spare block (spare block SB) for moving data is required. Here, in order to make a block a new spare block SB, it is necessary to perform an erasing process on the block. Accordingly, when a block is newly set as a spare block SB, the control unit 46 sets all bits of the block to a specified value (bit “1”).

また、ガベージコレクション機能とウェアレベリング機能を利用した場合の模式図を図5に示す。
メモリ45のデータブロックB1は、書換え頻度の少ないデータが格納されているデータブロックであり、ブロック消去される回数も少なくなっている(以下、データブロックB1を静的データブロックB1という。)。制御部46は、ウェアレベリング機能を利用する際に、この静的データブロックB1に着目する。
FIG. 5 shows a schematic diagram when the garbage collection function and the wear leveling function are used.
The data block B1 of the memory 45 is a data block in which data with a low rewrite frequency is stored, and the number of times of block erasure is reduced (hereinafter, the data block B1 is referred to as a static data block B1). The control unit 46 pays attention to the static data block B1 when using the wear leveling function.

制御部46は、ウェアレベリング機能を利用して、静的データブロックB1とスペアブロックSBを入れ替える処理を行う(図5(a)、(b)を参照。)。なお、制御部46は、ガベージコレクション機能を利用して、当該入れ替え処理を行っても良い。   The control unit 46 performs a process of exchanging the static data block B1 and the spare block SB using the wear leveling function (see FIGS. 5A and 5B). Note that the control unit 46 may perform the replacement process using a garbage collection function.

結果として、制御部46は、ウェアレベリング機能を発揮する前にスペアブロックSBとして存在していた使用頻度の高いブロックを、ウェアレベリング機能又はガベージコレクション機能を利用することによって、静的データを格納するブロックにし、使用頻度の低いブロックにすることができる。   As a result, the control unit 46 stores static data by using the wear leveling function or the garbage collection function for the frequently used blocks that existed as the spare block SB before the wear leveling function is exhibited. Blocks can be made into less frequently used blocks.

次に、制御部46は、ウェアレベリング機能又はガベージコレクション機能を利用して、管理用ブロックMBとスペアブロックSBを入れ替える処理を行う(図5(b)、(c)を参照。)。   Next, the control unit 46 performs processing for exchanging the management block MB and the spare block SB using the wear leveling function or the garbage collection function (see FIGS. 5B and 5C).

このようにして、メモリ45では、管理用ブロックMBとなったブロック位置は、当初、ウェアレベリング機能を利用する前に静的データが格納されていたブロックであり、今まで使用頻度が少なかったブロックが管理用ブロックに変更することができる。よって、記憶装置5は、メモリ45全体を均等に使用することになり、寿命を延ばすことができる。   In this way, in the memory 45, the block position that has become the management block MB is a block in which static data was initially stored before using the wear leveling function, and a block that has been used less frequently until now. Can be changed to a management block. Therefore, the storage device 5 uses the entire memory 45 evenly and can extend the life.

また、メモリ45のブロックには、上述したように、何もデータが書き込まれていない場合には、予め規定値(例えば、ビット「1」)が書き込まれている。
制御部46は、第2ページの一部に第2フラグを書き込む場合、当該第2フラグが書き込まれる領域以外の領域に規定値以外の値を書き込み、第1ページには第1フラグが書き込まれているものの、第2ページには第2フラグが書き込まれていない場合には、当該第1フラグに対応するユーザデータがユーザデータ用ブロックUBに正常に書き込まれていないと推定した上で、第2ページの第2フラグが書き込まれる領域以外の所定領域に規定値(例えば、FFh)が書き込まれているかどうかを判定する構成であっても良い。
Further, as described above, when no data is written in the block of the memory 45, a specified value (for example, bit “1”) is written in advance.
When writing the second flag to a part of the second page, the control unit 46 writes a value other than the specified value in an area other than the area in which the second flag is written, and the first flag is written in the first page. However, if the second flag is not written in the second page, it is estimated that the user data corresponding to the first flag is not normally written in the user data block UB. It may be configured to determine whether a prescribed value (for example, FFh) is written in a predetermined area other than the area where the second flag of 2 pages is written.

このような構成の場合には、制御部46は、第2ページの所定領域に規定値が書き込まれていると判定した場合には、第1フラグに対応するユーザデータが正常に書き込まれていないと判断する。これは、第1ページに第1フラグが書き込まれているが、第2ページが規定値のままであるので、ユーザデータを書き込んでいる最中に電源断が発生し、ユーザデータがユーザデータ用ブロックに対して正常に書き込めなかったものと判断できるからである。   In such a configuration, when the control unit 46 determines that the specified value is written in the predetermined area of the second page, the user data corresponding to the first flag is not normally written. Judge. This is because the first flag is written on the first page, but the second page remains at the specified value, so that power is cut off while user data is being written, and the user data is for user data. This is because it can be determined that the block could not be written normally.

また、制御部46は、第2ページの所定領域に規定値が書き込まれていないと判定した場合には、第1フラグに対応するユーザデータが正常に書き込まれていると判断し、当該ユーザデータが書き込まれているブロックに対して消去処理を行わない。これは、第2ページに第2フラグも書き込まれておらず、かつ規定値にもなっていなければ、第2ページにユニーク値を書き込んでいる最中に電源断が生じたものと考えられる。したがって、このような場合には、ユーザデータは、ユーザデータ用ブロックに対して正常に書き込めたものと判断することができる。   If the control unit 46 determines that the specified value is not written in the predetermined area of the second page, the control unit 46 determines that the user data corresponding to the first flag is normally written, and the user data The erase process is not performed on the block in which is written. If the second flag is not written on the second page and does not reach the specified value, it is considered that a power failure occurred while the unique value was written on the second page. Therefore, in such a case, it can be determined that the user data can be normally written in the user data block.

このように構成されることによって、記憶装置5は、電源投入時に、管理用エリアMAにアクセスし、第1ページに第1フラグが書き込まれていることを確認し、第2ページには第2フラグが書き込まれておらず、かつ規定値にもなっていないことを確認した場合には、ユーザデータが正常に書き込まれていると判断し、ユーザデータが書き込まれているユーザデータ用ブロックに対して消去処理を行わない。
したがって、記憶装置5は、メモリ45に書き込まれているユーザデータが正常に書き込まれたものか否かの判断を、メモリ45の負担を最小限にして行うことができる。
With this configuration, when the power is turned on, the storage device 5 accesses the management area MA, confirms that the first flag is written on the first page, and stores the second flag on the second page. If it is confirmed that the flag has not been written and has not reached the specified value, it is determined that the user data has been written normally, and the user data block to which the user data has been written is determined. Do not erase.
Therefore, the storage device 5 can determine whether or not the user data written in the memory 45 is normally written with the burden on the memory 45 minimized.

また、制御部46は、第2ページに規定値が書き込まれていると判定した場合には、第1フラグF1に対応するユーザデータが正常に書き込まれていないと判断し、その後、ユーザデータ用ブロックUBに対して所定回数ユーザデータの読み出しを行う構成であっても良い。   Further, when it is determined that the specified value is written in the second page, the control unit 46 determines that the user data corresponding to the first flag F1 is not normally written, and thereafter, for the user data The configuration may be such that user data is read out a predetermined number of times from the block UB.

このような構成の場合には、制御部46は、所定回数以内にユーザデータを有意なデータとして読み出せた場合には、当該ユーザデータが書き込まれているブロックに対して消去処理を行わない。
また、制御部46は、所定回数以内にユーザデータを有意なデータとして読み出せない場合には、当該ユーザデータが書き込まれているブロックに対して消去処理を行う。
In the case of such a configuration, when the user data can be read as significant data within a predetermined number of times, the control unit 46 does not perform an erasure process on the block in which the user data is written.
In addition, when the user data cannot be read as significant data within a predetermined number of times, the control unit 46 performs an erasing process on the block in which the user data is written.

ここで、第1ページには第1フラグが書き込まれているが、第2ページが規定値のままであるということは、ユーザデータをユーザデータ用ブロックUBに書き込んでいる最中に電源断が発生したものと考えられるが、理論的には、ユーザデータをユーザデータ用ブロックUBに書き終わった直後に電源断が発生したことも考えられる。   Here, the first flag is written in the first page, but the second page remains at the specified value. This means that the power is cut off while the user data is being written to the user data block UB. Although it is thought that it occurred, theoretically, it is conceivable that the power interruption occurred immediately after the user data was written in the user data block UB.

そこで、制御部46は、ユーザデータに対して所定回数アクセスを行い、有意なデータとして読み出せた場合には、ユーザデータを書き終わった後に電源断が生じたものと判断し、ユーザデータが書き込まれているブロックに対して消去処理を行わない。
また、制御部46は、ユーザデータに対して所定回数アクセスを行い、有意なデータとして読み出せなかった場合には、ユーザデータをユーザデータ用ブロックUBに書きこんでいる最中に電源断が発生したものと判断し(つまり、ユーザデータは壊れていると判断し)、ユーザデータが書き込まれているブロックに対して消去処理を行う。
Therefore, if the control unit 46 accesses the user data a predetermined number of times and can read it as significant data, the control unit 46 determines that the power interruption has occurred after the user data has been written, and the user data is written. The erase process is not performed on the existing block.
In addition, the control unit 46 accesses the user data a predetermined number of times, and if it cannot be read as significant data, a power interruption occurs while the user data is being written to the user data block UB. (That is, it is determined that the user data is broken), and an erasure process is performed on the block in which the user data is written.

したがって、記憶装置5は、メモリ45に書き込まれているユーザデータが正常に書き込まれたものか否かの判断を、メモリ45の負担を最小限にして行うことができ、正常にユーザデータの書き込みが行えなかった場合のみ、ユーザデータ用ブロックUBに対して消去処理を実行するので、メモリ45の負担を最小限にして消去処理を行うことができる。   Therefore, the storage device 5 can determine whether or not the user data written in the memory 45 is normally written, with the burden on the memory 45 being minimized, and the user data can be written normally. Since the erasure process is executed on the user data block UB only when the process cannot be performed, the erasure process can be performed with the burden on the memory 45 minimized.

ここで、データの書き込み処理について、図6に示すフローチャートを参照して説明する。
ステップST1において、制御部46は、管理用ブロックMBの所定のページに書き込みアドレスA1と第1フラグ(書き込み中フラグ)F1の書き込みを行う。
ステップST2において、制御部46は、ユーザデータ用ブロックUBのページにユーザデータの書き込みを行う。
Here, the data writing process will be described with reference to the flowchart shown in FIG.
In step ST1, the control unit 46 writes the write address A1 and the first flag (during writing flag) F1 to a predetermined page of the management block MB.
In step ST2, the control unit 46 writes user data to the page of the user data block UB.

ステップST3において、制御部46は、ステップST2の工程によるユーザデータの書き込みを終了した場合には、ステップST1の工程により第1フラグF1を書き込んだページ(第1ページP1)の次のページ(第2ページP2)に書き込みアドレスA1と第2フラグ(書き込み終了フラグ)F2の書き込みを行う。そして、制御部46は、書き込みアドレスA1と第2フラグF2の第2ページへの書き込みと同時に、第2ページP2の残りの領域にユニーク値を書き込む。   In step ST3, when the writing of the user data in step ST2 is completed, the control unit 46 is the page (first page P1) next to the page (first page P1) in which the first flag F1 is written in step ST1. The write address A1 and the second flag (write end flag) F2 are written to the second page P2). Then, the control unit 46 writes the unique value in the remaining area of the second page P2 simultaneously with the writing of the write address A1 and the second flag F2 to the second page.

また、ページのデータを読み出す処理について、図7に示すフローチャートを参照して説明する。
ステップST11において、制御部46は、ユーザデータが正常にユーザデータ用ブロックUBに書き込みの確認ができたことを条件に、指定されたユーザデータをユーザデータ用ブロックUBから読み出す。
Further, the process of reading page data will be described with reference to the flowchart shown in FIG.
In step ST11, the control unit 46 reads the designated user data from the user data block UB on condition that the user data has been normally confirmed to be written in the user data block UB.

制御部46は、具体的には、ユーザデータと当該ユーザデータが書き込まれている場所を示すアドレスが関連付けられているテーブルを参照することにより、指定されたユーザデータを所定のユーザデータ用ブロックの所定のページから読み出す処理を行う。   Specifically, the control unit 46 refers to a table in which user data and an address indicating the location where the user data is written are referred to, thereby specifying the specified user data in a predetermined user data block. A process of reading from a predetermined page is performed.

このようにして、制御部46は、ユーザデータが正常にユーザデータ用ブロックUBに書き込みの確認ができたことを条件に、管理用ブロックMBを意識することなくデータ用ブロックから指定のページデータを読み出すことができる。   In this way, the control unit 46 receives the specified page data from the data block without being aware of the management block MB on condition that the user data has been successfully written to the user data block UB. Can be read.

また、ページの破棄(ディスカード)処理について、図8に示すフローチャートを参照して説明する。また、上述したように、第2ページP2は、正常に書き込み処理が終了した場合には、書き込みアドレスA1と第2フラグF2(書込み終了フラグ)が書き込まれ、他のエリアには、ユニーク値(55h)が書き込まれている。なお、以下では、第2ページP2の確認と、ディスカード処理に焦点を絞って説明する。   The page discarding (discarding) process will be described with reference to the flowchart shown in FIG. As described above, the second page P2 is written with the write address A1 and the second flag F2 (write end flag) when the write process is normally completed, and a unique value ( 55h) is written. Note that the following description focuses on the confirmation of the second page P2 and the discard process.

ステップST21において、制御部46は、第2ページP2にアクセスし、ECCにより2ビットエラーが生じているか否かを判断する。2ビットエラーが生じていない場合(No)には、ステップST22に進む。また、2ビットエラーが生じている場合(Yes)には、ステップST23へ進む。   In step ST21, the control unit 46 accesses the second page P2, and determines whether or not a 2-bit error has occurred due to the ECC. If a 2-bit error has not occurred (No), the process proceeds to step ST22. If a 2-bit error has occurred (Yes), the process proceeds to step ST23.

ステップST22において、制御部46は、通常処理を行う。具体的には、制御部46は、書き込みアドレスA1と第2フラグF2の有無の確認を行う。   In step ST22, the control unit 46 performs normal processing. Specifically, the control unit 46 confirms the presence / absence of the write address A1 and the second flag F2.

ステップST23において、制御部46は、第2ページP2の他のエリアをチェックし、ユニーク値と一致するか否かの比較処理を行う。   In step ST23, the control unit 46 checks another area of the second page P2, and performs a comparison process as to whether or not it matches the unique value.

ステップST24において、制御部46は、ステップST23の工程による比較処理の結果から不定ページか否かの判断を行う。制御部46は、ユニーク値に不一致が多く、データが崩れている場合には、不定ページであると判断し、不定ページではない場合には、一般的に発生する2ビットエラーであると判断する。不定ページであると判断した場合(Yes)には、ステップST25に進み、不定ページではないと判断した場合(No)には、ステップST26に進む。   In step ST24, the control unit 46 determines whether or not the page is an indefinite page from the result of the comparison process in the process of step ST23. The control unit 46 determines that the unique value is inconsistent and the data is corrupted, and determines that the page is an indefinite page. If the data is not an indefinite page, the control unit 46 determines that a 2-bit error generally occurs. . If it is determined that the page is indefinite (Yes), the process proceeds to step ST25. If it is determined that the page is not indefinite (No), the process proceeds to step ST26.

ステップST25において、制御部46は、第2ページP2が不定ページであると判断した場合には、ユーザデータを正常に書き込み、その後、第2ページP2に第2フラグF2を書き込んでいる最中に電源断が発生したと考えられるので、管理用ブロックMBに対して消去処理を行わない。   In step ST25, when the control unit 46 determines that the second page P2 is an indefinite page, the user data is normally written, and then the second flag F2 is being written to the second page P2. Since it is considered that the power is cut off, the erasure process is not performed on the management block MB.

ステップST26において、制御部46は、第2ページP2が不定ページではないと判断した場合には、第2ページP2に一般的な2ビットエラーが生じていると考えられるので、管理用ブロックMBを全て破棄(ディスカード)し、ガーベッジコレクション機能の利用によって、管理用ブロックMBに対して消去処理を行う。   In step ST26, when the control unit 46 determines that the second page P2 is not an indefinite page, it is considered that a general 2-bit error has occurred in the second page P2. All are discarded (discarded), and the management block MB is erased by using the garbage collection function.

このようにして、記憶装置5は、第2ページP2がECCにより2ビットエラーが生じていると判断した場合、不定ページであるか否かを判断し、不定ページの場合には、消去処理を行わず、不定ページの場合には、消去処理を行うので、不必要な消去処理が発生せず、ECCによる2ビットエラーに対して、メモリ45の負担を最小限にして対応することができる。   In this way, the storage device 5 determines whether or not the second page P2 is an indefinite page when it determines that a 2-bit error has occurred due to the ECC. In the case of an indefinite page, an erasure process is performed. Therefore, an unnecessary erasure process does not occur, and a 2-bit error caused by ECC can be dealt with with a minimum load on the memory 45.

つぎに、電源投入後の処理について、図9に示すフローチャートを参照して説明する。ここで、電投入後の処理とは、記憶装置5を通常に起動したときの電源オン後の処理、及び電源断に再起動したときの電源オン後の処理のことである。   Next, processing after power-on will be described with reference to a flowchart shown in FIG. Here, the processing after power-on is processing after power-on when the storage device 5 is normally activated, and processing after power-on when the storage device 5 is restarted due to power-off.

ステップST31において、制御部46は、管理用ブロックMBをチェックし、第1ページP1のペアである第2ページP2が第2フラグF2(書込み終了フラグ)を含むページで終わっている否かを確認する。第2フラグF2が書き込まれている場合(Yes)には、ユーザデータが正常にユーザデータ用ブロックUBに書き込まれていると考えられるので、処理を終了する。また、第2フラグF2が書き込まれていない場合(No)には、ステップST32に進む。なお、ステップST31の工程では、第2ページP2には、第2フラグF2が書き込まれていないのか、又は、2ビットエラーにより第2フラグF2が書き込まれていないのかの判断ができない。後者であれば、ユーザデータは、正常にユーザデータ用ブロックUBに書き込まれていると考えられる。   In step ST31, the control unit 46 checks the management block MB and confirms whether or not the second page P2, which is a pair of the first page P1, ends with a page including the second flag F2 (write end flag). To do. When the second flag F2 is written (Yes), it is considered that the user data is normally written in the user data block UB, and thus the processing is terminated. If the second flag F2 has not been written (No), the process proceeds to step ST32. In the process of step ST31, it cannot be determined whether the second flag F2 is written in the second page P2 or whether the second flag F2 is not written due to a 2-bit error. In the latter case, it is considered that the user data is normally written in the user data block UB.

ステップST32において、制御部46は、第2ページP2が全て規定値(FFh)か否かを確認する。全て規定値の場合(Yes)には、ステップST33に進み、全て規定値ではない場合(No)には、ステップST34に進む。なお、第2ページが全て規定値ではないということは、第2ページP2への書き込み処理があったと考えられ、ユーザデータは、正常にユーザデータ用ブロックUBに書き込まれていると考えられる。   In step ST32, the control unit 46 confirms whether or not all the second pages P2 are the specified value (FFh). If all are specified values (Yes), the process proceeds to step ST33, and if all are not specified values (No), the process proceeds to step ST34. Note that the fact that all the second pages are not specified values is considered to have been written to the second page P2, and the user data is normally written to the user data block UB.

ステップST33において、制御部46は、第2ページP2が全て規定値であるので、ユーザデータを一のユーザデータ用ブロックUBに書き込み中に電源断が発生したと考えられ、不定値となっている当該一のユーザデータ用ブロックUBに対してディスカード処理を行って、処理を終了する。ここで、ディスカード処理されたブロックは、再使用されても良いし、再使用を禁止にしても良い。   In step ST33, since all of the second page P2 are specified values, the control unit 46 is considered to have lost power while writing user data to one user data block UB, and has an indefinite value. The discarding process is performed on the one user data block UB, and the process ends. Here, the discarded block may be reused, or reuse may be prohibited.

ステップST34において、制御部46は、第2ページP2のユニーク値が多数化けているか否かを確認する。ユニーク値が多数化けている、すなわちユニーク値が一定数以上含まれていない場合(Yes)には、第2ページP2に第2フラグF2等を書き込んでいる最中に電源断が発生したものと考えられ、消去処理を行わず、処理を終了する。また、ユニーク値が多数化けていない、すなわちユニーク値が一定数以上含まれている場合(No)には、ステップST35に進む。   In step ST34, the control part 46 confirms whether the unique value of the 2nd page P2 has become many. If the number of unique values is large, that is, if a certain number or more of unique values are not included (Yes), it is assumed that a power failure has occurred while writing the second flag F2 etc. on the second page P2. It is conceivable that the erasure process is not performed and the process is terminated. If the number of unique values is not increased, that is, if a certain number or more of unique values are included (No), the process proceeds to step ST35.

ステップST35において、制御部46は、第2ページP2に一般的な2ビットエラーが生じていると考えられ、管理用ブロックの全ページを破棄(ディスカード)する。この管理用ブロックを再使用する場合には、制御部46は、ガーベッジコレクション機能の利用によって、ブロックの消去処理を行い、処理を終了する。   In step ST35, the control unit 46 considers that a general 2-bit error has occurred in the second page P2, and discards (discards) all pages of the management block. When the management block is reused, the control unit 46 performs block erasure processing by using the garbage collection function, and ends the processing.

また、エラーページが属するブロックに対して消去処理を行うか否かについて、図10に一覧を示す。
制御部46は、読み出したページが電源断が起因してエラーページであった場合には、読み出したページをディスカードし、ブロックを消去しない。
In addition, FIG. 10 shows a list of whether or not the erasure process is performed on the block to which the error page belongs.
When the read page is an error page due to power failure, the control unit 46 discards the read page and does not erase the block.

また、制御部46は、読み出したページがメモリ45の不良が起因してエラーページであった場合には、所定回数(例えば、10回)読み出しをリトライして、所定回数以内に読み出しに成功した場合には、正常なページとして取り扱い、ブロックの消去を行わない。   Further, when the read page is an error page due to a defect in the memory 45, the control unit 46 retries the read a predetermined number of times (for example, 10 times) and succeeds in reading within the predetermined number of times. In this case, the page is treated as a normal page and the block is not erased.

また、制御部46は、読み出したページがメモリ45の不良が起因してエラーページであった場合には、所定回数(例えば、10回)読み出しをリトライして、全てエラーであった場合には、エラーページが属するブロックに対して、エラーを起こしたページを除いて予備ブロックへコピーし、当該ブロックを消去する。又は、制御部46は、当該ブロックを2度と使用しないようにしても良い(バッドブロック化)。   In addition, when the read page is an error page due to a defect in the memory 45, the control unit 46 retries reading a predetermined number of times (for example, 10 times). The block to which the error page belongs is copied to the spare block except the page where the error has occurred, and the block is erased. Alternatively, the control unit 46 may not use the block again (bad block formation).

このようにして、記憶装置5は、NAND型のメモリ45に対しても最小限の負担によって、電源断対策が可能となる。また、記憶装置5は、データの書き込み途中の不正なページデータを認識し、問題が発生しないようにできる。また、記憶装置5は、ユーザデータの書き込み途中で電源断が生じたかどうかの判断ができるだけでなく、管理用のページデータの書き込み途中で電源断が生じたかどうかの判定も行うことができる。また、記憶装置5は、使用頻度の高い管理用ブロックをメモリ45の任意のブロック位置にすることができ、メモリ45の寿命を延ばすことができる。   In this way, the storage device 5 can take measures against power interruption with a minimum burden on the NAND type memory 45. Further, the storage device 5 can recognize illegal page data in the middle of data writing and prevent a problem from occurring. Further, the storage device 5 can not only determine whether or not a power interruption has occurred during the writing of user data, but can also determine whether or not a power interruption has occurred during the writing of management page data. In addition, the storage device 5 can set a frequently used management block at an arbitrary block position in the memory 45, thereby extending the life of the memory 45.

また、管理用ブロックMBは、一つのブロックとして割り当てるが、ユーザデータ用ブロックUBと重複しないようにする必要がある。よって、記憶装置5は、論理アドレスの小さい位置にユーザデータ用ブロックUBを割り当て、論理アドレスが大きい位置に管理用ブロックMBを割り当てる。なお、ブロックサイズのバウンダリに合わせる必要があるので、論理アドレスの割り当ての際に、この点に留意する必要がある。   The management block MB is allocated as one block, but it is necessary not to overlap with the user data block UB. Therefore, the storage device 5 assigns the user data block UB to the position where the logical address is small, and assigns the management block MB to the position where the logical address is large. Since it is necessary to match the boundary of the block size, it is necessary to pay attention to this point when assigning logical addresses.

1 携帯電話装置
5 記憶装置
44 メモリドライバ
45 メモリ
46 制御部
UA ユーザデータエリア
MA 管理用エリア
UB ユーザデータ用ブロック
MB 管理用ブロック
1 Mobile phone device 5 Storage device 44 Memory driver 45 Memory 46 Control unit UA User data area MA Management area UB User data block MB Management block

Claims (5)

所定数のページからなるブロックを複数個有し、データの読み出し及び書き込みをページ単位で受け付け、データの消去をブロック単位で受け付ける不揮発性メモリと、
前記不揮発性メモリに対して、データの読み出し、書き込み及び消去を行う制御部を備え、
前記不揮発性メモリのブロックは、ユーザデータを記憶する複数のユーザデータ用ブロックと、当該ユーザデータ用ブロックを管理する複数の管理用ブロックによって構成され、
前記制御部は、ユーザデータを前記ユーザデータ用ブロックに書き込みを開始する時、前記管理用ブロックの第1ページに前記ユーザデータに対応する第1フラグを書き込み、当該ユーザデータの書き込みが終了した場合に、前記第1ページとは異なる前記管理用ブロックの第2ページに当該ユーザデータに対応する第2フラグを書き込み、
前記第1ページ及び前記第2ページにそれぞれ第1フラグと第2フラグが書き込まれている場合には、当該ユーザデータが前記ユーザデータ用ブロックに正常に書き込まれていると判断して、当該ユーザデータが書き込まれているブロックに対して消去処理を行わず、
前記第1ページには第1フラグが書き込まれているものの、前記第2ページには第2フラグが書き込まれていない場合には、当該ユーザデータが前記ユーザデータ用ブロックに正常に書き込まれていないと推定する記憶装置。
A non-volatile memory having a plurality of blocks each having a predetermined number of pages, accepting reading and writing of data in units of pages, and accepting erasing of data in units of blocks;
A control unit that reads, writes, and erases data with respect to the nonvolatile memory,
The non-volatile memory block includes a plurality of user data blocks for storing user data and a plurality of management blocks for managing the user data blocks.
When the controller starts writing user data to the user data block, the controller writes a first flag corresponding to the user data to the first page of the management block, and the writing of the user data is completed. And writing a second flag corresponding to the user data on a second page of the management block different from the first page,
When the first flag and the second flag are respectively written in the first page and the second page, it is determined that the user data is normally written in the user data block, and the user Do not erase the block where data is written,
When the first flag is written in the first page, but the second flag is not written in the second page, the user data is not normally written in the user data block. Storage device that estimates.
請求項1記載の記憶装置であって、
前記第2ページは、前記第1ページの次のページである記憶装置。
The storage device according to claim 1,
The storage device, wherein the second page is the next page of the first page.
請求項1記載の記憶装置であって、
前記制御部は、所定の期間又は前記不揮発性メモリの各ブロックの使用頻度に基づいて、一のブロックに書き込まれているデータを他のブロックに移動する処理を行う記憶装置。
The storage device according to claim 1,
The said control part is a memory | storage device which performs the process which moves the data currently written in one block to another block based on the predetermined period or the usage frequency of each block of the said non-volatile memory.
請求項1記載の記憶装置であって、
前記第2ページには、データが書き込まれる前においては、予め規定値が書き込まれており、
前記制御部は、前記第2ページの一部に前記第2フラグを書き込む場合、当該第2フラグが書き込まれる領域以外の領域に前記規定値以外の値を書き込み、前記第1ページには第1フラグが書き込まれているものの、前記第2ページには第2フラグが書き込まれていない場合には、当該第1フラグに対応するユーザデータが前記ユーザデータ用ブロックに正常に書き込まれていないと推定した上で、前記第2ページの第2フラグが書き込まれる領域以外の所定領域に前記規定値が書き込まれているかどうかを判定し、
前記所定領域に前記規定値が書き込まれていると判定した場合には、前記第1フラグに対応するユーザデータが正常に書き込まれていないと判断し、
前記所定領域に前記規定値が書き込まれていないと判定した場合には、前記第1フラグに対応するユーザデータが正常に書き込まれていると判断し、当該ユーザデータが書き込まれているブロックに対して消去処理を行わない記憶装置。
The storage device according to claim 1,
Before the data is written to the second page, a specified value is written in advance.
When the control unit writes the second flag in a part of the second page, the control unit writes a value other than the specified value in an area other than the area in which the second flag is written, If the flag is written but the second flag is not written in the second page, it is estimated that the user data corresponding to the first flag is not normally written in the user data block. And determining whether the specified value is written in a predetermined area other than the area where the second flag of the second page is written;
If it is determined that the specified value is written in the predetermined area, it is determined that the user data corresponding to the first flag is not normally written;
When it is determined that the specified value is not written in the predetermined area, it is determined that the user data corresponding to the first flag is normally written, and the block in which the user data is written is determined. A storage device that does not perform erasure processing.
請求項4に記載の記憶装置であって、
前記制御部は、前記第2ページに前記規定値が書き込まれていると判定した場合には、前記第1フラグに対応するユーザデータが正常に書き込まれていないと判断し、その後、ユーザデータ用ブロックに対して所定回数前記ユーザデータの読み出しを行い、
前記所定回数以内に前記ユーザデータを有意なデータとして読み出せた場合には、当該ユーザデータが書き込まれているブロックに対して消去処理を行わず、
前記所定回数以内に前記ユーザデータを有意なデータとして読み出せない場合には、当該ユーザデータが書き込まれているブロックに対して消去処理を行う記憶装置。
The storage device according to claim 4,
When it is determined that the specified value is written in the second page, the control unit determines that the user data corresponding to the first flag is not normally written, and thereafter, for the user data Read the user data a predetermined number of times to the block,
If the user data can be read as significant data within the predetermined number of times, the erasure process is not performed on the block in which the user data is written,
A storage device that performs an erasure process on a block in which the user data is written when the user data cannot be read as significant data within the predetermined number of times.
JP2010038639A 2010-02-24 2010-02-24 Storage device Pending JP2011175428A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010038639A JP2011175428A (en) 2010-02-24 2010-02-24 Storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010038639A JP2011175428A (en) 2010-02-24 2010-02-24 Storage device

Publications (1)

Publication Number Publication Date
JP2011175428A true JP2011175428A (en) 2011-09-08

Family

ID=44688234

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010038639A Pending JP2011175428A (en) 2010-02-24 2010-02-24 Storage device

Country Status (1)

Country Link
JP (1) JP2011175428A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016038778A (en) * 2014-08-08 2016-03-22 株式会社デンソー Storage medium management apparatus

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016038778A (en) * 2014-08-08 2016-03-22 株式会社デンソー Storage medium management apparatus

Similar Documents

Publication Publication Date Title
US10552311B2 (en) Recovery for non-volatile memory after power loss
JP5819610B2 (en) Method and apparatus for writing data to different storage devices
JP4722839B2 (en) MEMORY CONTROL CIRCUIT, NONVOLATILE MEMORY DEVICE, AND MEMORY CONTROL METHOD
US8510532B2 (en) Logical-to-physical address translation for a removable data storage device
EP2367110B1 (en) Emerging bad block detection
US8453021B2 (en) Wear leveling in solid-state device
CN101026848B (en) Mobile terminal and software update method
TWI436369B (en) Methods for measuring usable lifespan and replacing an in-system programming code of a memory device, and data storage system using the same
JP2011503741A5 (en)
JP2011503768A5 (en)
KR20080037283A (en) System comprising flash memory device and data recovery method thereof
JP2008040701A (en) Memory management method and portable terminal equipment
TW201915725A (en) Data storage device and methods for processing data in the data storage device
JP2007241618A (en) Nonvolatile storage device and its write determination method
JP4158526B2 (en) Memory card and data writing method to memory
JP4586469B2 (en) MEMORY CONTROL DEVICE, MEMORY CONTROL METHOD, PROGRAM
US9443604B2 (en) Electronic device and data-management method thereof
JP2011175428A (en) Storage device
JP2012068765A (en) Memory controller, flash memory system with memory controller, and control method of flash memory
JP2009134672A (en) Memory management method and portable terminal equipment
JP2008047155A (en) Batch erasable nonvolatile memory and mobile phone
JP2006126919A (en) Data management device for flash memory and control method of flash memory
JP2011154548A (en) Storage device
JP2014112419A (en) Mobile terminal apparatus, software update method, operation control method, and program
KR100575927B1 (en) Method for booting the nand flash memory using multi boot loader in mobile station

Legal Events

Date Code Title Description
RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20120803