JP3573706B2 - Method for writing / erasing storage device - Google Patents

Method for writing / erasing storage device Download PDF

Info

Publication number
JP3573706B2
JP3573706B2 JP2000347501A JP2000347501A JP3573706B2 JP 3573706 B2 JP3573706 B2 JP 3573706B2 JP 2000347501 A JP2000347501 A JP 2000347501A JP 2000347501 A JP2000347501 A JP 2000347501A JP 3573706 B2 JP3573706 B2 JP 3573706B2
Authority
JP
Japan
Prior art keywords
block
data
sector
writing
written
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.)
Expired - Lifetime
Application number
JP2000347501A
Other languages
Japanese (ja)
Other versions
JP2001195889A (en
Inventor
新平 小松
由美 森田
朋弘 林
省吾 柴崎
裕之 伊藤
勝 竹原
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.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2000347501A priority Critical patent/JP3573706B2/en
Publication of JP2001195889A publication Critical patent/JP2001195889A/en
Application granted granted Critical
Publication of JP3573706B2 publication Critical patent/JP3573706B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Description

【0001】
【産業上の利用分野】
本発明はパソコンの外部記憶装置等に使用されるフラッシュ・メモリ等の上書きのできない記憶装置の書き込み/消去方法に関する。
【0002】
【従来の技術】
近年、パソコン等の外部記憶装置として、フラッシュ・メモリを使った外部記憶装置が注目をあびている。フラッシュ・メモリは、不揮発性のためバックアップ電源が不要であり、電気的に書き換えることができ、しかも安価であるが、次のような問題点を持っている。
▲1▼ データを消去してからでなければ、データの書き込みはできず、また、消去の単位はバイト単位は不可能であり、セクタ、ブロックもしくはチップ単位となる。このため、通常のメモリのように、バイト単位でデータを書き換えることはできず、読み出し速度に対して、書き込み速度あるいは消去速度が遅い。
▲2▼ 消去回数に制限があり、通常、消去回数が10万〜100万回程度で消去不能となるといわれている。このため、セクタ、もしくはブロックの消去回数が平均化するように使用しないと、消去回数の多い部分が先に不良となり、使用可能領域が減少する。
フラッシュ・メモリは上記のような問題点をもっているため、フラッシュ・メモリを使用するにあたっては、データの退避領域を用意し、データの書き換え時にデータを退避したり、管理テーブルを設けてデータの書き込み/消去を管理したり、さらに、不良セクタ、ブロック等が発生した場合に救済措置を講ずるなど、種々の方策が講じる必要がある。
【0003】
【発明が解決しようとする課題】
フラッシュ・メモリは不揮発性で電気的に書き換えることができる等の長所を持っている反面、上記のように多くの問題点を持っており、従来から使用されているDRAM、SRAM等の半導体メモリとは異なり、その使用にあたって解決しなければならない問題点も多い。
本発明は上記した問題点に鑑みなされたものであって、本発明の目的は、フラッシュ・メモリ等のように上書きができず、また、バイト単位で消去することができないメモリの消去を効率的に行うことである。
【0004】
【課題を解決するための手段】
図1は本発明の全体の概略構成を示す原理図、図2〜図4は本発明の概要を示す原理図である。
図1ないし図4において、1は記憶装置、1aは上書きすることができず、また、セクタ、ブロック等の所定の単位でしかデータを消去することができない、例えばフラッシュ・メモリ等から構成される記憶領域、1bは記憶領域1aへのデータの書き込み等を制御したり、記憶領域1aの消去等を行う制御手段、1cは記憶領域1aへのデータの書き込み時に一時的にデータを格納したり、また、記憶領域1aのデータを退避するための一次記憶媒体、1d,1eは記憶領域1aのアドレスをデコードするためのデコードテーブル、2は本体処理装置である。
【0005】
前記課題を解決するため、本発明の請求項1の発明は、記憶領域1aが複数のブロック1a−1,…,1a−Nから構成され、書き込まれたデータをブロック単位で消去する記憶装置1において、図3(b)に示すようにブロック毎に書き込みの有無を示すフラグF1を設け、また、最終処理ブロックに実行中フラグを書き込み、該実行中フラグがあるか否かを調べ、実行中フラグがある場合に、上記フラグF1を参照して、書き込まれたデータを消去するようにしたものである。
本発明の請求項2の発明は、請求項1の発明において、全記憶領域を消去する際、書き込みの有無を示すフラグF1を参照して、書き込みの有るブロックのみ消去するようにしたものである。
【0006】
【作用】
図1において、本体処理装置2から記憶装置1に書き込みデータが送られてくると、制御手段1bはデータを一次記憶媒体1cに格納する。そして、デコード・テーブル1d(1e)を参照してアドレスをデコードし、一次記憶媒体1cに格納されたデータを記憶領域1aの新たなセクタもしくはブロックに書き込む。その際、書き込むデータの論理アドレスと同一の論理アドレスのデータが記憶領域1aに既に存在している場合には、そのデータを消去したり、そのデータを格納した領域に消去可能フラグを立てる。
また、データを格納した領域に消去フラグを立てた場合には、制御手段1bは所定の時期に所定の単位で、消去不可のデータを一次記憶媒体1cに退避して記憶領域1aを消去し、一次記憶媒体1cに退避したデータを記憶領域1aに書き戻す等の処理を行い、空き領域の作成等を行う。
さらに、制御手段1bは記憶領域1aの一部が不良になった場合には、デコード・テーブル1d(1e)を書き換えるなどして、不良部分を予備領域で代替する。
【0007】
図2(a)に示す記憶領域1aが複数のブロック1a−1,…,1a−Nと、該ブロックを区切ったセクタから構成され、書き込まれたデータをブロック単位で消去する記憶装置、図4に示す記憶領域が上書きできない複数のセクタで構成され、セクタに書き込まれたデータをセクタ単位で消去する記憶装置において、データの書き込み/消去は次のように行われる。
(1) 記憶領域1aが複数のブロック1a−1,…,1a−Nと、該ブロックを区切ったセクタから構成され、書き込まれたデータをブロック単位で消去する記憶装置1において、ブロック1a−1,…,1a−N内の消去不可のデータを空きセクタがある他のブロックに退避するに際して、図2(b)に示すように消去可能なセクタ数が多いブロックからmブロックと、消去可能が少ないブロックからnブロック(m,nは任意の整数)を選択し、選択されたブロックを同時に空きセクタがある他のブロックに、セクタを散在させて均一に、退避する。
これにより、空きブロックを作成することができるとともに、結果的に各ブロックに書き換えが多いセクタと書き換えが少ないセクタが混在することとなり、ブロックの消去回数を平均化することができる。
(2) 記憶領域1aが、退避領域を含む複数のブロック1a−1,…,1a−Nから構成され、書き込まれたデータをブロック単位で消去する記憶装置において、、図2(c)に示すように消去可能なデータを含むブロック1a−1,…,1a−Nのデータの内、消去不可のデータのみを退避領域に移動したのち、上記ブロックのデータを消去し、消去したブロックを新たな退避領域として、空き領域を作成する。
これにより、消去可能データをなくすことができ、本処理を予め行っておくことにより、書き込み時間を短縮することができる。
(3) データの書き込み方向に対して、退避領域の反対側のブロックの消去不可のデータのみを退避領域に移動したのち、上記ブロックのデータを消去し、消去したブロックを新たな退避領域とする。
これにより、書き込み場所を示す書き込みポインタと退避領域の間に全ての空き領域を存在させることができる。したがって、処理の中断があっても、書き込みポインタの示す位置からデータを書き込むことができ、処理中断後に必要とする処理量を少なくすることができる。
【0008】
(4) 記憶領域1aが、予備領域を含む複数のブロック1a−1,…,1a−Nから構成され、書き込まれたデータをブロック単位で消去する記憶装置において、図2(a)、図3(a)に示すように書き込みポイントを予備領域に設定し、データが書き込まれたブロックの消去不可のデータを予備領域に移動したのち、上記ブロックのデータを消去する処理を繰り返し、最後に消去したブロック以外のブロックの空きセクタ数が予備領域にあるセクタ数と等しいか、もしくは、大きくなったとき、予備領域のデータを最後に消去したブロック以外のブロックに移動する。
これにより、空き領域を作成することができる。また、空きブロックが使用不可になったとき、使用不可となったブロックを救済して空きブロックを作成することができる。
さらに、予備領域のデータを、データを最後に消去したブロック以外のブロックに移動する際、移動先の書き込みポイントを、データを最後に消去したブロックの後のブロックから検索して予備領域のデータを移動するようにすることにより、最後に消去をかけたブロックと書き込みポインタの間に全ての空きセクタを存在させることができ、処理中断後の処理を簡単にすることができる。
またさらに、処理中断後、処理を再開したとき、予備領域に消去可能なデータがあるか、あるいは、消去不可のデータのみがあるかに応じて、処理中断時点を判断することができ、処理中断時点の判断を単純化することができる。
(5) 図4に示すように、記憶領域1が上書きできない複数のセクタで構成され、セクタに書き込まれたデータをセクタ単位で消去する記憶装置において、同一のセクタ番号を持つセクタを少なくとも2個用意し、同一番号が付されたセクタのいずれか一方にデータがあった場合、他方のセクタにデータを書き込むと同時に、一方のセクタのデータを消去する。これにより、書き込み速度を向上することができる。
(6) 図4に示す記憶装置において、書き込みするセクタにデータがある場合、データを一次記憶装置1cに転送している間に、上記セクタのデータを消去し、データの消去完了後、もしくは、データ転送の終了後、上記セクタにデータを書き込む。これにより書き込み速度を向上することができる。
(7) 図4に示す記憶装置において、不良なセクタを代替する予備の領域1b−1,1b−2と、書き込みセクタを管理する書き換え可能なデコード・テーブル1dを設け、不良なセクタが発生したとき、上記デコード・テーブル1dを書き換えることにより、予備の領域1b−1,1b−2に書き込みセクタを変更し、予備の領域1b−1,1b−2がなくなつたとき、デコード・テーブル1dを書き換えてセクタを再構成するようにしたので、不良セクタ発生時の救済を行うことができる。
(8) 図4に示す記憶装置において、N個のセクタ番号に対してN+1個のセクタを設けるとともに、N+1個の各セクタをN個のセクタ番号で共有し、データをセクタへ書き込む際、データをN+1個のセクタの内の空いているセクタに書き込む。これにより、書き込み速度を向上することができるとともに、余分に用意するセクタの数を少なくすることができ、コストダウンを図ることができる。
また、不良なセクタを代替する予備の領域1b−1,1b−2を設け、不良なセクタが発生したとき、デコード・テーブル1dを書き換え、予備の領域1b−1,1b−2に書き込みブロックあるいはセクタを変更するようにしたり、デコード・テーブル1dを再編成する。これにより、不良セクタ発生時の救済を行うことができる。
(9) 読み書きが可能で、かつ、記憶領域の一部が破壊する可能性のある記憶領域1aと、記憶領域1a中のデータが記憶されている場所を示す書き換え可能なデコーダ1dとを備えた記憶装置において、図4に示すようにデコーダを2段設け、記憶装置1の記憶領域1aの一部が破壊したとき、もしくは、デコータ1d,1eの一部が破壊したとき、2段のデコーダ1d,1eのいずれか一方、もくしは、両方を書き換えることにより、破壊した部分へのデコードが行われないようにする。これにより、デコーダとして、EEPROM、フラッシュメモリ等のその一部が破壊する可能性のある記憶媒体を用いた場合においても、アドレスがエラーとなる確率を著しく減少させることができ、信頼性を確保することができる。
(10)記憶領域1aが複数に分割されており、分割されたチップ内に複数のブロックが設けられ、チップ内のブロックにデータを書き込む際、新たなブロックにデータを書き込み、書き込んだデータがチップ内に既に存在している場合には、そのデータをブロック単位で消去する記憶装置において、データを書き込むチップを、書き込むデータに対応させて固定する。これにより、制御手段1bは各チップ内のデータのみを管理すればよく、全領域を管理する必要がない。このため、制御手段1bにおける管理テーブルを簡単にすることができ、書き込み速度を向上させることができる。
また、各チップ内にデータを書き込むための複数のワークブロックを設けることにより、ワークブロックに不良が発生した場合に、不良となったワークブロックを救済することができる。
【0009】
本発明の請求項1,2の発明は、上述の記憶領域1aが複数のブロック1a−1,…,1a−Nから構成され、書き込まれたデータをブロック単位で消去する記憶装置1において、ブロック毎に書き込みの有無を示すフラグF1を設け、また、最終処理ブロックに実行中フラグを書き込み、該実行中フラグがあるか否かを調べ、実行中フラグがある場合に、図3(b)に示すように、フラグF1を参照して書き込まれたデータを消去するようにしたので、不要な消去を避けることができ、消去時間の短縮を図ることができるとともに、記憶媒体の寿命を延ばすことができる。
なお、記憶領域1a上に同一の機能に対応した複数ビットのフラグを記録し、該フラグの論理積によりフラグの判定を行うようにすれば、全ビットが不良にならない限り、正しい判定値を常に出力することができ、システムの信頼性を向上させることができる。
【0010】
【実施例】
次に、本発明の実施例を説明する。
A.本発明の前提となる記憶装置の構成。
図5は本発明の前提となるフラッシュ・メモリを使用した記憶装置の構成を示すブロック図である。
同図において、20は例えばメモリ・カード等の記憶装置、21はフラッシュ・メモリのデータの書換え、消去等を制御するコントローラLSI、22はプロセッサ、23は各種テーブルを格納したり、データの書き込み時のデータ・バッファあるいは退避バッファとして使用されるSRAM、24はクロック発振器、25−1〜25−5はフラッシュ・メモリである。
同図において、本体よりSRAM23に転送されたデータをフラッシュ・メモリ25−1〜25−5に書き込む際、前記したようにフラッシュ・メモリは上書きができないので、データを書き込み場合には、新たな領域にデータを書き込む。また、データ更新の場合には、旧データに消去フラグを立てる等の措置を講ずる。そして、旧データに消去フラグが立てられている場合には、所定の時期に、消去フラグが付されていないデータのみを所定の単位でSRAM23の退避領域に退避し、フラッシュ・メモリの書き込むべき領域を消去したのち、データを書き戻すことによりデータの整理を行う。
【0011】
図6は上記したSRAM23の内容を示す図であり、同図に示すように、SRM23には下記のデータが格納される。
(1) 消去回数テーブル
フラッシュ・メモリの各ブロックの消去回数を保持している。
(2) 消去可能セクタ数テーブル
各ブロックの消去可能セクタ・フラグの立っている総数値を保持する。
(3) 書き込みポインタ
フラッシュ・メモリに書き込みを開始するチップNo. ,ブロックNo. ,セクタ・アドレスNo. を保持する。
(4) WORK−BLOCK−No.
現在のWORK−BLOCK−No. を示し、チップNo. ,ブロックNo. を保持する。
(5) 整理ポインタ
現在、整理をしているチップNo. ,ブロックNo. ,セクタ・アドレスNo. を保持する。
(6) 書き換え有無
現在、書き込みするデータが新規であるかどうかを示す。
(7) 書き込み回数
整理時の本体書き込み回数を管理する。
(8) 退避カウンタ
整理時の退避動作のセクタ数を管理する。
(9) チップ数
カードの搭載フラッシュ−チップ数を保持する。
(10)セクタマップ・テーブル
論理アドレスの変換用にチップNo. ,ブロックNo. ,セクタ・アドレスNo. を保持する。
【0012】
図7、図8はフラッシュ・メモリ25−1〜25−5の内容を示す図であり、フラッシュ・メモリの各セクタには、次の(1) から(5) に示す制御情報、データ等が格納されている。なお、この例においては、セクタが126設けられており、各セクタには、(1) から(5) の管理情報等とデータが格納され、126番目のセクタの後に、次の(6) から(14)の管理情報等が格納されている。
(1) 不良フラグ
このセクタの状態を示し、使用不可の場合に、ここに書き込みを行う。
(2) 消去フラグ
このセクタのデータの状態を示し、書き換え等で無効になった場合に、ここに書き込みを行う。
(3) 論理アドレス
このセクタの論理アドレスを示す。
(4) データ
このセクタに書き込まれたデータ。
(5) チェックサム
書き込んだデータのチェックサム
(6) 不良セクタ・メモリ
整理対象ブロックの中の不良セクタを示す。
(7) 整理元消去回数
整理対象ブロックの消去回数。
(8) 退避ブロックNo.
データを退避してくるチップNo. ,ブロックNo.
(9) 消去Start
整理対象ブロックの消去を開始する時に立てる。
(10)消去End
整理対象ブロックの消去を終了するときに立てる。
(11)All Erase対象
All Erase時に消去対象として確定した時に立てる。
(12)空きブロック
ブロック内にデータがあるかを示し、データがある場合に立てられる。
(13)ブロック・ステータス
このブロックの状態を示し、使用不可になった場合に立てる。
【0013】
図9ないし図13はフラッシュ・メモリ25−1から25−5へのデータ書き込み時のプロセッサ22における処理を示すフローチャートであり、同図を参照して書き込み時の動作を詳細に説明する。
図9のステップS1において、SRAM23の、現在書き込みをするデータが新規であるか否かを示す「書き換えの有無」(図6参照)を0として、ステップS2において、整理中であるか否かを判別する。整理中でない場合には、ステップS5に行き、SRAM23の、整理時の本体書き込み回数を管理する「書き込み回数」を0にしステップS7に行く。
また、整理中の場合には、ステップS3に行き、「書き込み回数」に1を加え、ステップS4において、書き込み回数が6であるか否かを判別する。書き込み回数が6の場合には、ステップS6に行き、書き込み回数を1にする。また、書き込み回数が6でない場合には、ステップS7に行く。
【0014】
上記処理は、後述するように、書き込み回数が2〜5の場合には整理動作を行わないようし、書き込み回数が1の時のみ整理動作を行うことにより、頻繁な整理動作を避けるためであり、上記のように書き込み回数を設定することにより、5回に1回整理動作を行うこととなる。
ステップS7において、書き込むデータの論理アドレスがオーバーしているか否かを判別し、オーバーしている場合には、エラー処理を行う。
論理アドレスがオーバーしていない場合には、ステップS8に行き、旧データかあるか否か、すなわち、現在書き込むデータが新規なデータであるか否か判別し、新規なデータでない場合には、ステップS9において、SRAM23の「書き換えの有無」を1にしてステップS11に行く。また、新規なデータの場合には、ステップS10において、SRAM23の「書き換えの有無」を0にしてステップS11に行く。
【0015】
ついで、ステップS11において、本体からデータをSRAMに転送し、ステップS12において転送エラーがあるか否かを判別する。転送エラーがある場合にはエラー処理を行う。転送エラーがない場合には、図10のステップS13に行き、書き換えの有無、すなわち、新規データであるかどうか判別し、新規データでない場合には、データの更新であるので、ステップS14において旧データのあるセクタに消去ビットを書き込み、ステップS15に行く。
ステップS15において、SRAM23の整理時の書き込み回数を管理する「書き込み回数」が1であるか否かを判別し、「書き込み回数」が1の場合には、ステップS16以降でフラッシュ・メモリの整理を行う。また、「書き込み回数」が1でない場合には、図13のステップS46に行き、ステップS46以降で、SRAM23のデータをフラッシュ・メモリへ書き込む。
【0016】
ステップS16において、SRAM23上の整理時における退避動作のセクタ数を管理する「退避カウンタ」を0にして、ステップS17において、現在整理をしているセクタアドレスNo. を示す「整理ポインタ」(セクタアドレス)が126セクタより多いか否かを判別し、126より小さくない場合には、整理が終了したものとして、図12のステップS38に行く。また、「整理ポインタ」(セクタアドレス)が126セクタより少ない場合には、ステップS18に行き、整理ポインタが0であるか否かを判別し、整理ポインタが0でない場合にはステップS22に行く。
整理ポインタが0の場合には、ステップS19において、各ブロックの消去回数や消去可能セクタ数をSRAM23のテーブルから求め、それをもとにして、整理対象を選択する。ついで、ステップS20において、フラッシュ・メモリ上のWORK−BLOCKの退避ブロックNo. (図8参照)に整理対象のチップNo. ,ブロックNo. を書き込む。
【0017】
ステップS21において、書き込みエラーがあるか否か判別し、書き込みエラーがある場合には、エラー処理を行い、書き込みエラーがない場合には、ステップS22に行く。
ステップS22において、退避するデータを検索する。すなわち、フラッシュ・メモリのデータに消去フラグ(図7参照)が書き込まれている場合には、次のセクタに行く。また、論理アドレスが無い場合には消去フラグを書き込み、次のセクタに行き、論理アドレスが異常のものは消去フラグと不良フラグを書き込み、次のセクタに行く。
次いで、図11のステップS23に行き、書き込みエラーがあるか否かを判別し、書き込みエラーがない場合には、ステップS24において、整理ポインタ(セクタアドレス)が126番目のセクタを指しているか否かを判別し、整理ポインタが126である場合には、整理が終わったものとして、図12のステップS38に行く。
【0018】
整理ポインタが126でない場合には、ステップS25に行き、退避するデータをフラッシュ・メモリからSRAM23に移動し、ステップS26において、生成したチェックサムがフラッシュ・メモリ上のチェックサム(図7参照)と一致するか否かを判別する。一致しない場合には、ステップS27において、チェックサムがFFhであるか否かを判別する。
そして、チェックサムがFFhでない場合には、ステップS28にいき、フラッシュ・メモリ上のチェックサムをFFhとし、データ退避元のセクタの不良フラグを書き込み、ステップS29に行く。ステップS29において、書き込みエラーが有るか否か判別し、ステップS30に行く。
また、ステップS26において、チェックサムが一致するか、S27において、チェックサムがFFhの場合には、ステップS30に行き、書き込みポインタが示すセクタから書き込めるセクタを探し、ステップS31において、書き込み可能セクタがあるか否かを判別する。書き込み可能セクタがない場合には、エラー処理を行い、書き込み可能セクタがある場合には、ステップS32に行き、SRAM23上のデータをフラッシュ・メモリに移動する。
ステップS33において、書き込みエラーが有るか否かを判別し、書き込みエラーがある場合には、ステップS30に戻る。書き込みエラーがない場合には、図12のステップS34に行き、データ退避元のセクタの消去フラグを書き込む。
【0019】
そして、ステップS35において、書き込みエラーがあるか否かを判別し、書き込みエラーがない場合には、ステップS36において、SRAM23上のセクタマップテーブルを書き換えるとともに、退避カウンタに1を加える。
ついで、ステップS38において、退避動作が予め定められた所定回数(この場合には60回)行われたか否かを判別し、退避動作が60回になった場合には、ひとまずフラッシュメモリの整理を終えてステップS38に行く。また、退避動作が60回になっていない場合には、図10のステップS22に戻り上記処理を繰り返す。
退避カウンタが60になっているか、前記した図10のステップS17において、整理ポインタが126より小さくないと判別された場合には、ステップS38に行き、退避カウンタが0であるか否か判別する。
そして、退避カウンタが0である場合、つまり、整理ポインタが126より小さくない場合であって、かつ、退避動作が行われていない場合には、ステップS39に行き、ステップS39以降で、不良フラグの情報を不良セクタメモリに書き込む等の処理を行う。
【0020】
すなわち、退避カウンタが0である場合には、処理時間が短かかったので、S39以降の不良フラグの情報を不良セクタメモリに書き込む等の処理を行い、また、退避カウンタが0でない場合には、図13のステップS46に行き、SRAM23上のデータをフラッシュ・メモリに移動する等の処理を行う。
ステップS39において、退避したブロックの不良フラグの情報を書き込み先(書き込み先はWORK−BLOCK)の不良セクタ・メモリ(図8参照)に書き込み、また、消去回数を整理元消去回数欄(図8参照)に書き込む。ステップS40において、書き込みエラーがあるか否かを判別し、書き込みエラーがない場合には、ステップS41に行き、整理したブロックを消去する。ステップS42において、消去エラーがあるか否か判別し、消去エラーがない場合には、図13のステップS43に行き、消去したブロックに不良セクタメモリから不良フラグ情報を戻し、整理元消去回数に1を加えて、消去回数に書き込む。
【0021】
ついで、ステップS44において、消去したブロックに対応するテーブルの消去回数に1を加え、消去可能セクタ数を0にする。ステップS45において、整理ポインタをWORK−BLOCKに入れ、整理ポインタを0とする。
次にステップS46に行き、書き込みポインタの示すセクタから書き込めるセクタを探し、ステップS47において書き込み可能セクタが有るか否かを判別する。書き込み可能セクタがある場合には、ステップS48に行き、SRAM23上のデータをフラッシュ・メモリに移動し、ステップS49において、書き込みエラーがあるか否かを判別する。
書き込みエラーが有る場合には、ステップS46に戻り、書き込みエラーがない場合には、ステップS50に行く。ステップS50において、書き換え有無が1であるか否か、すなわち、書き込みするデータが新規であるか否か判別し、書き換えの有無が1の場合には、ステップS51で消去フラグを書き込んだセクタに対応する消去可能セクタ数テーブル(図6参照)の値に1を加え、ステップS52に行く。
ステップS50において、書き換え有無が0である場合には、ステップ52において、セクタマップテーブル(図6参照)を書き換え、ステップS53において、次の書き込みに備えて、書き込みポインタの示すセクタから書き込めるセクタを探しておき終了する。
【0022】
B.書き込み/消去処理。
前記したように、フラッシュ・メモリは、消去回数に制限があり、全てのメモリを有効に活用するためには、消去回数を平均化する必要がある。
また、フラッシュ・メモリは上書きをすることができず、データを書き換える場合には、新たなセクタにデータを書き込んで、旧データに消去可能フラグを立ておくなどの措置を講じ、適宜の時点で消去可能フラグが立っているセクタを消去する必要がある。
このため、消去可能なデータを消去してデータを書き込むための空き領域を確保する必要があるとともに、上記空き領域が、不良ブロックが発生するなどの原因により使えなくなったとき、救済措置を講じて新たな空き領域を作成する必要がある。
【0023】
以下に、上記した消去回数の平均化(実施例1)、消去可能なデータを消去して空き領域を確保する空き領域の作成(実施例2)、不良ブロック発生時の空き領域作成のための救済措置(実施例3)等の領域処理についての本発明の実施例を示す。
(1)実施例1(消去回数の平均化)
前記したように、フラッシュ・メモリは、消去回数に制限があり、全てのメモリを有効に活用するためには、消去回数を平均化する必要がある。
本実施例は、各ブロックの消去回数を意識することなく、消去回数のバラツキを抑えることが可能な実施例を示しており、本実施例においては、セクタ単位で追記書き込み、ブロック単位で消去するメモリにおいて、ブロックをセクタ単位で区切り、以下に示すように、消化可能なセクタが多いブロックと、消去可能なセクタが少ないブロックとを混ぜ合わせて新しいブロックに書き込むことにより、消去回数を平均化している。
【0024】
次に本実施例について説明する。
図14ないし図18は本実施例における書き込み処理を示す図であり、本実施例においては、6セクタを持つ6ブロックのフラッシュ・メモリにAからOの論理セクタを書き込む例を示している。
また、以下の説明においては、ブロック内の空きセクタの数がN個(本実施例では2個)になった場合にM個のブロック(本実施例では2個)に退避動作を行うこととし、また、消去可能セクタ数が多い方からmブロック(本実施例では1ブロック)と消去可能セクタの少ない方からnブロック(本実施例では1ブロック)を選択して、同時に退避する。
なお、退避動作を行う場合には、前記したように、消去可能フラグが立っていないセクタを読み出して、図5に示すSRAM23に移動し、ついで、SRAM23に移動したセクタを新たなブロックに書き込む。
【0025】
図14の(a)において、同一のセクタがないので、ブロック1とブロック2にセクタA,B,C,D,E,F,G,H,Iを、最初のセクタから順番に書き込む。
(b)において、セクタC,Dを書き込む。この場合には、同一のセクタC,Dがあるので、既にC,Dが書き込まれているセクタに消去可能フラグを立て、新しいセクタC,Dを書き込む。
ついで、図15の(c)において、セクタJ,K,L,M,N,Oを書き込む。この場合にも、(a)の場合と同様、同一のセクタがないので、既に書き込まれたセクタの後に順番に書き込む。
(d)において、セクタH,I,J,K,M,Nを書き込む。同一セクタが書き込まれているので、消去可能フラグを立て、新しいセクタH,I,J,K,M,Nを書き込む。
【0026】
図16(e−1),(e−2)において、セクタC,Dを書き込む。その際、空きブロックの数が2個になっているので、退避動作を行う。
すなわち、図15の(d)において、消去可能なセクタが最も多いブロック3と、消去可能セクタが最も少ないブロック4を選択し、ブロック3のセクタとブロック4のセクタを混在させ、退避先の各ブロックのセクタ数が均一になるように、空きブロック5と6に書き込む。
その結果、図16(e−1)に示すように、セクタO,I,K,Mがブロック5に、また、セクタH,J,L,Nがブロック6に書き込まれ、ブロック3と4が空きブロックとなる。
この状態で、既にC,Dが書き込まれたブロック2に消去可能フラグを立て、セクタC,Dを図16(e−2)に示すようにブロック5に書き込む。
【0027】
図17(f−1)において、セクタH,I,Jを書き込む。この場合にも、同一のセクタが既にあるので、ブロック5とブロック6に消去可能フラグを立て、ブロック6にセクタH,Iを書き込むが、セクタJを書き込む時点で空きブロックが2個になったので、前記と同様退避動作を行う。
すなわち、(f−2)に示すように、消去可能なセクタが最も多いブロック2と、消去可能セクタが最も少ないブロック6を選択し、ブロック2のセクタとブロック6のセクタを混在させ、退避先の各ブロックのセクタ数が均一になるように、空きなブロック3と4に書き込む。
ついで、(f−3)に示すように、セクタJを書き込む。この場合にも同一セクタがあるので、既に書き込まれているブロック4のセクタに消去可能フラグを立て、ブロック3にセクタJを書き込む。
図18(g)において、セクタE,F,Gを書き込む。この場合にも同一セクタがあるので、既に書き込まれているブロック1,3のセクタに消去可能フラグを立て、ブロック3と4にセクタE,F,Gを書き込む。
【0028】
図19は本実施例の処理を示すフローチャートであり、同図により本実施例の処理について説明する。
ステップS1において、本体よりデータを受け取ると、ステップS2のおいて、空きセクタ有りのブロック数がN以下であるか否か判別する。空きセクタ有りのブロック数がN以下でない場合には、ステップS7に行く。空きセクタ有りのブロック数がN以下の場合には、ステップS3において、消去可能セクタ数が多いブロックからmブロックを退避対象とし、ステップS4において、消去可能セクタ数が少ないブロックからnブロックを退避対象とする。
ステップS5において、退避対象のブロックからデータを空きブロックに移動する。その際の書き込み方は、データを移動する毎に書き込みブロックを変え、M個のブロックに書き込んだら最初に書き込んだブロックに戻る。ついで、ステップS6において、退避対象のブロックを消去する。
ステップS7において、同一論理セクタがあれば、既に書き込まれている物理セクタに消去可能フラグを立て、ステップS8において、本体から受け取ったデータをフラッシュ・メモリに書き込む。
【0029】
ところで、一般にセクタには、システム・プログラムのように殆ど書き換えが行われないデータを格納したセクタと、常時書き換えが行われるデータを格納したセクタがあり、普通にデータの書き込み/退避をおこなっていると、殆ど書き換えが行われないセクタが多いブロックは消去回数が少なくなる。
したがって、上記のように、消去可能なセクタが多いブロック(常時書き換えが行われるセクタが多いブロック)と、消去可能なセクタが少ないブロック(殆ど書き換えが行われないセクタが多いブロック)とを混ぜ合わせて新しいブロックに書き込むことにより、結果的に各ブロックに書き換えが多いセクタと書き換えが少ないセクタが混在することとなり、ブロックの消去回数を平均化することができる。
【0030】
本実施例においては、上記のような原理に基づき書き込み処理をおこなっているので、各ブロックの消去回数を意識することなく、消去回数のバラツキを抑えることができ、フラッシュ・メモリのように消去回数が有限なメモリの寿命を延ばすことが可能となる。また、消去回数をカウントすることなく消去回数のバラツキを抑えることができるので、消去回数をカウントするための領域を設けることなく、メモリの管理を行うことも可能となる。
【0031】
(2)実施例2(消去可能データの消去による空き領域の作成)
前記したように、フラッシュ・メモリは上書きをすることができず、消去した後でなければ書き込みを行うことができない。このため、書き込み時、同一のセクタがある場合には消去可能フラグを立て、適宜の時点で消去可能フラグが立っているセクタを消去する必要がある。
本実施例は、上記のように、消去フラグがたっている消去可能なデータを記憶媒体上からなくすための領域処理を示しており、本実施例による領域処理を処理の空き時間などに予め行っておくことにより、書き込みできる領域を確保でき、書き込み時間を短縮することができる。
【0032】
図20から図23は本実施例における書き込み/消去処理を示す図であり、同図により本実施例を説明する。なお、本実施例においては、次の点を前提としている。
▲1▼ ブロック数が6個で、1ブロックあたり、6個のセクタがあり、リード/ライトはセクタ単位で行い、消去はブロック単位で行う。
▲2▼ 書き込み方式は追記書き込み方式であり、同じアドレスの論理セクタを書き込むときは、旧論理セクタに格納されている物理セクタに消去可能フラグを立てる。
▲3▼ 追記のために書き込み領域を5ブロック+退避領域1ブロック(ブロック1〜ブロック6)とする。
▲4▼ 書き込み領域がなくなった場合には、消去可能フラグが立っている物理セクタが一番多いブロックの消去不可の物理セクタのデータを退避領域に移動して、移動元のブロックを消去する。そして、そのブロックを退避領域として使用し、今までの退避領域を書き込み領域とする(この一連の動作を退避動作と呼ぶ)。
▲5▼ 本体から送られて来るセクタのアドレスはAからPとする。
▲6▼ ブロック中に消去可能なデータがm以上あるとき、本実施例における領域処理の対象とする(図20から図23の例においては、m=1としている)。
なお、図20から図23中のブロックの右に付された矢印は書き込み場所を示す書き込みポインタの位置である。
【0033】
図20(a)において、論理セクタA〜Gを書き込む。この場合には、同一アドレスの論理セクタがないので、書き込みポインタが指す位置から順番に書き込む。
(b)において、論理セクタA,D〜Gを書き込む。この場合には、同アドレスの論理セクタ(A,D,E,F,G)があるので、消去可能フラグを立てた後に、(a)と同様に書き込む。
(c)において、論理セクタH〜Nを書き込む。この場合には、同一アドレスの論理セクタがないので、そのまま書き込む。
図21(d)において、A,G〜Lを書き込む。この場合には、同アドレスの論理セクタ(A,G,H,I,J,K,L)があるので、消去可能フラグを立てた後に書き込む。
(e)において、A,H〜Jを書き込む。この場合にも、同アドレスの論理セクタ(A,H,I,J,)があるので、消去可能フラグを立てた後に書き込む。
(f−1)において、A,I〜Lの書き込みを行おうとするが書き込み領域がないので、退避動作をを行う。すなわち、消去可能フラグが立っている物理セクタが一番多いブロック(ブロック3)のデータを退避領域(ブロック6)に移動して、移動元のブロックを消去する。そして、そのブロック(ブロック3)を退避領域として使用し、今までの退避領域(ブロック6)を書き込み領域とする。
その結果、(f−1)のようになる。
【0034】
ついで、図22(f−2)に示すように、A,I〜Lを書き込む。この場合には、同アドレスの論理セクタがあるので、消去可能フラグを立てた後にA,I〜Lを書き込む。この時、書き込みポインタは退避領域(ブロック6)の先頭にある。
以上のよう書き込むことにより、消去可能なデータを増えたので、本実施例による領域処理を行う。
すなわち、退避領域(ブロック3)から見て、書き込み方向に対して一つ反対方向のブロック(ブロック2)を処理対象として、ブロック2と3で退避動作を行う。その結果、図22(g−1)に示すように、ブロック2が退避領域となり、ブロック3にブロック2の消去不可のデータが移される。
【0035】
次に上記と同様に、ブロック1とブロック2で退避動作を行う。その結果(g−2)に示すように、ブロック1が退避領域となり、ブロック2にブロック1の消去不可のデータが移される。
ついで、上記と同様にブロック5と1で退避動作を行う。その結果、図23(g−3)に示すように、ブロック5が退避領域となり、ブロック1にブロック5の消去不可のデータが移される。なお、ブロック6には消去可能のデータがないので、領域処理の対象としない。
同様にブロック4と5で退避動作を行う。その結果、(g−4)に示すように、ブロック4が退避領域となり、ブロック5にブロック4の消去不可のデータが移される。そして、退避領域の位置が処理を行う前の退避領域の位置まできたので、領域処理を終わる。
以上のような処理を行うことにより、消去可能データは記憶媒体上からなくなる。
【0036】
次に(h)に示すように、A,H〜Jを書き込む。この場合にも、同アドレスの論理セクタがあるので、消去可能フラグを立てたのち書き込む。
図24は本実施例の処理を示すフローチャートであり、同図により本実施例の処理を説明する。
ステップS1において、現在の退避領域のブロックNo. を記憶し、ステップS2において、退避領域を処理対象とする。ステップS3において、処理対象を書き込み方向とは反対方向に一つ進める。
ステップS4において、処理対象とステップS1において保存した保存ブロックNo. を比較し、同じであれば処理を終了する。
処理対象と保存ブロックNo. が異なる場合には、ステップS5に行き、処理対象の消去可能セクタ数を所定値mと比較し、消去可能セクタ数がm以下の場合には、ステップS3に戻り、上記処理を繰り返す。消去可能セクタ数がmより大きい場合には、ステップS6に行き、処理対象を退避対象として、ステップS7において、書き込みポインタを退避領域の先頭に移動する。
ステップS8において、退避対象のブロックからデータを移動する。ステップS9において、退避対象のブロックを消去し、ステップS10において、退避対象のブロックを退避領域とし、ステップS3に戻り上記処理を繰り返す。
【0037】
本実施例においては、上記のようにして領域処理を行っているので消去可能データを無くすことができ、本実施例の領域処理を予めおこなっておくことにより、書き込み時間の短縮を図ることができる。
また、領域処理の対象となるブロックを書き込み方向とは反対方向に進めているので、書き込み場所を示している書き込みポインタと退避領域の間に全ての空き領域を存在させることができる。その結果、どのような場合に処理の中断がおこっても、書き込みポインタの示す位置からデータを書き込んで行くことができ、処理中断後に必要とする処理を少なくすることができ、また、処理を全ておえていなくても、支障がない。
【0038】
(3)実施例3(空き領域の作成のための救済措置)
前記したように、フラッシュ・メモリはデータ書込みのため、メモリ中に空き領域を確保しておく必要があるが、本実施例は、上記空き領域が、不良ブロックが発生するなどの原因により使えなくなったとき、救済措置を講じて新たな空き領域を作成する実施例を示している。
図25から図31は本実施例の空き領域の作成処理を示す図であり、同図により本実施例を説明す。なお、本実施例においては、次の点を前提としている。
▲1▼ ブロック数が7個で、1ブロックあたり、6個のセクタがあり、リード/ライトはセクタ単位で行い、消去はブロック単位で行う。
▲2▼ 書き込み方式は追記書き込み方式であり、同じアドレスの論理セクタを書き込むときは、旧論理セクタに格納されている物理セクタに消去可能フラグを立てる。
▲3▼ 障害時の救済用に1ブロックの予備領域(ブロック0)を確保し、追記のために書き込み領域を5ブロック+退避領域1ブロック(ブロック1〜ブロック6)とする。
▲4▼ 書き込み領域がなくなった場合には、消去可能フラグが立っている物理セクタが一番多いブロックの消去不可の物理セクタのデータを退避領域に移動して、移動元のブロックを消去する。そして、そのブロックを退避領域として使用し、今までの退避領域を書き込み領域とする(この一連の動作を退避動作と呼ぶ)。▲5▼ 本体から送られて来るセクタのアドレスはAからPとする。
【0039】
図25(a)において、セクタA〜Gを書き込む。この場合には、同じ論理セクタがないので、そのまま、ブロック1から書き込む。
(b)において、セクタA,D〜Gを書き込む。この場合には、セクタA,D〜Gと同一論理セクタがあるので、同一の論理セクタに消去可能フラグを立てたのち書き込む。
(c)において、セクタH〜Nを書き込む。この場合には、同じ論理セクタがないので、そのまま書き込む。
図26(d)において、セクタA,G〜Lを書き込む。この場合、セクタA,G〜Lと同一論理セクタがあるので、同一の論理セクタに消去可能フラグを立てたのち書き込む。
(e)において、セクタA,H〜Jを書き込む。この場合、セクタA,H〜Jと同一論理セクタがあるので、同一の論理セクタに消去可能フラグを立てたのち書き込む。
【0040】
図27(f−1)において、セクタA,I〜Lを書き込むが、この場合には、書き込み領域がないので、退避動作を行った後書き込み処理を行う。すなわち、消去可能フラグが立っているデータが最も多いブロック(ブロック3)の消去可能でないデータを退避領域(ブロック6)に移動して、移動元のブロックを消去する。そして、そのブロック(ブロック3)を退避領域として使用し、今までの退避領域を書き込み領域とする。
ついで、(f−2)において、セクタA,I〜Lを書き込み領域となったブロック6に書き込む。
次に、(g)において、A,M,Nを書き込みを行うが、上記(f)と同様書き込み領域がないので、まず、退避動作を行う。すなわち、消去可能フラグが立っているデータが最も多いブロック(ブロック5)の消去可能でないデータを退避領域(ブロック3)に移動して、移動元のブロックを消去する。そして、そのブロック(ブロック5)を退避領域として使用し、今までの退避領域を書き込み領域とする。
【0041】
ここで、ブロック5が消去失敗により使用不可となったとすると、退避領域がなくなるので救済措置を行う。
そこで、図28(h)に示すように、予備ブロック0を仮の退避領域として退避動作を行う。すなわち、図27(g)において、消去可能でないデータが最も多いブロック(ブロック1)の消去可能でないデータを仮の退避領域(ブロック0)に移動して、移動元のブロックを消去する。そして、そのブロック(ブロック1)を退避領域として使用する。ついで、(i)に示すように、予備ブロック(ブロック0)の退避動作を行う。すなわち、仮の退避領域として用いた予備領域(ブロック0)の論理セクタB,Cをブロック3に移動する。
これで、予備領域と退避領域が作成されたので、(j)において、論理セクタA,M,Nをブロック3に書き込む。
次に、セクタA,G,H,O,Pを書き込もうとするが、書き込み領域がないので、図29(k−1)に示すように退避動作を行う。すなわち、消去可能なデータが最も多いブロック(ブロック4)の消去可能でないデータを退避領域(ブロック1)に移動して、移動元のブロックを消去する。そして、そのブロック(ブロック4)を退避領域として使用する。
【0042】
ついで、(k−2)に示すように、セクタA,G,H,O,Pを書き込むが、セクタA,G,Hについては同じアドレスの論理セクタがあるので、消去フラグを立てたのちブロック1に書き込み、セクタO,Pについては、そのまま、書き込む。
次に、(l)において、セクタAを書き込もうとするが、書き込み領域がないので、退避動作を行う。その結果、ブロック2が退避領域となり、ブロック2にあったセクタD,E,Fがブロック4に移動する。
ここで、ブロック2が消失失敗で使用不可になったとすると、退避領域がなくなるので、救済措置を行う。すなわち、消去可能なデータが最も多いブロック(ブロック3)のデータを仮の退避領域(ブロック0)に移動して、移動元のブロックを消去する。そして、そのブロック(ブロック3)を退避領域として使用する。その結果、図30(m)に示すようになる。
【0043】
なお、この状態で、電力不足などにより、処理に一旦ストップをかけたすると、処理を再開したとき、装置側は予備領域に消去可能なセクタがなく、データがあるので、空き領域作成中と判断できる。
続いて、空き領域作成のための救済措置を行い、ブロック6のセクタI,Jを予備領域(ブロック0)に移動し、ブロック6のセクタK,Lをブロック3に移動する。その結果図30(n)に示すようになる。
ここで、退避領域のセクタを除いた空きセクタ数が、予備領域(ブロック0)にあるデータの数以上なので、書き込みポイントを退避領域の後ろから検索し、空いている領域に、予備領域(ブロック0)からデータを移動する。
その際、図31(o)に示すように、予備領域(ブロック0)のセクタB,C,M,Nを移動した段階で、本体側が電力不足等により一旦処理にストップをかけたとする。この場合には、処理を再開した時に、装置側は予備領域に消去可能なセクタがあるので、空きブロック作成中の予備領域のデータ移動中と判断できる。
続いて、図31(p)に示すように、予備領域(ブロック0)の論理セクタI,Jをブロック4に移動して処理を終了する。
【0044】
図32は本実施例における空き領域作成処理を示すフローチャートであり、同図により、本実施例の処理を説明する。
ステップS1において、予備領域に消去可能セクタが有るか否かを判別し、ある場合には、ステップS11に行く。ない場合には、ステップS2に行き、書き込みポインタを予備領域の先頭とし、ステップS3において予備領域にデータがあるか否かを判別する。予備領域にデータがある場合には、ステップS10に行き、ない場合にはステップS4に行き、退避領域を予備領域とする。
ステップS5において、書き込み領域の各ブロックに消去可能セクタがない場合には、空き領域を作成できないので処理を放棄(Abort )する。消去可能セクタがある場合には、ステップS6に行き、消去可能セクタの一番多いブロックを退避対象とし、ステップS7において、退避対象のブロックからデータを予備領域に移動する。
ステップS8において退避対象となるブロックを消去し、ステップS9において、退避対象のブロックを退避領域にする。
ステップS10において、▲1▼予備領域のデータ数が▲2▼退避領域以外の空きセクタ数より多いか否か判別し、▲1▼>▲2▼の場合には、ステップS5に戻り、上記処理を繰り返す。また、▲1▼≦▲2▼の場合には、ステップS11に行き、書き込みポインタを退避領域の次から書き込み方向に対して検索し、ステップS12において、空きセクタに予備領域からデータを移動する。ステップS13において、予備領域を消去して終了する。
【0045】
本実施例においては、上記のように空き領域を作成しているので、記憶媒体中に使用不可のブロックが発生しても、救済措置により空き領域を作成することができ、記憶装置して使用不可能となることを避けることができる。
また、処理途中で、本体側の電力不足などにより処理が中断しても、どの段階で処理が中断したかを容易に判断することができ、処理中断における処理段階の判断を単純化することが可能となる。
【0046】
C.消去処理の効率化
次に、本発明の請求項1,2の発明の実施例について説明する。
フラッシュ・メモリは前記したように上書きをすることができず、消去した後でなければ書き込みを行うことができない。本実施例は、上記のようなフラッシュ・メモリにおいて、書き込み有無を示すフラグと、全空間消去処理を実行中であることを示す実行中フラグを設けることにより、全記憶空間を消去する際の消去処理を効率良く行うとともに、消去中に何らかの原因で処理が中断された場合においても、処理再開をすることができるようにしたものである。
次に図33、図34により本実施例の処理を説明する。なお、本実施例においは、ブロック数は6個とし、各ブロックに書き込みフラグを書き込む領域を設け、ブロック6に全空間消去処理を実行中であることを示す実行中フラグを書き込む領域を設けている。
【0047】
図33(a)において、ブロック1,2,4の書き込み前に、ブロック1,2,4に書き込み有無フラグを書き込む。
ついで、全空間をクリアする初期化処理に当たり、(b−1)に示すように、ブロック6に実行中フラグを書き込む。
(b−2)において、書き込み有無フラグが書き込まれたブロック1を消去し、書き込む有無フラグを消す。
図33(b−3)において、書き込み有無フラグが書き込まれたブロック2を消去し、書き込む有無フラグを消す。
ここで、ブロック2の消去後、何らかの原因により、ストップ・シーケンスに移り、その後立ち上がった場合でも、ブロック6に実行中フラグが書き込まれているので、直ちに初期化動作中と判断し、初期化動作に移ることができる。
(b−4)において、ブロック1〜3には書き込み有無フラグに書き込まれていないため、ブロック4を消去し、書き込む有無フラグを消す。
(b−5)において、ブロック1〜5には書き込み有無フラグに書き込まれていないため、ブロック6を消去し、実行中フラグを消す。
【0048】
図35は本実施例の処理を示すフローチャートであり、同図により本実施例を説明する。
ステップS1において、実行中フラグの書き込みがあるか否かを判別し、有る場合には、ステップS3に行き、ない場合にはステップS2において、最終処理ブロックに実行中フラグを書き込む。
ステップS3において、処理対象をクリアし、ステップS4において、処理対象に書き込み有無フラグがあるか否かを判別する。書き込み有無フラグがない場合には、ステップS6に行き、有る場合には、ステップS5において、処理対象を消去し、ステップS6において、処理対象を次に進める。
ステップS7において、実行中フラグの書き込みかあるか否か判別し、ある場合には、ステップS4に戻り上記処理を繰り返す。また、実行中フラグがない場合には、終了する。
本実施例においては、上記のように書き込み有無フラグを設けているので、不要な消去を避けることができ、消去時間を短縮することができるとともに、媒体の寿命を延ばすことができる。
また、初期化実行中であることを示す実行中フラグを設けているので、不意の中断に対応することができる。
【0049】
D.書き込み速度の向上、および、不良セクタ発生時の予備領域の割り当て
前記したように、フラッシュ・メモリは上書きをすることができず、消去した後でなければセクタの書き込みを行うことができない。このため、前記したように、書き込み時、同一のセクタがある場合には消去可能フラグを立て、適宜の時点で消去可能フラグが立っているセクタを消去する必要があり、書込みの時間が掛かる。
また、前記したように、フラッシュ・メモリは、消去回数に制限があり、所定回数以上消去を行うと消去が出来なくなる。このため、不良セクタが発生した場合には、予備の領域を割り当て救済措置を講ずる必要があり、
以下に示す実施例は、上書きができず、セクタ単位で消去可能なメモリにおいて、上記した書き込み時のタイムラグをなくし、書き込み速度を向上するとともに、不良セクタが発生した場合に予備領域を割り当てる実施例を示している。
【0050】
図36は本実施例のシステム構成を示す図であり、図5に示したシステムに、EEPROM26が付加されており、その他の構成は図5に示したものと同一である。EEPROM26にはアドレス変換を行うデコード・テーブルが格納されており、上記EEPROM26によりアドレスのデコードが行われる。そして、フラッシュ・メモリの一部が不良になったとき、EEPROM26を書き換えて、救済措置を行う。なお、図36には、EEPROM26が例示されているが、デコード・テーブルを格納した記憶媒体としては、書き換えが可能な記憶媒体であればよく、その他フラッシュ・メモリ等を用いることができる。
【0051】
(1)実施例1
図37、図38は本実施例の構成を示す図であり、図37において、261はEEPROM26(もしくはフラッシュ・メモリ等の書き換え可能なROM)から構成されるセクタ変換部である。25はフラッシュ・メモリであり、フラッシュ・メモリは第1の領域A、第2の領域B、および予備領域Cが設けられ、第1の領域A、第2の領域Bには、それぞれ、1〜4の4個のセクタが設けられている。
図37において、データをセクタ1に書き込む場合には、第1の領域Aと第2の領域Bを見て、既に第1の領域Aにデータが有る場合には、第2の領域Bにデータを書き込む。また、上記データを書き込んでいる間に、第1の領域Aのセクタ1−Aを消去する。
その際、書き込みエラーが発生した場合には、予備領域Cを代替セクタとして割り当てる。
すなわち、第1の領域Aのセクタ1−Aに書き込みエラーが発生した場合には、予備領域Cをセクタ1−Aの代替とするため、セクタ変換部261のROMを書き換え、図38に示すように、セクタ1−Aとして、予備領域Cを割り当てる。
以上のように、書き込みエラーが発生した場合、予備がある限り予備領域のセクタを割り当て、予備がなくなった場合には、データを全て図36に示したSRAM23等の外部の領域に退避し、セクタ変換部261のROMを再編成し、データの空間と予備の空間に分ける。また、その時、セクタは、システムの構成に応じて、昇順、または、降順で初期状態と同様に割り当てていくが、不良セクタは除外する。
【0052】
本実施例においては、上記のように、書き込みと同時に消去を行っているので、書き込み時のタイムラグをなくすことができ、書き込み速度を向上させることができる。また、予備領域を設け、不良セクタが発生した場合に、予備領域に代替しているので、不良セクタが発生した際の救済を行うことができる。
【0053】
(2)実施例2
図39、図40は本実施例の構成を示す図であり、図39において、261はEEPROM、もしくは、フラッシュ・メモリ等の書き換え可能なROMから構成されるセクタ変換部、25はフラッシュ・メモリであり、フラッシュ・メモリは第1の領域A、予備領域Cが設けられ、第1の領域Aには1〜4の4個のセクタが設けられている。また、231は図36に示したSRAM23等のデータの一次記憶媒体である。
図39において、データの書き込み時、一次媒体231にデータを転送している間に、書き込むセクタを調べ、書き込むべきセクタにデータがあった場合には、そのセクタを消去する。なお、転送が早く終了した場合には、消去終了までまち、また、転送が遅い場合には、転送終了後、データを書き込む。
また、書き込みエラーが発生した場合には、セクタ変換部261のROMの書き換えをおこなって、図40に示すように(セクタ1−Aにエラーが発生した場合を示している)、予備領域Cにセクタ1−Aの書き込みを行う。なお、通常のセクタがエラーにならない限り、予備領域Cへの書き込みは行わない。
【0054】
本実施例においては、上記のように、データを一次記憶媒体231に転送している間に、書き込むべきセクタにデータがあった場合、消去を行っているので、第1の実施例と同様、書き込み時のタイムラグをなくすことができ、書き込み速度を向上させることができる。また、予備領域を設け、不良セクタが発生した場合に、予備領域に代替しているので、不良セクタが発生した際の救済を行うことができる。
【0055】
(3)実施例3
図41、図42は本実施例の構成を示す図であり、図41において、261はEEPROM、もしくは、フラッシュ・メモリ等の書き換え可能なROMから構成されるセクタ変換部、25はフラッシュ・メモリであり、フラッシュ・メモリはブロック1,ブロック2,予備ブロック1,予備ブロック2が設けられ、各ブロックには、ブロック1,ブロック2には、セクタ1〜3A,1〜3B,…,1〜3D、4〜6A,4〜6B,…,4〜6Dが設けられている。
そして、セクタ1〜3A,1〜3B,…,1〜3Dは物理アドレスとしてはそれぞれ1セクタであり、ここに論理アドレス1,2または3のデータを書き込むことができる。すなわち、論理アドレス1,2または3のデータを書き込む領域がA〜Dの4セクタ分設けられており、データを書き込む場合には、A〜Dの内の空いている領域に書き込む。
同様に、セクタ4〜6A,4〜6B,…,4〜6Dも上記と同様であり、論理アドレス4,5または6のデータを書き込む場合には、A〜Dの内の空いている領域に書き込む。
以上のように、本実施例においては、n+1(この実施例においてはn=3)セクタ単位でブロック化されており、書き込む論理アドレスに対して、1セクタの空きが設けられている。
【0056】
図41において、データをセクタ1に書き込む際、セクタ1〜3A,1〜3B,…,1〜3Dを見て、これらの中にセクタ1が既に存在する場合には、そのセクタを消去する。また、セクタには必ず空いているセクタが存在するので、上記した消去と同時に、空いているセクタに書き込みを行う。
書き込み時、書き込みエラーが発生した場合には、代替ブロックとして予備ブロックを割り当てる。例えば、セクタ1〜3Aが不良となった場合には、図42に示すように、予備ブロック1を代替ブロックとして割り当てる。そして、セクタ変換部261のROMを書き換えて、エラーのあったブロック1を予備ブロック1に割り当てる代替処理を行う。これにより予備ブロック1がブロック1となる。
予備がある限り上記のような処理を行い、予備がなくなった場合には、データを全て図36に示したSRAM23等の外部の領域に退避し、セクタ変換部261のROMを再編成し、データの空間と予備の空間に分ける。また、その時、セクタは、システムの構成に応じて、昇順、または、降順で初期状態と同様に割り当てていくが、不良セクタは除外する。
セクタ変換部261は、論理セクタから物理セクタへの変換時、上記したように、n+1セクタ単位でブロック化し、デコードするセクタ1に対して、書き込み可能なn+1のセクタが存在するように構成する。
そして、一部のセクタが不良となった場合には、上記セクタ変換部261のテーブルを書き換えることにより、書き込みブロックを移動して、常にn+1のセクタのブロックを作成する。
【0057】
本実施例においては、上記のように、n+1セクタ単位でブロック化し、1セクタを空けておき、書き込みと同時に消去を行っているので、実施例1,2と同様、書き込み時のタイムラグをなくすことができ、書き込み速度を向上させることができる。また、予備領域を設け、不良セクタが発生した場合に、予備領域に代替しているので、不良セクタが発生した際の救済を行うことができる。
【0058】
(4)実施例4
図43、図44は本実施例の構成を示す図であり、図43において、261はEEPROM、もしくは、フラッシュ・メモリ等の書き換え可能なROMから構成されるセクタ変換部、25はフラッシュ・メモリであり、フラッシュ・メモリはブロック1,ブロック2,予備1A〜1Dが設けられ、ブロック1,ブロック2には、それぞれ、セクタ1〜3A,1〜3B,…,1〜3D,4〜6A,4〜6B,…,4〜6Dが設けられている。
また、本実施例においては、実施例3と同様、n+1(この実施例においてはn=3)セクタ単位でブロック化し、1セクタを空けておく。
【0059】
図43において、データをセクタ1に書き込む際、セクタ1〜3A,1〜3B,…,1〜3Dを見て、これらの中にセクタ1が既に存在する場合には、そのセクタを消去する。また、セクタには必ず空いているセクタが存在するので、上記した消去と同時に、空いているセクタに書き込みを行う。
書き込み時、書き込みエラーが発生した場合には、代替セクタとして予備1A〜1Dを割り当てる。例えば、セクタ1〜3Aが不良となった場合には、図44に示すように、予備1A〜1Dがブロック1となり、セクタ1〜3Aに対して予備1Aを割り当て、セクタ変換部261のROMを書き換えて代替処理を行う。これにより予備セクタ1Aがセクタ1〜3Aとなり、予備1B〜1Dはブロック1の予備となる。
予備がある限り上記のような処理を行い、予備がなくなった場合には、データを全て図36に示したSRAM23等の外部の領域に退避し、セクタ変換部261のROMを再編成し、データの空間と予備の空間に分ける。また、その時、セクタは、システムの構成に応じて、昇順、または、降順で初期状態と同様に割り当てていくが、不良セクタは除外する。
セクタ変換部261は、論理セクタから物理セクタへの変換時、上記したように、n+1セクタ単位でブロック化し、デコード時には、そのデコード・データよりアドレス変換するテーブルを設けセクタ1に対して書き込み可能なn+1のセクタが存在するように構成する。そして、一部のセクタが不良となった場合には、上記セクタ変換部261のテーブルを書き換えることにより、常にn+1のセクタのブロックを作成する。
【0060】
本実施例においては、上記のように、n+1セクタ単位でブロック化し、1セクタを空けておき、書き込みと同時に消去を行っているので、実施例1,2,3と同様、書き込み時のタイムラグをなくすことができ、書き込み速度を向上させることができる。また、予備領域を設け、不良セクタが発生した場合に、予備領域に代替しているので、不良セクタが発生した際の救済を行うことができる。
【0061】
(5)実施例5
図45、図46は本実施例の構成を示す図であり、図45,図46において、図37、図38に示したものと同一のものには同一の符号が付されており、261はEEPROM、もしくは、フラッシュ・メモリ等の書き換え可能なROMから構成されるセクタ変換部、25はフラッシュ・メモリであり、フラッシュ・メモリはブロック1,ブロック2,予備ブロック1,予備ブロック2が設けられ、ブロック1,ブロック2、セクタ1〜3A,1〜3B,…,1〜3D,4〜6A,4〜6B,…,4〜6Dが設けられている。
また、本実施例においては、実施例3と同様、n+1(この実施例においてはn=3)セクタ単位でブロック化し、1セクタを空けておく。
【0062】
図45において、データをセクタ1に書き込む際、セクタ1〜3A,1〜3B,…,1〜3Dを見て、これらの中にセクタ1が既に存在する場合には、そのセクタを消去する。また、必ず空いているセクタが存在するので、上記した消去と同時に、空いているセクタに書き込みを行う。
書き込み時、書き込みエラーが発生した場合には、代替セクタとして予備セクタを割り当てる。例えば、セクタ1〜3Aが不良となった場合には、予備ブロック1を割り当て、セクタ変換部261のROMを書き換えて、代替処理を行う。これにより、図46に示すように、予備ブロックのセクタ1,n,mAがセクタ1に置き変わり、予備ブロックにセクタ1が存在することとなり、元のブロックにはセクタ2,3がそのまま残る。
すなわち、この実施例においては、ブロックの構成は続きセクタでなくてもよく、元のブロックの構成数を変更する。
予備がある限り上記のような処理を行い、予備がなくなった場合には、データを全て図36に示したSRAM23等の外部の領域に退避し、セクタ変換部1 1のROMを再編成し、データの空間と予備の空間に分ける。また、その時、セクタは、システムの構成に応じて、昇順、または、降順で初期状態と同様に割り当てていくが、不良セクタは除外する。
【0063】
本実施例においては、上記のように、n+1セクタ単位でブロック化し、1セクタを空けておき、書き込みと同時に消去を行っているので、実施例1,2,3,4と同様、書き込み時のタイムラグをなくすことができ、書き込み速度を向上させることができる。また、予備領域を設け、不良セクタが発生した場合に、予備領域に代替しているので、不良セクタが発生した際の救済を行うことができる。
【0064】
図47〜図49は上記実施例における処理を示すフローチャートであり、図36に示したシステムにおける本実施例の処理を説明する。
ステップS1において、本体からセクタデータの書き込み要求があると、ステップS2において、CPU22はコントローラLSI21からの通知によりデータの書き込み要求があることを認識する。なお、コントローラLSI21がCPU22に割り込みをかけて、データの書き込み要求を通知してもよい。
ステップS3において、CPU22はEEPROM26のデータを読み込み、その書き込み場所を認識し、セクタデータが書かれているか否かをチェックするため、フラッシュ・メモリ25−1,…,25−5をアクセスし、ECCデータ、あるいは、フラッシュ・メモリに格納された管理情報等を参照する。そして、ステップS5において、フラッシュ・メモリにデータが書かれているか否かを判断し、データが書かれていない場合には、図48のステップS8に行く。また、データが書かれている場合には、ステップS6において、第2のセクタにデータを書き込むための情報を読み込むため、CPU22はEEPROM26をアクセスし、データを得る。ついで、ステップS7において、フラッシュ・メモリのデータを消去し(効率を上げるためエラーチェックは後で行う)、図48のステップS8に行く。
【0065】
ステップS8において、本体よりデータをSRAM23にデータを転送し、終了を待つ。ステップS9において、フラッシュ・メモリにデータを書き込むため、CPU22はコントローラLSI21に対してデータの書き込みを通知し、コントローラLSI21はSRAM23よりフラッシュ・メモリにデータを書き込む。ついで、ステップS10において、CPU22はコントローラLSI21よりデータ書き込み終了の通知を受け、ステップS11において、データの書き込みエラーがあったか否かを判断する。
データの書き込みエラーがなかった場合には終了し、書き込みエラーがあった場合には、ステップS12において、代替用セクタが有るか否かを判断し、代替用セクタがある場合には、ステップS13に行き、セクタアドレスを変更するため、EEPROM26をアクセスしてデータを変更し、ステップS9に戻る。
また、代替用セクタがない場合には、図49のステップS14に行き、消去中のフラッシュ・メモリがあるか否かを判断し、消去中のフラッシュ・メモリがある場合には、ステップS15に行き、消去終了まで待って、消去したセクタにデータを書き込み終了する。
ステップS14において、消去中のフラッシュ・メモリがないと判断された場合には、ステップS16において、本体側にエラーを通知する。
【0066】
本体側では、ステップS17において、データを吸い上げEEPROM26を再編成するコマンドを送る。記憶装置側では、本体側からのコマンドに応じて、EEPROM26を再編成し、本体から送られる1論理セクタに対して、2セクタ以上の選択ができるようにする。これにより、少し容量は減るが記憶装置として使用可能となる。
なお、上記処理においては、SRAM23にデータを転送し、フラッシュ・メモリにデータを書き込む場合について説明したが、SRAM23を設けず、直接フラッシュ・メモリにデータを書き込むこともできる(この場合には、上記フローチャートのステップS8,S9は一処理となる)。
【0067】
E.アドレス変換用デコード部の信頼性の向上
論理アドレスを物理アドレスに変換するための変換テーブルとしてROMが使用されることがある。また、ROMの代わりに、フラッシュEEPROM、EEPROM等を使用することも可能であるが、通常はデコード部を可変にする必要がないため、使用されることが少ない。
一方、フラッシュ・メモリは、その媒体の性質上、消去回数に制限があり、不良になると、不良になったアドレスが使用出来なくなる。そこで、前記したD.の実施例(1)〜(5)に示すように、論理アドレスを物理アドレスに変換するための変換テーブルとして、フラッシュEEPROM、EEPROMなどの書き換え可能なデコード部を用い、不良のセクタが発生した場合、デコード部を書き換え、不良アドレスがないように見せかける方法が用いられる。
しかしながら、変換テーブルとして、フラッシュEEPROM、EEPROMなどを用いた場合、これらのフラッシュEEPROM、EEPROMなどにも、消去回数に制限があり、所定回数以上消去を行うと不良が発生する。
本実施例は、上記のように、デコード部としてフラッシュEEPROM、EEPROMなどの書き換え可能な記憶媒体が使用されている場合において、前記図4に示したようにデコード部を2段化とすることにより、デコード部の寿命を延ばし、アドレス変換用デコード部の信頼性を向上させる実施例を示している。
【0068】
図50は本実施例のデコード部の構成を示す図であり、同図(a)は通常の場合、(b)はセクタが不良になった場合、(c)はデコード部が不良になった場合を示しており、301は1次デコード部、302は2次デコード部、303はフラッシュ・メモリのセクタを示している。
同図において、フラッシュ・メモリのセクタが正常な場合には、(a)に示すように、1次デコード部301がセクタ0のアドレスのデコード値としてアドレス「0000h」を出力し、2次デコード部302が「0000h」のデコード値として物理アドレス「5555h」を出力し、フラッシュ・メモリのセクタ0の物理アドレスを指定している。
ここで、フラッシュ・メモリの消去回数が制限値を越えてセクタが不良となり、セクタ0の物理アドレスをアドレス8888hの予備のセクタに切り替える場合には、同図(b)に示すように、2次デコード部302を書き換えて、「0000h」のデコード値を「5555h」から「8888h」に切り替える。これにより、セクタ0として物理アドレス「8888h」が割り当てられる。
【0069】
上記のようにして、2次デコード部(もしくは1次デコード部)を何度か書き換えることにより書き換え制限値以上になり、2次デコード部に不良になると、同図(c)に示すように、一次デコード部301を書き換えてそのデコード値をずらし、2次デコード部302がデコード値として「8888h」を出力する「2222h」をデコード値として出力するように書き換える。これにより、2次デコード部302が不良になっても、物理アドレス「8888h」をデコード値として出力することができる。
以上のように、デコード部を2段化し、一方のデコード部が不良になった場合に、他方のデコード部を書き換えることにより、デコード部の寿命を2乗化することができる。
例えば、セクタが不良になるまでの回数をL回(書き換え制限値)、2次デコード部が不良になるまでの回数をM回(書き換え制限値)、1次デコード部が不良になるまでの回数をN回(書き換え制限値)とすると、アドレスがエラーになるまでの回数はN×M×L回となる。
基本的に書き換え制限値はフラッシュEEPROMで10万〜100万回、EEPROMで1万回程度といわれているので、事実上、デコード部を2段化するだけで、信頼性を十分確保することができる。
【0070】
F.書き込み時間の推定処理
フラッシュ・メモリにおいては、データの書き込みに際、退避処理等を行う必要があり、通常の半導体メモリの場合より書き込みに時間がかかる。
本実施例は、フラッシュ・メモリへの書き込み時間の推定を行い、消費電力の推定、異常の検出等を行う実施例を示している。
図51に本実施例のシステム全体の概略構成を示す。1は記憶装置、1aは上書きすることができず、また、セクタ、ブロック等の所定の単位でしかデータを消去することができない、例えばフラッシュ・メモリ等から構成される記憶領域、1bはコントローラ、2は本体処理装置である。
【0071】
次に本実施例について説明する。今、記憶装置が図52に示すような状態になっている場合に、3セクタのデータを書き込む場合を考える。
まず、前記した図5の本体よりプロセッサ22に書き込むセクタ数を送る。書き込むセクタ数がプロセッサ22に送られると、プロセッサは書き込むセクタ数により書き込み時間を求める。ここで、図52のように書き込むブロックが無い場合には、退避動作が行われるので、書き込み時間tは次のようにして求められる。
t=〔1セクタの書き込みに掛かる時間〕×3+〔データの退避時間〕(秒)
プロセッサ22は上記のようにして書き込み時間を計算し、本体へ返す。本体は、上記書き込み時間を元に、次の式により書き込み動作時の消費電力W1を求める。
W1=t÷3600×〔書き込み動作の消費電力〕(W)
また、本体はその電源部から残りの電力W2を読み取り、得られた書き込み電力と比較し、W2>W1ならデータの書き込みを行う。
一方、本体は上記のようにして得た書き込み時間tと実際の書き込み時間を比較し、上記書き込み時間tを越えても書き込みが終了しない場合には、記憶装置の異常と判断し、例えば、ユーザに通知したり、書き込み処理をストップ等の措置を行う。
【0072】
図53は本実施例における本体の処理を示すフローチャートであり、同図により本実施例を説明する。
ステップS1において、これから書き込むデータのサイズを記憶装置に送り、書き込みにかかる時間を得る。
ステップS2において、書き込みにかかる時間と、時間当たりの消費電力をかけて書き込みにかかる電力を得る。ステップS3において、残り電力と書き込みで使用する電力を比較し、残り電力の方が少ない場合には、異常処理を行う。また、残り電力の方が多い場合には、ステップS4に行きデータを書き込み、ステップS5において、実際の書き込み時間が予想した時間より多いか否か判別し、多い場合には、異常処理を行う。また、書き込み時間が予想した時間以内の場合には、ステップS6に行き、書き込み終了か否かを判別し、書き込み終了でない場合にはステップS5に戻り、書き込み終了の場合には、終了する。
【0073】
以上のように、本実施例においては、書き込み時間を求めることにより、書き込みに要する電力を推定しているので、残り電力量で書き込みができるかどうかの判断を行うことができる。このため、電池駆動等のシステムにおいて、書き込み中に電力がなくなり書き込みが途中で中断することを避けることができ、システムの信頼性を向上させることができる。
また、実際の書き込み時間と推定した書き込み時間を比較することにより、記憶装置の異常を検出することができ、また、書き込み時間を表示するなどしてユーザに知らせることにより、ユーザが記憶装置の異常を判断することが可能となる。
【0074】
G.フラグ判定処理における信頼性の向上
フラグの判定は、通常、1ビットを1機能に割り当て判定している場合が多い。しかしながら、フラッシュ・メモリは過剰消去により消去不能になるという、致命的不良原因を構造的にもっており、これが発生したセルはハイレベルのままで、ローレベルに戻らない状態に陥る。
このため、フラッシュ・メモリ上のフラグを1ビット1機能に対応させた場合には、そのビットが不良になったとき、フラグの有効性がなくなってしまう。
本実施例は、フラッシュ・メモリ上の消去フラグ、不良フラグ、パリテイー等に対して、フラグを複数用意することにより、上記したフラッシュ・メモリの構造的欠点に対処し、前記図51に示したように、論理積によりフラグ判定を行うことにより、フラグ判定の信頼性を向上させた実施例を示している。
【0075】
(1)実施例1
図54は実施例1を示す図であり、同図(a)はフラグレジスタ、(b)は判定のための論理積回路、(c)は真理値表を示している。
本実施例においては、同図(a)に示すように、一つの機能に対してフラグb0 ,b4 を用意してフラグレジスタに格納する。そして、フラグ判定を行う場合には、(b)に示すように、これらのフラグの論理積を求めることにより、最終的な判定結果を得る。
上記のように判定しているので、同図(c)の行番号2のようにビットb0 がハイレベルで固定になっても、その論理積結果としては、正しい結果を得ることができる。同様に、行番号3のように、ビットb4 がハイレベルで固定になっても、その論理積結果としては、正しい結果を得ることができる。
【0076】
(2)実施例2
図55は実施例2を示す図であり、同図(a)は第1のフラグレジスタ、(b)は第2のフラグレジスタ、(c)はフラグ判定を行う論理積回路を示している。
本実施例は同一機能に対するフラグを別々のフラグレジスタに格納するようにしたものであり、同図(a)に示す第1のフラグレジスタのビットb0 にフラグを格納し、同図(b)に示す第2のフラグレジスタのビットb0 とビットb2 に第1のフラグレジスタに格納したフラグと同一の機能に対応するフラグを格納している。
そして、フラグを判定する場合には、同図(c)に示す論理積回路により上記フラグの論理積を求める。
本実施例においても、実施例1と同様、フラグの一部がハイレベルで固定しても、正しい判定結果を得ることができる。
以上のように、本実施例においては、フラグの判定を複数ビットで行うようにしているので、全てのビットが不良にならない限り、正しい判定値を常に出力することができ、フラグ判定の信頼性を向上することができる。
【0077】
H.管理テーブルの節約
本実施例は記憶装置が複数チップで構成され、各チップ内に複数のブロックが設けられたフラッシュ・メモリ・システムにおいて、管理テーブルを簡単化するとともに、各ブロックを平均的に使用することができる実施例を示している。
以上示した実施例においては、データを書き込むチップ、ブロックに制約がなく、データは全ブロックのセクタに書き込むことができたため、全領域を管理するテーブルを設ける必要があったが、本実施例においては、各チップ内に書き込むデータを固定とし、チップ内において書き込むブロックを移動して書き込んでいくことにより、全領域を管理することなくデータの書き込みができるようにし、フラッシュ・メモリの管理を簡単化するとともに、各ブロックの使用を平均化している。
また、本実施例においては、チップ内に書き込まれるデータをチップの全容量より一定量少なくし、この一定量のブロックをワークブロックと不良ブロック発生時の救済ブロックに当てている。そして、ブロック内のデータの並びは固定とし、データを書き換える場合、すでに旧ブロックに有効なデータが存在している場合には、そのデータを前記した図5のSRAM23に退避して、新データと一緒にして空いている領域に書き込み、書き込みが成功したら旧データのブロックを消去するようにしている。
【0078】
次に本実施例を説明する。
図56は本実施例におけるチップ、ブロック、セクタ内構成を示す図であり、同図に示すように、チップは2Mbyteであり、チップ内は1ブロック4KbyteのNo.000〜No.511の512個のブロックに分割され、各ブロック内には、1セクタ528byte のNo.00〜No.07の8個のセクタが設けられている。なお、同図のブロックNo.およびセクタNo.は物理アドレスを示している。
さらに、セクタ内には、同図に示すように、256byte の実データ領域、Long命令用のECC領域、不良データフラグ、不良ブロックフラグ、ブロックアドレス、256byte の実データ用領域ECC領域が設けられている。
ブロック・アドレスは、SRAM23に格納されているブロック・ポインタのアドレス値を示し、ブロック・アドレスには、実データなしと判断したセクタも書き込むこととしている。このようにすることにより、活線抜き差し時、セクタアドレス数が多い物が正常データと判断することができる。なお、セクタアドレス数が等しい場合はECC・チェックサムの正誤で判断する。
【0079】
不良ブロックフラグは、ブロックのコンディションを示しており、FFhで正常ブロック、≠FFhで不良ブロックとしている。
不良データフラグは、データのコンディションを示しており、FFhで正常データ、≠FFhで不良データとしている。
Long命令用のECC領域は最大4byte である。
ECC領域は、実データのコンディションを示しており、この領域の値によりデータの訂正および誤り検出を行う。
【0080】
図57〜図61は本実施例における書き込み処理を示す図であり、同図により本実施例を説明する。本実施例においては、チップがNo.00〜No.04の5個で、各チップにワークブロックを4個設けた場合の書き込みおよび管理方式を示している。
図57は全ブロックを消去した状態を示しており、同図に示すように、各チップにはワークブロックがwork01〜04の4個設けられており、データは上記ワークブロックwork01〜04に書き込まれる。書き込みはセクタ単位で可能であるが、セクタ005の書き込み後にセクタ004を書き込むなど、上位のセクタの書き込み後には下位のセクタの書き込みはできない。
また、チップを越えてデータが移動することはなく、ブロック内のセクタの順番は不動である。さらに、例えば、論理ブロックアドレス00にセクタ000〜005のみを書き込む場合のように、書き込みデータが8セクタ全てを満たさない場合には、セクタ000〜005のデータを書き込み後、セクタ006,007にブロックアドレスのみを書き込む。
なお、この場合、1ブロックが8セクタであり、また、チップが5個であるので、論理アドレスnのデータは、(論理アドレスn÷8)の商をさらに5で割ったときに得られた余りのチップに書き込まれる。例えば、n=121の場合には、121÷8は15で余り1であり、15÷5は5で余りが0なので、No.00のチップに書き込まれる。
【0081】
本実施例におけるデータの書き込み処理は次のように行われる。まず、図57に示す全ブロックを消去した状態からセクタNo.000〜039(論理アドレス)の40セクタを連続書き込みすると、図58に示すように各チップのwork01にデータが書き込まれる。
すなわち、最初に書き込まれるセクタNo.000〜007は論理ブロックアドレスが00なので、本体からSRAM23にセクタNo.000〜007のデータを転送して、チップNo.00の書き込みポインタが指すwork01からデータを書き込む。なお、論理ブロックアドレスはチップ単位で管理される。
そして、この場合には論理ブロックアドレス00が過去の存在しないので、チップNo.00のwork01はwork04の次の空き領域に移動する。
8セクタ分の書き込みが終了したら、書き込みポインタをチップNo.01のwork01に移動し、上記と同様にセクタNo.008〜015のデータをwork01に書き込む。
【0082】
以上のようにして、書き込みがチップNo.04まで完了したら、書き込みポインタをチップNo.00のwork02に移動する。
次に、図58の状態から、図59に示すようにセクタNo.120〜191(論理アドレス)の72セクタの連続書き込みをする。
上記と同様、本体からSRAM23にセクタNo.120〜127のデータを転送して、セクタNo.120〜127は論理ブロックアドレスが03なので、チップNo.00の書き込みポインタが指すwork02からデータを書き込む。そして、上記と同様、チップNo.00のwork02、work03はwork01の次の空き領域に移動する。
以下同様に、セクタNo.128〜191のデータをチップNo.00〜No.04に書き込む。
【0083】
ここで、図59の状態から、セクタNo.002〜003の2セクタを連続書き込みすると、図60に示すようになる。
まず、SRAM23にセクタNo.002〜003のデータを転送する。この場合、書き込みデータがセクタNo.002〜003なので、論理ブロックアドレス00が指定され、これは過去に存在するので、旧データの退避が必要と判断される。また、書き込みデータがセクタNo.002〜003で、論理ブロックアドレス00の最初から書き込まれないので、旧論理ブロックアドレス00のデータをSRAM23に退避する。
なお、書き込みデータが論理ブロックアドレスの先頭より2セクタ分のときには、書き込みデータを先に処理した後に旧論理ブロックアドレスのデータの退避動作を行う。
【0084】
次に、SRAM23に退避した旧データ000,001,004,005,006,007と新データ002,003を書き込みポインタが指すチップNo.00のwork04に書き込む。その際、書き込みは000,001,002,003,004,005,006,007の順番に書き込む。
ついで、論理ブロックアドレス00がすでに存在しているので、旧論理ブロックアドレスの消去を行う。また、work04を旧論理ブロックアドレス00に移動する。
上記のように2セクタ連続書き込みを行ったのち、電源がOFFになり、再びONにすると、図61に示すように、ワークブロックは使われているブロックの次より指定される。また、上記のようにワークブロックを指定していき、チップの最後まで検索してもワークブロックを全部指定できなくなった場合には、チップの最初に戻り、ワークブロックを指定する。
【0085】
上記の処理において、ブロック消去エラーが発生した場合には、不良フラグに00hを設定し、そのブロックは書き込みおよび読み出し不可とする。すなわち、ワークブロックを一つ潰すことにより対処し、ワークブロックがなくなったら、そのシステムは書き込み不可とする。
また、データ退避途中にエラーが発生した場合には、不良データフラグを立てたのちにデータを書き込む。なお、読み出し動作ではそのブロックにエラーが検出されても、そのブロックを不良ブロックとしては扱わない。
データ書き込みエラーが発生した場合には、そのブロックを不良ブロックとする。不良フラグの立て方は、一度書かれているデータを退避し、不良ブロックフラグのみを立てて、再度書き込む。不良ブロックフラグも通常書き込みと同様、該当ブロック全てのセクタに対して立てる。
データ消去途中でエラーが検出された場合には、そのブロックは不良ブロックとする。不良ブロックフラグの立て方は、不良ブロックフラグのみを立てるのではなく、実データを含め全てALL〔00〕を書き込む。不良処理は該当ブロック全てのセクタに対して行う。
【0086】
以上のように、本実施例においては、各チップ内に書き込むデータを固定とし、チップ内において書き込むブロックを移動して書き込んでいくので、全領域を管理する必要がない。このため、データを各チップ内でのみ管理すればよく、管理テーブルを節約することができ、また、書き込み動作の高速化を図ることができる。
また、ワークブロックにデータを書き込み、ワークブロックをチップ内で移動させるように構成したので、各ブロックを平均的に使用することができる。
【0087】
【発明の効果】
以上説明したように、本発明においては、記憶領域が複数のブロックと、該ブロックを区切ったセクタから構成され、書き込まれたデータをブロック単位で消去する記憶装置において、ブロック毎に書き込みの有無を示すフラグを設けて、書き込みの有無を示すフラグを参照して、書き込まれたデータを消去するようにしたので、不要な消去を避けることができ、消去時間の短縮を図ることができるとともに、記憶媒体の寿命を延ばすことができる。
【図面の簡単な説明】
【図1】本発明の全体の概略構成を示す原理図である。
【図2】本発明の原理を示す原理図(1)である。
【図3】本発明の原理を示す原理図(2)である。
【図4】本発明の原理を示す原理図(3)である。
【図5】本発明の前提となる記憶装置の構成を示すブロック図である。
【図6】記憶装置におけるSRAMの内容を示す図である。
【図7】記憶装置におけるフラッシュ・メモリの内容を示す図である。
【図8】記憶装置におけるフラッシュ・メモリの内容を示す図(続き)である。
【図9】記憶装置における書き込み時の処理を示すフローチャートである。
【図10】記憶装置における書き込み時の処理を示すフローチャート(続き)である。
【図11】記憶装置における書き込み時の処理を示すフローチャート(続き)である。
【図12】記憶装置における書き込み時の処理を示すフローチャート(続き)である。
【図13】記憶装置における書き込み時の処理を示すフローチャート(続き)である。
【図14】消去回数のバラツキを抑える実施例を示す図である。
【図15】消去回数のバラツキを抑える実施例を示す図(続き)である。
【図16】消去回数のバラツキを抑える実施例を示す図(続き)である。
【図17】消去回数のバラツキを抑える実施例を示す図(続き)である。
【図18】消去回数のバラツキを抑える実施例を示す図(続き)である。
【図19】消去回数のバラツキを抑える実施例の処理を示すフローチャートである。
【図20】消去可能データをなくす処理の実施例を示す図である。
【図21】消去可能データをなくす処理の実施例を示す図(続き)である。
【図22】消去可能データをなくす処理の実施例を示す図(続き)である。
【図23】消去可能データをなくす処理の実施例を示す図(続き)である。
【図24】消去可能データをなくす処理の実施例を示すフローチャートである。
【図25】空き領域の作成処理の実施例を示す図である。
【図26】空き領域の作成処理の実施例を示す図(続き)である。
【図27】空き領域の作成処理の実施例を示す図(続き)である。
【図28】空き領域の作成処理の実施例を示す図(続き)である。
【図29】空き領域の作成処理の実施例を示す図(続き)である。
【図30】空き領域の作成処理の実施例を示す図(続き)である。
【図31】空き領域の作成処理の実施例を示す図(続き)である。
【図32】空き領域の作成処理の実施例のフローチャートである。
【図33】消去処理の実施例を示す図である。
【図34】消去処理の実施例を示す図(続き)である。
【図35】消去処理の実施例のフローチャートである。
【図36】書き込み速度の向上を図る実施例のシステム構成を示す図である。
【図37】書き込み速度の向上を図る第1の実施例を示す図である。
【図38】書き込み速度の向上を図る第1の実施例を示す図(続き)である。
【図39】書き込み速度の向上を図る第2の実施例を示す図である。
【図40】書き込み速度の向上を図る第2の実施例を示す図(続き)である。
【図41】書き込み速度の向上を図る第3の実施例を示す図である。
【図42】書き込み速度の向上を図る第3の実施例を示す図(続き)である。
【図43】書き込み速度の向上を図る第4の実施例を示す図である。
【図44】書き込み速度の向上を図る第4の実施例を示す図(続き)である。
【図45】書き込み速度の向上を図る第5の実施例を示す図である。
【図46】書き込み速度の向上を図る第5の実施例を示す図(続き)である。
【図47】書き込み速度の向上を図る実施例のフローチャートである。
【図48】書き込み速度の向上を図る実施例のフローチャート(続き)である。
【図49】書き込み速度の向上を図る実施例のフローチャート(続き)である。
【図50】アドレス変換用デコード部を2段とした実施例を示す図である。
【図51】書き込み時間推定処理を行うシステムの全体の概略構成を示す図である。
【図52】書き込み時間推定処理の実施例における記憶領域の状態を示す図である。
【図53】書き込み時間推定処理の実施例のフローチャートである。
【図54】フラグ判定処理の第1の実施例を示す図である。
【図55】フラグ判定処理の第2の実施例を示す図である。
【図56】管理テーブルを節約する実施例における記憶領域の構成を示す図である。
【図57】管理テーブルを節約する実施例を示す図である。
【図58】管理テーブルを節約する実施例を示す図(続き)である。
【図59】管理テーブルを節約する実施例を示す図(続き)である。
【図60】管理テーブルを節約する実施例を示す図(続き)である。
【図61】管理テーブルを節約する実施例を示す図(続き)である。
【符号の説明】
1,20 記憶装置
1a 記憶領域
1b 一次記憶媒体
1c 制御手段
1d,1e デコード・テーブル
2 本体処理装置
21 コントローラLSI
22 プロセッサ
23 SRAM
24 クロック発振器
25−1〜25−5 フラッシュ・メモリ
26 EEPROM
261 セクタ変換部
301 1次デコード部
302 2次デコード部
[0001]
[Industrial applications]
The present invention relates to a method for writing / erasing a non-overwritable storage device such as a flash memory used for an external storage device of a personal computer.
[0002]
[Prior art]
In recent years, an external storage device using a flash memory has attracted attention as an external storage device such as a personal computer. A flash memory is non-volatile and does not require a backup power supply, can be electrically rewritten, and is inexpensive, but has the following problems.
{Circle around (1)} Unless data is erased, data cannot be written, and the unit of erasure cannot be a byte unit, but is a sector, block or chip unit. Therefore, unlike a normal memory, data cannot be rewritten in byte units, and the writing speed or the erasing speed is lower than the reading speed.
{Circle around (2)} There is a limit to the number of erasures, and it is generally said that erasure becomes impossible when the number of erasures is about 100,000 to 1,000,000. For this reason, unless the sector or block is used so as to average the number of erasures, a portion having a large number of erasures becomes defective first, and the usable area decreases.
Since the flash memory has the above-mentioned problems, when using the flash memory, a data save area is prepared, the data is saved when data is rewritten, or a management table is provided to write / write data. It is necessary to take various measures such as managing erasing and taking remedies when a defective sector, block, or the like occurs.
[0003]
[Problems to be solved by the invention]
While flash memories have the advantage of being non-volatile and capable of being electrically rewritten, they have many problems as described above, and have the disadvantage of using conventional semiconductor memories such as DRAM and SRAM. However, there are many problems that need to be solved when using it.
The present invention has been made in view of the above-described problems, and an object of the present invention is to efficiently erase a memory that cannot be overwritten and cannot be erased in byte units, such as a flash memory. It is to do.
[0004]
[Means for Solving the Problems]
FIG. 1 is a principle diagram showing an overall schematic configuration of the present invention, and FIGS. 2 to 4 are principle diagrams showing an outline of the present invention.
1 to 4, reference numeral 1 denotes a storage device, 1a cannot be overwritten, and data can be erased only in a predetermined unit such as a sector or a block. The storage area 1b controls the writing of data to the storage area 1a, and the control means for erasing the storage area 1a. The storage section 1c temporarily stores data when writing data to the storage area 1a. Further, primary storage media for saving data in the storage area 1a, 1d and 1e are decode tables for decoding addresses of the storage area 1a, and 2 is a main body processing device.
[0005]
In order to solve the above-mentioned problem, according to a first aspect of the present invention, there is provided a storage device, wherein a storage area is composed of a plurality of blocks, and erases written data in block units. In FIG. 3, as shown in FIG. 3B, a flag F1 is provided for each block to indicate the presence or absence of writing. In addition, the execution flag is written in the final processing block, and it is checked whether or not the execution flag is present. The written data is erased by referring to the flag F1.
According to a second aspect of the present invention, in the first aspect of the present invention, when erasing the entire storage area, referring to the flag F1 indicating the presence or absence of writing, only the block having the writing is erased. .
[0006]
[Action]
In FIG. 1, when write data is sent from the main processing unit 2 to the storage device 1, the control unit 1b stores the data in the primary storage medium 1c. Then, the address is decoded with reference to the decode table 1d (1e), and the data stored in the primary storage medium 1c is written to a new sector or block of the storage area 1a. At this time, if data having the same logical address as the logical address of the data to be written already exists in the storage area 1a, the data is erased or an erasable flag is set in the area storing the data.
When an erasure flag is set in the area storing the data, the control unit 1b saves the non-erasable data to the primary storage medium 1c and erases the storage area 1a in a predetermined unit at a predetermined time. Processing such as writing back the data saved in the primary storage medium 1c to the storage area 1a is performed to create a free area, and the like.
Further, when a part of the storage area 1a becomes defective, the control means 1b replaces the defective part with a spare area by rewriting the decode table 1d (1e).
[0007]
A storage area 1a shown in FIG. 2A is composed of a plurality of blocks 1a-1,..., 1a-N and sectors dividing the blocks, and erases written data in block units. In a storage device in which the storage area shown in (1) is composed of a plurality of sectors that cannot be overwritten and erases data written in the sector in sector units, data writing / erasing is performed as follows.
(1) The storage area 1a is composed of a plurality of blocks 1a-1,..., 1a-N and sectors dividing the blocks. ,..., 1a-N, when the non-erasable data is saved to another block having a free sector, as shown in FIG. N blocks (m and n are arbitrary integers) are selected from a small number of blocks, and the selected blocks are simultaneously evacuated to other blocks having empty sectors by scattered sectors.
As a result, an empty block can be created, and as a result, a sector with many rewrites and a sector with few rewrites coexist in each block, and the number of erase times of the block can be averaged.
(2) A storage device in which a storage area 1a is composed of a plurality of blocks 1a-1,..., 1a-N including a save area and erases written data in block units is shown in FIG. .., 1a-N including the erasable data, only the non-erasable data is moved to the save area, the data of the block is erased, and the erased block is replaced with a new one. A free area is created as a save area.
As a result, erasable data can be eliminated, and by performing this processing in advance, the writing time can be reduced.
(3) After moving only the non-erasable data of the block on the opposite side of the save area with respect to the data write direction to the save area, the data of the block is erased and the erased block is set as a new save area. .
This allows all free areas to exist between the write pointer indicating the write location and the save area. Therefore, even if the processing is interrupted, data can be written from the position indicated by the write pointer, and the amount of processing required after the interruption of the processing can be reduced.
[0008]
(4) In a storage device in which the storage area 1a is composed of a plurality of blocks 1a-1,..., 1a-N including a spare area and erases written data in block units, FIG. As shown in (a), the write point is set in the spare area, the non-erasable data of the block in which the data is written is moved to the spare area, and then the process of erasing the data in the block is repeated, and the data is erased last When the number of free sectors in the blocks other than the blocks is equal to or larger than the number of sectors in the spare area, the data in the spare area is moved to a block other than the last erased block.
As a result, a free area can be created. When an empty block becomes unusable, the unusable block can be rescued to create an empty block.
Further, when moving the data in the spare area to a block other than the block from which the data was erased last, the write point of the movement destination is searched from the block after the block from which the data was erased last, and the data in the spare area is searched. By moving, all empty sectors can be present between the last erased block and the write pointer, and the processing after the interruption of the processing can be simplified.
Furthermore, when the processing is resumed after the processing is interrupted, the point at which the processing is interrupted can be determined according to whether there is erasable data in the spare area or only non-erasable data. The determination of the time can be simplified.
(5) As shown in FIG. 4, in a storage device in which the storage area 1 is composed of a plurality of sectors that cannot be overwritten and erases data written in the sector in sector units, at least two sectors having the same sector number are used. When data is prepared in any one of the sectors with the same number, data is written in the other sector and data in one sector is erased at the same time. Thereby, the writing speed can be improved.
(6) In the storage device shown in FIG. 4, when data is present in the sector to be written, the data in the sector is erased while the data is being transferred to the primary storage device 1c, and after the data is completely erased, or After the data transfer is completed, data is written to the sector. Thereby, the writing speed can be improved.
(7) In the storage device shown in FIG. 4, spare areas 1b-1 and 1b-2 for replacing a defective sector and a rewritable decode table 1d for managing a write sector are provided, and a defective sector occurs. At this time, the write sector is changed to the spare areas 1b-1 and 1b-2 by rewriting the decode table 1d, and when the spare areas 1b-1 and 1b-2 are gone, the decode table 1d is rewritten. Since the sector is reconfigured by rewriting, it is possible to relieve when a defective sector occurs.
(8) In the storage device shown in FIG. 4, N + 1 sectors are provided for the N sector numbers, and each of the N + 1 sectors is shared by the N sector numbers. Is written to a vacant sector among the N + 1 sectors. As a result, the writing speed can be improved, the number of extra sectors can be reduced, and the cost can be reduced.
Also, spare areas 1b-1 and 1b-2 are provided to replace defective sectors. When a defective sector occurs, the decoding table 1d is rewritten, and a write block or a spare block is written in the spare areas 1b-1 and 1b-2. The sector is changed or the decoding table 1d is rearranged. As a result, it is possible to relieve when a defective sector occurs.
(9) A storage area 1a which is readable and writable and a part of the storage area may be destroyed, and a rewritable decoder 1d indicating a location where data in the storage area 1a is stored are provided. In the storage device, two stages of decoders are provided as shown in FIG. 4, and when a part of the storage area 1a of the storage device 1 is destroyed, or when a part of the decoders 1d and 1e is destroyed, a two-stage decoder 1d , 1e, or both, so that decoding to the destroyed portion is not performed. Thus, even when a storage medium such as an EEPROM or a flash memory which may be partially destroyed is used as a decoder, the probability of an address error can be significantly reduced, and reliability is ensured. be able to.
(10) The storage area 1a is divided into a plurality of blocks, and a plurality of blocks are provided in the divided chip. When writing data to a block in the chip, the data is written in a new block, and the written data is stored in the chip. If the data already exists in the storage device, the chip to which the data is to be written is fixed in the storage device for erasing the data in block units in correspondence with the data to be written. Thus, the control means 1b only needs to manage the data in each chip, and does not need to manage the entire area. Therefore, the management table in the control unit 1b can be simplified, and the writing speed can be improved.
Further, by providing a plurality of work blocks for writing data in each chip, when a failure occurs in a work block, the defective work block can be relieved.
[0009]
According to the invention of claims 1 and 2 of the present invention, in the storage device 1 in which the storage area 1a is composed of a plurality of blocks 1a-1,..., 1a-N and erases written data in block units, A flag F1 indicating the presence or absence of writing is provided for each In addition, the execution flag is written in the final processing block, and it is checked whether or not the execution flag is present. As shown in FIG. 3B, since the written data is erased with reference to the flag F1, unnecessary erasure can be avoided, the erasing time can be reduced, and the storage medium can be shortened. Life can be extended.
By storing a flag of a plurality of bits corresponding to the same function in the storage area 1a and determining the flag by the logical product of the flags, a correct determination value is always obtained unless all bits become defective. Can be output, and the reliability of the system can be improved.
[0010]
【Example】
Next, examples of the present invention will be described.
A. 1 illustrates a configuration of a storage device that is a premise of the present invention.
FIG. 5 is a block diagram showing a configuration of a storage device using a flash memory as a premise of the present invention.
In FIG. 1, reference numeral 20 denotes a storage device such as a memory card, 21 denotes a controller LSI for controlling rewriting and erasing of data in a flash memory, 22 denotes a processor, and 23 denotes a table for storing various tables and for writing data. SRAM used as a data buffer or save buffer, 24 is a clock oscillator, and 25-1 to 25-5 are flash memories.
In the figure, when writing data transferred from the main body to the SRAM 23 to the flash memories 25-1 to 25-5, the flash memory cannot be overwritten as described above. Write data to In the case of data update, measures such as setting an erasure flag on old data are taken. If the erase flag is set for the old data, only the data without the erase flag is saved in the save area of the SRAM 23 in a predetermined unit at a predetermined time, and the area to be written in the flash memory is saved. After erasing the data, the data is rearranged by rewriting the data.
[0011]
FIG. 6 is a diagram showing the contents of the above-described SRAM 23. As shown in FIG. 6, the following data is stored in the SRM 23.
(1) Erase count table
The number of times of erasure of each block of the flash memory is held.
(2) Erasable sector count table
Holds the total number of erasable sector flags in each block.
(3) Write pointer
Chip No. to start writing to the flash memory , Block No. , Sector address No. Hold.
(4) WORK-BLOCK-No.
The current WORK-BLOCK-No. And chip No. , Block No. Hold.
(5) Sorting pointer
Currently, chip Nos. , Block No. , Sector address No. Hold.
(6) Rewriting
Indicates whether the data to be written is new.
(7) Number of writing
Manages the number of times the device is written when organizing.
(8) Save counter
It manages the number of sectors in the evacuation operation during sorting.
(9) Number of chips
Holds the number of flash-chips mounted on the card.
(10) Sector map table
For the conversion of the logical address, the chip No. , Block No. , Sector address No. Hold.
[0012]
7 and 8 are diagrams showing the contents of the flash memories 25-1 to 25-5. In each sector of the flash memory, control information, data, and the like shown in the following (1) to (5) are stored. Is stored. In this example, 126 sectors are provided. In each sector, management information and the like (1) to (5) and data are stored. After the 126th sector, the following (6) to (5) The management information of (14) is stored.
(1) Bad flag
This indicates the state of this sector, and if it is unusable, writing is performed here.
(2) Erase flag
This indicates the data state of this sector, and if it becomes invalid due to rewriting or the like, writing is performed here.
(3) Logical address
Indicates the logical address of this sector.
(4) Data
Data written to this sector.
(5) Checksum
Checksum of written data
(6) Bad sector memory
Indicates a bad sector in the rearrangement target block.
(7) Number of erasures of rearranging source
Number of erases of the block to be pruned.
(8) Evacuation block No.
Chip No. that saves data , Block No.
(9) Erase Start
Set when erasing the rearrangement target block is started.
(10) Erase End
Set when finishing erasing the block to be rearranged.
(11) All erase target
Set when it is determined to be erased during All Erase.
(12) Empty block
Indicates whether there is data in the block and is set when there is data.
(13) Block status
Indicates the state of this block and is set when it becomes unavailable.
[0013]
FIGS. 9 to 13 are flowcharts showing processing in the processor 22 at the time of writing data to the flash memories 25-1 to 25-5. The writing operation will be described in detail with reference to FIG.
In step S1 of FIG. 9, the "whether rewriting" (see FIG. 6) indicating whether the data to be written in the SRAM 23 is new is set to 0, and in step S2, whether or not the data is being sorted is determined. Determine. If not, the process proceeds to step S5, where the "number of times of writing" in the SRAM 23 for managing the number of times of body writing at the time of organizing is set to 0, and the process proceeds to step S7.
If the data is being sorted, the process proceeds to step S3, where 1 is added to the "number of times of writing". In step S4, it is determined whether or not the number of times of writing is 6. If the number of times of writing is 6, the procedure goes to step S6, and the number of times of writing is set to 1. If the number of writings is not 6, the procedure goes to step S7.
[0014]
The above-described processing is for avoiding frequent organizing operations by not performing the organizing operation when the number of writings is 2 to 5 and performing the organizing operation only when the number of writings is 1 as described later. By setting the number of times of writing as described above, the organizing operation is performed once every five times.
In step S7, it is determined whether or not the logical address of the data to be written is over, and if it is, error processing is performed.
If the logical address is not over, go to step S8, and determine whether or not there is old data, that is, determine whether or not the data to be written is new data. In S9, the "rewriting presence / absence" of the SRAM 23 is set to 1, and the process goes to step S11. In the case of new data, in step S10, "whether rewriting is performed" in the SRAM 23 is set to 0, and the process proceeds to step S11.
[0015]
Next, in step S11, the data is transferred from the main body to the SRAM, and in step S12, it is determined whether or not there is a transfer error. If there is a transfer error, error processing is performed. If there is no transfer error, the flow proceeds to step S13 in FIG. 10, and it is determined whether or not there is rewriting, that is, whether or not the data is new data. If not, the data is updated. An erase bit is written in a certain sector, and the process goes to step S15.
In step S15, it is determined whether or not the "write count" for managing the number of writes at the time of organizing the SRAM 23 is 1. If the "write count" is 1, the flash memory is organized in step S16 and thereafter. Do. If the "write count" is not 1, the process goes to step S46 in FIG. 13, and after step S46, the data in the SRAM 23 is written to the flash memory.
[0016]
In step S16, the "save counter" for managing the number of sectors in the save operation at the time of sorting on the SRAM 23 is set to 0, and in step S17, the sector address No. currently sorted is set. It is determined whether or not the “arrangement pointer” (sector address) indicating the number is greater than 126 sectors. If the number is not smaller than 126, it is determined that the organization is completed and the process proceeds to step S38 in FIG. If the "arrangement pointer" (sector address) is smaller than 126 sectors, the process proceeds to step S18, where it is determined whether or not the organization pointer is 0. If the arrangement pointer is not 0, the process proceeds to step S22.
If the organizing pointer is 0, in step S19, the number of erasures and the number of erasable sectors of each block are obtained from the table in the SRAM 23, and the organizing target is selected based on the number. Next, in step S20, the save block No. of WORK-BLOCK on the flash memory is read. (See FIG. 8). , Block No. Write.
[0017]
In step S21, it is determined whether or not there is a write error. If there is a write error, error processing is performed. If there is no write error, the flow proceeds to step S22.
In step S22, data to be saved is searched. That is, if the erase flag (see FIG. 7) has been written to the data in the flash memory, the operation proceeds to the next sector. If there is no logical address, an erasure flag is written and the operation goes to the next sector. If the logical address is abnormal, an erasure flag and a failure flag are written and the operation goes to the next sector.
Next, the process proceeds to step S23 in FIG. 11, and it is determined whether or not there is a write error. If there is no write error, in step S24, it is determined whether or not the rearrangement pointer (sector address) points to the 126th sector. Is determined, and if the organizing pointer is 126, it is determined that the organizing has been completed, and the process proceeds to step S38 in FIG.
[0018]
If the rearrangement pointer is not 126, the process proceeds to step S25, and the data to be saved is moved from the flash memory to the SRAM 23. In step S26, the generated checksum matches the checksum on the flash memory (see FIG. 7). It is determined whether or not to perform. If they do not match, in step S27, it is determined whether the checksum is FFh.
If the checksum is not FFh, the process proceeds to step S28, the checksum on the flash memory is set to FFh, the defect flag of the data saving source sector is written, and the process proceeds to step S29. In step S29, it is determined whether or not there is a write error, and the process proceeds to step S30.
If the checksums match in step S26 or if the checksum is FFh in step S27, the process goes to step S30 to search for a writable sector from the sector indicated by the write pointer, and in step S31 there is a writable sector. It is determined whether or not. If there is no writable sector, error processing is performed. If there is a writable sector, the process proceeds to step S32 to move the data on the SRAM 23 to the flash memory.
In step S33, it is determined whether or not there is a write error. If there is a write error, the process returns to step S30. If there is no write error, the process proceeds to step S34 in FIG. 12, and the erasure flag of the data save source sector is written.
[0019]
Then, in step S35, it is determined whether or not there is a write error. If there is no write error, in step S36, the sector map table on the SRAM 23 is rewritten, and 1 is added to the save counter.
Next, in step S38, it is determined whether or not the evacuation operation has been performed a predetermined number of times (in this case, 60 times). If the evacuation operation has been performed 60 times, the flash memory is sorted out for the time being. After finishing, go to step S38. If the evacuation operation has not been performed 60 times, the process returns to step S22 in FIG. 10 to repeat the above processing.
If the save counter is 60 or if it is determined in step S17 of FIG. 10 that the rearrangement pointer is not smaller than 126, the process proceeds to step S38, where it is determined whether the save counter is 0.
If the evacuation counter is 0, that is, if the rearrangement pointer is not smaller than 126 and the evacuation operation is not performed, the process proceeds to step S39, and after step S39, the defect flag is set. Processing such as writing information to the bad sector memory is performed.
[0020]
That is, when the save counter is 0, the processing time is short, so that processing such as writing the information of the bad flag after S39 to the bad sector memory is performed, and when the save counter is not 0, The process proceeds to step S46 in FIG. 13 to perform processing such as moving data on the SRAM 23 to the flash memory.
In step S39, the information of the defective flag of the evacuated block is written to the defective sector memory (see FIG. 8) of the write destination (write destination is WORK-BLOCK), and the number of erasures is set in the rearrangement source erase frequency column (see FIG. ). In step S40, it is determined whether or not there is a write error. If there is no write error, the flow proceeds to step S41, and the arranged blocks are erased. In step S42, it is determined whether or not there is an erasure error. If there is no erasure error, the flow goes to step S43 in FIG. And write the number of erases.
[0021]
Next, in step S44, 1 is added to the number of erasures of the table corresponding to the erased block, and the number of erasable sectors is set to 0. In step S45, the organizing pointer is put into WORK-BLOCK, and the organizing pointer is set to 0.
Next, in step S46, a writable sector is searched from the sector indicated by the write pointer, and in step S47, it is determined whether or not there is a writable sector. If there is a writable sector, the process proceeds to step S48, where the data in the SRAM 23 is moved to the flash memory, and in step S49, it is determined whether or not there is a write error.
If there is a write error, the process returns to step S46. If there is no write error, the process goes to step S50. In step S50, it is determined whether or not the rewrite is 1 or not, that is, whether or not the data to be written is new. If the rewrite is 1 or not, it corresponds to the sector in which the erase flag was written in step S51. One is added to the value of the erasable sector number table (see FIG. 6) to be executed, and the process goes to step S52.
If the presence or absence of rewriting is 0 in step S50, the sector map table (see FIG. 6) is rewritten in step 52, and in step S53, a writable sector is searched from the sector indicated by the write pointer in preparation for the next writing. And exit.
[0022]
B. Write / erase processing.
As described above, the flash memory has a limit on the number of erasures, and it is necessary to average the number of erasures in order to effectively utilize all the memories.
In addition, flash memory cannot be overwritten, and when rewriting data, take measures such as writing data to a new sector and setting an erasable flag on old data, and erasing at appropriate time. It is necessary to erase the sector where the enable flag is set.
Therefore, it is necessary to secure an empty area for writing data by erasing erasable data, and to take a remedy when the empty area becomes unusable due to the occurrence of a bad block or the like. A new free area needs to be created.
[0023]
In the following, averaging of the number of erasures described above (Example 1), creation of a free area for erasing erasable data to secure a free area (Example 2), and creation of a free area when a defective block occurs are described. An example of the present invention regarding area processing such as a rescue procedure (Example 3) will be described.
(1) Example 1 (Average of erase count)
As described above, the flash memory has a limit on the number of erasures, and it is necessary to average the number of erasures in order to effectively utilize all the memories.
This embodiment shows an embodiment capable of suppressing variation in the number of erasures without being aware of the number of erasures of each block. In this embodiment, additional writing is performed in sector units and erasing is performed in block units. In the memory, the blocks are divided into sectors, and as shown below, a block having many digestible sectors and a block having few erasable sectors are mixed and written in a new block, thereby averaging the number of erases. I have.
[0024]
Next, this embodiment will be described.
FIGS. 14 to 18 are diagrams showing the write processing in this embodiment. In this embodiment, an example is shown in which a logical sector from A to O is written in a six-block flash memory having six sectors.
In the following description, when the number of empty sectors in a block becomes N (two in this embodiment), the evacuation operation is performed on M blocks (two in this embodiment). Also, m blocks (one block in this embodiment) from the largest number of erasable sectors and n blocks (one block in this embodiment) from the smaller number of erasable sectors are selected and simultaneously saved.
When the save operation is performed, as described above, the sector in which the erasable flag is not set is read, the sector is moved to the SRAM 23 shown in FIG. 5, and the sector moved to the SRAM 23 is written in a new block.
[0025]
In FIG. 14A, since there is no identical sector, sectors A, B, C, D, E, F, G, H, and I are written in blocks 1 and 2 in order from the first sector.
In (b), sectors C and D are written. In this case, since the same sectors C and D are present, an erasable flag is set for the sector in which C and D are already written, and new sectors C and D are written.
Next, in FIG. 15C, sectors J, K, L, M, N, and O are written. Also in this case, as in the case of (a), there is no identical sector, so that the data is written sequentially after the already written sectors.
In (d), sectors H, I, J, K, M, and N are written. Since the same sector has been written, an erasable flag is set, and new sectors H, I, J, K, M, and N are written.
[0026]
16 (e-1) and (e-2), sectors C and D are written. At this time, since the number of empty blocks is two, a save operation is performed.
That is, in FIG. 15D, the block 3 having the largest number of erasable sectors and the block 4 having the smallest number of erasable sectors are selected, and the sectors of the block 3 and the block 4 are mixed, and each of the save destinations is selected. The data is written into the empty blocks 5 and 6 so that the number of sectors in the block becomes uniform.
As a result, as shown in FIG. 16 (e-1), sectors O, I, K, and M are written in block 5, sectors H, J, L, and N are written in block 6, and blocks 3 and 4 are written. It becomes an empty block.
In this state, an erasable flag is set for the block 2 in which C and D have already been written, and the sectors C and D are written to the block 5 as shown in FIG.
[0027]
In FIG. 17 (f-1), sectors H, I, and J are written. Also in this case, since the same sector already exists, the erasable flag is set in the blocks 5 and 6, and the sectors H and I are written in the block 6, but when the sector J is written, the number of empty blocks becomes two. Therefore, the evacuation operation is performed as described above.
That is, as shown in (f-2), the block 2 having the largest number of erasable sectors and the block 6 having the smallest number of erasable sectors are selected. Are written to empty blocks 3 and 4 so that the number of sectors in each block becomes uniform.
Next, as shown in (f-3), the sector J is written. Also in this case, since there is the same sector, an erasable flag is set in the already written sector of block 4 and sector J is written in block 3.
In FIG. 18G, sectors E, F, and G are written. Also in this case, since the same sector exists, an erasable flag is set for the already written sector of blocks 1 and 3, and sectors E, F and G are written to blocks 3 and 4, respectively.
[0028]
FIG. 19 is a flowchart showing the processing of this embodiment. The processing of this embodiment will be described with reference to FIG.
In step S1, when data is received from the main unit, it is determined in step S2 whether the number of blocks having empty sectors is N or less. If the number of blocks with empty sectors is not less than N, the procedure goes to step S7. If the number of blocks having empty sectors is N or less, m blocks are evacuated from blocks having a large number of erasable sectors in step S3, and n blocks are evacuated from blocks having a small number of erasable sectors in step S4. And
In step S5, data is moved from the block to be saved to an empty block. The writing method at that time changes the write block every time data is moved, and returns to the first written block after writing in M blocks. Next, in step S6, the block to be saved is erased.
If there is the same logical sector in step S7, an erasable flag is set for the physical sector that has already been written, and in step S8, the data received from the main unit is written to the flash memory.
[0029]
By the way, in general, there are sectors storing data that is hardly rewritten, such as system programs, and sectors storing data that is constantly rewritten, and data is normally written / saved. In this case, the number of erasures of a block having many sectors where rewriting is hardly performed is reduced.
Therefore, as described above, a block with many erasable sectors (a block with many sectors that are constantly rewritten) and a block with a few erasable sectors (a block with many sectors that are hardly rewritten) are mixed. By writing to a new block in this way, as a result, a sector with many rewrites and a sector with few rewrites are mixed in each block, and the number of erasures of the block can be averaged.
[0030]
In the present embodiment, since the writing process is performed based on the above-described principle, it is possible to suppress variations in the number of erasures without being aware of the number of erasures of each block, and to reduce the number of erasures as in a flash memory. Can extend the life of a finite memory. In addition, since the variation in the number of times of erasing can be suppressed without counting the number of times of erasing, it is also possible to manage the memory without providing an area for counting the number of times of erasing.
[0031]
(2) Embodiment 2 (creation of free space by erasing erasable data)
As described above, the flash memory cannot be overwritten and can only be written after erasing. For this reason, at the time of writing, if there is the same sector, it is necessary to set an erasable flag and to erase the sector where the erasable flag is set at an appropriate time.
In the present embodiment, as described above, the area processing for eliminating the erasable data with the erase flag set from the storage medium is shown, and the area processing according to the present embodiment is performed in advance during the idle time of the processing. By doing so, a writable area can be secured, and the writing time can be reduced.
[0032]
20 to 23 are diagrams showing the write / erase processing in the present embodiment, and the present embodiment will be described with reference to FIGS. In this embodiment, the following points are assumed.
{Circle around (1)} The number of blocks is six, and there are six sectors per block. Read / write is performed in sector units, and erasure is performed in block units.
{Circle around (2)} The write method is a write-once write method, and when writing a logical sector at the same address, an erasable flag is set for a physical sector stored in the old logical sector.
{Circle around (3)} The write area is assumed to be 5 blocks + an evacuation area 1 block (block 1 to block 6) for additional writing.
{Circle around (4)} When the write area is exhausted, the data of the non-erasable physical sector of the block having the largest number of physical sectors with the erasable flag set is moved to the save area, and the source block is erased. Then, the block is used as a save area, and the save area up to now is set as a write area (this series of operations is called a save operation).
{Circle around (5)} The addresses of the sectors sent from the main unit are A to P.
{Circle around (6)} When there is m or more erasable data in a block, the data is subjected to area processing in the present embodiment (m = 1 in the examples of FIGS. 20 to 23).
The arrows attached to the right of the blocks in FIGS. 20 to 23 indicate the positions of the write pointers indicating the write locations.
[0033]
In FIG. 20A, logical sectors A to G are written. In this case, since there is no logical sector having the same address, writing is performed in order from the position indicated by the write pointer.
In (b), the logical sectors A, D to G are written. In this case, since there is a logical sector (A, D, E, F, G) having the same address, writing is performed in the same manner as (a) after setting the erasable flag.
In (c), the logical sectors H to N are written. In this case, since there is no logical sector having the same address, the data is written as it is.
In FIG. 21D, A, G to L are written. In this case, since there is a logical sector (A, G, H, I, J, K, L) of the same address, writing is performed after setting the erasable flag.
In (e), A, H to J are written. Also in this case, since there is a logical sector (A, H, I, J,) of the same address, writing is performed after setting the erasable flag.
In (f-1), writing of A, I to L is to be performed, but since there is no write area, a save operation is performed. That is, the data of the block (block 3) having the largest number of physical sectors with the erasable flag set is moved to the save area (block 6), and the source block is erased. Then, the block (block 3) is used as a save area, and the save area (block 6) up to now is set as a write area.
As a result, it becomes like (f-1).
[0034]
Next, as shown in FIG. 22 (f-2), A, I to L are written. In this case, since there is a logical sector at the same address, A, I to L are written after setting the erasable flag. At this time, the write pointer is at the head of the save area (block 6).
By writing as described above, the erasable data is increased, and the area processing according to the present embodiment is performed.
That is, when viewed from the save area (block 3), the save operation is performed in blocks 2 and 3 with the block (block 2) in the opposite direction to the writing direction as the processing target. As a result, as shown in FIG. 22 (g-1), the block 2 becomes a save area, and the non-erasable data of the block 2 is moved to the block 3.
[0035]
Next, a retreat operation is performed in blocks 1 and 2 in the same manner as described above. As a result, as shown in (g-2), the block 1 becomes a save area, and the non-erasable data of the block 1 is moved to the block 2.
Next, a retreat operation is performed in blocks 5 and 1 in the same manner as described above. As a result, as shown in FIG. 23 (g-3), the block 5 becomes a save area, and the non-erasable data of the block 5 is moved to the block 1. Since there is no erasable data in the block 6, it is not subjected to the area processing.
Similarly, the retreat operation is performed in blocks 4 and 5. As a result, as shown in (g-4), the block 4 becomes a save area, and the non-erasable data of the block 4 is moved to the block 5. Then, since the position of the save area has reached the position of the save area before performing the processing, the area processing ends.
By performing the above processing, the erasable data disappears from the storage medium.
[0036]
Next, as shown in (h), A, H to J are written. Also in this case, since there is a logical sector at the same address, writing is performed after setting an erasable flag.
FIG. 24 is a flowchart showing the processing of this embodiment, and the processing of this embodiment will be described with reference to FIG.
In step S1, the block No. of the current save area is set. Is stored, and in step S2, the save area is set as a processing target. In step S3, the processing target is advanced by one in the direction opposite to the writing direction.
In step S4, the process target and the storage block No. stored in step S1. Are compared, and if they are the same, the process ends.
Processing target and storage block No. If the number is different, the process goes to step S5, where the number of erasable sectors to be processed is compared with a predetermined value m. If the number of erasable sectors is less than m, the process returns to step S3 and repeats the above processing. If the number of erasable sectors is larger than m, the procedure goes to step S6, where the processing target is set as a save target, and the write pointer is moved to the head of the save area in step S7.
In step S8, data is moved from the block to be saved. In step S9, the block to be saved is erased. In step S10, the block to be saved is set as a save area, and the process returns to step S3 to repeat the above processing.
[0037]
In the present embodiment, since the area processing is performed as described above, erasable data can be eliminated, and by performing the area processing of the present embodiment in advance, the writing time can be reduced. .
Further, since the block to be subjected to the area processing is advanced in the direction opposite to the writing direction, all free areas can be present between the write pointer indicating the writing location and the save area. As a result, no matter what case the processing is interrupted, data can be written from the position indicated by the write pointer, and the number of processes required after the process is interrupted can be reduced. There is no problem even if you do not finish.
[0038]
(3) Third Embodiment (Relief Measures for Creating Free Space)
As described above, the flash memory needs to secure an empty area in the memory for writing data, but in this embodiment, the empty area cannot be used due to the occurrence of a bad block or the like. In this example, a remedy is taken to create a new free space.
FIG. 25 to FIG. 31 are diagrams showing a process of creating a free area according to the present embodiment, and the present embodiment will be described with reference to FIG. In this embodiment, the following points are assumed.
{Circle around (1)} The number of blocks is 7, and there are 6 sectors per block. Read / write is performed in sector units, and erase is performed in block units.
{Circle around (2)} The write method is a write-once write method, and when writing a logical sector at the same address, an erasable flag is set for a physical sector stored in the old logical sector.
{Circle around (3)} One spare area (block 0) is reserved for rescue at the time of failure, and the write area is set to 5 blocks + one save area (block 1 to block 6) for additional recording.
{Circle around (4)} When the write area is exhausted, the data of the non-erasable physical sector of the block having the largest number of physical sectors with the erasable flag set is moved to the save area, and the source block is erased. Then, the block is used as a save area, and the save area up to now is set as a write area (this series of operations is called a save operation). {Circle around (5)} The addresses of the sectors sent from the main unit are A to P.
[0039]
In FIG. 25A, sectors A to G are written. In this case, since there is no same logical sector, the data is written from the block 1 as it is.
In (b), sectors A and D to G are written. In this case, since the same logical sector exists as the sectors A and D to G, an erasable flag is set in the same logical sector before writing.
In (c), sectors H to N are written. In this case, since there is no same logical sector, the data is written as it is.
In FIG. 26D, sectors A and G to L are written. In this case, since there is the same logical sector as the sectors A and G to L, writing is performed after setting an erasable flag in the same logical sector.
In (e), sectors A, H to J are written. In this case, since there is the same logical sector as the sectors A, H to J, writing is performed after setting an erasable flag in the same logical sector.
[0040]
In FIG. 27 (f-1), sectors A and I to L are written. In this case, since there is no write area, write processing is performed after the save operation is performed. That is, the non-erasable data of the block (block 3) having the most data with the erasable flag set is moved to the save area (block 6), and the source block is erased. Then, the block (block 3) is used as a save area, and the save area up to now is set as a write area.
Next, in (f-2), the sectors A and I to L are written into the block 6 which has become the write area.
Next, in (g), A, M, and N are written. However, since there is no write area as in (f) above, first, a save operation is performed. That is, the non-erasable data of the block (block 5) having the most data with the erasable flag set is moved to the save area (block 3), and the source block is erased. Then, the block (block 5) is used as a save area, and the save area up to now is set as a write area.
[0041]
Here, if the block 5 becomes unusable due to erasure failure, there is no save area, so a rescue measure is taken.
Therefore, as shown in FIG. 28H, the evacuation operation is performed using the spare block 0 as a temporary evacuation area. That is, in FIG. 27G, the non-erasable data of the block (block 1) having the most non-erasable data is moved to the temporary save area (block 0), and the source block is erased. Then, the block (block 1) is used as a save area. Next, as shown in (i), the evacuation operation of the spare block (block 0) is performed. That is, the logical sectors B and C of the spare area (block 0) used as the temporary save area are moved to block 3.
As a result, the spare area and the save area are created, and the logical sectors A, M, and N are written in the block 3 in (j).
Next, sectors A, G, H, O, and P are to be written, but since there is no write area, a save operation is performed as shown in FIG. 29 (k-1). That is, the non-erasable data of the block (block 4) having the largest number of erasable data is moved to the save area (block 1), and the source block is erased. Then, the block (block 4) is used as a save area.
[0042]
Next, as shown in (k-2), sectors A, G, H, O, and P are written. However, since sectors A, G, and H have logical sectors having the same address, the block is set after the erase flag is set. 1 and the sectors O and P are written as they are.
Next, in (l), an attempt is made to write sector A, but since there is no write area, a save operation is performed. As a result, block 2 becomes a save area, and the sectors D, E, and F that were in block 2 move to block 4.
Here, if the block 2 becomes unusable due to the failure to be erased, there is no save area, so a rescue measure is taken. That is, the data of the block (block 3) having the largest number of erasable data is moved to the temporary save area (block 0), and the source block is erased. Then, the block (block 3) is used as a save area. As a result, the result is as shown in FIG.
[0043]
In this state, if the processing is temporarily stopped due to power shortage or the like, when the processing is restarted, the apparatus determines that the vacant area is being created because there is no erasable sector in the spare area and there is data. it can.
Subsequently, a rescue procedure for creating an empty area is performed, and sectors I and J of block 6 are moved to the spare area (block 0), and sectors K and L of block 6 are moved to block 3. As a result, the result is as shown in FIG.
Here, since the number of empty sectors excluding the sectors in the save area is equal to or greater than the number of data in the spare area (block 0), a write point is searched from the back of the save area, and a spare area (block Move data from 0).
At this time, as shown in FIG. 31 (o), it is assumed that the main body side has temporarily stopped the processing due to power shortage or the like at the stage when the sectors B, C, M, and N in the spare area (block 0) have been moved. In this case, when the process is restarted, the device side can determine that the data is being moved to the spare area where an empty block is being created because there is an erasable sector in the spare area.
Subsequently, as shown in FIG. 31 (p), the logical sectors I and J in the spare area (block 0) are moved to block 4 and the processing is terminated.
[0044]
FIG. 32 is a flowchart showing the free area creation processing in the present embodiment, and the processing in the present embodiment will be described with reference to FIG.
In step S1, it is determined whether or not there is an erasable sector in the spare area. If there is, the process proceeds to step S11. If not, the process proceeds to step S2, where the write pointer is set to the head of the spare area, and in step S3, it is determined whether or not there is data in the spare area. If there is data in the spare area, the procedure goes to step S10; otherwise, the procedure goes to step S4, and the save area is set as the spare area.
In step S5, if there is no erasable sector in each block of the writing area, the process is abandoned (Abort) because a free area cannot be created. If there is an erasable sector, the process proceeds to step S6, where the block having the largest number of erasable sectors is set as a save target, and in step S7, data is moved from the save target block to the spare area.
In step S8, the block to be saved is erased, and in step S9, the block to be saved is set as a save area.
In step S10, it is determined whether (1) the number of data in the spare area is larger than (2) the number of empty sectors other than the save area, and if (1)> (2), the process returns to step S5 to execute the above processing. repeat. If (1) ≦ (2), the process proceeds to step S11, where a write pointer is searched from the next save area in the write direction, and in step S12, data is moved from the spare area to a free sector. In step S13, the spare area is erased and the process ends.
[0045]
In the present embodiment, since the free space is created as described above, even if an unusable block occurs in the storage medium, the free space can be created by the rescue procedure, and the storage device can be used. You can avoid becoming impossible.
Further, even if the processing is interrupted due to a power shortage on the main unit side during the processing, it is possible to easily determine at which stage the processing was interrupted, and to simplify the determination of the processing stage in the interrupted processing. It becomes possible.
[0046]
C. Efficient erasing process
Next, embodiments of the first and second aspects of the present invention will be described.
As described above, the flash memory cannot be overwritten, and can only be written after erasing. In the present embodiment, in the flash memory as described above, by providing a flag indicating the presence or absence of writing and an in-execution flag indicating that the entire space erasing process is being executed, the erasing when erasing the entire storage space is performed. The processing is performed efficiently, and even if the processing is interrupted for some reason during the erasing, the processing can be restarted.
Next, the processing of this embodiment will be described with reference to FIGS. In this embodiment, the number of blocks is six, an area for writing a write flag is provided in each block, and an area for writing an in-execution flag indicating that the entire space erasing process is being executed is provided in block 6. I have.
[0047]
In FIG. 33 (a), before writing in blocks 1, 2, and 4, a writing presence / absence flag is written in blocks 1, 2, and 4.
Next, in the initialization processing for clearing the entire space, the execution flag is written in the block 6 as shown in (b-1).
In (b-2), the block 1 in which the writing presence / absence flag has been written is erased, and the writing presence / absence flag is erased.
In FIG. 33 (b-3), the block 2 to which the write presence / absence flag has been written is erased, and the write presence / absence flag is erased.
Here, after the block 2 is erased, the stop sequence is started for some reason, and even if the block 2 starts up, since the execution flag is written in the block 6, it is immediately determined that the initialization operation is being performed. You can move on to
In (b-4), since the blocks 1 to 3 have not been written with the write presence flag, the block 4 is erased and the write presence flag is erased.
In (b-5), since the writing presence / absence flag is not written in the blocks 1 to 5, the block 6 is erased and the execution flag is erased.
[0048]
FIG. 35 is a flowchart showing the processing of the present embodiment. The present embodiment will be described with reference to FIG.
In step S1, it is determined whether or not the execution flag is written. If there is, the process proceeds to step S3. If not, the execution flag is written in the last processing block in step S2.
In step S3, the processing target is cleared, and in step S4, it is determined whether or not the processing target has a writing presence / absence flag. If there is no writing presence / absence flag, the process goes to step S6. If there is, the process target is deleted in step S5, and the process target is advanced to the next in step S6.
In step S7, it is determined whether or not the execution flag has been written. If so, the process returns to step S4 to repeat the above processing. If there is no running flag, the process ends.
In this embodiment, since the writing presence / absence flag is provided as described above, unnecessary erasing can be avoided, the erasing time can be shortened, and the life of the medium can be extended.
Further, since an in-execution flag indicating that initialization is being executed is provided, it is possible to cope with an unexpected interruption.
[0049]
D. Improve writing speed and allocate spare area when bad sector occurs
As described above, the flash memory cannot be overwritten, and the sector cannot be written without erasing. For this reason, as described above, it is necessary to set an erasable flag when there is the same sector at the time of writing, and to erase the sector where the erasable flag is set at an appropriate time, which takes a long time for writing.
Further, as described above, the flash memory has a limit on the number of erasures, and if the erasure is performed more than a predetermined number of times, the erasure cannot be performed. Therefore, when a bad sector occurs, it is necessary to allocate a spare area and take a remedy,
The following embodiment is an embodiment in which in a memory which cannot be overwritten and which can be erased in sector units, the above-described time lag at the time of writing is eliminated, the writing speed is improved, and a spare area is allocated when a defective sector occurs. Is shown.
[0050]
FIG. 36 is a diagram showing a system configuration of the present embodiment. An EEPROM 26 is added to the system shown in FIG. 5, and the other configuration is the same as that shown in FIG. A decode table for performing address conversion is stored in the EEPROM 26, and the address is decoded by the EEPROM 26. When a part of the flash memory becomes defective, the EEPROM 26 is rewritten to perform a remedy. Although the EEPROM 26 is illustrated in FIG. 36, the storage medium storing the decode table may be any rewritable storage medium, and a flash memory or the like may be used.
[0051]
(1) Example 1
FIGS. 37 and 38 are diagrams showing the configuration of the present embodiment. In FIG. 37, reference numeral 261 denotes a sector converter composed of an EEPROM 26 (or a rewritable ROM such as a flash memory). Reference numeral 25 denotes a flash memory. The flash memory is provided with a first area A, a second area B, and a spare area C. The first area A and the second area B respectively have 1 to 4 sectors are provided.
In FIG. 37, when writing data to the sector 1, the first area A and the second area B are viewed, and when data already exists in the first area A, the data is written to the second area B. Write. While writing the data, the sector 1-A in the first area A is erased.
At this time, if a write error occurs, the spare area C is assigned as a substitute sector.
That is, when a write error occurs in the sector 1-A of the first area A, the ROM of the sector conversion unit 261 is rewritten to substitute the spare area C for the sector 1-A, as shown in FIG. , A spare area C is allocated as sector 1-A.
As described above, when a write error occurs, a sector in a spare area is allocated as long as there is a spare, and when there is no spare, all data is evacuated to an external area such as the SRAM 23 shown in FIG. The ROM of the conversion unit 261 is reorganized and divided into a data space and a spare space. At this time, sectors are allocated in ascending order or descending order according to the system configuration in the same manner as in the initial state, but bad sectors are excluded.
[0052]
In this embodiment, as described above, erasing is performed simultaneously with writing, so that a time lag at the time of writing can be eliminated, and the writing speed can be improved. Further, a spare area is provided, and when a defective sector occurs, the spare area is replaced with the spare area, so that it is possible to perform relief when a defective sector occurs.
[0053]
(2) Example 2
39 and 40 are diagrams showing the configuration of the present embodiment. In FIG. 39, reference numeral 261 denotes a sector conversion unit composed of an EEPROM or a rewritable ROM such as a flash memory, and 25 denotes a flash memory. The flash memory has a first area A and a spare area C. The first area A has four sectors 1-4. Reference numeral 231 denotes a primary storage medium for data such as the SRAM 23 shown in FIG.
In FIG. 39, at the time of data writing, while data is being transferred to the primary medium 231, the sector to be written is checked, and if there is data in the sector to be written, the sector is erased. If the transfer is completed early, the data is written until the end of the erasure. If the transfer is slow, the data is written after the transfer is completed.
When a write error occurs, the ROM of the sector conversion unit 261 is rewritten, and the spare area C is stored in the spare area C as shown in FIG. Write to the sector 1-A. Note that writing to the spare area C is not performed unless an error occurs in a normal sector.
[0054]
In this embodiment, as described above, if data is present in the sector to be written while data is being transferred to the primary storage medium 231, erasing is performed. The time lag at the time of writing can be eliminated, and the writing speed can be improved. Further, a spare area is provided, and when a defective sector occurs, the spare area is replaced with the spare area, so that it is possible to perform relief when a defective sector occurs.
[0055]
(3) Example 3
41 and 42 are diagrams showing the configuration of the present embodiment. In FIG. 41, reference numeral 261 denotes a sector conversion unit constituted by an EEPROM or a rewritable ROM such as a flash memory, and 25 denotes a flash memory. The flash memory is provided with a block 1, a block 2, a spare block 1, and a spare block 2. In each block, the block 1 and the block 2 have sectors 1 to 3A, 1 to 3B,. , 4 to 6A, 4 to 6B,..., 4 to 6D.
Each of the sectors 1 to 3A, 1 to 3B,..., 1 to 3D is one sector as a physical address, and data of the logical address 1, 2, or 3 can be written therein. That is, areas for writing data of logical addresses 1, 2, or 3 are provided for four sectors A to D, and when writing data, writing is performed in an empty area among A to D.
Similarly, sectors 4 to 6A, 4 to 6B,..., 4 to 6D are the same as above, and when data of logical addresses 4, 5, or 6 is to be written, an empty area among A to D is written. Write.
As described above, in the present embodiment, blocks are formed in units of n + 1 (in this embodiment, n = 3) sectors, and a space of one sector is provided for a logical address to be written.
[0056]
In FIG. 41, when writing data to sector 1, sectors 1 to 3A, 1 to 3B,..., 1 to 3D are looked at, and if sector 1 already exists in these sectors, the sector is erased. Since there is always a vacant sector in the sector, writing is performed on the vacant sector at the same time as the above-described erasure.
At the time of writing, if a write error occurs, a spare block is assigned as a substitute block. For example, when the sectors 1 to 3A are defective, the spare block 1 is assigned as a substitute block as shown in FIG. Then, the ROM of the sector conversion unit 261 is rewritten, and an alternative process of allocating the block 1 having an error to the spare block 1 is performed. As a result, the spare block 1 becomes the block 1.
The above processing is performed as long as there is a spare, and when there is no spare, all the data is saved to an external area such as the SRAM 23 shown in FIG. 36, the ROM of the sector conversion unit 261 is reorganized, and And a spare space. At this time, sectors are allocated in ascending order or descending order according to the system configuration in the same manner as in the initial state, but bad sectors are excluded.
When converting a logical sector to a physical sector, the sector conversion unit 261 blocks the data in units of n + 1 sectors as described above, and configures the sector 1 to be decoded so that there are n + 1 writable sectors.
Then, when some of the sectors become defective, the write block is moved by rewriting the table of the sector conversion unit 261 to always create a block of (n + 1) sectors.
[0057]
In the present embodiment, as described above, blocks are formed in units of n + 1 sectors, one sector is left, and erasing is performed at the same time as writing, so that the time lag at the time of writing is eliminated as in the first and second embodiments. And the writing speed can be improved. Further, a spare area is provided, and when a defective sector occurs, the spare area is replaced with the spare area, so that it is possible to perform relief when a defective sector occurs.
[0058]
(4) Example 4
FIGS. 43 and 44 show the configuration of this embodiment. In FIG. 43, reference numeral 261 denotes a sector conversion unit constituted by an EEPROM or a rewritable ROM such as a flash memory, and 25 denotes a flash memory. The flash memory is provided with a block 1, a block 2, and spares 1A to 1D. In the blocks 1 and 2, sectors 1 to 3A, 1 to 3B,..., 1 to 3D, 4 to 6A, 4 .., 4 to 6D.
In the present embodiment, as in the third embodiment, blocks are formed in units of n + 1 (n = 3 in this embodiment) sectors, and one sector is left.
[0059]
In FIG. 43, when writing data to sector 1, sectors 1 to 3A, 1 to 3B,..., 1 to 3D are looked at, and if sector 1 already exists in these sectors, the sector is erased. Since there is always a vacant sector in the sector, writing is performed on the vacant sector at the same time as the above-described erasure.
At the time of writing, if a write error occurs, spares 1A to 1D are assigned as substitute sectors. For example, when the sectors 1 to 3A are defective, as shown in FIG. 44, the spares 1A to 1D become the block 1, the spare 1A is allocated to the sectors 1 to 3A, and the ROM of the sector conversion unit 261 is stored. Rewrite and perform alternative processing. As a result, the spare sector 1A becomes the sectors 1 to 3A, and the spares 1B to 1D become spares for the block 1.
The above processing is performed as long as there is a spare, and when there is no spare, all the data is saved to an external area such as the SRAM 23 shown in FIG. 36, the ROM of the sector conversion unit 261 is reorganized, and And a spare space. At this time, sectors are allocated in ascending order or descending order according to the system configuration in the same manner as in the initial state, but bad sectors are excluded.
As described above, the sector conversion unit 261 divides a logical sector into a physical sector into blocks in units of n + 1 sectors. The configuration is such that there are n + 1 sectors. When some sectors become defective, the table of the sector conversion unit 261 is rewritten to always create a block of (n + 1) sectors.
[0060]
In the present embodiment, as described above, blocks are formed in units of (n + 1) sectors, one sector is left, and erasing is performed at the same time as writing. The writing speed can be improved. Further, a spare area is provided, and when a defective sector occurs, the spare area is replaced with the spare area, so that it is possible to perform relief when a defective sector occurs.
[0061]
(5) Example 5
FIGS. 45 and 46 show the structure of this embodiment. In FIGS. 45 and 46, the same components as those shown in FIGS. 37 and 38 are denoted by the same reference numerals. A sector conversion unit composed of an EEPROM or a rewritable ROM such as a flash memory, 25 is a flash memory, and the flash memory is provided with block 1, block 2, spare block 1, and spare block 2. , 1 to 3D, 4 to 6A, 4 to 6B,..., 4 to 6D are provided.
In the present embodiment, as in the third embodiment, blocks are formed in units of n + 1 (n = 3 in this embodiment) sectors, and one sector is left.
[0062]
In FIG. 45, when writing data to sector 1, sectors 1 to 3A, 1 to 3B,..., 1 to 3D are looked at, and if sector 1 already exists in these sectors, the sector is erased. In addition, since there is always a vacant sector, writing is performed in the vacant sector at the same time as the above-described erasure.
At the time of writing, if a write error occurs, a spare sector is assigned as a substitute sector. For example, when the sectors 1 to 3A become defective, the spare block 1 is allocated, the ROM of the sector conversion unit 261 is rewritten, and the substitution process is performed. As a result, as shown in FIG. 46, the sectors 1, n, and mA of the spare block are replaced with the sector 1, the sector 1 is present in the spare block, and the sectors 2, 3 remain in the original block.
That is, in this embodiment, the block configuration does not need to be a continuous sector, and the number of original block configurations is changed.
The above processing is performed as long as there is a spare, and when there is no spare, all data is saved to an external area such as the SRAM 23 shown in FIG. 36, and the ROM of the sector converter 11 is reorganized. Divide into data space and spare space. At this time, sectors are allocated in ascending order or descending order according to the system configuration in the same manner as in the initial state, but bad sectors are excluded.
[0063]
In this embodiment, as described above, the block is divided into n + 1 sectors, and one sector is left, and erasing is performed at the same time as writing. The time lag can be eliminated, and the writing speed can be improved. Further, a spare area is provided, and when a defective sector occurs, the spare area is replaced with the spare area, so that it is possible to perform relief when a defective sector occurs.
[0064]
FIGS. 47 to 49 are flowcharts showing the processing in the above embodiment, and the processing of this embodiment in the system shown in FIG. 36 will be described.
In step S1, when there is a sector data write request from the main unit, the CPU 22 recognizes in step S2 that there is a data write request from a notification from the controller LSI. Note that the controller LSI 21 may interrupt the CPU 22 to notify a data write request.
In step S3, the CPU 22 reads the data in the EEPROM 26, recognizes the write location, accesses the flash memories 25-1,..., 25-5 to check whether or not sector data has been written. Reference is made to data or management information stored in the flash memory. Then, in step S5, it is determined whether or not data has been written in the flash memory. If no data has been written, the flow proceeds to step S8 in FIG. If data has been written, in step S6, the CPU 22 accesses the EEPROM 26 to obtain data in order to read information for writing data in the second sector. Next, in step S7, the data in the flash memory is erased (error checking is performed later to improve efficiency), and the process proceeds to step S8 in FIG.
[0065]
In step S8, the data is transferred from the main body to the SRAM 23, and the process is waited for completion. In step S9, to write data to the flash memory, the CPU 22 notifies the controller LSI 21 of the data writing, and the controller LSI 21 writes the data from the SRAM 23 to the flash memory. Next, in step S10, the CPU 22 receives a data write completion notification from the controller LSI 21, and determines in step S11 whether a data write error has occurred.
If there is no data write error, the process ends. If there is a write error, it is determined in step S12 whether or not there is a replacement sector. If there is a replacement sector, the process proceeds to step S13. Then, in order to change the sector address, the EEPROM 26 is accessed to change the data, and the process returns to step S9.
If there is no replacement sector, the flow goes to step S14 in FIG. 49 to determine whether there is a flash memory being erased. If there is a flash memory being erased, go to step S15. After waiting for the end of the erasure, the data is written into the erased sector, and the operation ends.
If it is determined in step S14 that there is no flash memory being erased, an error is notified to the main body in step S16.
[0066]
In step S17, the main body sends a command to download the data and reorganize the EEPROM 26. On the storage device side, the EEPROM 26 is reorganized in response to a command from the main unit so that two or more sectors can be selected for one logical sector sent from the main unit. As a result, the storage capacity can be slightly reduced, but the storage device can be used.
In the above-described processing, the case where the data is transferred to the SRAM 23 and the data is written to the flash memory has been described. However, the data may be directly written to the flash memory without providing the SRAM 23 (in this case, Steps S8 and S9 of the flowchart are one process).
[0067]
E. FIG. Improved reliability of the address translation decoder
A ROM may be used as a conversion table for converting a logical address into a physical address. Also, a flash EEPROM, an EEPROM, or the like can be used instead of the ROM. However, since the decoding unit does not normally need to be variable, it is rarely used.
On the other hand, in the flash memory, the number of erasures is limited due to the nature of the medium. Therefore, the above-mentioned D.I. As shown in the embodiments (1) to (5), when a rewritable decoding unit such as a flash EEPROM or an EEPROM is used as a conversion table for converting a logical address to a physical address, In this case, a method is used in which the decoding unit is rewritten so that there is no defective address.
However, when a flash EEPROM, an EEPROM, or the like is used as the conversion table, these flash EEPROMs, EEPROMs, and the like are also limited in the number of erasures.
In the present embodiment, as described above, when a rewritable storage medium such as a flash EEPROM or an EEPROM is used as the decoding unit, the decoding unit is divided into two stages as shown in FIG. An embodiment is shown in which the life of the decoding unit is extended and the reliability of the address conversion decoding unit is improved.
[0068]
50A and 50B are diagrams showing the configuration of the decoding unit of this embodiment. FIG. 50A shows a normal case, FIG. 50B shows a case where a sector becomes defective, and FIG. 50C shows a case where the decoding unit becomes defective. In this case, reference numeral 301 denotes a primary decoding unit, 302 denotes a secondary decoding unit, and 303 denotes a sector of the flash memory.
In the figure, when the sector of the flash memory is normal, the primary decoding unit 301 outputs the address "0000h" as the decoded value of the address of the sector 0, as shown in FIG. Reference numeral 302 outputs the physical address “5555h” as the decoded value of “0000h”, and designates the physical address of sector 0 of the flash memory.
Here, when the number of erasures of the flash memory exceeds the limit value and the sector becomes defective and the physical address of sector 0 is switched to the spare sector at address 8888h, as shown in FIG. The decoding unit 302 is rewritten to switch the decoded value of “0000h” from “5555h” to “8888h”. As a result, the physical address “8888h” is assigned as the sector 0.
[0069]
As described above, when the secondary decoding unit (or the primary decoding unit) is rewritten several times, the rewriting limit value is exceeded and the secondary decoding unit becomes defective, as shown in FIG. The primary decoding unit 301 is rewritten to shift the decoding value, and the secondary decoding unit 302 is rewritten so that “2222h” that outputs “8888h” as the decoding value is output as the decoding value. Thereby, even if the secondary decoding unit 302 becomes defective, the physical address “8888h” can be output as a decoded value.
As described above, the decoding section is divided into two stages, and when one of the decoding sections becomes defective, the other decoding section is rewritten, whereby the life of the decoding section can be squared.
For example, the number of times until the sector becomes defective is L (rewrite limit value), the number of times until the secondary decoding unit becomes defective is M (rewrite limit value), and the number of times until the primary decode unit becomes defective. Is N times (rewrite limit value), the number of times until an address becomes an error is N × M × L times.
Basically, the rewrite limit is said to be 100,000 to 1,000,000 times for a flash EEPROM and about 10,000 times for an EEPROM. Therefore, it is practically sufficient to secure sufficient reliability only by using two decoding units. it can.
[0070]
F. Write time estimation process
In a flash memory, it is necessary to perform a save process or the like when writing data, and it takes longer to write data than in a normal semiconductor memory.
This embodiment shows an embodiment in which the writing time to the flash memory is estimated, the power consumption is estimated, the abnormality is detected, and the like.
FIG. 51 shows a schematic configuration of the entire system of this embodiment. 1 is a storage device, 1a cannot be overwritten, and data can be erased only in a predetermined unit such as a sector or a block. For example, a storage area composed of a flash memory or the like, 1b is a controller, Reference numeral 2 denotes a main body processing device.
[0071]
Next, this embodiment will be described. Now, consider a case where data of three sectors is written when the storage device is in a state as shown in FIG.
First, the number of sectors to be written is sent from the main unit of FIG. When the number of sectors to be written is sent to the processor 22, the processor determines the writing time from the number of sectors to be written. Here, when there is no block to be written as shown in FIG. 52, the save operation is performed, and thus the write time t is obtained as follows.
t = [time required to write one sector] × 3 + [data saving time] (sec)
The processor 22 calculates the write time as described above and returns it to the main unit. The main body obtains the power consumption W1 at the time of the write operation by the following equation based on the write time.
W1 = t ÷ 3600 × [power consumption of write operation] (W)
The main body reads the remaining power W2 from the power supply unit, compares the remaining power W2 with the obtained writing power, and writes data if W2> W1.
On the other hand, the main body compares the writing time t obtained as described above with the actual writing time. If the writing is not completed even if the writing time t is exceeded, it is determined that the storage device is abnormal, and And take measures such as stopping the writing process.
[0072]
FIG. 53 is a flowchart showing processing of the main body in the present embodiment, and the present embodiment will be described with reference to FIG.
In step S1, the size of data to be written is sent to the storage device, and the time required for writing is obtained.
In step S2, the power required for writing is obtained by multiplying the time required for writing and the power consumption per time. In step S3, the remaining power is compared with the power used for writing, and if the remaining power is smaller, an abnormal process is performed. If the remaining power is larger, the process goes to step S4 to write the data. In step S5, it is determined whether or not the actual writing time is longer than the predicted time. If the writing time is within the expected time, the process proceeds to step S6, where it is determined whether or not the writing is completed. If the writing is not completed, the process returns to step S5, and if the writing is completed, the process ends.
[0073]
As described above, in the present embodiment, since the power required for writing is estimated by obtaining the writing time, it is possible to determine whether or not the writing can be performed with the remaining power. For this reason, in a battery-driven system or the like, it is possible to prevent power from being lost during writing and to avoid interruption of writing, thereby improving the reliability of the system.
Further, by comparing the actual writing time with the estimated writing time, an abnormality in the storage device can be detected. In addition, by notifying the user by displaying the writing time or the like, the user can detect the abnormality in the storage device. Can be determined.
[0074]
G. FIG. Improvement of reliability in flag judgment processing
In most cases, the flag is determined by allocating one bit to one function. However, the flash memory structurally has a fatal cause of failure, that is, erasure cannot be performed due to over-erasure, and the cell in which this has occurred remains at a high level and does not return to a low level.
For this reason, when the flag on the flash memory is made to correspond to one bit and one function, when the bit becomes defective, the validity of the flag is lost.
This embodiment addresses the above-mentioned structural disadvantage of the flash memory by preparing a plurality of flags for the erase flag, the defective flag, the parity, etc. on the flash memory, and as shown in FIG. FIG. 11 shows an embodiment in which the reliability of the flag determination is improved by performing the flag determination based on the logical product.
[0075]
(1) Example 1
FIGS. 54A and 54B show the first embodiment. FIG. 54A shows a flag register, FIG. 54B shows an AND circuit for determination, and FIG. 54C shows a truth table.
In this embodiment, flags b0 and b4 are prepared for one function and stored in a flag register as shown in FIG. When the flag is determined, a final determination result is obtained by calculating the logical product of these flags as shown in FIG.
Since the determination is made as described above, even if the bit b0 is fixed at a high level as in the row number 2 in FIG. 3C, a correct result can be obtained as the logical product result. Similarly, even when the bit b4 is fixed at the high level as in the row number 3, a correct result can be obtained as the logical product result.
[0076]
(2) Example 2
FIGS. 55A and 55B show the second embodiment. FIG. 55A shows a first flag register, FIG. 55B shows a second flag register, and FIG. 55C shows an AND circuit for performing flag determination.
In this embodiment, flags for the same function are stored in separate flag registers. The flag is stored in bit b0 of the first flag register shown in FIG. Flags corresponding to the same functions as the flags stored in the first flag register are stored in bits b0 and b2 of the second flag register shown.
When the flag is determined, the logical product of the flags is obtained by the logical product circuit shown in FIG.
Also in this embodiment, as in the first embodiment, a correct determination result can be obtained even if a part of the flag is fixed at a high level.
As described above, in the present embodiment, the determination of the flag is performed with a plurality of bits, so that a correct determination value can always be output as long as all the bits do not become defective, and the reliability of the flag determination is improved. Can be improved.
[0077]
H. Management table savings
In the present embodiment, in a flash memory system in which a storage device is composed of a plurality of chips and a plurality of blocks are provided in each chip, a management table can be simplified and each block can be used on average. An example is shown.
In the embodiment described above, there is no restriction on the chip or block into which data is written, and data can be written in the sectors of all blocks. Therefore, it is necessary to provide a table for managing all areas. Simplifies flash memory management by fixing the data to be written in each chip, moving blocks to be written in the chip, and writing data without having to manage the entire area. In addition, the use of each block is averaged.
In this embodiment, the data written in the chip is reduced by a certain amount from the total capacity of the chip, and this fixed amount of blocks is used as a work block and a rescue block when a defective block occurs. Then, the arrangement of the data in the block is fixed, and when rewriting the data, when valid data already exists in the old block, the data is evacuated to the SRAM 23 shown in FIG. Together, the data is written in an empty area, and when the writing is successful, the old data block is erased.
[0078]
Next, this embodiment will be described.
FIG. 56 is a diagram showing a configuration in a chip, a block, and a sector in the present embodiment. As shown in FIG. 56, the chip is 2 Mbytes, and the chip has a No. of 4 Kbytes per block. 000-No. 511 bytes are divided into 512 blocks. 00-No. 07 eight sectors are provided. The block No. in FIG. And sector No. Indicates a physical address.
Further, in the sector, a real data area of 256 bytes, an ECC area for a long instruction, a bad data flag, a bad block flag, a block address, and a real data area of 256 bytes ECC area are provided as shown in FIG. I have.
The block address indicates the address value of the block pointer stored in the SRAM 23, and the sector determined to have no actual data is also written in the block address. In this way, when hot-plugging or unplugging, a data having a large number of sector addresses can be determined as normal data. If the number of sector addresses is the same, the determination is made based on whether the ECC and the checksum are correct.
[0079]
The bad block flag indicates the condition of the block. FFh indicates a normal block and $ FFh indicates a bad block.
The bad data flag indicates the condition of the data. Normal data is indicated by FFh, and defective data is indicated by $ FFh.
The maximum length of the ECC area for the Long instruction is 4 bytes.
The ECC area indicates the condition of actual data, and data correction and error detection are performed based on the value of this area.
[0080]
FIGS. 57 to 61 are diagrams showing the write processing in the present embodiment, and the present embodiment will be described with reference to FIGS. In the present embodiment, the chip is No. 00-No. 04 shows the writing and management method when four work blocks are provided in each chip.
FIG. 57 shows a state in which all blocks have been erased. As shown in FIG. 57, each chip is provided with four work blocks of work01 to work04, and data is written to the work blocks work01 to work04. . Writing can be performed in sector units, but writing to the lower sector cannot be performed after writing to the upper sector, such as writing to sector 004 after writing to sector 005.
In addition, data does not move beyond the chip, and the order of the sectors in the block does not change. Further, when the write data does not satisfy all eight sectors, for example, when only the sectors 000 to 005 are written at the logical block address 00, the data of the sectors 000 to 005 are written, and then the blocks 006 to 007 are written. Write only the address.
In this case, since one block has eight sectors and five chips, the data of the logical address n is obtained by further dividing the quotient of (logical address n) 8) by 5. It is written to the surplus chip. For example, when n = 121, 121 ÷ 8 is 15 and the remainder is 1, and 15 ÷ 5 is 5 and the remainder is 0. 00 is written to the chip.
[0081]
The data write processing in this embodiment is performed as follows. First, from the state where all the blocks shown in FIG. When 40 sectors of 000 to 039 (logical addresses) are continuously written, data is written to work01 of each chip as shown in FIG.
That is, the sector No. to be written first. 000 to 007 have a logical block address of 00, and therefore the sector number is stored in the SRAM 23 from the main unit. 000 to 007, and the data of the chip No. Data is written from work01 pointed to by the write pointer 00. The logical block address is managed on a chip-by-chip basis.
In this case, since the logical block address 00 does not exist in the past, the chip No. Work01 of 00 moves to the next free area of work04.
When writing for eight sectors is completed, the write pointer is set to the chip No. 01, and moves to sector 01 in the same manner as described above. Write data 008 to 015 to work01.
[0082]
As described above, writing is performed for the chip No. 04, the write pointer is set to the chip No. It moves to work02 of 00.
Next, from the state of FIG. 58, as shown in FIG. Continuous writing of 72 sectors of 120 to 191 (logical address) is performed.
In the same manner as described above, the sector number is stored in the SRAM 23 from the main unit. The data of the sector No. 120 to 127 is transferred. Since the logical block addresses of 03 to 120 to 127 are 03, the chip Nos. Data is written from work02 pointed to by the write pointer 00. Then, as described above, the chip No. Work02 and work03 of 00 move to the next free area of work01.
Similarly, the sector No. The data of 128 to 191 is stored in the chip No. 00-No. Write to 04.
[0083]
Here, from the state of FIG. When two sectors 002 to 003 are continuously written, the result is as shown in FIG.
First, the sector number is stored in the SRAM 23. 002 and 003 are transferred. In this case, the write data is the sector No. Since it is 002 to 003, the logical block address 00 is designated, and since it exists in the past, it is determined that the old data needs to be saved. If the write data is a sector No. In 002-003, since the data is not written from the beginning of the logical block address 00, the data of the old logical block address 00 is saved in the SRAM 23.
When the write data is two sectors from the beginning of the logical block address, the write data is processed first, and then the data of the old logical block address is saved.
[0084]
Next, the old data 000, 001, 004, 005, 006, 007 and the new data 002, 003 saved in the SRAM 23 are stored in the chip No. indicated by the write pointer. Write to work04 of 00. At this time, writing is performed in the order of 000,001,002,003,004,005,006,007.
Next, since the logical block address 00 already exists, the old logical block address is erased. Also, work04 is moved to the old logical block address 00.
After the two-sector continuous writing is performed as described above, the power is turned off and then turned on again, and as shown in FIG. 61, the work block is designated next to the used block. When the work blocks are designated as described above and all the work blocks cannot be designated even when the search is performed to the end of the chip, the process returns to the beginning of the chip and the work block is designated.
[0085]
In the above processing, when a block erase error has occurred, 00h is set in the failure flag, and the block cannot be written or read. In other words, a measure is taken by crushing one work block, and when there is no more work block, the system is disabled from writing.
If an error occurs during data saving, data is written after setting a bad data flag. In the reading operation, even if an error is detected in the block, the block is not treated as a bad block.
If a data write error occurs, the block is determined to be a bad block. The method of setting the bad flag is to save the data once written, set only the bad block flag, and write again. The bad block flag is set for all the sectors of the block in the same manner as in the normal writing.
If an error is detected during data erasure, the block is determined to be a bad block. The method of setting the bad block flag is not to set only the bad block flag, but to write ALL [00] including the actual data. The defect processing is performed on all sectors of the block.
[0086]
As described above, in this embodiment, the data to be written in each chip is fixed, and the block to be written is moved and written in the chip, so that it is not necessary to manage the entire area. Therefore, it is only necessary to manage data only in each chip, so that the management table can be saved and the speed of the write operation can be increased.
Further, since data is written in the work blocks and the work blocks are moved in the chip, each block can be used on average.
[0087]
【The invention's effect】
As described above, according to the present invention, in a storage device in which a storage area is composed of a plurality of blocks and sectors that divide the blocks, and in which the written data is erased in units of blocks, the presence or absence of writing for each block is determined. A flag indicating whether or not writing has been performed is provided with reference to a flag indicating whether or not writing has been performed. Thus, unnecessary erasing can be avoided, and erasing time can be reduced. The life of the medium can be extended.
[Brief description of the drawings]
FIG. 1 is a principle diagram showing a general schematic configuration of the present invention.
FIG. 2 is a principle diagram (1) showing the principle of the present invention.
FIG. 3 is a principle diagram (2) showing the principle of the present invention.
FIG. 4 is a principle diagram (3) showing the principle of the present invention.
FIG. 5 is a block diagram showing a configuration of a storage device as a premise of the present invention.
FIG. 6 is a diagram showing the contents of an SRAM in the storage device.
FIG. 7 is a diagram showing the contents of a flash memory in a storage device.
FIG. 8 is a diagram (continued) showing the contents of the flash memory in the storage device.
FIG. 9 is a flowchart illustrating a writing process in the storage device.
FIG. 10 is a flowchart (continued) showing a write process in the storage device.
FIG. 11 is a flowchart (continued) showing processing at the time of writing in the storage device.
FIG. 12 is a flowchart (continued) showing processing at the time of writing in the storage device.
FIG. 13 is a flowchart (continued) showing a write process in the storage device.
FIG. 14 is a diagram showing an embodiment in which variations in the number of times of erasing are suppressed.
FIG. 15 is a diagram (continued) showing an embodiment for suppressing variation in the number of erasures.
FIG. 16 is a diagram (continued) showing an embodiment for suppressing variation in the number of erasures.
FIG. 17 is a diagram (continued) showing an embodiment for suppressing variation in the number of erasures.
FIG. 18 is a diagram (continued) showing an embodiment for suppressing variation in the number of times of erasing;
FIG. 19 is a flowchart illustrating a process according to an embodiment that suppresses variations in the number of erasures.
FIG. 20 is a diagram showing an embodiment of processing for eliminating erasable data.
FIG. 21 is a diagram (continued) showing an embodiment of a process for eliminating erasable data.
FIG. 22 is a diagram (continued) showing an embodiment of a process for eliminating erasable data.
FIG. 23 is a diagram (continued) showing an embodiment of a process for eliminating erasable data.
FIG. 24 is a flowchart showing an embodiment of a process for eliminating erasable data.
FIG. 25 is a diagram showing an embodiment of a process of creating a free area.
FIG. 26 is a diagram (continued) illustrating an embodiment of a process of creating a free area;
FIG. 27 is a diagram (continued) illustrating an embodiment of a process of creating a free area;
FIG. 28 is a diagram (continued) illustrating an embodiment of a process of creating a free area;
FIG. 29 is a diagram (continued) illustrating an embodiment of a process of creating a free area;
FIG. 30 is a diagram (continued) illustrating an embodiment of a process of creating a free area;
FIG. 31 is a diagram (continued) illustrating an embodiment of a process of creating a free area;
FIG. 32 is a flowchart of an embodiment of a process of creating a free area.
FIG. 33 is a diagram illustrating an example of an erasing process.
FIG. 34 is a diagram (continued) illustrating an example of an erasing process.
FIG. 35 is a flowchart of an embodiment of an erasing process.
FIG. 36 is a diagram showing a system configuration of an embodiment for improving a writing speed.
FIG. 37 is a diagram showing a first embodiment for improving the writing speed.
FIG. 38 is a diagram (continued) showing the first embodiment for improving the writing speed.
FIG. 39 is a diagram showing a second embodiment for improving the writing speed.
FIG. 40 is a diagram (continued) showing a second embodiment for improving the writing speed.
FIG. 41 is a diagram showing a third embodiment for improving the writing speed.
FIG. 42 is a diagram (continued) showing a third embodiment for improving the writing speed.
FIG. 43 is a diagram showing a fourth embodiment for improving the writing speed.
FIG. 44 is a diagram (continued) showing a fourth embodiment for improving the writing speed.
FIG. 45 is a diagram showing a fifth embodiment for improving the writing speed.
FIG. 46 is a diagram (continued) showing a fifth embodiment for improving the writing speed.
FIG. 47 is a flowchart of an embodiment for improving the writing speed.
FIG. 48 is a flowchart (continued) of the embodiment for improving the writing speed.
FIG. 49 is a flowchart (continued) of the embodiment for improving the writing speed;
FIG. 50 is a diagram showing an embodiment having two stages of address conversion decoding units.
FIG. 51 is a diagram showing an overall schematic configuration of a system for performing a writing time estimation process.
FIG. 52 is a diagram illustrating a state of a storage area in an example of a writing time estimation process.
FIG. 53 is a flowchart of an example of a writing time estimation process.
FIG. 54 is a diagram illustrating a first example of a flag determination process.
FIG. 55 is a diagram illustrating a second example of the flag determination process.
FIG. 56 is a diagram showing a configuration of a storage area in an embodiment for saving a management table.
FIG. 57 is a diagram showing an embodiment for saving the management table.
FIG. 58 is a diagram (continued) showing an embodiment for saving the management table;
FIG. 59 is a diagram (continued) showing an embodiment for saving the management table;
FIG. 60 is a diagram (continued) showing an embodiment for saving the management table;
FIG. 61 is a diagram (continued) showing an embodiment for saving the management table.
[Explanation of symbols]
1,20 storage device
1a Storage area
1b Primary storage medium
1c Control means
1d, 1e decode table
2 Main unit
21 Controller LSI
22 processor
23 SRAM
24 clock oscillator
25-1 to 25-5 Flash Memory
26 EEPROM
261 sector conversion unit
301 Primary decoding unit
302 Secondary decoding unit

