Data storage device and parameter rewriting method

By using the controller to judge and return the corresponding UPIU reply message in the flash memory, it avoids the non-rewritable mode parameters from being changed, solves the problem of improper device operation caused by users improperly rewriting parameters, and improves the stability and performance of the device. .

CN112992231BActive Publication Date: 2024-10-18SILICON MOTION INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110181275.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-01-30
Publication Date
2024-10-18
Estimated Expiration
2038-01-30

AI Technical Summary

Technical Problem

In flash memory, users may improperly rewrite operating parameters, causing the device to operate in inappropriate environments, such as long write and read cycles or too much storage space being eliminated. A method is needed to prevent non-rewritable parameters from being changed. to prevent this from happening.

Method used

Provide a data storage device and parameter writing method, and use the controller to determine whether the data output message will change the non-rewritable mode parameter. If it will change, a failed UPIU reply message will be sent back. If it will not change, a successful UPIU will be sent back. Reply with the message and use logic operations and arrays to determine whether the new mode parameters will change the non-overritable parameters.

Benefits of technology

It effectively avoids the host from rewriting the non-rewritable mode parameters, prevents improper operation of flash memory, and enhances the stability and performance of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112992231B_ABST
    Figure CN112992231B_ABST
Patent Text Reader

Abstract

The present invention provides a data storage device and a parameter rewriting method. The data storage device includes a flash memory and a controller. The flash memory is used to store a firmware, wherein the firmware has a plurality of mode page settings, and each mode page setting includes a plurality of mode parameters. The controller receives a data output message from a host for rewriting a first mode page setting in the mode page setting, and determines whether the data output message will change the non-rewritable mode parameters in the first mode page setting according to the data output message, wherein when the data output message changes the non-rewritable mode parameters in the first mode page setting, the controller returns a UPIU reply message corresponding to the failure to the host.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of invention patent application number: 201810088967.8. Technical Field

[0002] The present invention relates to a parameter rewriting method; in particular, to a parameter rewriting method for preventing non-rewritable parameters from being changed. Background Art

[0003] Flash memory is a common non-volatile data storage device that is erased and programmed electrically. Taking NAND flash memory (i.e. NAND FLASH) as an example, it is commonly used in memory cards, USB flash devices, solid-state drives (SSDs), embedded flash memory modules (eMMCs), etc.

[0004] In the operation of the flash memory, the controller needs to access and maintain the flash memory according to many parameters. Generally speaking, the operating parameters have preset values ​​so that the flash memory can work in an appropriate environment. However, the user can rewrite the operating parameters through specific commands. If the user rewrites improperly, the flash memory will operate in an inappropriate environment, such as too long write-read cycles, or too much memory space will be eliminated. Therefore, a method is needed to prevent the parameters that cannot be rewritten from being changed by the user to prevent the flash memory from operating improperly. Summary of the invention

[0005] The data storage device and parameter writing method provided by the present invention can reject the request that will change the non-rewritable mode parameters and notify the host.

[0006] The present invention provides a data storage device, the data storage device comprising:

[0007] a flash memory for storing a firmware, wherein the firmware has a plurality of mode page settings, and each mode page setting includes a plurality of mode parameters; and

[0008] A controller receives a mode selection command and a data output message from a host, wherein the data output message is used to rewrite a first mode page setting among the mode page settings, and determines whether the data output message will change the non-rewritable mode parameters in the first mode page setting according to the data output message,

[0009] When the data output message will not change the non-rewritable mode parameters in the first mode page setting, the controller determines whether a plurality of new mode parameters are retained in the flash memory after the data storage device is turned off according to the mode selection command.

[0010] In addition, when the data output message does not change the non-rewritable mode parameters in the first mode page setting, the controller returns the UFSPIU reply message corresponding to success to the host.

[0011] In one embodiment, the controller fills the mode parameters preset in the first mode page into a second array, performs a mutually exclusive OR logic operation on the first array and the second array, and fills the result of the mutually exclusive OR logic operation into a third array.

[0012] wherein the controller performs an AND logic operation on the third array and a fourth array, and fills the result of the AND logic operation into a fifth array, wherein the bits in the fourth array corresponding to the non-rewritable mode parameters are logic 1, and the bits corresponding to the rewritable mode parameters are 0, and

[0013] When any bit in the fifth array is a non-zero integer, the controller determines that the data output message will change the non-rewritable mode parameters in the first mode page setting.

[0014] The present invention provides a data storage device. The data storage device includes a flash memory and a controller. The flash memory is used to store a firmware, wherein the firmware has a plurality of mode page settings, and each mode page setting includes a plurality of mode parameters. The controller receives a data output message from a host for rewriting a first mode page setting in the mode page setting, and determines whether the data output message will change the non-rewritable mode parameters in the first mode page setting according to the data output message, wherein when the data output message will change the non-rewritable mode parameters in the first mode page setting, the controller returns a UPIU reply message corresponding to the failure to the host.

[0015] In addition, when the data output message does not change the non-rewritable mode parameters in the first mode page setting, the controller returns a UPIU reply message corresponding to success to the host.

