Patent Description:
Document <CIT> describes a flash memory update technique where data can be directly overwritten without sector erasure if the update does not require an already existing stored bit to be unset.

The dependent claims define particular embodiments.

Computing devices, such as personal computers, laptops, desktops, or other types of computing devices, may have programs, such as a basic input/output system (BIOS) stored on memory, such as flash memory. Flash memory may be updated by a flash operation, in which the flash memory is erased and then an update is written to the blank or erased memory. Erase operations are lengthy and time-consuming, leading to lengthy and time-consuming flash operations. Further, erase operations may not be performed on a bit-by-bit basis and are performed on sectors having a minimum size (e.g., a minimum number of bits).

In an example flash operation, a processor obtains bits stored on a flash memory. Each of the stored bits is in a set state or an unset state. For example, bits having a value of "<NUM>" may be defined as being in the unset state, while bits having a value of "<NUM>" may be defined as being in the set state. The processor further obtains target bits. Each of the target bits is in the set state or the unset state. Additionally, each target bit corresponds to a stored bit and represents a value to which the stored bit is to be updated. The processor determines whether, for one stored bit in the set state, the corresponding target bit is in the unset state. When the determination is positive, the processor sets the stored bits to the unset state and, after setting the stored bits to the unset state, updates the stored bits to match the corresponding target bits. When the determination is negative, the processor updates the stored bits to match the corresponding target bits. The processor thus determines the type of updates (e.g., an erase operation from the set state to the unset state, or a write operation from the unset state to the set state) and selects the appropriate update process. If any of the stored bits are to be erased, the processor performs a flash operation (i.e., an erase operation followed by a write operation) on all the stored bits. If the only updates are write operations, the processor performs bit-wise write operations. Thus, unnecessary erase operations, which are lengthy and time-consuming, may be reduced. The flash operation may be performed during manufacture, during an update to the flash memory (e.g., an update to the BIOS), or during a recovery process.

<FIG> shows a block diagram of a non-transitory machine-readable storage medium <NUM> storing machine-readable instructions. The storage medium <NUM> includes stored bit instructions <NUM>, target bits instructions <NUM>, determination instructions <NUM>, flash instructions <NUM>, and update instructions <NUM>.

The stored bit instructions <NUM>, when executed, cause a processor to obtain stored bits stored on a flash memory. Each of the stored bits may be in a set state or an unset state.

The target bit instructions <NUM>, when executed, cause the processor to obtain target bits. Each of the target bits may also be in the set state or the unset state. In particular, each target bit corresponds to one of the stored bits and represents the state (i.e., set or unset) to which the stored bit is to be updated.

The determination instructions <NUM>, when executed, cause the processor to determine whether, for one stored bit in the set state, the corresponding target bit is in the unset state. In particular, erase operations (setting bits from the set state to the unset state) have a minimum sector size. That is, erase operations may not be performed on a bit-by-bit basis and are performed on a sector having a minimum number of bits. Thus, the determination instructions <NUM> are to determine if any stored bits in the set state are to be updated to the unset state, the sector is erased (i.e., set to the unset state).

The flash instructions <NUM>, when executed, cause the processor to perform a flash operation. In particular, the processor performs the flash operation on the flash memory when the determination is positive. The processor sets the stored bits to the unset state (i.e., performs an erase operation on at least the minimum sector). After setting the stored bits to the unset state, the processor updates the stored bits to match the corresponding target bits (i.e., performs an update operation on the stored bits).

The update instructions <NUM>, when executed, cause the processor to perform an update operation. In particular, the processor performs the update operation on the flash memory when the determination is negative. The processor updates the stored bits to match the corresponding target bits. In particular, since no stored bits are to be set from the set state to the unset state, the processor either updates the stored bits from the unset state to the set state or leaves the stored bits in their current state.

<FIG> shows a flowchart of an example method <NUM> of updating a flash memory. In particular, the flash memory may store a program, such as a basic input/output system (BIOS), to be updated. The program may be stored in the flash memory as stored bits. Each of the bits may be in a set state or an unset state. A write or update operation may be performed on a bit in the unset state by updating the bit to the set state. An erase operation may be performed by setting bits to the unset state. In particular, erase operations are not performed bit-wise and are performed on a minimum number of bits. The method <NUM> may be performed by a processor capable of executing instructions, such as the instructions stored in the machine-readable storage medium <NUM>.