Claims (2)

記憶領域(1a)が複数のブロック(1a-1,…,1a-N)から構成され、書き込まれたデータをブロック単位で消去する記憶装置(1) の書き込み/消去方法において、
ブロック毎に書き込みの有無を示すフラグ(F1)を設け、また、最終処理ブロックに実行中フラグを書き込み、該実行中フラグがあるか否かを調べ、実行中フラグがある場合に、上記フラグ(F1)を参照して書き込まれたデータを消去し、最後に実行中フラグを消去することを特徴とする記憶装置の書き込み/消去方法。
A storage area (1a) is composed of a plurality of blocks (1a-1,..., 1a-N), and a write / erase method of a storage device (1) for erasing written data in blocks.
A flag (F1) indicating the presence / absence of writing is provided for each block, an execution flag is written in the final processing block, and it is checked whether or not the execution flag is present. A data write / erase method for a storage device, wherein data written with reference to F1) is erased , and finally, a running flag is erased .
全記憶領域を消去する際、書き込みの有無を示すフラグ(F1)を参照して、書き込みの有るブロックのみ消去することを特徴とする請求項1の記憶装置の書き込み/消去方法。2. The writing / erasing method for a storage device according to claim 1, wherein when erasing the entire storage area, referring to a flag (F1) indicating the presence / absence of writing, only the block having the writing is erased.
JP2000347501A 2000-11-15 2000-11-15 Method for writing / erasing storage device Expired - Lifetime JP3573706B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000347501A JP3573706B2 (en) 2000-11-15 2000-11-15 Method for writing / erasing storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000347501A JP3573706B2 (en) 2000-11-15 2000-11-15 Method for writing / erasing storage device

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP24654793A Division JP3215237B2 (en) 1993-10-01 1993-10-01 Storage device and method for writing / erasing storage device