[0016] In one embodiment, the controller receives a mode selection command from the host, and sends a ready-to-send message to the host in response to the mode selection command, and then receives a data output message sent back by the host in response to the ready-to-send message. The mode selection command includes a page storage parameter to indicate whether the new mode parameter is retained after the data storage device is shut down.

[0017] In yet another embodiment, the controller fills the new mode parameters into a first array, and performs a logic operation on the first array to determine whether the data output message will change the non-rewritable mode parameters in the first mode page setting. Specifically, the controller is also used to fill the preset mode parameters of the first mode page setting into a second array, perform an exclusive OR logic operation on the first array and the second array, and fill the exclusive OR logic operation into a third array. The controller is further used to perform an AND logic operation on the third array and a fourth array, and fill the result of the AND logic operation into a fifth array, wherein the bits corresponding to the non-rewritable mode parameters in the fourth array are logic 1, and the bits corresponding to the rewritable mode parameters are 0. When any bit in the fifth array is a non-zero integer, the controller determines that the data output message will change the non-rewritable mode parameters in the first mode page setting.

[0018] The present invention further provides a parameter rewriting method, which is applicable to a data storage device, wherein the data storage device includes a flash memory for storing firmware having a plurality of mode page settings, and each mode page setting includes a plurality of mode parameters. The parameter rewriting method includes: receiving a data output message for rewriting a first mode page setting in the mode page settings from a host; determining whether the data output message will change the non-rewritable mode parameters in the first mode page setting according to the data output message; and returning a UPIU reply message corresponding to a failure to the host when the data output message will change the non-rewritable mode parameters in the first mode page setting.

[0019] In addition, the parameter rewriting method further includes returning a UPIU reply message corresponding to success to the host when the data output message does not change the non-rewritable mode parameters in the first mode page setting.

[0020] In one embodiment, the parameter rewriting method also includes: receiving a mode selection command from the host; and transmitting a ready-to-send message to the host in response to the mode selection command, wherein the data output message is returned by the host in response to the ready-to-send message, wherein the mode selection command includes a page storage parameter for indicating whether the new mode parameter is retained after the data storage device is shut down.

[0021] In addition, the step of determining whether the data output message will change the non-rewritable mode parameters in the first mode page setting according to the data output message also includes: filling the new mode parameters into a first array; and performing a logical operation on the first array to determine whether the data output message will change the non-rewritable mode parameters in the first mode page setting.

[0022] In one embodiment, the step of performing a logical operation on the first array includes: filling a mode parameter preset in the first mode page setting into a second array; performing an exclusive OR logical operation on the first array and the second array; filling the exclusive OR logical operation into a third array; performing an AND logical operation on the third array and a fourth array; filling the result of the AND logical operation into a fifth array, wherein the bits corresponding to the non-rewritable mode parameters in the fourth array are logic 1, and the bits corresponding to the rewritable mode parameters are 0; when any bit in the fifth array is a non-zero integer, it is determined that the data output message will change the non-rewritable mode parameters in the first mode page setting; and when any bit in the fifth array is not a non-zero integer, it is determined that the data output message will not change the non-rewritable mode parameters in the first mode page setting.

[0023] In addition, the data storage device complies with the unified flash storage specification. The mode page setting includes a control mode page setting, a read / write error mode page setting and a cache mode page setting.

[0024] In one implementation, the UPIU reply message includes a reply field, a status field, a sense data [2] field, and a sense data

[12] -

[13] field, wherein in the UPIU reply message corresponding to a failure, the reply field is set to "TARGET FAILURE", the status field is set to "CHECK CONDITION", the sense data [2] field is set to "ILLEGAL REQUEST", and the sense data

[12] -

[13] fields are set to "INVALID FIELD IN PARAMETERLIST". In the UPIU reply message corresponding to a success, the reply field is set to "TARGET SUCESS", and the status field is set to "GOOD". The data output message includes a header and a new mode page setting, wherein the new mode page setting corresponds to the first mode page setting and has a plurality of new mode parameters corresponding to the mode parameters of the first mode page setting. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 is a block diagram of an embodiment of an electronic system of the present invention.

[0026] Figure 2 It is a schematic diagram of an embodiment of the data structure of the mode page setting of the present invention.

[0027] Figure 3 It is a flow chart of an embodiment of the parameter rewriting method of the present invention.

[0028] Figure 4 is a schematic diagram of an embodiment of the first array of the present invention.

[0029] Figure 5 is a schematic diagram of an embodiment of the second array of the present invention.

[0030] Explanation of symbols

[0031] 100 Electronic Systems

[0032] 120 Host

[0033] 140 Data storage device

[0034] 160 Controller

[0035] 162 Arithmetic Unit

[0036] 164 Persistent Storage

[0037] 166 Random Access Memory

[0038] 180 Flash memory

[0039] 200 Table

[0040] A0, B0, C0-C5, D0-D7, E0-E3, F0, G0-G1, H0, A0', B0', C0'-C5', D0'-D7', E0'-E3', F0', G0'-G1', H0' bit

