TW202136995A - Memory apparatus and memory management method for safe power-up - Google Patents

Memory apparatus and memory management method for safe power-up Download PDF

Info

Publication number
TW202136995A
TW202136995A TW109110766A TW109110766A TW202136995A TW 202136995 A TW202136995 A TW 202136995A TW 109110766 A TW109110766 A TW 109110766A TW 109110766 A TW109110766 A TW 109110766A TW 202136995 A TW202136995 A TW 202136995A
Authority
TW
Taiwan
Prior art keywords
read
code
boot code
block
flag
Prior art date
Application number
TW109110766A
Other languages
Chinese (zh)
Other versions
TWI768316B (en
Inventor
陳治良
Original Assignee
旺宏電子股份有限公司
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 旺宏電子股份有限公司 filed Critical 旺宏電子股份有限公司
Priority to TW109110766A priority Critical patent/TWI768316B/en
Publication of TW202136995A publication Critical patent/TW202136995A/en
Application granted granted Critical
Publication of TWI768316B publication Critical patent/TWI768316B/en

Links

Images

Abstract

A memory apparatus and a memory management method for safe power-up are provided. The memory management method includes: dividing a memory cell array into a first block and a second block ; storing a boot code in the first block and storing a backup boot code in the second block by backing up the boot code; in a power up sequence, setting a fail-safe flag , and reading the boot code from the first block to obtain a fist read-out boot code according to a reset command; judging whether the first read-out boot code is normal or not to generate a judging result, and setting a prequalify flag according to the judging result or the fail-safe flag, and determining whether to read the backup boot code to obtain a second read-out boot code or not.

Description

記憶體裝置以及安全開機的記憶體管理方法Memory device and memory management method for safe booting

本發明是有關於一種記憶體裝置以及安全開機的記憶體管理方法,且特別是有關於一種可提升開機成功率的記憶體裝置以及安全開機的記憶體管理方法。The present invention relates to a memory device and a memory management method for safe booting, and more particularly to a memory device that can increase the success rate of booting and a memory management method for safe booting.

在現今的電子裝置中,主機端的開機碼常儲存在非揮發性記憶體中,例如快閃記憶體。儲存在快閃記憶體中的開機碼,常因各種原因而發生損壞的現象,一旦開機碼的內容發生損壞,主機端將無碼正確的開機,且無法正常的進行運作。並且,習知技術中,當主機端發生無法開機而當機的情況下,只能將系統送回至供應者端進行維修,在使用上極端的不便利。In today's electronic devices, the boot code of the host is often stored in a non-volatile memory, such as a flash memory. The boot code stored in the flash memory is often damaged due to various reasons. Once the boot code content is damaged, the host will boot up correctly without code and cannot operate normally. Moreover, in the conventional technology, when the host side fails to boot and crashes, the system can only be sent back to the supplier side for maintenance, which is extremely inconvenient to use.

本發明提供一種記憶體裝置以及安全開機的記憶體管理方法,可提升主機端的開機成功的機率。The invention provides a memory device and a memory management method for safe booting, which can improve the chance of successful booting of a host.

本發明的安全開機的記憶體管理方法,包括:在記憶胞陣列中區分出第一區塊以及第二區塊;使開機碼在儲存在第一區塊,並備份開機碼以在第二區塊儲存備份開機碼;在開機程序中,設定失敗-安全旗標,並依據主機端可程式軟體命令以讀取第一區塊中的開機碼以獲得第一讀出開機碼;判斷第一讀出開機碼是否正確以產生判斷結果,以及,依據判斷結果或失敗-安全旗標以設定預審旗標,並依據預審旗標決定是否讀出備份開機碼以作為第二讀出開機碼。The memory management method for safe boot of the present invention includes: distinguishing the first block and the second block in the memory cell array; storing the boot code in the first block, and backing up the boot code to be in the second area Block storage backup boot code; in the boot process, set the fail-safe flag, and read the boot code in the first block according to the host-side programmable software command to obtain the first read boot code; determine the first read Whether the startup code is correct to generate a judgment result, and based on the judgment result or the failure-safe flag to set a pre-audit flag, and based on the pre-audit flag, determine whether to read the backup startup code as the second read startup code.

本發明的記憶體裝置包括記憶胞陣列以及控制電路。記憶胞陣列具有第一區塊以及第二區塊,第一區塊以及第二區塊分別儲存開機碼以及備份開機碼。控制電路耦接在記憶胞陣列以及主機端間,用以執行上述的安全開機的管理方法。The memory device of the present invention includes a memory cell array and a control circuit. The memory cell array has a first block and a second block, and the first block and the second block respectively store the boot code and the backup boot code. The control circuit is coupled between the memory cell array and the host terminal for executing the above-mentioned safe boot management method.

基於上述,本發明透過在記憶胞陣列中的第一區塊以及第二區塊,分別儲存開機碼以及備份開機碼。並透過在開機程序中,依據失敗-安全旗標或第一讀出開機碼是否正確的判斷結果來設定預審旗標,並依據預審旗標決定是否讀出備份開機碼以執行主機端的開機動動作。可維持主機端的正常運作。Based on the above, the present invention stores the activation code and the backup activation code in the first block and the second block in the memory cell array, respectively. In the boot process, the pre-audit flag is set according to the judgment result of the failure-safe flag or whether the first read boot code is correct, and based on the pre-check flag, it is determined whether to read the backup boot code to execute the host-side startup maneuver. . The normal operation of the host can be maintained.

請參照圖1,圖1繪示本發明一實施例的安全開機的記憶體管理方法的流程圖。其中,在步驟S110中,記憶體中的記憶胞陣列可區分出第一區塊以及第二區塊。第一區塊以及第二區塊可以為在記憶胞陣列中,位址連續或不連續的兩個不同的區塊。在本發明實施例中,第一區塊可以設置在記憶胞陣列中,具有相對低的位址範圍中,第二區塊則可以設置在記憶胞陣列中,具有相對高的位址範圍中。在本實施例中,記憶體可以為非揮發性記憶體,例如為快閃記憶體。Please refer to FIG. 1. FIG. 1 is a flowchart of a memory management method for secure boot according to an embodiment of the present invention. Wherein, in step S110, the memory cell array in the memory can distinguish the first block and the second block. The first block and the second block can be two different blocks with consecutive or discontinuous addresses in the memory cell array. In the embodiment of the present invention, the first block may be arranged in the memory cell array with a relatively low address range, and the second block may be arranged in the memory cell array with a relatively high address range. In this embodiment, the memory may be a non-volatile memory, such as a flash memory.

接著,在步驟S120中,則使開機碼儲存在第一區塊,並備份開機碼以在第二區塊儲存備份開機碼。其中開機碼用以提供主機端進行讀取,並提供主機端執行開機動作。Then, in step S120, the activation code is stored in the first block, and the activation code is backed up to store the backup activation code in the second block. The startup code is used to provide the host side for reading and provide the host side to execute the startup action.

在步驟S130中,進入開機程序,並在開機程序中,設定失敗-安全旗標,並依據重置命令以讀取第一區塊中的開機碼以獲得第一讀出開機碼。其中,在快閃記憶體中可以設置一失敗-安全旗標。並且,在步驟S130中,可設定失敗-安全旗標為第一邏輯準位(例如為邏輯準位1)。接著,主機端可透過主機端可程式軟體執行一重置命令,而基於重置命令的觸發,主機端可對記憶胞陣列中的第一區塊的開機碼進行讀取動作,並藉以讀出第一讀出開機碼。In step S130, the boot process is entered, and in the boot process, the failure-safe flag is set, and the boot code in the first block is read according to the reset command to obtain the first read boot code. Among them, a failure-safe flag can be set in the flash memory. In addition, in step S130, the failure-safe flag may be set to the first logic level (for example, logic level 1). Then, the host side can execute a reset command through the host side programmable software, and based on the trigger of the reset command, the host side can read the boot code of the first block in the memory cell array and read it out First read the boot code.

在此,當執行對記憶體的第一區塊的開機碼的讀取動作時,可設定存取位址為第一起始存取位址,並針對記憶胞陣列的第一起始存取位址執行讀取動作以獲得第一讀出開機碼。Here, when reading the boot code of the first block of the memory, the access address can be set as the first initial access address, and the first initial access address of the memory cell array can be set Perform a reading action to obtain the first read boot code.

接著,在步驟S140中,可針對第一讀出開機碼是否正確進行判斷,並藉以產生判斷結果。在本實施例中,可以透過對第一讀出開機碼執行循環冗餘校驗(Cyclic redundancy check,CRC)以獲得判斷結果。或者,在本發明其他實施例中,也可在主機端依據第一讀出開機碼執行開機動作後,透過執行特定的功能檢查來獲得判斷結果,並藉以得知記憶胞陣列中的第一區塊所儲存的開機碼是否正確。Then, in step S140, a judgment can be made as to whether the first read boot code is correct, and thereby a judgment result can be generated. In this embodiment, the judgment result can be obtained by performing a cyclic redundancy check (CRC) on the first read boot code. Alternatively, in other embodiments of the present invention, after the host side executes the boot action according to the first read boot code, the judgment result can be obtained by performing a specific function check, and thereby know the first area in the memory cell array Whether the boot code stored in the block is correct.

附帶一提的,在當步驟S140中所獲得的判斷結果表示第一讀出開機碼是正確的,失敗-安全旗標可以被清除為第二邏輯準位(例如為邏輯準位0)。若當步驟S140中所獲得的判斷結果表示第一讀出開機碼是錯誤的,失敗-安全旗標可以被保持為第一邏輯準位(例如為邏輯準位1)。Incidentally, when the judgment result obtained in step S140 indicates that the first read boot code is correct, the failure-safe flag can be cleared to the second logic level (for example, logic level 0). If the judgment result obtained in step S140 indicates that the first read boot code is wrong, the failure-safe flag may be maintained at the first logic level (for example, logic level 1).

在步驟S150中,可依據判斷結果或失敗-安全旗標來設定一預審旗標。其中,預審旗標是為配置在記憶體中的揮發性記憶體旗標。並且,在開機程序中,當失敗-安全旗標為被設定(等於第一邏輯準位)的狀態,或者步驟S140的判斷結果指示第一讀出開機碼為錯誤的條件下,預審旗標可以被設定為等於第一邏輯準位。此外,在預審旗標等於第一邏輯準位的狀態下,主機端可讀取記憶胞陣列中的第二區塊的備份開機碼,並藉以獲得第二讀出開機碼。主機端並可依據第二讀出開機碼進行重新開機的動作。In step S150, a pre-audit flag can be set according to the judgment result or the failure-safe flag. Among them, the pre-review flag is a volatile memory flag configured in the memory. In addition, in the boot process, when the failure-safe flag is set (equal to the first logic level), or the judgment result in step S140 indicates that the first read boot code is wrong, the pre-audit flag can be Is set equal to the first logic level. In addition, in the state where the pre-review flag is equal to the first logic level, the host can read the backup activation code of the second block in the memory cell array, and thereby obtain the second read activation code. The host terminal can perform a restart action according to the second read-out boot code.

在另一方面,在上述的步驟S150中,當要針對記憶胞陣列的第二區塊的備份開機碼執行讀取動作時,主機端可依據等於第一邏輯準位的預審旗標,在不變更起始存取位址的條件下,對記憶胞陣列執行讀取動作以獲得第二讀出開機碼。On the other hand, in the above step S150, when the read operation is to be performed on the backup boot code of the second block of the memory cell array, the host can rely on the pre-audit flag equal to the first logic level. Under the condition of changing the initial access address, a read operation is performed on the memory cell array to obtain the second read boot code.

由上述的說明不難得知,本發明實施例的安全開機的記憶體管理方法中,在當記憶胞陣列所儲存的開機碼發生錯誤時,記憶胞陣列可提供第二區塊中所儲存的備份開機碼,並透過備份開機碼使主機端成功開機動作,有效提升主機端成功開機的機率。It is not difficult to know from the above description that in the memory management method for secure boot of the embodiment of the present invention, when an error occurs in the boot code stored in the memory cell array, the memory cell array can provide the backup stored in the second block Boot code, and through the backup boot code to enable the host to successfully boot, effectively improve the probability of successful boot of the host.

請參照圖2,圖2繪示本發明實施例的記憶胞陣列的配置方式的示意圖。在圖2中,記憶體的記憶胞陣列200可區分為第一區塊Z1以及第二區塊Z2。在本實施例中,第一區塊Z1配置在位址ADD1至位址ADD2間,第二區塊Z2則配置在位址ADD2至位址ADD3間。並且,開機碼BC1儲存在第一區塊Z1,且備份開機碼BC2儲存在第二區塊Z2中。當要針對第一區塊Z1中的開機碼BC1進行讀取動作時,可設定作為起始位址的位址ADD1作為存取位址,並進行開機碼BC1的讀取動作。相對的,當預審旗標致能時,要針對第二區塊Z2中的備份開機碼BC2進行讀取動作時,主機端維持原來起始位址的位址(ADD1)作為存取位址,並進行備份開機碼BC2的讀取動作。Please refer to FIG. 2. FIG. 2 is a schematic diagram of a configuration of a memory cell array according to an embodiment of the present invention. In FIG. 2, the memory cell array 200 of the memory can be divided into a first block Z1 and a second block Z2. In this embodiment, the first block Z1 is arranged between the address ADD1 and the address ADD2, and the second block Z2 is arranged between the address ADD2 and the address ADD3. In addition, the activation code BC1 is stored in the first block Z1, and the backup activation code BC2 is stored in the second block Z2. When the startup code BC1 in the first block Z1 is to be read, the start address ADD1 can be set as the access address, and the startup code BC1 is read. In contrast, when the pre-audit flag Peugeot is to read the backup boot code BC2 in the second block Z2, the host side maintains the original start address (ADD1) as the access address, and Read the backup boot code BC2.

在此,第一區塊Z1以及第二區塊Z2的記憶容量大於開機碼BC1以及備份開機碼BC2的尺寸。此外,第一區塊Z1以及第二區塊Z2在位址的配置上可以是連續的,但也可以是不連續的,沒有一定的限制。Here, the memory capacity of the first block Z1 and the second block Z2 is larger than the size of the startup code BC1 and the backup startup code BC2. In addition, the address configuration of the first block Z1 and the second block Z2 may be continuous, but may also be discontinuous, and there is no certain limit.

請參照圖3,圖3繪示本發明另一實施例的記憶體管理方法的流程圖。在圖3中,步驟S310啟動開機程序。步驟S320針對錯誤安全旗標是否已被設定進行判斷,在當錯誤安全旗標為已被設定的狀態下,執行步驟S3100,相對的,在當錯誤安全旗標非為被設定的狀態下,執行步驟S330。在此,步驟S320可依據錯誤安全旗標的邏輯準位進行判斷。例如,當錯誤安全旗標為第一邏輯準位時,可視錯誤安全旗標為被設定的狀態。相反的,當錯誤安全旗標為第二邏輯準位時,則可視錯誤安全旗標為非被設定的狀態。其中第一邏輯準位與第二邏輯準位互補。Please refer to FIG. 3, which is a flowchart of a memory management method according to another embodiment of the present invention. In Fig. 3, step S310 starts the boot procedure. Step S320 judges whether the error safety flag has been set. When the error safety flag is set, step S3100 is executed. On the other hand, when the error safety flag is not set, it is executed. Step S330. Here, step S320 can be judged according to the logic level of the false safety flag. For example, when the error safety flag is the first logic level, the visible error safety flag is in a set state. Conversely, when the error safety flag is the second logic level, the error safety flag can be viewed as a non-set state. The first logic level is complementary to the second logic level.

值得注意的,當步驟S320中判斷出錯誤安全旗標已被設定,表示錯誤安全開機的條件已存在,且錯誤安全開機的機制需要被啟動。在此情況下,代表前一次開機(讀取開機碼BC1)失敗,錯誤安全旗標未被清除。接著執行步驟S3100,以設定預審旗標為致能。It is worth noting that when it is determined in step S320 that the error safety flag has been set, it means that the conditions for error safety booting already exist, and the error safety booting mechanism needs to be activated. In this case, it means that the previous boot (read the boot code BC1) failed, and the error security flag has not been cleared. Then, step S3100 is executed to set the pre-audit flag to be enabled.

附帶一提的,錯誤安全旗標可被設置在非揮發性記憶體(例如快閃記憶體)中,因此,透過主機端的重新開機動作,並不會變更錯誤安全旗標的邏輯準位。另外,在本發明實施例中,錯誤安全旗標可以儲存在與儲存開機碼相同的快閃記憶體中。在本發明其他實施例中,錯誤安全旗標與開機碼也可儲存在不同的快閃記憶體中。Incidentally, the error safety flag can be set in a non-volatile memory (such as flash memory). Therefore, the logic level of the error safety flag will not be changed through the reboot action on the host side. In addition, in the embodiment of the present invention, the error security flag may be stored in the same flash memory as the boot code. In other embodiments of the present invention, the error security flag and the boot code can also be stored in different flash memories.

步驟S330中設定錯誤安全旗標為第一邏輯準位,接著在步驟S340中,主機端可發送重置記憶體命令,在步驟S350中下載在記憶胞陣列中的第一區塊的開機碼。接著,步驟S360中針對所讀出的第一讀出開機碼進行功能檢查或是CRC檢查,並藉以確認第一讀出開機碼是否正確。其中,當步驟S360的檢查結果為通過時,表示第一讀出開機碼正確,並可執行步驟S370。相對的,當步驟S360的檢查結果非為通過時,表示第一讀出開機碼錯誤並對應執行步驟S390。In step S330, the error safety flag is set to the first logic level, and then in step S340, the host can send a memory reset command, and in step S350, download the boot code of the first block in the memory cell array. Next, in step S360, a function check or a CRC check is performed on the first read boot code, so as to confirm whether the first read boot code is correct. Wherein, when the check result of step S360 is passed, it indicates that the first read-out power-on code is correct, and step S370 can be executed. In contrast, when the check result of step S360 is not passed, it means that the first read-out power-on code is wrong and step S390 is executed correspondingly.

步驟S370中,基於第一讀出開機碼是正確的,錯誤安全旗標可被清除為第二邏輯準位,以表示執行錯誤安全開機的條件不存在。並在步驟S380中,主機端可以執行正常的動作。In step S370, based on the fact that the first read-out power-on code is correct, the error safety flag can be cleared to the second logic level to indicate that the conditions for performing an error-safe startup do not exist. And in step S380, the host can perform normal actions.

在另一方面,步驟S390中,主機端再次執行重置命令或啟動硬體重置(Hardware Reset)動作。接著,透過步驟S3100,記憶體內部設定預審旗標為致能。在此,可透過此設定預審旗標為高邏輯準位來完成設定預審旗標為致能的動作,相對應的,當預審旗標為第二邏輯準位時,可視預審旗標為禁能。On the other hand, in step S390, the host side executes a reset command again or initiates a hardware reset (Hardware Reset) action. Then, through step S3100, the pre-audit flag is set to enable in the memory. Here, you can set the pre-review flag to enable by setting the pre-review flag to the high logic level. Correspondingly, when the pre-review flag is at the second logic level, the pre-review flag can be viewed as disabled .

步驟S3110中,則依據被設定為致能的預審旗標來下載記憶體的第二區塊中的備份開機碼,並藉此獲得第二讀出開機碼。接著,步驟S3120針對第二讀出開機碼執行功能檢查或CRC檢查。若步驟S3120的第二讀出開機檢查動作通過時,則執行步驟S3130。相反的,若步驟S3120的第二讀出開機檢查動作未通過,則進行回報錯誤的動作(步驟S3140)。In step S3110, the backup activation code in the second block of the memory is downloaded according to the pre-audit flag set to enable, and the second read activation code is obtained thereby. Next, step S3120 performs a function check or a CRC check for the second read-out startup code. If the second read-out power-on check action of step S3120 is passed, step S3130 is executed. Conversely, if the second read power-on check operation of step S3120 fails, an error report operation is performed (step S3140).

在步驟S3130中,主機端可執行錯誤安全旗標的清除動作(清除為第二邏輯準位),並可執行記憶體中第一區塊的開機碼的修復動作。值得一提的,關於開機碼的修復動作的細節,首先可針對記憶體中的第一區塊進行抹除動作。接著再透過將第二區塊中的備份開機碼(亦即第二讀出開機碼)寫回記憶體的第一區塊來完成。In step S3130, the host side can perform a clearing action of the error security flag (clearing to the second logic level), and can perform a repairing action of the boot code of the first block in the memory. It is worth mentioning that regarding the details of the boot code restoration action, the first block in the memory can be erased first. Then, it is completed by writing the backup boot code in the second block (that is, the second read boot code) back to the first block of the memory.

在此請注意,在本實施例中,錯誤安全旗標設置在記憶體中。因此,圖3的記憶體管理流程可透過記憶體以及對應的控制電路來完成。Please note here that in this embodiment, the error security flag is set in the memory. Therefore, the memory management process of FIG. 3 can be completed through the memory and the corresponding control circuit.

以下請參照圖4,圖4繪示本發明另一實施例的安全開機的記憶體管理方法的流程圖。與前述實施例不相同的,圖4的實施例透過記憶體及其控制器外的使用者(外部電子裝置)來設定強迫交換旗標(等同於前述實施例的錯誤安全旗標)的邏輯準位。Please refer to FIG. 4 below. FIG. 4 is a flowchart of a memory management method for secure boot according to another embodiment of the present invention. Different from the previous embodiment, the embodiment of FIG. 4 uses a user (external electronic device) outside of the memory and its controller to set the logic criterion of the forced exchange flag (equivalent to the error safety flag of the previous embodiment). Bit.

在動作細節上,步驟S410中啟動開機程序。接著,在步驟S430中,可由記憶體的第一區塊下載開機碼,並獲得第一讀出開機碼。In terms of action details, the booting procedure is started in step S410. Then, in step S430, the activation code can be downloaded from the first block of the memory, and the first read activation code can be obtained.

步驟S440中,則針對第一讀出開機碼進行CRC或功能檢查,並藉以判斷第一讀出開機碼的正確與否。若步驟S440的判斷結果,指示第一讀出開機碼是正確的,步驟S450中可先行禁用強迫交換旗標,並執行正常動作(步驟S460)。相反的,步驟S440的判斷結果,指示第一讀出開機碼是錯誤的,則系統端可將連接至記憶體(強迫交換腳)(步驟S445)的一外部訊號設置為高邏輯準位,並執行一暖開機(warm reboot)的重新開機動作,此同時,記憶體設定預審旗標為致能的動作(步驟S470)。在步驟S480的暖開機動作的等待結束後,在步驟S490中進行下載記憶體中第二區塊的備份開機碼的動作。In step S440, a CRC or function check is performed on the first read-out power-on code to determine whether the first read-out power-on code is correct. If the result of the determination in step S440 indicates that the first read-out boot code is correct, the forced exchange flag can be disabled in step S450, and normal actions can be performed (step S460). On the contrary, if the judgment result of step S440 indicates that the first read-out boot code is wrong, the system side can set an external signal connected to the memory (forcibly swapped pins) (step S445) to a high logic level, and A warm reboot (warm reboot) restart action is performed, and at the same time, the memory sets the pre-review flag as an enabled action (step S470). After the waiting of the warm boot action in step S480 is over, in step S490, the action of downloading the backup boot code of the second block in the memory is performed.

在此請注意,在本實施例中,強迫交換旗標的邏輯準位可由外部的電子裝置來進行設定。在當強迫交換旗標被啟用,且當強迫交換旗標為第一邏輯準位的條件下,步驟S490可以執行下載記憶體中第二區塊的備份開機碼的動作,並藉此獲得第二讀出開機碼。Please note that in this embodiment, the logic level of the forced exchange flag can be set by an external electronic device. Under the condition that the forced exchange flag is enabled and the forced exchange flag is the first logic level, step S490 can perform the action of downloading the backup boot code of the second block in the memory, and thereby obtain the second Read the startup code.

接著,步驟S4100中,針對第二讀出開機碼執行功能檢查或CRC檢查,並在檢查通過時執行步驟S4120,或在檢查不通過時執行步驟S4110以進行錯誤回報。Next, in step S4100, a function check or a CRC check is performed for the second read-out startup code, and step S4120 is performed when the check is passed, or step S4110 is performed when the check fails to report an error.

在步驟S4120中,可進行記憶體中第一區塊的開機碼的修復動作,強迫交換旗標可在第一區塊的開機碼修復之後被清除(清除為第二邏輯準位)。In step S4120, the startup code of the first block in the memory can be repaired, and the forced exchange flag can be cleared after the startup code of the first block is repaired (cleared to the second logic level).

以下請參照圖5A以及圖5B,圖5A以及圖5B分別繪示本發明實施例的記憶體裝置的不同實施方式的示意圖。在圖5A中,記憶體裝置501包括記憶胞陣列510以及控制電路520。記憶胞陣列510區分為第一區塊以及第二區塊,並分別儲存開機碼BC1以及備份開機碼BC2。Please refer to FIGS. 5A and 5B below. FIGS. 5A and 5B respectively illustrate schematic diagrams of different implementations of the memory device according to an embodiment of the present invention. In FIG. 5A, the memory device 501 includes a memory cell array 510 and a control circuit 520. The memory cell array 510 is divided into a first block and a second block, and stores the activation code BC1 and the backup activation code BC2, respectively.

控制電路520可用以執行前述實施例的記憶體管理流程,藉以提升主機端成功開機的機率。The control circuit 520 can be used to execute the memory management process of the foregoing embodiment, so as to improve the probability of successful booting of the host.

在另一方面,控制電路520包括正反器FF1、邏輯電路522以及位址解碼器521。正反器FF1的資料端接收開機位址設定值BA-DEF,正反器FF1的時脈端接收開機觸發信號PUT,正反器FF1的輸出端依據重開機動作所產生的開機觸發信號PUT來產生開機位址設定值BA-DEF。On the other hand, the control circuit 520 includes a flip-flop FF1, a logic circuit 522, and an address decoder 521. The data terminal of the flip-flop FF1 receives the boot address setting value BA-DEF, the clock terminal of the flip-flop FF1 receives the boot trigger signal PUT, and the output terminal of the flip-flop FF1 receives the boot trigger signal PUT generated by the restart action. Generate the boot address setting value BA-DEF.

在另一方面,邏輯電路522可作為主機端以及記憶胞陣列510間的膠合邏輯(glue logic)電路。邏輯電路522接收開機碼設定值BC-DEF、最高位元位址HMSB以及正反器FF1的輸出,並進行邏輯運算來產生切換位址MMSAD。另外,位址解碼器521接收低位元位址HLSB以及切換位址MMSAD,並依據低位元位址HLSB以及切換位址MMSAD以值行位址解碼動作來產生存取位址。並依據存取位址以讀取記憶胞陣列510中的開機碼BC1或備份開機碼BC2。On the other hand, the logic circuit 522 can be used as a glue logic circuit between the host and the memory cell array 510. The logic circuit 522 receives the output of the startup code setting value BC-DEF, the highest bit address HMSB, and the flip-flop FF1, and performs logic operations to generate the switching address MMSAD. In addition, the address decoder 521 receives the low-order address HLSB and the switching address MMSAD, and generates an access address according to the low-order address HLSB and the switching address MMSAD by performing a value row address decoding operation. According to the access address, the startup code BC1 or the backup startup code BC2 in the memory cell array 510 can be read.

在動作細節上,當開機碼設定值BC-DEF被禁能時,位址解碼器521僅能提供存取位址來針對記憶胞陣列510的第一區塊的開機碼BC1進行讀取。在當開機碼設定值BC-DEF被致能時,邏輯電路522可依據最高位元位址HMSB以及正反器FF1的輸出來產生的切換位址MMSAD。In terms of operation details, when the startup code setting value BC-DEF is disabled, the address decoder 521 can only provide an access address to read the startup code BC1 of the first block of the memory cell array 510. When the startup code setting value BC-DEF is enabled, the logic circuit 522 can generate the switching address MMSAD according to the highest bit address HMSB and the output of the flip-flop FF1.

進一步說明,在此條件下,當正反器FF1的輸出例如為邏輯準位0時,邏輯電路522可輸出高位元位址HMSB以作為切換位址MMSAD。位址解碼器521則依據切換位址MMSAD以及低位元位址HLSB來產生存取位址。切換位址MMSAD可以為單一個位元,可以做為存取為位址的最高位元,並用以與低位元位址HLSB相整合。在低位元位址HLSB為0且切換位址MMSAD也為0的條件下,位址解碼器521可產生等於000000h(十六進位值)的存取位址來讀取開機碼BC1。To further explain, under this condition, when the output of the flip-flop FF1 is, for example, the logic level 0, the logic circuit 522 can output the high bit address HMSB as the switching address MMSAD. The address decoder 521 generates an access address according to the switching address MMSAD and the lower address HLSB. The switch address MMSAD can be a single bit, can be used as the highest bit of the address, and used to integrate with the low bit address HLSB. Under the condition that the low bit address HLSB is 0 and the switching address MMSAD is also 0, the address decoder 521 can generate an access address equal to 000000h (hexadecimal value) to read the boot code BC1.

當正反器FF1的輸出例如為邏輯準位1時,邏輯電路522可使切換位址MMSAD反向,並使切換位址MMSAD成為邏輯準位1。位址解碼器521則可產生等於800000h(十六進位值)的存取位址來讀取備份開機碼BC2。When the output of the flip-flop FF1 is, for example, the logic level 1, the logic circuit 522 can reverse the switching address MMSAD and make the switching address MMSAD become the logic level 1. The address decoder 521 can generate an access address equal to 800000h (hexadecimal value) to read the backup boot code BC2.

在此請注意,正反器FF1的輸出可依據開機位址設定值BA-DEF來產生,而當開機位址設定值BA-DEF變更後,正反器FF1需在重開機動作發生後,才可依據開機觸發信號PUT變更所產生的輸出。Please note here that the output of the flip-flop FF1 can be generated based on the boot address setting value BA-DEF, and when the boot address setting value BA-DEF is changed, the flip-flop FF1 needs to be restarted after the restart action occurs. The output generated can be changed according to the power-on trigger signal PUT.

接著請參照圖5B,與圖5A的實施方式不相同的,圖5B的記憶體裝置502中的控制電路520更包括互斥或閘XOR。互斥或閘XOR耦接在正反器FF1的輸出端以及邏輯電路522間。互斥或閘XOR接收預審旗標PREQ以及正反器FF1的輸出。在當預審旗標PREQ被啟用時,正反器FF1的輸出可依據預審旗標PREQ而被反向(或不反向),並藉以變更邏輯電路522所產生的切換位址MMSAD,並選擇讀出開機碼BC1或備份開機碼BC2。Next, please refer to FIG. 5B. Unlike the embodiment of FIG. 5A, the control circuit 520 in the memory device 502 of FIG. 5B further includes a mutual exclusion or gate XOR. The exclusive OR gate XOR is coupled between the output terminal of the flip-flop FF1 and the logic circuit 522. The exclusive or gate XOR receives the pre-audit flag PREQ and the output of the flip-flop FF1. When the pre-audit flag PREQ is enabled, the output of the flip-flop FF1 can be inverted (or not inverted) according to the pre-audit flag PREQ, thereby changing the switching address MMSAD generated by the logic circuit 522, and selecting read Output the startup code BC1 or backup startup code BC2.

在此,預審旗標PREQ可由一隨機存取記憶體來提供。也就是說,外部電子裝置可以透過對隨機存取記憶體寫入資料來變更預審旗標PREQ,並據以進行讀出開機碼BC1或備份開機碼BC2的切換動作。Here, the pre-audit flag PREQ can be provided by a random access memory. That is to say, the external electronic device can change the pre-audit flag PREQ by writing data to the random access memory, and perform the switching action of reading the boot code BC1 or the backup boot code BC2 accordingly.

綜上所述,本發明透過在記憶胞陣列中的不同區塊分別儲存開機碼以及備份開機碼。並在當開機碼判斷為發生錯誤的狀態下,切換讀取備份開機碼以執行開機動作。如此一來,主機端確保可成功開機,維持系統的正常運作。In summary, the present invention stores the activation code and the backup activation code in different blocks in the memory cell array. And when the startup code is judged to have an error state, switch to read the backup startup code to perform the startup action. In this way, the host ensures that it can successfully boot and maintain the normal operation of the system.

S110~S150、S310~S3130、S410~S4120:記憶體管理步驟 200:記憶胞陣列 501:記憶體裝置 510:記憶胞陣列 520:控制電路 521:位址解碼器 522:邏輯電路 ADD1~ADD3:位址 BA-DEF:開機位址設定值 BC1:開機碼 BC2:備份開機碼 BC-DEF:開機碼設定值 FF1:正反器 HLSB:低位元位址 HMSB:最高位元位址 MMSAD:切換位址 PREQ:預審旗標 PUT:開機觸發信號 XOR:互斥或閘 Z1:第一區塊 Z2:第二區塊S110~S150, S310~S3130, S410~S4120: Memory management steps 200: Memory cell array 501: memory device 510: Memory Cell Array 520: control circuit 521: Address Decoder 522: Logic Circuit ADD1~ADD3: address BA-DEF: Boot address setting value BC1: startup code BC2: Backup boot code BC-DEF: Boot code setting value FF1: Flip-Flop HLSB: Low bit address HMSB: Most significant bit address MMSAD: switch address PREQ: Pre-audit flag PUT: Power-on trigger signal XOR: Mutually exclusive or gate Z1: first block Z2: second block

圖1繪示本發明一實施例的安全開機的記憶體管理方法的流程圖。 圖2繪示本發明實施例的記憶胞陣列的配置方式的示意圖。 圖3繪示本發明另一實施例的記憶體管理方法的流程圖。 圖4繪示本發明另一實施例的安全開機的記憶體管理方法的流程圖。 圖5A以及圖5B分別繪示本發明實施例的記憶體裝置的不同實施方式的示意圖。FIG. 1 shows a flowchart of a memory management method for secure boot according to an embodiment of the present invention. FIG. 2 is a schematic diagram of the configuration of the memory cell array according to the embodiment of the present invention. FIG. 3 shows a flowchart of a memory management method according to another embodiment of the present invention. FIG. 4 shows a flowchart of a memory management method for secure boot according to another embodiment of the present invention. 5A and 5B respectively show schematic diagrams of different implementations of the memory device according to an embodiment of the present invention.

S110~S150:記憶體管理步驟S110~S150: Memory management steps

Claims (10)

一種安全開機的記憶體管理方法,包括: 在一記憶胞陣列中區分出一第一區塊以及一第二區塊; 使一開機碼儲存在該第一區塊,並備份該開機碼以在該第二區塊儲存一備份開機碼; 在一開機程序中,設定一失敗-安全旗標,並依據一主機端可程式軟體命令以讀取該第一區塊中的該開機碼以獲得一第一讀出開機碼; 判斷該第一讀出開機碼是否正確以產生一判斷結果;以及 依據該判斷結果或該失敗-安全旗標以設定一預審旗標,並依據該預審旗標決定是否讀出該備份開機碼以作為一第二讀出開機碼。A memory management method for safe booting includes: Distinguish a first block and a second block in a memory cell array; Storing a boot code in the first block, and backing up the boot code to store a backup boot code in the second block; In a boot process, set a failure-safe flag, and read the boot code in the first block according to a host-side programmable software command to obtain a first read boot code; Judging whether the first read-out boot code is correct to generate a judgment result; and According to the judgment result or the failure-safe flag, a pre-audit flag is set, and according to the pre-audit flag, it is determined whether to read the backup startup code as a second read startup code. 如申請專利範圍第1項所述的記憶體管理方法,其中當該一判斷結果指示該第一讀出開機碼為正確時,更包括清除該失敗-安全旗標。For the memory management method described in item 1 of the scope of patent application, when the judgment result indicates that the first read-out boot code is correct, it further includes clearing the failure-safe flag. 如申請專利範圍第1項所述的記憶體管理方法,其中當該一判斷結果指示該第一讀出開機碼為錯誤時,設定該預審旗標。For example, in the memory management method described in item 1 of the scope of patent application, the pre-examination flag is set when the judgment result indicates that the first read-out boot code is wrong. 如申請專利範圍第3項所述的記憶體管理方法,更包括依據該預審旗標以讀出該備份開機碼以作為該第二讀出開機碼。As described in item 3 of the scope of patent application, the memory management method further includes reading the backup boot code as the second read boot code according to the pre-review flag. 如申請專利範圍第1項所述的記憶體管理方法,其中判斷該第一讀出開機碼是否正確以產生該判斷結果的步驟包括: 針對該第一讀出開機碼執行循環冗餘校驗以獲得該判斷結果;或者 依據該第一讀出開機碼對一主機端執行開機動作,並使該主機端執行功能檢查以獲得該判斷結果。For the memory management method described in item 1 of the scope of patent application, the step of judging whether the first read-out boot code is correct to generate the judgment result includes: Perform a cyclic redundancy check on the first read boot code to obtain the judgment result; or Perform a boot action on a host terminal according to the first read boot code, and make the host terminal perform a function check to obtain the judgment result. 如申請專利範圍第1項所述的記憶體管理方法,更包括: 針對該第二開機碼進行循環冗餘校驗,或依據該第二讀出開機碼對一主機端執行開機動作,並使該主機端執行功能檢查,以校驗該第二讀出開機碼是否為正確;以及 當該第二讀出開機碼被校驗為正確時,清除該失敗-安全旗標。The memory management method described in item 1 of the scope of patent application further includes: Perform a cyclic redundancy check on the second boot code, or perform a boot action on a host terminal according to the second read boot code, and make the host perform a function check to verify whether the second read boot code Is correct; and When the second read power-on code is verified as correct, the failure-safe flag is cleared. 如申請專利範圍第6項所述的記憶體管理方法,更包括: 針對該第一區塊中的該開機碼進行一修復動作。The memory management method described in item 6 of the scope of patent application further includes: Perform a repair operation on the boot code in the first block. 如申請專利範圍第7項所述的記憶體管理方法,其中該修復動作包括: 針對該第一區塊執行抹除動作;以及 複製該第二讀出開機碼以寫入至該第一區塊。The memory management method described in item 7 of the scope of patent application, wherein the repairing action includes: Perform an erase operation on the first block; and Copy the second read boot code to write to the first block. 如申請專利範圍第1項所述的記憶體管理方法,其中該第一區塊以及該第二區塊分別對應一第一起始存取位址以及一第二起始存取位址,其中讀取該第一區塊中的該開機碼以獲得該第一讀出開機碼的步驟包括: 設定一存取位址為該第一起始存取位址,依據該存取位址對該記憶胞陣列執行讀取動作以獲得該第一讀出開機碼, 其中,依據該預審旗標決定是否讀出該備份開機碼以作為該第二讀出開機碼的步驟包括: 依據該預審旗標以及該起始存取位址,對該記憶胞陣列執行讀取動作以獲得該第二讀出開機碼。As described in the first item of the patent application, the first block and the second block respectively correspond to a first initial access address and a second initial access address, wherein the read The step of obtaining the activation code in the first block to obtain the first read activation code includes: Setting an access address as the first initial access address, and performing a read operation on the memory cell array according to the access address to obtain the first read boot code, Wherein, the step of determining whether to read the backup boot code as the second read boot code according to the pre-review flag includes: According to the pre-review flag and the initial access address, a read operation is performed on the memory cell array to obtain the second read-out startup code. 一種記憶體裝置,包括: 一記憶胞陣列,具有一第一區塊以及一第二區塊,該第一區塊以及該第二區塊分別儲存一開機碼以及一備份開機碼; 一控制電路,耦接在該記憶胞陣列以及一主機端間,用以執行: 在一開機程序中,設定一失敗-安全旗標,並依據一主機端可程式軟體命令以讀取該第一區塊中的該開機碼以獲得一第一讀出開機碼; 判斷該第一讀出開機碼是否正確以產生一判斷結果;以及 依據該判斷結果或該失敗-安全旗標以設定一預審旗標,並依據該預審旗標決定是否讀出該備份開機碼以作為一第二讀出開機碼。A memory device includes: A memory cell array having a first block and a second block, the first block and the second block respectively storing an activation code and a backup activation code; A control circuit, coupled between the memory cell array and a host terminal, is used to execute: In a boot process, set a failure-safe flag, and read the boot code in the first block according to a host-side programmable software command to obtain a first read boot code; Judging whether the first read-out boot code is correct to generate a judgment result; and A pre-audit flag is set according to the judgment result or the failure-safe flag, and whether to read the backup startup code is determined according to the pre-audit flag as a second read startup code.
TW109110766A 2020-03-30 2020-03-30 Memory apparatus and memory management method for safe power-up TWI768316B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW109110766A TWI768316B (en) 2020-03-30 2020-03-30 Memory apparatus and memory management method for safe power-up

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW109110766A TWI768316B (en) 2020-03-30 2020-03-30 Memory apparatus and memory management method for safe power-up

Publications (2)

Publication Number Publication Date
TW202136995A true TW202136995A (en) 2021-10-01
TWI768316B TWI768316B (en) 2022-06-21

Family

ID=79601292

Family Applications (1)

Application Number Title Priority Date Filing Date
TW109110766A TWI768316B (en) 2020-03-30 2020-03-30 Memory apparatus and memory management method for safe power-up

Country Status (1)

Country Link
TW (1) TWI768316B (en)

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI307015B (en) * 2003-06-03 2009-03-01 Hon Hai Prec Ind Co Ltd System and method for automatically bootstrap with double boot areas in a single flash rom
US10977050B2 (en) * 2018-01-11 2021-04-13 Macronix International Co., Ltd. Method for managing system boot code memory, memory device and electronic system using the same
US10445088B2 (en) * 2018-01-11 2019-10-15 Macronix International Co., Ltd. System boot code clone

Also Published As

Publication number Publication date
TWI768316B (en) 2022-06-21

Similar Documents

Publication Publication Date Title
TWI722361B (en) Method for managing system boot code memory, memory device and electronic system using the same
TWI664574B (en) Method of patching boot code of read-only memory and system-on-chip
JP5909264B2 (en) Secure recovery apparatus and method
JP4994112B2 (en) Semiconductor integrated circuit device and memory control method
TWI514408B (en) Handling errors during device bootup from a non-volatile memory
US7444543B2 (en) Data control unit capable of correcting boot errors, and corresponding self-correction method
JP4840859B2 (en) Semiconductor device and startup method
US8812910B2 (en) Pilot process method for system boot and associated apparatus
JP7022809B2 (en) Computer systems, their safety management methods, and computer software products
WO2012071945A1 (en) Method and device for backing up and upgrading bootstrap
US9817600B2 (en) Configuration information backup in memory systems
CN104951405A (en) Storage system and method for performing and authenticating write-protection thereof
TW201535382A (en) DRAM row sparing
US20080098388A1 (en) Safe Flashing
US11099949B2 (en) Method apparatus for resuming and recovery checking from interrupted programming of one-time programmable memory device
US20080195893A1 (en) A repairable semiconductor memory device and method of repairing the same
CN105786545B (en) Breakpoint recovery method and system based on heterogeneous hybrid memory
JP2010033576A (en) Electronic device and method for updating bios
JP2007310916A (en) Memory card
JP4743182B2 (en) Microcomputer
JP2007094921A (en) Memory card and control method for it
WO2011001486A1 (en) Data processing method and semiconductor integrated circuit
CN103744700A (en) System starting method and electronic device
TW202136995A (en) Memory apparatus and memory management method for safe power-up
CN113094107B (en) Data protection method, device, equipment and computer storage medium