Publications (2)

Publication Number Publication Date
JP2001195889A JP2001195889A (en) 2001-07-19
JP3573706B2 true JP3573706B2 (en) 2004-10-06

Family

ID=18821216

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000347501A Expired - Lifetime JP3573706B2 (en) 2000-11-15 2000-11-15 Method for writing / erasing storage device

Country Status (1)

Country Link
JP (1) JP3573706B2 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003280979A (en) 2002-03-20 2003-10-03 Toshiba Corp Information storage device
JP3792602B2 (en) 2002-05-29 2006-07-05 エルピーダメモリ株式会社 Semiconductor memory device
JP2009252255A (en) * 2008-04-01 2009-10-29 Renesas Technology Corp Nonvolatile semiconductor memory device
JP5253471B2 (en) * 2010-09-21 2013-07-31 三菱電機株式会社 Memory controller

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2582487B2 (en) * 1991-07-12 1997-02-19 インターナショナル・ビジネス・マシーンズ・コーポレイション External storage system using semiconductor memory and control method thereof
JPH05233426A (en) * 1992-02-20 1993-09-10 Fujitsu Ltd Flash memory using method
JP3485938B2 (en) * 1992-03-31 2004-01-13 株式会社東芝 Nonvolatile semiconductor memory device
JPH0757481A (en) * 1993-08-06 1995-03-03 Brother Ind Ltd Storage device