In some examples, the method <NUM> may be performed during a manufacturing process. For example, the processor may be a manufacturing processor. In particular, the manufacturing processor may perform the method <NUM> to update a flash memory with a BIOS prior to securing the flash memory to a motherboard. In other examples, the processor may perform the method <NUM> after the flash memory is secured to the motherboard during an in-circuit test. For example, the processor may be integrated with a bed-of-nails fixture to update the flash memory with the BIOS during the in-circuit testing. In further examples, the method <NUM> may be performed in a computing device to update or restore the BIOS. For example, the processor may be a security controller of the computing device, and may update a protected copy of the BIOS at the first instance of receiving power. In other examples, other suitable processors or systems may perform the method <NUM>.

At block <NUM>, the processor obtains a stored sector of the program to be updated. In particular, the processor is to update the program in smaller portions represented by the stored sectors. The stored sector therefore includes a subset of the stored bits which form the program. For example, the stored sectors may be selected based on the minimum number of bits for an erase operation. For example, referring to <FIG>, a stored program <NUM> is depicted. The stored program includes stored bits <NUM>-<NUM>, <NUM>-<NUM> to <NUM>-m. The stored bits may be grouped into stored sectors <NUM>-<NUM>, <NUM>-<NUM> to <NUM>-n. For example, the stored sector <NUM>-<NUM> may include the stored bits <NUM>-<NUM>, <NUM>-<NUM> through to <NUM>-p, where p is the minimum number of bits for an erase operation. Accordingly, at block <NUM> of <FIG>, the processor may obtain, for example, the stored sector <NUM>-<NUM> for processing.

In some examples, the processor may also perform pre-processing operations on the stored sector. For example, the stored sector <NUM>-n may not include p bits based on the size of the stored program <NUM>. Accordingly, the processor may expand the stored sector <NUM>-n to include p bits by adding a sufficient number of bits in the unset state after the stored bit <NUM>-m. In particular, the stored sector <NUM>-n may be expanded to allow for erase operations to be performed.

In some examples, the program to be updated may be pre-populated with a subset of the target bits from the target program. For example, during a manufacturing process, the flash memory may be pre-populated with portions of the BIOS.

At block <NUM>, the processor obtains the target sector corresponding to the stored sector obtained at block <NUM>. In particular, the target program includes target bits, each of which correspond to a stored bit. Accordingly, each stored sector may define a corresponding target sector based on the target bits which correspond to the stored bits in the stored sector. For example, referring to <FIG>, a target program <NUM> is depicted. The target program <NUM> includes target bits <NUM>-<NUM>, <NUM>-<NUM> to <NUM>-m which correspond, respectively, to the stored bits <NUM>-<NUM>, <NUM>-<NUM> to <NUM>-m. The target bits may also be grouped into target sectors <NUM>-<NUM>, <NUM>-<NUM> to <NUM>-n. Similarly, the target sectors correspond, respectively, to the stored sectors <NUM>-<NUM>, <NUM>-<NUM>, to <NUM>-n. For example, the target sector <NUM>-<NUM> includes the target bits <NUM>-<NUM>, <NUM>-<NUM>, through to <NUM>-p. Accordingly, at block <NUM> of <FIG>, the processor may obtain, for example, the target sector <NUM>-<NUM> corresponding to the stored sector <NUM>-<NUM> obtained at block <NUM>.

In some examples, the processor may also perform pre-processing operations on the target sector. For example, the target sector <NUM>-n may be the same size as the stored sector <NUM>-n and hence may not include p bits. Accordingly, the processor may expand the target sector <NUM>-n to include p bits by adding a sufficient number of bits in the unset state after the target bit <NUM>-m. In particular, the target sector <NUM>-n may be expanded to allow for a bit-by-bit comparison with the stored sector <NUM>-n.

In some examples, at block <NUM>, the processor may additionally obtain a buffer sector. The buffer sector is a pre-defined sector having the minimum number of bits to perform an erase operation (i.e., p bits). In particular, the buffer sector includes buffer bits which are in the unset state. In particular, the buffer sector may be utilized if it is determined that the processor is to perform an erase operation.

At block <NUM>, the processor begins processing the sector using a bit-by-bit process. In particular, the processor obtains a stored bit from the stored sector obtained at block <NUM>. For example, the processor may obtain the stored bit <NUM>-<NUM>.

At block <NUM>, the processor obtains the target bit corresponding to the stored bit obtained at block <NUM>. For example, the processor may obtain the target bit <NUM>-<NUM>.

