Patent ID: 8606987

Claim:
A data writing method for a flash memory, comprising: (a) receiving a first write command and dividing new data corresponding to the first write command into at least one sub-data according to a size of a writing unit; (b) selecting one of a plurality of spare blocks from the flash memory as a substitute block for substituting a data block, wherein the new data is to be written into the data block; (c) determining whether each of the at least one sub-data has the same size as the writing unit; (d) sequentially writing sub-data having the same size as the writing unit into the substitute block in units of the writing unit; (e) storing sub-data not having the same size as the writing unit into a temporary area; (f) receiving a second write command and determining whether an address of subsequent new data corresponding to the second write command is consecutive with an address of the new data corresponding to the first write command; (g) when the address of the subsequent new data corresponding to the second write command is not consecutive with the address of the new data corresponding to the first write command, writing the sub-data stored in the temporary area together with valid data in the data block into the substitute block in units of the writing unit; and (h) when the address of the subsequent new data is consecutive with the address of the new data, dividing the sub-data stored in the temporary area together with the subsequent new data into at least one sub-data according to the size of the writing unit and sequentially writing new sub-data having the same size as the writing unit into the substitute block in units of the writing unit, wherein the temporary area is configured only for storing small quantity data, wherein a size of the small quantity data is smaller than the size of the writing unit.