[0041] ARR1, ARR2 arrays

[0042] EL0, EL1, EL2 elements

[0043] Steps S302 to S312 DETAILED DESCRIPTION

[0044] The following will discuss in detail the apparatus and methods of use of various embodiments of the present invention. However, it is worth noting that many feasible inventive concepts provided by the present invention can be implemented in various specific scopes. These specific embodiments are only used to illustrate the apparatus and methods of use of the present invention, but are not used to limit the scope of the present invention.

[0045] Figure 1is a block diagram of an embodiment of an electronic system of the present invention. The electronic system 100 includes a host 120 and a data storage device 140. The data storage device 140 includes a flash memory 180 and a controller 160, and operates in response to commands received from the host 120. It is worth noting that in one embodiment, the data storage device 140 complies with the specifications of Universal Flash Storage (UFS). In addition, the electronic system 100 can be implemented on other computer system configurations, such as mobile devices, multi-processor systems, microprocessor-based or programmable consumer electronics, network computers, mini computers, mainframes, and similar devices. For example, the electronic system 100 can be implemented in a mobile device, such as a mobile phone, a tablet, a smart watch, or a virtual reality device, wherein the host 120 can be a central processing unit (CPU) or a microprocessor (MCU) in the mobile device, and the data storage device 140 can be a memory device in the mobile device.

[0046] The controller 160 is used to control the flash memory 180 based on the firmware stored in the flash memory 180. The controller 160 includes a computing unit 162, a permanent memory 164 (ROM) and a random access memory 166 (RAM). The permanent memory 164 and the program code loaded therein constitute a bootloader, which is executed by the computing unit 162 to boot the data storage device 140. The random access memory 166 is used to temporarily store the execution data and firmware to be provided to the computing unit 162. The flash memory 180 includes a plurality of blocks, and each block includes a plurality of pages to store data or the firmware of the data storage device 140.

[0047] In one embodiment, the firmware includes a plurality of mode page settings (i.e., SCSI mode settings), and the mode page settings may include a control mode page setting, a read-write error mode page setting, and a cache mode page setting, wherein each mode page setting includes a plurality of mode parameters. The controller 160 may operate based on the mode parameters in each mode page setting. In one embodiment, the control mode page setting may be used to provide control parameters (e.g., task set management and error logging) under a SCSI interface (Small Computer System Interface) applicable to all devices; the read-write error mode page setting may be used to formulate error recovery parameters (error recovery parameters) that should be used in the reading and writing of the flash memory 180 by the data storage device 140 under any command (e.g., a read command, a write command, or a confirmation command); and the cache mode page setting may be used to define parameters for how to use the cache.

[0048] In one embodiment, the mode parameters in the control mode page setting, the read / write error mode page setting, and the cache mode page setting may be pre-set as the default mode parameters, respectively. The host 120 may issue a mode select command (Mode Select command) to request the controller 160 to rewrite one of the mode page settings into a new mode page setting having new parameters different from the default parameters. In one embodiment, the mode select command may include a page save parameter (i.e., SP parameter) to indicate whether the new mode parameters of the new mode page setting are to be retained after the data storage device 140 is shut down. For example, when the SP parameter in the mode select command is "0", the controller 160 may rewrite the corresponding default mode parameters temporarily stored in the random access memory 166 into the new mode parameters. When the SP parameter in the mode select command is "1", the controller 160 may rewrite the corresponding default mode parameters temporarily stored in the random access memory 166 into the new mode parameters and simultaneously rewrite the corresponding default mode parameters stored in the flash memory 180 into the new mode parameters.

[0049] In one embodiment, most of the preset mode parameters in each mode page setting are not rewritable. If the host 120 commands the controller 160 to rewrite the non-rewritable mode parameters, the data storage device 140 cannot operate properly and normally. In one embodiment, all mode parameters except software write protect ("SWP") in the control mode page setting are not rewritable, wherein the software write protect specifies whether to reject (terminate) the write command received from the host 120. In other words, the parameters of the software write protect specify that after all caches or buffers are written with data, the controller 160 needs to prohibit the write operation to the flash memory 180. For example, the structure of the write command may include a format unit command, write (6), write (10), write (16), synchronize cache command, unmap command, and verify command. If the software write protection parameter is set to "1", the controller 160 may prohibit the write command, and if the software write protection parameter is set to "0", the controller 160 may allow the write command to be executed. Therefore, when the software write protection parameter is "1", all commands that need to write to the flash memory 180 will be terminated and error information will be returned, that is, a UPIU response message (UFS Protocol Information Units, UPIU) is sent to the host 120 after termination, wherein the UPIU response message (response UPIU) includes a response field (response field) set to "TARGET FAILURE", a status field (status field) set to "CHECK CONDITION", a sense data [2] field (sense key) set to "DATAPROTECT", and a sense data

[12] -