At block <NUM>, the processor determines whether the bits obtained at blocks <NUM> and <NUM> match. If they match, the method <NUM> proceeds directly to block <NUM>. If the bits do not match, the method <NUM> proceeds to block <NUM>.

At block <NUM>, the processor determines whether the stored bit obtained at block <NUM> can be updated to the target bit obtained at block <NUM>. In particular, if the stored bit is in the unset state, and the target bit is in the set state, then the processor determines that the stored bit may be updated, and the method <NUM> proceeds to block <NUM>.

At block <NUM>, the processor updates the stored bit to match the corresponding target bit. The method <NUM> then proceeds to block <NUM>.

At block <NUM>, the processor determines whether there are any stored bits left to process in the sector. If there are, the method <NUM> returns to block <NUM>, where the processor obtains the next stored bit for processing. If there are no stored bits in the sector which are in the set state, and whose corresponding target bit is in the unset state, the method <NUM> proceeds in this manner until all the stored bits in the stored sector have been updated to match the corresponding target bits.

For example, referring to <FIG>, an example stored sector <NUM> and its corresponding target sector <NUM> are depicted. In the present example, bits having a value of "<NUM>" are in the unset state, while bits having a value of "<NUM>" are in the set state. In particular, the processor may update the stored sector <NUM> according to iterations through blocks <NUM>, <NUM>, <NUM>, <NUM>, <NUM>, and <NUM> of the method <NUM> described above, in which all the stored bits are either matching, or are updated from the unset state to the set state to match the corresponding target bits.

For example, the stored bit <NUM>-<NUM> is in the unset state and matches the corresponding target bit <NUM>-<NUM> in the unset state. Accordingly, at block <NUM>, the method <NUM> proceeds to block <NUM> and returns to block <NUM>, where the processor selects the next stored bit <NUM>-<NUM>. The stored bit <NUM>-<NUM> is in the unset state, and its corresponding target bit <NUM>-<NUM> is in the set state. Accordingly, at block <NUM>, the method proceeds to block <NUM>, where the processor updates the stored bit <NUM>-<NUM> to match the target bit <NUM>-<NUM>. In particular, the stored bit <NUM>-<NUM> is updated to an updated bit <NUM>-<NUM>' depicted in <FIG>, which is in the set state. The processor iterates through the stored bits in the sector <NUM> until the stored bit <NUM>-<NUM> is updated to updated bit <NUM>-<NUM>'. Accordingly, at block <NUM>, no stored bits remain in the stored sector <NUM> and the updated sector <NUM>' has been updated to match the corresponding target sector <NUM>.

Returning to <FIG>, if, at block <NUM>, the stored bit is in the set state and the target bit is in the unset state, then the processor determines that the stored bit may not be updated, and the method proceeds to block <NUM>.

At block <NUM>, the processor erases the stored sector by setting all the stored bits in the stored sector to the unset state. For example, the processor may utilize the buffer sector obtained at block <NUM> and replace the stored sector with the buffer sector.

At block <NUM>, the processor updates the stored sector to match the corresponding target sector. In particular, the stored sector contains only stored bits in the unset state, and can be updated bit-wise to match the corresponding target bits in the target sector.

For example, referring to <FIG>, an example stored sector <NUM> and its corresponding target sector <NUM> are depicted. In the present example, bits having a value of "<NUM>" are in the unset state, while bits having a value of "<NUM>" are in the set state. In particular, the processor may update the stored sector <NUM> according to blocks <NUM> and <NUM>.

First, the processor may iterate through iterations of blocks <NUM> through <NUM>, as appropriate. For example, the stored bit <NUM>-<NUM> is in the unset state and matches the corresponding target bit <NUM>-<NUM> in the unset state. Accordingly, at block <NUM>, the method <NUM> proceeds to block <NUM> and returns to block <NUM>, where the processor selects the next stored bit <NUM>-<NUM>. The stored bit <NUM>-<NUM> is in the set state, and its corresponding target bit <NUM>-<NUM> is in the unset state. Accordingly, at block <NUM>, the method proceeds to block <NUM>.

At block <NUM>, the processor may set the stored bits in the stored sector <NUM> to the unset state, for example, by obtaining a buffer sector <NUM> having all bits in the unset state and replacing the stored sector <NUM> with the buffer sector <NUM> to obtain an erased stored sector <NUM>', as depicted in <FIG>.

At block <NUM>, the processor updates the erased stored bits in the erased stored sector <NUM>' to match the corresponding target sector <NUM> to obtain updated stored sector <NUM>", as depicted in <FIG>.

