Method for updating security data stored in a microcontroller's memory
The method of copying and updating security data in microcontroller sectors using a state machine addresses vulnerabilities from power outages, ensuring data integrity and robustness in the update process.
Patent Information
- Application Number
- FR2024005544
- Authority / Receiving Office
- FR · FR
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2025-12-05
AI Technical Summary
Current methods for updating security data in microcontroller memories are vulnerable to power outages, leading to potential data loss or corruption during the update process.
A method involving a state machine to sequentially copy valid security data from a first sector to a second sector, erase the first sector, and assign the new data to the second sector, ensuring robustness against power losses by maintaining valid data integrity.
Ensures data integrity by preventing loss or corruption of security data during power outages or resets, enhancing the robustness and efficiency of the update process.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Title of the invention: Method for updating security data stored in the memory of a microcontroller technical field
[0001] This description relates generally to methods for updating security data in non-volatile memories of a microcontroller and to microcontrollers implementing these methods. Previous technique
[0002] Security data stored in microcontroller memories must be updatable. Current update procedures may have weaknesses in terms of robustness, for example, with respect to a power outage affecting the microcontroller. Summary of the invention
[0003] There is a need to improve the processes for updating the security data of microcontrollers.
[0004] An embodiment overcomes all or part of the disadvantages of known processes.
[0005] One embodiment provides a method for updating security data stored in a first sector of a non-volatile memory of a microcontroller, a first status being assigned to the first sector, the process comprising the following successive steps: - erase the contents of a second non-volatile memory sector, different from the first sector, - write a new version of the security data in the second sector; and - assign the first status to the second sector.
[0006] One embodiment provides a microcontroller comprising a memory having a first memory sector and a second memory sector different from the first sector, a security data to be updated being stored in the first sector, a first status being assigned to the first sector, the microcontroller being configured to successively: - erase the contents of the second memory sector, - write a new version of the security data in the second sector; and - assign the first status to the second sector.
[0007] According to one embodiment, each sector includes several security data.
[0008] According to one embodiment, after writing the new version of the security data in the second sector and before assigning the first status to the second sector, the security data stored in the first sector is copied sequentially into the second sector.
[0009] According to one embodiment, the copying of said security data from the first sector into the second sector is implemented by a state machine.
[0010] According to one embodiment, the first sector and the second sector comprise memory spaces each referenced by an address index, said security data of the first sector each being stored in one of said memory spaces of the first sector, and each copied into the second sector if the memory space of the second sector, having an address index corresponding to the address index of the memory space associated with the security data of the first sector to be copied, is empty.
[0011] According to one embodiment, the erasure of the contents of the second sector is implemented by a memory control circuit following the first software command.
[0012] According to one embodiment, the writing of the new version of the security data in the second sector is implemented by said control circuit following a second software command.
[0013] According to one embodiment, a second status is assigned to the first sector once the first status has been assigned to the second sector.
[0014] According to one embodiment, prior to the update, the first status is assigned to the first sector and the second status is assigned to the second sector.
[0015] According to one embodiment, each memory sector includes a space dedicated to storing the status assigned to the sector.
[0016] According to one embodiment, only the memory sector affected by the first status is read.
[0017] According to one embodiment, the security data is or are keys to encryption.
[0018] One embodiment provides a system comprising a microcontroller as described above and an update unit external to the microcontroller; the update unit being configured to transmit, to the microcontroller and during an update, said new version of the security data. Brief description of the drawings
[0019] These features and advantages, as well as others, will be described in detail in the following description of particular embodiments, given by way of non-limiting example, in relation to the accompanying figures, among which:
[0020] Fig. 1 represents, in a very schematic and block-like manner, an example of a microcontroller of the type to which the described embodiments apply;
[0021] [Fig.2] illustrates an example of the microcontroller of [Fig.1];
[0022] [Fig. 3] represents an operating method of the microcontroller of [Fig. 1] according to an example; and
[0023] [Fig.4] represents a method of operation of the microcontroller of [Fig. 1] according to an embodiment. Description of the implementation methods
[0024] The same elements have been designated by the same reference numerals in the different figures. In particular, structural and / or functional elements common to the different embodiments may have the same reference numerals and may have identical structural, dimensional and material properties.
[0025] For the sake of clarity, only the steps and elements useful for understanding the described embodiments have been represented and are detailed.
[0026] Unless otherwise specified, when referring to two elements connected together, this means directly connected without intermediate elements other than conductors, and when referring to two elements coupled together, this means that these two elements can be connected or linked through one or more other elements.
[0027] In the following description, when reference is made to absolute position qualifiers, such as the terms "front", "back", "top", "bottom", "left", "right", etc., or relative position qualifiers, such as the terms "above", "below", "superior", "inferior", etc., or to orientation qualifiers, such as the terms "horizontal", "vertical", etc., reference is made, unless otherwise specified, to the orientation of the figures.
[0028] Unless otherwise specified, the expressions "approximately", "roughly", and "on the order of" mean to within 10% or 10°, preferably to within 5% or 5°.
[0029] Figure 1 represents, in a very schematic and block-like fashion, an example of a microcontroller 100 of the type to which the described embodiments apply. The circuit 100 is, for example, a microcontroller.
[0030] The microcontroller 100 includes a non-volatile memory 104 (NVM), for example of the FLASH or phase-change memory type, capable of communicating, via a communication bus 114, with a non-volatile memory interface 106 (NVM INTERFACE) configured to write or read data into and from the non-volatile memory 104.
[0031] The circuit 100 further comprises, for example, a processing unit 110 (CPU) comprising one or more processors under the control of instructions stored in an instruction memory 112 (INSTR MEM). The instruction memory 112 is, for example, a volatile random access memory (RAM). The processing unit 110 and the memory 112 communicate, for example, via a system bus 140 (data, address and control). The FLASH memory 104 is connected to the system bus 140 via the non-volatile memory interface 106 and via the bus 114. The device 100 further includes an input / output interface 108 (FO interface) connected to the system bus 140 for communication with the outside.
[0032] The device 100 can integrate other circuits implementing other functions (for example, one or more volatile and / or non-volatile memories, or other processing units), symbolized by a block 116 (FCT) in [Fig. 1]. Among these other circuits, the circuit 100 includes, for example, a read-only or static memory 118 (ROM).
[0033] Memory 104 contains, for example, security data, that is, data such as security keys or sensitive data, which are linked, for example, to user-selected options (Option Bytes Keys) of the microcontroller. It may be useful to update some of this security data.
[0034] In the example shown, an update unit 190, external to the microcontroller 100, is configured to transmit a new version of the security data to be updated to the microcontroller 100 during an update. This transmission can be wired or wireless (Over The Air, OTA). The update unit and the microcontroller 100 form a system 195.
[0035] [Fig.2] illustrates an example of the microcontroller of [Fig.1].
[0036] In particular, the example in [Fig.2] illustrates an example of memory 104. In this example, memory 104 comprises a first and a second memory sectors 200, 220.
[0037] Each of these two memory sectors 200,220 includes memory spaces 202, 204, 206, 208, 210, 212, 214, 222, 224, 226, 228, 230, 232 and 234. Other intermediate memory spaces are present but not shown for clarity.
[0038] The memory spaces are each referenced by an address index Addr_index. Before a copy step described in other figures, security data Key 0, Key 1, ..., Key 19, Key 20, Key 21, ..., Key 510, from the first sector 200 are each stored respectively in one of the memory spaces of the first sector with the corresponding index. For example, the security data Key 0 is stored in the memory space with index 0.
[0039] Memory spaces 202 and 222 each contain a value, for example a byte linked to a register, representing the read status of the memory sector in which it is stored. In the example shown, memory space 202 of the first sector 200 has the value OBK_Sel_0. This value means, for example, that the first sector is not read when security data is requested. In In the example shown, memory space 222 of the second sector 2220 has the value OBK_SEL_1. This value means, for example, that the second sector is the one that is read when security data is requested.
[0040] In an example, an OBK_SEL_2 value means, for example, that the corresponding sector is the one that is read when security data is requested.
[0041] When one of the security data, for example in the example shown, the Key 20 data in memory space 208 of sector 200, is updated, it is updated in the other sector, that is, sector 220, which is called the replacement sector. Then, once the update is complete, the status of the replacement sector is changed so that it becomes the current sector, that is, the one that is read when a security data is requested. To do this, the memory space 228 with the corresponding index in the other sector 220 must first be erased. In one example, the entire sector 220, that is, all the memory spaces dedicated to security data, is erased and not just memory space 228. Then the new version of the security data, Key_20_update, is written into sector 228, for example following a software command implemented with memory interface 106.The still-valid security data is then copied from sector 200 to the second sector 220, into the respective index memory spaces, with the exception of memory space 228 where the data has been updated.
[0042] Fig. 3 represents an operating method of the circuit of Fig. 1 according to an example.
[0043] More specifically, the example shown illustrates a method of updating one of the security data, such as the Key 20 data as in the previous figure.
[0044] In this example, at the beginning of the process, sector 200 is the current sector, that is, the sector that is read when security data is required, and sector 220 is the substitution sector. In other words, at the beginning of the process, the value of the memory space dedicated to the read status of sector 200 is OBK_Sel_1 or OBK_Sel_2, and the value of the memory space dedicated to the read status of sector 220 is OBK_Sel_0.
[0045] In this example, sector 220 is empty at the start of the process, that is to say that the memory spaces dedicated to security data have been previously erased during a previous execution of the process as will be described below.
[0046] In a first step 301 (Write new version of Data in 220), the new version of the security data to be updated is written to the second sector 220, for example, using a software command implemented with memory interface 106 via reading from an ALT_SECT register. The writing takes place in the memory space having the same memory index as the memory space containing the data to be updated. in sector 200. In one example, this writing is done directly using an address bitmap linked to sectors 200 and / or 220.
[0047] In the continuation of the process, steps 302, 304, 306, 307, 308, 310, 312 and 314 are implemented by a state machine 300, for example implemented in the memory interface or in a circuit of the microcontroller 100.
[0048] In the next step 302 (SWAP Request), a copy of the data from sector 200 which are valid, i.e. which have not been updated, begins.
[0049] In the next step 304 (Addr_index=0), the copying begins with the memory space whose memory address index is 0.
[0050] In the next step 306 (data in 220 is virgin?), the state machine 300 checks whether the memory space at address index 0 is empty in sector 220.
[0051] If yes (branch Y), step 307 (Copy data from 200 to 220) is carried out and if no (branch N), step 310 (end of sector?) is implemented.
[0052] Step 307 consists of copying the security data present in the index of sector 200, whose value is that in output Y of step 306, to the memory space having the same index in sector 220.
[0053] For the memory space of sector 220 whose index 228 is that of the updated data Key_20_update, step 306 returns a negative result (branch N) because the data is already present in sector 220 before the copying of the other data from sector 200. This branch N is followed by step 310.
[0054] In step 310, if (branch Y) the address index corresponds to the value of the last address index relating to security data in sector 220, then step 312 (Erase current sector: 200) is implemented. Otherwise, step 308 is implemented.
[0055] Step 308 (Addr_index+1) consists of incrementing the value of the address index Addr_index by one unit, which then becomes Addr_index+1.
[0056] In step 312 (Erase current sector: 200), sector 200, which is the current sector, is erased by state machine 300. In other words, the state machine erases the memory spaces in sector 200 that are dedicated to security data; that is, the memory space dedicated to read status is not erased.
[0057] Then, in step 314 (Swap current / aletmate sector 220 / 220), the status of sector 200 is assigned to sector 220. In other words, the state machine 300 changes the OBK_Sel_1 value of sector 200 to the OBK_Sel_0 value and the OBK_Sel_0 value of sector 200 to the OBK_Sel_1 value. At the end of the process in [Fig. 3], sector 220 becomes the current sector and sector 200 becomes the substitution sector.
[0058] In this example of a process, the state machine performs all steps 302 to 314. This makes the microcontroller vulnerable because if a power outage or a The microcontroller reset occurs between steps 312 and 314, so the sector status change will not have been performed, but the current sector, i.e., sector 200, will have already been erased or corrupted. During the reboot, current sector 200 will be read, but it will then contain either no data or corrupted data.
[0059] It should be noted that step 312 cannot be implemented between steps 302 and 304 since it is necessary to copy the valid security data from sector 200 to sector 220 and it is necessary to keep the valid data in the current sector 200 until the copying is completed, i.e. until step 310 has implemented the associated branch Y.
[0060] One possible solution is to check, at each reboot, whether at least one of the steps 302 to 314 implemented by the state machine was interrupted during the reset. If so, a load option byte will be launched to update the memory space of sector 200 related to the read status to OBK_Sel_0. However, this has the disadvantage of having to be implemented at the startup of each application.
[0061] The embodiments described below provide for overcoming these drawbacks by implementing a method for updating a security data stored in the first sector 200, a first status (OBK_Sel_1 or OBK_Sel_2) being assigned to the first sector 200, the method comprising the following successive steps: - erase the contents of the second memory sector 220, - write a new version of the security data in the second sector 220; and - assign the first status (OBK_Sel_1 or OBK_Sel_2) to the second sector 220.
[0062] This prevents the loss of existing keys even if a reset or power loss occurs before the sector read status is changed.
[0063] Fig. 4 represents a method of operation of the microcontroller of Fig. 1 according to one embodiment.
[0064] More specifically, the example shown illustrates a method of updating one of the security data, for example the Key 20 data as in the previous figure.
[0065] In this example, at the beginning of the process, sector 200 is the current sector and sector 220 is the replacement sector.
[0066] In a first step 412 (Erase alterate sector: 220), sector 220, which is the replacement sector (OBK_Sel_0), has its content dedicated to security data erased, for example by memory interface 106, following a software command (alternate_OBK_erase).
[0067] In a subsequent step 414 (Write new version of Data in 220), the new version of the Key 20 update security data is copied into sector 220, for example, using memory interface 106, following another software command (ALT_SEC). In one example, this writing is done directly via a bitmap associated with sectors 200 and / or 220.
[0068] Following step 414, steps 302, 304, 306, 307, 308, 310 and 314 are implemented in a similar manner to those of [Fig.3] except that step 312 is no longer present and that, in step 310, when branch Y is taken, then step 314 is directly implemented without step 312 being executed.
[0069] This ensures that if a power loss or reset occurs during the clearing step 414, it does not affect the operation of the state machine that implements steps 302, 304, 306, 307, 308, 310, and 314. Thus, if a power loss or reset occurs during the implementation of steps 302, 304, 306, 307, 308, 310, and 314 of [Fig. 4], then the current sector remains valid since there is no further clearing of the current sector in the steps implemented by the state machine 300. This adds robustness against power outages or forced resets.
[0070] In addition, since fewer steps are implemented by the state machine 300, this increases the processing speed.
[0071] Various embodiments and variations have been described. Those skilled in the art will understand that certain features of these various embodiments and variations could be combined, and other variations will be apparent to those skilled in the art. In particular, step 412 can also be implemented by a state machine that is different from state machine 300.
[0072] Finally, the practical implementation of the embodiments and variants described is within the reach of a person skilled in the art, based on the functional indications given above.
Claims
Demands
1. A method for updating a security data (Key 20) stored in a first sector (200) of a non-volatile memory (104) of a microcontroller (100), a first status (OBK_Sel_1, OBK_Sel_2) being assigned to the first sector (200), the method comprising the following successive steps: - erase (alternate_OBK_erase) the contents of a second sector (220) of the non-volatile memory, different from the first sector (200), - write a new version of the security data (Key 20 update) in the second sector (220); and - assign the first status (OBK_Sel_1, OBK_Sel_2) to the second sector (220).
2. Method according to claim 1, wherein each sector (200, 220) comprises several security data.
3. A method according to claim 2, wherein, after writing the new version of the security data into the second sector and before assigning the first status to the second sector, the security data stored in the first sector (200) are copied sequentially into the second sector (220).
4. Method according to claim 3, wherein the copying of said security data from the first sector (200) into the second sector (220) is carried out by a state machine (300).
5. A method according to claim 3 or 4, wherein the first sector (200) and the second sector (220) comprise memory spaces each referenced by an address index (Addr_index), said security data of the first sector (200) each being stored in one of said memory spaces of the first sector (200), and each copied into the second sector (220) if the memory space of the second sector (220), having an address index corresponding to the address index of the memory space associated with the security data of the first sector to be copied, is empty.
6. A method according to any one of claims 1 to 5, wherein the erasure of the contents of the second sector is implemented by a memory control circuit (106) following the first software command (alternate_OBK_erase).
7. A method according to claim 6, wherein the writing of the new version of the security data in the second sector is put implemented by said control circuit (106) following a second software command.
8. A method according to any one of claims 1 to 7, wherein a second status is assigned to the first sector once the first status has been assigned to the second sector.
9. Method according to claim 8, wherein, prior to the update, the first status (OBK_Sel_1, OBK_Sel_2) is assigned to the first sector and the second status (OBK_Sel_0) is assigned to the second sector (220).
10. A method according to claim 8 or 9, wherein each memory sector includes a space dedicated to storing the status assigned to the sector.
11. A method according to any one of claims 1 to 10, wherein only the memory sector affected by the first status (OBK_Sel_1, OBK_Sel_2) is read.
12. A method according to any one of the preceding claims, wherein the security data is or are encryption keys.
13. Microcontroller (100) comprising a memory having a first memory sector (200) and a second memory sector (220) different from the first sector, a security data (Key 20) to be updated being stored in the first sector (200), a first status (OBK_Sel_1, OBK_Sel_2) being assigned to the first sector (200), the microcontroller (100) being configured to implement the method according to any one of claims 1 to 12.
14. System comprising a microcontroller according to claim 13 and an update unit (190) external to the microcontroller (100); the update unit being configured to transmit, to the microcontroller (100) and during an update, said new version of the security data.
Citation Information
Patent Citations
Memory system and control method
US20210405907A1
Method for managing a zone of sensitive data in a flash memory
US20230384953A1