Also Published As

Publication number Publication date
JP2001195889A (en) 2001-07-19

Similar Documents

Publication Publication Date Title
JPH07105691A (en) Method of writing/erasing and controlling storage
KR0128218B1 (en) Nonvolatile memory with flash erase capability
KR100595909B1 (en) Moving sectors within a block in a flash memory
US6718430B2 (en) Window-based flash memory storage system and management and access methods thereof
JP4844639B2 (en) MEMORY CONTROLLER, FLASH MEMORY SYSTEM HAVING MEMORY CONTROLLER, AND FLASH MEMORY CONTROL METHOD
US6865658B2 (en) Nonvolatile data management system using data segments and link information
US8255614B2 (en) Information processing device that accesses memory, processor and memory management method
JP2005301591A (en) Device with nonvolatile memory, and memory controller
JP4762261B2 (en) Memory system
JP2009521045A (en) Nonvolatile memory having block erasable memory locations
TWI406127B (en) Method for updating user data
JP2009211225A (en) Memory system
JP3573706B2 (en) Method for writing / erasing storage device
JP2010152778A (en) Semiconductor storage device
JPH08315596A (en) Semiconductor memory
JP4703673B2 (en) Memory system
JP3362031B2 (en) Method for writing / erasing storage device
JP2004326523A (en) Storage device with rewritable nonvolatile memory, and control method of nonvolatile memory for storage device
JP2001188711A (en) Method for judging flag of storage device
JP2001188713A (en) Method for managing storage device
JP3390740B2 (en) Method of controlling storage device
JPH0896589A (en) Semiconductor storage device
JP2005107600A (en) Memory controller, flash memory system equipped with same, and control method of flash memory
JP2009026062A (en) Memory controller, memory system, and memory control method

Legal Events

Date Code Title Description
TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20040629

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20040629

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20080709

Year of fee payment: 4

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090709

Year of fee payment: 5

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100709

Year of fee payment: 6

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100709

Year of fee payment: 6

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20110709

Year of fee payment: 7

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20110709

Year of fee payment: 7

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120709

Year of fee payment: 8

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120709

Year of fee payment: 8

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130709

Year of fee payment: 9

EXPY Cancellation because of completion of term