Returning to <FIG>, at block <NUM>, having updated the stored sector to match the corresponding target sector by either direct update operations (blocks <NUM> through <NUM>) or by a flash operation (blocks <NUM> and <NUM>), the processor determines whether any sectors remain in the program to process to update the program.

<FIG> shows a block diagram of an example computing device <NUM>. The computing device <NUM> includes a main processor <NUM>, a memory <NUM>, a shared flash memory <NUM>, a security controller <NUM> and a private flash memory <NUM>.

The main processor <NUM> is interconnected with the memory <NUM> and the shared flash memory <NUM>. The main processor <NUM> may include a central processing unit (CPU), a microcontroller, a microprocessor, a processing core, a field-programmable gate array (FPGA), or similar device capable of executing instructions. The main processor <NUM> may cooperate with the memory <NUM> to execute instructions. The memory <NUM> may include a non-transitory machine-readable storage medium that may be may electronic, magnetic, optical, or other physical storage device that stores executable instructions. The machine-readable storage medium may include, for example, random access memory (RAM), read-only memory (ROM), electrically-erasable programmable read-only memory (EEPROM), flash memory, a storage drive, an optical disc, and the like. The machine-readable storage medium may be encoded with executable instructions. For example, the memory <NUM> may include instructions to update a basic input/output system (BIOS) <NUM> stored on the shared flash memory <NUM>.

The shared flash memory <NUM> is a flash memory storing the BIOS <NUM>. The private flash memory <NUM> is a flash memory storing a protected copy <NUM> of the BIOS <NUM>. In particular, the private flash memory <NUM> is accessible by the security controller <NUM>. The BIOS <NUM> may be represented in the shared flash <NUM> as stored bits, each stored bit in a set state or an unset state. Similarly, the protected BIOS copy <NUM> may be represented in the private flash memory <NUM> as stored bits, each stored bit in a set state or an unset state.

The security controller <NUM> is interconnected with the shared flash memory <NUM> and the private flash memory <NUM>. The security controller <NUM> may also include a central processing unit (CPU), a microcontroller, a microprocessor, a processing core, a field-programmable gate array (FPGA), or similar device capable of executing instructions. In particular, the security controller <NUM> is to perform updates between the shared flash memory <NUM> and the private flash memory <NUM>.

For example, the BIOS <NUM> may be updated, such as during a system upgrade or the like. In particular, the BIOS <NUM> may be updated via execution of instructions by the main processor <NUM>. The security controller <NUM> may detect the update to the BIOS <NUM> and update the protected BIOS copy <NUM>. In some examples, the security controller <NUM> may further verify the updated BIOS <NUM> prior to updating the protected BIOS copy <NUM> stored in the private flash memory <NUM>. The security controller <NUM> may thus detect tampering with the BIOS <NUM> and may reject the update to the protected BIOS copy <NUM> if the verification fails.

Upon verifying the update to the BIOS <NUM>, the security controller <NUM> may update the protected BIOS copy <NUM>. In particular, the security controller <NUM> may designate the protected BIOS copy <NUM> as the stored program, and the BIOS <NUM> as the target program in the method <NUM>.

Accordingly, the security controller <NUM> obtains a stored sector of the protected BIOS copy <NUM> and a corresponding target sector of the updated BIOS <NUM>. The security controller <NUM> determines whether, for one stored bit of the stored sector of the protected BIOS copy <NUM> in the set state, the corresponding target bit of the updated BIOS <NUM> is in the unset state. When the determination is positive, the security controller <NUM> sets the stored bits of the stored sector of the protected BIOS copy <NUM> to the unset state. After setting the stored bits to the unset state, the security controller <NUM> updates the stored bits to match the corresponding target bits of the updated BIOS <NUM>. If the determination is negative, the security controller <NUM> updates the stored bits to match the corresponding target bits of the updated BIOS <NUM>. The security controller <NUM> may thus proceed through sectors of the protected BIOS copy <NUM> to update the protected BIOS copy <NUM> to match the updated BIOS <NUM>.

In another example, during a verification of the BIOS <NUM>, the security controller <NUM> may determine that the BIOS <NUM> is invalid, corrupted, or otherwise not viable for execution, for example during a boot of the computing device <NUM>. Accordingly, the security controller <NUM> may execute a recovery operation to restore the BIOS <NUM> to the protected BIOS copy <NUM>. In particular, the security controller <NUM> may designate the BIOS <NUM> as the stored program and the protected BIOS copy <NUM> as the target program in the method <NUM>.