[13] field (sense data

[12] -

[13] field (ASC & ASCQ) set to "WRITE PROTECTED"). The default mode of the data storage device 140 may be a normal operation mode, which allows execution of write commands received from the host 120 .When receiving a new control mode page setting with a software write protection parameter set to "1", the data storage device 140 may switch to a data protection mode, wherein the data protection mode prohibits the execution of a write command received from the host 120. When the data storage device 140 receives a write command in the data protection mode, the data storage device 140 may reply the aforementioned UPIU reply message to the host 120. Then, the data storage device 140 may continue to operate in the data protection mode until receiving a new control mode page setting with a software write protection parameter set to "0", wherein the control mode page setting with the software write protection parameter set to "0" may cause the data storage device 140 to switch back to the normal operation mode. In the embodiment of the present invention, UPIU is an abbreviation for UFS Protocol Information Units.

[0050] In one embodiment, all mode parameters except the read retry count (RRC), the write retry count (WRC) and the recovery time limit (RTL) in the Read-Write Error Mode Page Setting are not rewritable, wherein the read retry count specifies how many times the controller 160 needs to execute the recovery algorithm in the read process, the write retry count specifies how many times the controller 160 needs to execute the recovery algorithm in the write process, and the recovery time limit specifies how long (in milliseconds) the controller 160 can continue to execute the recovery process, but the present invention is not limited thereto. In one embodiment, the data storage device 140 may have a normal operation mode, a high read recovery mode, a high write recovery mode and a high read-write recovery mode. In detail, the data storage device 140 may be preset to operate in a normal operation mode, wherein the number of repeated reads, the number of repeated writes, and the number of recovery limits may be preset to a first value, a second value, and a third value, respectively. For example, the preset number of repeated reads, the number of repeated writes, and the number of recovery limits may be "0", "0", and "0x4b0", respectively. When a new read-write error mode page setting having a number of repeated reads set to a fourth value is received, the data storage device 140 may be switched to a high read recovery mode, wherein the fourth value is a non-negative integer, and the fourth value is greater than the first value. In other embodiments, when a new read-write error mode page setting having a number of repeated writes set to a fifth value is received, the data storage device 140 may be switched to a high write recovery mode, wherein the fifth value is a non-negative integer, and the fifth value is greater than the second value. In yet another embodiment, when a new read-write error mode page setting having a number of repeated reads set to a fourth value and a number of repeated writes set to a fifth value is received, the data storage device 140 may be switched to a high read-write recovery mode.

[0051] In one embodiment, all mode parameters except write back cache enable (WCE) and read cache disable (RCD) in the caching mode page setting are not rewritable. When the parameter of write back cache enable "WCE" is set to "0", the data storage device 140 should complete the write command with good status (i.e., reply with a UPIU reply message with a reply field set to "TARGET SUCCESS" and a status field set to "GOOD") after all data are correctly written to the flash memory 180; and when the parameter of write back cache enable "WCE" is set to "1", the data storage device 140 only needs to complete the write command with good status (Good Status) after receiving the correct data and before the data is written to the flash memory 180. When the parameter of the read cache disable "RCD" is set to "0", the data storage device 140 can read the data required by the read command from the random access memory 166 or the flash memory 180 and return it; when the parameter of the read cache disable "RCD" is set to "1", the data storage device 140 can only read the data required by the read command from the flash memory 180 and return it (that is, when the data required by the read command is stored in the random access memory 166, the controller 160 needs to write the required data from the random access memory 166 to the flash memory 180 before it can read the required data from the flash memory 180 and return it to the host 120). In one embodiment, the data storage device 140 has a normal operation mode, a write back cache disable mode, and a read cache enable mode. The data storage device 140 can be preset to operate in the normal operation mode, wherein in the preset cache mode page setting, the parameter of the read cache disable "RCD" is preset to "0" and the parameter of the write back cache enable "WCE" is preset to "1". When receiving a new cache mode page setting with the parameter of the read cache disable "RCD" set to "1", the data storage device 140 can switch from the normal operation mode to the read cache enable mode. When receiving a new cache mode page setting with the parameter of the write back cache enable "WCE" set to "0", the data storage device 140 can switch from the normal operation mode to the write back cache disable mode.

[0052] Figure 2 It is a schematic diagram of an embodiment of the data structure of the mode page setting of the present invention. Figure 2A table 200 is included for representing bit data stored in a mode page setting, wherein the data length of the mode page setting is 3 bytes, the first row of the table 200 shows that the data of the first byte in the mode page setting are bits A0, B0, C0-C5 respectively, the second row shows that the data of the second byte after the first byte in the mode page setting are bits respectively, and the third row shows that the data of the third byte after the second byte in the mode page setting are bits E0-E3, F0, G0-G1 and H0 respectively. In addition, each code A0, B0, C0-C5, D0-D7, E0-E3, F0, G0-G1, H0 is 1 bit (i.e., "0" or "1"), wherein bit A0 is a first mode parameter, bit B0 is a second mode parameter, bits C0-C5 constitute a third mode parameter, bits D0-D7 constitute a fourth mode parameter, bits E0-E3 constitute a fifth mode parameter, bit F0 is a sixth mode parameter, bits G0-G1 constitute a seventh mode parameter, and bit H0 is an eighth mode parameter. In other words, the mode parameter is composed of at least one bit, and the lengths of the mode parameters are not necessarily the same.