Accordingly, the security controller <NUM> obtains a stored sector of the BIOS <NUM> and a corresponding target sector of the protected BIOS copy <NUM>. The security controller <NUM> determines whether, for one stored bit of the stored sector of the BIOS <NUM> in the set state, the corresponding target bit of the protected BIOS copy <NUM> is in the unset state. When the determination is positive, the security controller <NUM> sets the stored bits of the stored sector of the BIOS <NUM> to the unset state. After setting the stored bits to the unset state, the security controller <NUM> updates the stored bits to match the corresponding target bits of the protected BIOS copy <NUM>. If the determination is negative, the security controller <NUM> updates the stored bits to match the corresponding target bits of the protected BIOS copy <NUM>. The security controller <NUM> may thus proceed through sectors of the BIOS <NUM> to restore the BIOS <NUM> to match the protected BIOS copy <NUM>.

As described above, a processor may perform updates to flash memory based on determinations of bits to erase. The processor obtains stored bits and target bits, each of the bits in the set state or the unset state. The processor determines whether, for one stored bit in the set state, the corresponding target bit is in the unset state. That is, the processor determines whether there are stored bits to erase (i.e., set from the set state to the unset state). When the determination is positive, the processor sets the stored bits to the unset state and, after setting the stored bits to the unset state, updates the stored bits to match the corresponding target bits. In particular, the processor may set the stored bits to the unset state according to the minimum number of bits for an erase operation. When the determination is negative, the processor updates the stored bits to match the corresponding target bits.

Thus, based on the determination of bits to erase, the processor selects an appropriate update operation. If any of the stored bits are to be erased, the processor performs a flash operation (i.e., an erase operation followed by a write operation) on all the stored bits. If the only updates are write operations, the processor performs bit-wise write operations. Thus, unnecessary erase operations, which are lengthy and time-consuming, may be reduced. The flash operation may be performed during manufacture, during an update to the flash memory (e.g., an update to the BIOS), or during a recovery process.

Claim 1:
A non-transitory machine-readable storage medium storing machine-readable instructions which, when executed by a computing device according to claim <NUM>, cause the computing device to:
for each of a plurality of stored sectors of a stored program to be updated to a target program until each of the plurality of stored sectors has been processed:
obtain stored bits (<NUM>-m, <NUM>-m, <NUM>-m) stored on a flash memory (<NUM>), each of the stored bits (<NUM>-m, <NUM>-m, <NUM>-m) in a set state or an unset state wherein the stored bits (<NUM>-m, <NUM>-m, <NUM>-m) form a stored sector (<NUM>-n, <NUM>, <NUM>) of the stored program, and the stored sector is a subset of the stored bits which form the program;
obtain target bits (<NUM>-m, <NUM>-m, <NUM>-m) wherein the target bits (<NUM>-m, <NUM>-m, <NUM>-m) form a target sector (<NUM>-n, <NUM>, <NUM>) of the target program (<NUM>), each of the target bits (<NUM>-m, <NUM>-m, <NUM>-m) in the set state or the unset state, wherein each target bit (<NUM>-m, <NUM>-m, <NUM>-m) corresponds to a stored bit (<NUM>-m, <NUM>-m, <NUM>-m) to update the stored bit (<NUM>-m, <NUM>-m, <NUM>-m);
iteratively determine for each of the stored bits if a stored bit matches the corresponding target bit and if so, determine whether any sectors remain in the program to process to update the program;
wherein, if any stored bit does not match the corresponding target bit, further determine whether, for one stored bit (<NUM>-m, <NUM>-m, <NUM>-m) in the set state, the corresponding target bit (<NUM>-m, <NUM>-m, <NUM>-m) is in the unset state; and
when the further determination is positive:
set the stored bits (<NUM>-m, <NUM>-m, <NUM>-m) to the unset state; and
after setting the stored bits (<NUM>-m, <NUM>-m, <NUM>-m) to the unset state, update the stored bits (<NUM>-m, <NUM>-m, <NUM>-m) to match the corresponding target bits (<NUM>-m, <NUM>-m, <NUM>-m);
when the further determination is negative:
update the stored bits (<NUM>-m, <NUM>-m, <NUM>-m) to match the corresponding target bits (<NUM>-m, <NUM>-m, <NUM>-m), and after updating the stored bits (<NUM>-m, <NUM>-m, <NUM>-m) to match the corresponding target bits, determine whether any sectors remain in the program to process to update the program.