[0053] As described above, the present invention also includes an embodiment that can prevent the host 120 from rewriting the mode parameters that cannot be rewritten. In one embodiment, when the controller 160 receives a mode selection command from the host 120, the controller 160 can return a ready to transfer message (Ready To Transfer UPIU) to cause the host 120 to send a data output message (Data Out UPIU), wherein the data output message includes a header and a new mode page setting. In other words, the data output message includes a message that the mode page setting needs to be rewritten and the new mode parameters that need to be written into the mode page setting.

[0054] In one embodiment, after obtaining the new mode parameters, the controller 160 needs to perform multiple judgments. During the judgment process, the controller 160 needs to declare the variables of each preset mode parameter respectively, and compare each new mode parameter with the preset mode parameter respectively to determine which parameters are changed, and whether the changed parameters are mode parameters that cannot be rewritten.

[0055] The above judgment process will take up a lot of time and resources of the controller 160. Therefore, the present invention also provides another embodiment for using a specific logical operation and array to judge whether the new mode parameters different from the preset mode parameters cannot be rewritten. For detailed process, please refer to Figure 3 Description.

[0056] Figure 3 FIG. 1 is a flow chart of an embodiment of the parameter rewriting method of the present invention. Figure 3As shown, in step S302, after obtaining the new mode parameters, the controller 160 fills the obtained new mode parameters into a first array RR1, such as Figure 4 As shown, the first array ARR1 has three elements EL0-EL2, each of which is 1 byte in size and is used to store parameters corresponding to a row in the mode page setting. In other words, the size of the first array ARR1 corresponds to the size of the new mode page setting. For example, the controller 160 can obtain eight new mode parameters corresponding to Figure 2 The mode parameters shown, wherein the obtained new mode parameters include a new first mode parameter with bit A0', a new second mode parameter with bit B0', a new third mode parameter with bits C0'-C5', a new fourth mode parameter with bits D0'-D7', a new fifth mode parameter with bits E0'-E3', a new sixth mode parameter with bit F0', a new seventh mode parameter with bits G0'-G1' and a new eighth mode parameter with bit H0'. Next, the controller 160 fills the eight bits A0', B0' and C0'-C5' corresponding to the first row of table 200 into the first element EL0 of the first array ARR1, fills the eight bits D0'-D7' and E0' corresponding to the second row of table 200 into the second element EL1 of the first array ARR1, and fills the eight bits E1'-E3', F0', G0'-G1' and H0' corresponding to the third row of table 200 into the third element EL2 of the first array ARR1. It is worth noting that the size of each element in the first array ARR1 is the length of the bit corresponding to each row in the mode page setting. In other words, based on the size of each row in the mode page setting, the size of the elements in the first array ARR1 can be greater than 1 byte, and the number of elements in the array is not limited to the number in the present embodiment. In addition, the architecture of other arrays disclosed in the present invention can also be referred to. Figure 4 as well as Figure 5 The architecture revealed.

[0057] Next, in step S304, the controller 160 performs an exclusive OR logic operation (XOR operation) on the first array ARR1 and the second array ARR2, and fills the result of the exclusive OR operation into a third array, wherein the second array ARR2 (such as Figure 5The elements EL0~EL2 in the first array ARR1 and the second array ARR2 are filled with the preset mode parameters set in the preset mode page, and the third array can represent the difference between the first array and the second array. In addition, in the mutually exclusive or logical operation, the corresponding elements in the first array ARR1 and the second array ARR2 will perform mutually exclusive or logical operations respectively. In detail, in the mutually exclusive or logical operation, the controller 160 first performs mutually exclusive or logical operations on the bits in the element EL0 in the first array ARR1 and the bits in the element EL0 in the second array ARR2 to obtain a first result; then, the bits in the element EL1 in the first array ARR1 and the bits in the element EL1 in the second array ARR2 are performed mutually exclusive or logical operations to obtain a second result; then, the bits in the element EL2 in the first array ARR1 and the bits in the element EL2 in the second array ARR2 are performed mutually exclusive or logical operations to obtain a third result; finally, the bits of the first result, the second result and the third result are sequentially filled into EL0~EL2 of the third array. As shown Figure 5 As shown, the preset mode parameters are Figure 2 The mode parameters are the same as shown, and the 1-byte mode parameter will be filled into one element.

[0058] Next, in step S306, the controller 160 performs an AND operation on the third array and a fourth array, and fills the result of the AND operation into a fifth array, wherein in the AND operation, the corresponding elements in the third array and the fourth array are respectively ANDed, and the value of the fourth array indicates which bits in the default mode page setting cannot be rewritten. Specifically, in the exclusive OR operation, the controller 160 first performs an AND operation on the bit in the element EL0 in the third array and the bit in the element EL0 in the fourth array to obtain a first result; then, performs an AND operation on the bit in the element EL1 in the third array and the bit in the element EL1 in the fourth array to obtain a second result; then, performs an AND operation on the bit in the element EL2 in the third array and the bit in the element EL2 in the fourth array to obtain a third result; finally, the bits of the first result, the second result, and the third result are sequentially filled into EL0-EL2 of the fifth array. For example, each element in the fourth array corresponds to a row (i.e., 1 byte) in the preset mode page setting. If a bit in an element in the fourth array is set to "1", the parameter corresponding to the bit set to "1" is not rewritable in the preset page mode setting (i.e., a non-rewritable mode parameter). If a bit in an element in the fourth array is set to "0", the parameter corresponding to the bit set to "0" is rewritable in the preset page mode setting (i.e., a rewritable mode parameter). Finally, in step S308, the controller 160 can determine whether the data output message (Data Out UPIU) has a new mode page setting that will rewrite the non-rewritable mode parameter based on the result of the fifth array. In detail, if any element in the fifth array includes any non-zero bit (i.e., the bit value is 1), the new mode parameter corresponding to the non-zero bit will change the non-rewritable mode parameter in the preset mode page setting. Therefore, when any element in the fifth array includes a non-zero bit, the process proceeds to step S312; otherwise, the process proceeds to step S310. In step S312, the controller 160 rejects the mode selection command and responds "failure" to the host 120. In step S310, the controller 160 accepts the mode selection command, rewrites the default mode page setting, and responds "success" to the host 120.

[0059] For example, the controller 160 obtains new mode parameters from the data output message, wherein the new mode parameters include a new first mode parameter with a bit value of "1" (A0'), a new second mode parameter with a bit value of "0" (B0'), a new third mode parameter with a bit value of "001011" (C0'-C5'), a new fourth mode parameter with a bit value of "00110001" (D0'-D7'), a new fifth mode parameter with a bit value of "1101" (E0'-E3'), a new sixth mode parameter with a bit value of "0" (F0'), a new seventh mode parameter with a bit value of "00" (G0'-G1'), and a new eighth mode parameter with a bit value of "1" (H0'). Then, the controller 160 fills the obtained new mode parameters into the elements of the first array ARR1. As described above, the first element EL0 of the first array ARR1 filled with the new mode parameters is "10001011" (A0', B0', C0'-C5'), the second element EL1 is "00110001" (D0'-D7'), and the third element EL2 is "11010001" (E0'-E3', F0', G0'-G1', H0'). In addition, the first element of the second array ARR2 filled with the preset mode parameters is "11001011" (A0, B0, C0-C5), the second element EL1 is "00110111" (D0-D7), and the third element EL2 is "11010001" (E0-E3, F0, G0-G1, H0). Next, the controller 160 performs an exclusive OR logic operation on the bit "10001011" in the element EL0 of the first array ARR1 and the bit "11001011" in the element EL0 of the second array ARR2, and obtains a first result "01000000"; then performs an exclusive OR logic operation on the bit "00110001" in the element EL1 of the first array ARR1 and the bit "00110111" in the element EL1 of the second array ARR2, and obtains a second result "00000110"; then performs an exclusive OR logic operation on the bit "11010001" in the element EL2 of the first array ARR1 and the bit "11010001" in the element EL2 of the second array ARR2, and obtains a third result "00000000"; finally, the bits of the first result, the second result, and the third result are sequentially filled into EL0 to EL2 of the third array. From the obtained results, it can be seen that the bit values ​​corresponding to B0 and B0' in element EL0 have changed, and the bit values ​​corresponding to D5-D6 and D5'-D6' in element EL1 have changed. In other words, the new second mode parameters and the new fourth mode parameters are different from the preset second mode parameters and the fourth mode parameters.Next, the controller 160 may determine whether the changed new second mode parameters and new fourth mode parameters are unchangeable parameters through the fourth array and logic operation.

[0060] In this embodiment, assuming that only the second mode parameter (B0) and the fifth mode parameter (E0-E3) of the mode parameters can be rewritten, the bit in the element EL0 of the fourth array will be set to "10111111", the bit in the element EL1 will be set to "11111111", and the bit in the element EL2 will be set to "00001111". The results of the AND logic operation of the three elements in the third array and the fourth array are "00000000", "00000110", and "00000000", respectively, and these results will be filled into the elements EL0-EL2 of the fifth array in sequence. From the result of the fifth array, it can be seen that the bit values ​​corresponding to D5 and D6 in the element EL1 are non-zero. Therefore, the controller 160 can know that the new fourth mode parameter will rewrite the original fourth mode parameter that cannot be changed. Therefore, in this embodiment, the controller 160 rejects the mode selection command and replies "failed" to the host 120.

[0061] In another embodiment, assuming that only the second mode parameter (B0) and the fourth mode parameter (D0-D7) of the mode parameters can be rewritten, the bit in the element EL0 of the fourth array will be set to "10111111", the bit in the element EL1 will be set to "00000000", and the bit in the element EL2 will be set to "11111111". The results of the AND logic operation of the three elements in the third array and the fourth array are "00000000", "00000000", and "00000000", respectively, and these results will be filled in the elements EL0-EL2 of the fifth array in sequence. It can be seen from the results of the fifth array that all bit values ​​are zero. Therefore, in this embodiment, the controller 160 accepts the mode selection command, rewrites the default mode page setting, and replies "success" to the host 120.

[0062] In one embodiment, the controller 160 may respond to the host 120 with a success or failure message via a UPIU response message (response UPIU), wherein the UPIU response message includes a response field, a status field, a sense data [2] field, and a sense data

[12] -

[13] field. For example, when the controller 160 responds to the host 120 with a failure message, the response field, the status field, the sense data [2] field, and the sense data

[12] -

[13] field in the UPIU response message are set to "TARGETFAILURE", "CHECK CONDITION", "ILLEGAL REQUEST", and "INVALID FIELD IN PARAMETERLIST", respectively. When the controller 160 responds successfully to the host 120, the response field and the status field in the UPIU response message are set to "TARGET SUCESS" and "GOOD" respectively.

[0063] As shown in the above method, the data storage device 100 can reject the request that will change the non-rewritable mode parameter and notify the host 120 that the request has been rejected. In addition, the controller 160 can use arrays and logical operations to determine whether the non-rewritable mode parameter will be changed. Therefore, the embodiment of the present invention can prevent the data storage device 140 from operating in an inappropriate environment and thereby improve performance by determining whether the non-rewritable mode parameter will be changed.

[0064] The method of the present invention, or a specific form or part thereof, may exist in the form of program code. The program code may be stored in a physical medium, such as a floppy disk, an optical disk, a hard disk, or any other machine-readable (such as computer-readable) storage medium, or a computer program product not limited to an external form, wherein when the program code is loaded and executed by a machine, such as a computer, the machine becomes a device for participating in the present invention. The program code may also be transmitted through some transmission medium, such as wires or cables, optical fibers, or any transmission mode, wherein when the program code is received, loaded and executed by a machine, such as a computer, the machine becomes a device for participating in the present invention. When implemented on a general-purpose processing unit, the program code combines with the processing unit to provide a unique device that operates similarly to an application-specific logic circuit.

[0065] The above is only the preferred embodiment of the present invention, and it cannot be used to limit the scope of the implementation of the present invention. That is, all simple equivalent changes and modifications made according to the scope of the patent application and the content of the invention description of the present invention are still within the scope of the patent of the present invention. In addition, any embodiment or patent application of the present invention does not need to achieve all the purposes, advantages or features disclosed by the present invention. In addition, the abstract part and the title are only used to assist in searching patent documents, and are not used to limit the scope of rights of the present invention.

Claims

1. A data storage device, comprising: a flash memory for storing a firmware, wherein the firmware has a plurality of mode page settings, and each mode page setting includes a plurality of mode parameters; as well as A controller receives a mode selection command and a data output message from a host, wherein the data output message includes a plurality of new mode parameters for rewriting the plurality of mode parameters of a first mode page setting among the mode page settings, and determines whether the data output message will change the non-rewritable mode parameters in the first mode page setting according to the data output message, When the data output message does not change the non-rewritable mode parameters in the first mode page setting, the controller determines whether the multiple new mode parameters are retained in the flash memory after the data storage device is turned off according to the mode selection command.

2. The data storage device according to claim 1, wherein: When the data output message changes the non-rewritable mode parameters in the first mode page setting, the controller returns a unified flash storage protocol information unit reply message corresponding to the failure to the host. The UPSI reply message includes a reply field, a status field, a sensing data [2] field, and a sensing data [12]-[13] field, and In the UPSIM response message corresponding to the failure, the response field is set to "TARGET FAILURE", the status field is set to "CHECK CONDITION", the sense data [2] field is set to "ILLEGAL REQUEST", and the sense data [12]-[13] fields are set to "INVALID FIELD INPARAMETER LIST".

3. The data storage device according to claim 1, wherein: When the data output message does not change the non-rewritable mode parameters in the first mode page setting, the controller returns a UFSIP reply message corresponding to success to the host. The UPSI reply message includes a reply field and a status field, and In the UFP Response message corresponding to a success, the Response field is set to “TARGET SUCESS” and the Status field is set to “GOOD”.

4. The data storage device according to claim 1, wherein: The data output message includes a header and a new mode page setting, and The new mode page setting corresponds to the first mode page setting and has the new mode parameters corresponding to the mode parameters of the first mode page setting.

5. The data storage device according to claim 4, wherein: After the controller sends a ready-to-send message to the host in response to the mode selection command, the controller receives the data output message returned by the host in response to the ready-to-send message.

6. The data storage device according to claim 5, wherein: The mode selection command includes a page storage parameter for indicating whether the new mode parameters are to be retained after the data storage device is shut down.

7. The data storage device according to claim 6, wherein: When the page storage parameter is "0", the controller determines that the new mode parameters are not retained in the flash memory after the data storage device is turned off, and when the page storage parameter is "1", the controller determines that the new mode parameters are retained in the flash memory after the data storage device is turned off.

8. The data storage device according to claim 4, wherein: The controller fills the new mode parameters into a first array, and performs a logic operation on the first array to determine whether the data output message will change the non-rewritable mode parameters in the first mode page setting.

9. The data storage device according to claim 8, wherein: The controller fills the mode parameters preset in the first mode page into a second array, performs a mutually exclusive or logic operation on the first array and the second array, and fills the result of the mutually exclusive or logic operation into a third array. wherein the controller performs an AND logic operation on the third array and a fourth array, and fills the result of the AND logic operation into a fifth array, wherein the bits in the fourth array corresponding to the non-rewritable mode parameters are logic 1, and the bits corresponding to the rewritable mode parameters are 0, and When any bit in the fifth array is a non-zero integer, the controller determines that the data output message will change the non-rewritable mode parameters in the first mode page setting.

10. A parameter rewriting method, applicable to a data storage device, wherein the data storage device includes a flash memory for storing firmware having a plurality of mode page settings, and each mode page setting includes a plurality of mode parameters, the parameter rewriting method comprising: receiving a mode selection command and a data output message from a host, wherein the data output message includes a plurality of new mode parameters for rewriting the plurality of mode parameters of a first mode page setting among the mode page settings; Determine, according to the data output message, whether the data output message will change the mode parameters that cannot be overwritten in the first mode page setting; as well as When the data output message will not change the non-rewritable mode parameters in the first mode page setting, it is determined according to the mode selection command whether the multiple new mode parameters are retained in the flash memory after the data storage device is turned off.

11. The parameter rewriting method according to claim 10, characterized in that: Also includes: When the data output message changes the non-rewritable mode parameters in the first mode page setting, the controller returns a unified flash storage protocol information unit reply message corresponding to the failure to the host. The UPSI reply message includes a reply field, a status field, a sensing data [2] field, and a sensing data [12]-[13] field, and In the UPSIM response message corresponding to the failure, the response field is set to "TARGET FAILURE", the status field is set to "CHECK CONDITION", the sense data [2] field is set to "ILLEGAL REQUEST", and the sense data [12]-[13] fields are set to "INVALID FIELD INPARAMETER LIST".

12. The parameter rewriting method according to claim 10, characterized in that: Also includes: When the data output message does not change the non-rewritable mode parameters in the first mode page setting, a unified flash storage protocol information unit reply message corresponding to success is returned to the host.

13. The parameter rewriting method according to claim 12, characterized in that: The UPSI reply message includes a reply field and a status field, and In the UFP Response message corresponding to a success, the Response field is set to “TARGET SUCESS” and the Status field is set to “GOOD”.

14. The parameter rewriting method according to claim 10, characterized in that: The data output message includes a header and a new mode page setting, and The new mode page setting corresponds to the first mode page setting and has the new mode parameters corresponding to the mode parameters of the first mode page setting.

15. The parameter rewriting method according to claim 14, characterized in that: Also includes: A ready-to-send message is sent to the host in response to the mode selection command, wherein the data output message is returned by the host in response to the ready-to-send message.

16. The parameter rewriting method according to claim 15, characterized in that: The mode selection command includes a page storage parameter for indicating whether the new mode parameters are to be retained after the data storage device is shut down.

17. The parameter rewriting method according to claim 16, characterized in that: When the page storage parameter is "0", it is determined that the new mode parameters are not retained in the flash memory after the data storage device is turned off, and When the page storage parameter is “1”, it is determined that the new mode parameters are retained in the flash memory after the data storage device is turned off.

18. The parameter rewriting method according to claim 14, characterized in that: The step of determining whether the data output message will change the non-rewritable mode parameters in the first mode page setting according to the data output message also includes: Filling these new mode parameters into a first array; as well as A logic operation is performed on the first array to determine whether the data output message will change the non-rewritable mode parameters in the first mode page setting.

19. The parameter rewriting method according to claim 18, characterized in that: The above-mentioned step of performing a logical operation on the first array also includes: Filling the mode parameters preset in the first mode page into a second array; Performing a mutually exclusive OR logic operation on the first array and the second array; as well as The result of the exclusive OR logic operation is filled into a third array.

20. The parameter rewriting method according to claim 19, characterized in that: The above-mentioned step of performing a logical operation on the first array also includes: Performing an AND logic operation on the third array and a fourth array; Filling the result of the AND logic operation into a fifth array, wherein the bits in the fourth array corresponding to the mode parameters that cannot be overwritten are logic 1, and the bits corresponding to the mode parameters that can be overwritten are 0; When any bit in the fifth array is a non-zero integer, it is determined that the data output message will change the non-rewritable mode parameters in the first mode page setting; as well as When any bit in the fifth array is not a non-zero integer, it is determined that the data output message will not change the non-rewritable mode parameters in the first mode page setting.

Citation Information

Patent Citations

  • Flash storage device and control method for flash memory

    CN103678144A

  • Data storage device and voltage protection method thereof

    CN104346296A