Security chip and statistical method for Flash update times of security chip
By designing address mapping tables and Flash updates cumulative pages in the security chip, dynamically record the number of Flash erases and generate a life warning, the problem of the inability to accurately ensure the number of erases caused by space limitations in the existing technology is solved, and accurate prediction and early warning of the life of the security chip is achieved.
Patent Information
- Application Number
- CN202311759565.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-20
- Publication Date
- 2025-06-20
AI Technical Summary
Due to the limited page space of the pre-allocated number of erases, the existing security chips cannot accurately ensure the storage of Flash erases, and cannot accurately predict the chip life, which in turn cannot generate a failure warning in advance.
Design a security chip with built-in address mapping table and Flash update cumulative page. Through the cooperation of the Flash update number field and Flash update cumulative page in the address mapping table, dynamically record the number of Flash erases, and generate an early warning when the accumulated page reaches the design life threshold.
Accurate statistics and life warning of the number of times the security chip Flash erases are realized, avoiding functional abnormalities caused by the arrival of the chip life, and ensuring the normal use of IoT devices.
Smart Images

Figure CN120179570A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of security chips, and in particular to a security chip and a method for counting the number of Flash updates of a security chip. Background Art
[0002] During the use of the functions of Internet of Things devices, data will be saved to the Flash of the security chip. Due to the limitation of the number of erase and write cycles of the Flash of the security chip, when the number of erase and write cycles exceeds the capacity of the Flash, data saving will fail, affecting the normal functions of the Internet of Things devices.
[0003] The number of times the functions of Internet of Things devices are used may be affected by the usage environment and scenarios, resulting in different numbers of erase and write cycles of the Flash of the security chips in different Internet of Things devices at the same time. Since the lifespan of the security chip is directly related to the number of erase and write cycles of the Flash of the security chip, it is impossible to accurately estimate the service life of the security chip, let alone generate a warning before the chip lifespan ends.
[0004] In existing security chips, generally a page for counting the number of erase and write cycles is pre-allocated to count the number of erase and write cycles of a specified address or address block. Each time the area to be counted is updated, the number of updates in the pre-allocated page for counting the number of erase and write cycles is incremented by one, so that the number of counts is greatly restricted by the allocated space. If the pre-allocated space is small, the erase and write lifespan of the counting page may have reached, resulting in the inability to correctly save the number of Flash erase and write cycles and the inability to accurately predict the number of Flash erase and write cycles.
[0005] Therefore, during the use of the security chip, due to the limited space of the pre-allocated page for counting the number of erase and write cycles, the number of Flash erase and write cycles cannot be accurately saved, making it impossible to accurately predict the number of Flash erase and write cycles, and thus unable to generate a warning of security chip failure in advance. Summary of the Invention
[0006] In view of the above analysis, embodiments of the present invention aim to provide a security chip and a method for counting the number of Flash updates of a security chip to solve the problem that the number of Flash erase and write cycles of an existing security chip cannot be accurately saved due to the limited space of the pre-allocated page for counting the number of erase and write cycles during use.
[0007] On the one hand, the present invention discloses a security chip, which internally has an address mapping table and a Flash update count accumulation page; wherein,
[0008] A Flash update count field is set in the address mapping table, and N1 bytes are allocated to record the number of Flash updates of the security chip; each time the security chip performs a Flash erase and write, a Flash update is performed;
[0009] The Flash update count cumulative page allocates N2 bytes to record the number of times the Flash update count of the security chip reaches the maximum value carried by N1 bytes.
[0010] When the Flash update count recorded in the Flash update count field reaches the maximum value carried by N1 bytes, the Flash update count cumulative page is incremented by 1, and the Flash update count recorded in the Flash update count field is set to zero.
[0011] Based on the above solution, the present invention has also made the following improvements:
[0012] Further, in the Flash update count cumulative page, the maximum value carried by N2 bytes is designed as the lifetime threshold of the security chip.
[0013] When the value recorded in the Flash update count cumulative page reaches the maximum value carried by N2 bytes, a lifetime termination warning of the security chip is issued.
[0014] Further, the address mapping table further includes a mapping relationship table between logical addresses and physical addresses, and a data check code within the mapping relationship table.
[0015] Further, the address mapping table adopts a file rolling storage method to implement the rolling storage of files.
[0016] On the other hand, the present invention also discloses a method for counting the Flash update count of a security chip, the method including:
[0017] Each time the security chip performs a Flash erase and write, the Flash update count field in the address mapping table is updated.
[0018] Determine whether the Flash update count field in the updated address mapping table reaches the storage maximum value of the Flash update count field.
[0019] If so, update the Flash update count field and the Flash update count cumulative page; then, find the rolling destination page and mapping page, and update the destination data page and the address mapping table.
[0020] Based on the above solution, the present invention has also made the following improvements:
[0021] Further, the method further includes:
[0022] If not, directly find the rolling destination page and mapping page, update the destination data page and the address mapping table, and end.
[0023] Further, when updating the Flash update times field and the Flash update times cumulative page, execute:
[0024] Increment the Flash update times cumulative page by 1, and set the Flash update times recorded in the Flash update times field to zero.
[0025] Further, when updating the Flash update times field and the Flash update times cumulative page, also execute:
[0026] After incrementing the Flash update times cumulative page by 1, also determine whether the value recorded in the latest Flash update times cumulative page reaches the storage maximum value of the Flash update times cumulative page;
[0027] If so, give a warning for the end of the life of the security chip; then, set the Flash update times recorded in the Flash update times field to zero;
[0028] If not, directly set the Flash update times recorded in the Flash update times field to zero.
[0029] Further, if N1 bytes are allocated to the Flash update times field, the storage maximum value of the Flash update times field is the maximum value carried by N1 bytes.
[0030] Further, if N2 bytes are allocated to the Flash update times cumulative page, the storage maximum value of the Flash update times cumulative page is the maximum value carried by N2 bytes.
[0031] Compared with the prior art, the present invention can at least achieve one of the following beneficial effects:
[0032] The security chip and the method for counting the Flash erase / write times of the security chip provided by the present invention do not need to allocate corresponding storage spaces according to the life of the security chip to be counted, and the counting times are not limited by the space size, and can truly count all the erase / write times during the use of the security chip. When the Flash erase / write times are greater than the capabilities of the security chip, a warning signal is generated to prompt the user to replace the security chip to ensure the normal use of the functions of the Internet of Things device.
[0033] In the present invention, the above technical solutions can also be combined with each other to achieve more preferred combined solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can be obvious from the description, or understood by implementing the present invention. The objectives and other advantages of the present invention can be realized and obtained from the content specifically pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings are only for the purpose of showing specific embodiments and are not considered as limitations of the present invention. Throughout the drawings, the same reference signs denote the same components;
[0035] Figure 1 It is a flowchart of the method for counting the Flash update times of the security chip provided by the embodiment of the present invention. Specific embodiments
[0036] The preferred embodiments of the present invention will be specifically described below with reference to the accompanying drawings. The accompanying drawings form a part of this application and are used together with the embodiments of the present invention to explain the principles of the present invention, rather than to limit the scope of the present invention.
[0037] A specific embodiment of the present invention provides a security chip. The security chip internally stores an address mapping table and a Flash update times accumulation page. Among them, a Flash update times field is set in the address mapping table, and N1 bytes are allocated to record the Flash update times of the security chip. Each time the security chip performs a Flash erase and write operation, a Flash update is executed. The Flash update times accumulation page is allocated N2 bytes to record the number of times the Flash update times of the security chip reach the maximum value carried by N1 bytes. When the Flash update times recorded in the Flash update times field reach the maximum value carried by N1 bytes, the Flash update times accumulation page is incremented by 1, and the Flash update times recorded in the Flash update times field are set to zero.
[0038] Preferably, in this embodiment, the maximum value carried by N2 bytes is designed as the life threshold of the security chip. When the value recorded in the Flash update times accumulation page reaches the maximum value carried by N2 bytes, a life termination warning of the security chip is given.
[0039] Next, the address mapping table and the Flash update times accumulation page are introduced in detail as follows:
[0040] 1. Address mapping table
[0041] In the address mapping table, in addition to setting the Flash update times field, it also includes a mapping table of logical addresses and physical addresses and a data check code in the mapping table.
[0042] In this embodiment, the address mapping table adopts a file rolling storage method to achieve the rolling storage of files. Specifically, the address mapping table saves the correspondence between the logical address of the updated file and the new physical address, and confirms the valid address page of the file by looking up the correspondence between the logical address and the physical address. That is, after the file is updated, the latest physical address will be stored.
[0043] Each time the content of the security chip is updated, such as a file update, the address mapping table is updated once, and the Flash update times field in the address mapping table is updated simultaneously.
[0044] The address mapping table in this embodiment is shown in Table 1. In Table 1, the Flash update times field occupies 4 bytes.
[0045] Table 1 Address Mapping Table
[0046] Data item length Content 4 Checksum 4 Flash update count 4 Mapping table identifier 1 Mapping table entry 1 1 Mapping table entry 2
[0047] 2. Flash Update Times Cumulative Page
[0048] Table 2 Flash Update Times Cumulative Page
[0049] Data item length Content 4 Flash update threshold reached count
[0050] The Flash update times cumulative page is shown in Table 2. In the specific implementation process, the Flash update times cumulative page needs to allocate a space of 1 page size.
[0051] In the specific implementation process, each time the security chip performs a Flash update, the Flash update times field in the address mapping table is incremented by 1. If the Flash update times in the address mapping table reach the set maximum value (when the Flash update times field allocates 4 bytes, the set maximum value is the maximum value that 4 bytes can record), the value in the Flash update times count cumulative page is incremented by 1. Since in this embodiment, the maximum value carried by N2 bytes is designed as the life threshold of the security chip, if the value in the Flash update times cumulative page (saving the cumulative value of the card's Flash update) is greater than the designed life of the security chip, the user is reminded by means such as text messages and on-screen prompts. The life termination warning function is realized.
[0052] In this embodiment, taking the Flash update times field and the Flash update times cumulative page both allocating 4 bytes as an example, the Flash update times is the number of cycles within the record of 4-byte times, from 0 to FFFFFFFF; after reaching FFFFFFFF, the counting starts from 0 again. And the Flash update times cumulative page is the number of times when the Flash update times reaches FFFFFFFF.
[0053] In summary, the security chip provided in this embodiment stores the Flash erase count in a dynamic manner. Through the cooperation of the cumulative page of Flash update counts and the Flash update count field set in the address mapping table, the Flash update count of the security chip can be recorded to the greatest extent, and the problem that the statistical count of the erase count of the security chip is limited by the allocated space is well solved. By designing the maximum value carried by all bytes in the cumulative page of Flash update counts as the life threshold of the security chip, it is convenient to carry out the life warning of the security chip.
[0054] Another specific embodiment of the present invention also discloses a method for counting the Flash update count of a security chip. The flowchart is as Figure 1 shown and includes the following steps:
[0055] Step S1: Each time the security chip performs a Flash erase, update the Flash update count field in the address mapping table.
[0056] Step S2: Determine whether the Flash update count field in the updated address mapping table reaches the storage maximum value of the Flash update count field.
[0057] In this embodiment, the security chip will provide the single-page Flash erase count capability according to its own situation. Accordingly, the storage maximum value of the Flash update count field is generally set to the Flash space used in a single page * %2 of the recycled Flash space.
[0058] Step S3: If not, find the destination page and mapping page to be scrolled, update the destination data page and the address mapping table, and end.
[0059] Step S4: If so, update the Flash update count field and the cumulative page of Flash update counts; then, find the destination page and mapping page to be scrolled, update the destination data page and the address mapping table, and end.
[0060] In Step S4, the update of the Flash update count field and the cumulative page of Flash update counts is specifically performed as follows: increment the cumulative page of Flash update counts by 1, and set the Flash update count recorded in the Flash update count field to zero.
[0061] More specifically, in Step S4, after incrementing the cumulative page of Flash update counts by 1, it is also determined whether the value recorded in the latest cumulative page of Flash update counts reaches the storage maximum value of the cumulative page of Flash update counts; if so, a life termination warning of the security chip is issued (such as reporting by SMS / display on the screen); then, the Flash update count recorded in the Flash update count field is set to zero;
[0062] Otherwise, directly set the Flash update count recorded in the Flash update count field to zero.
[0063] It should be noted that the security chip can still be used normally after the warning. The set threshold is the minimum Flash update count guaranteed by the chip, and the actual update count is usually greater than the count guaranteed by the chip manufacturer; only a warning message is generated to remind the user.
[0064] In this embodiment, if N1 bytes are allocated for the Flash update count field, the maximum storage value of the Flash update count field is the maximum value carried by N1 bytes. If N2 bytes are allocated for the Flash update count cumulative page, the maximum storage value of the Flash update count cumulative page is the maximum value carried by N2 bytes.
[0065] In step S4, the specific process of finding the target page and mapping page for scrolling, and updating the target data page and address mapping table is described as follows: In the specific implementation process, if a certain file needs to be updated, the content before the update may be saved on the first page, and the content after the update is saved on the second page. Through this step, the storage page of the current file content is found. Update the target data page, that is, store the modified file content in the Flash; update the address mapping table, that is, store the mapping relationship between the modified logical address and physical address in the Flash.
[0066] The Flash update count statistical method of the security chip provided by the embodiment of the present invention realizes the warning function for the end of the life of the security chip, and solves the problem that the security chip has abnormal functions due to the reaching of the Flash erase life, which brings the problem of inaccessibility to the users of Internet of Things devices.
[0067] The key technical points and innovations of the present invention are described as follows:
[0068] 1. After the life of the security chip reaches its end, a warning signal can be generated to prompt the user to replace it, avoiding serious problems caused by the inaccessibility of the device.
[0069] 2. The address mapping page follows the physical page to scroll, and there is no need to allocate a fixed-size Flash space for the address mapping page. Since the address mapping page is also stored in the Flash, there will also be a life problem. If a fixed-size space is allocated to store the address mapping page, then the statistical count is the space * the life of a single-page Flash; this solution does not use fixed-position storage, which can solve the problem that the life count is affected by the allocated Flash space.
[0070] Those skilled in the art can understand that all or part of the processes for implementing the methods of the above embodiments can be completed by instructing relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. Among them, the computer-readable storage medium is a disk, an optical disc, a read-only memory or a random access memory, etc.
[0071] As mentioned above, the above are only the preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A security chip, characterized in that, The security chip internally contains an address mapping table and a Flash update count cumulative page; wherein, A Flash update count field is set in the address mapping table, and N1 bytes are allocated to record the Flash update count of the security chip; each time the security chip performs a Flash erase and write operation, a Flash update is executed. The Flash update count cumulative page, with N2 bytes allocated, is used to record the number of times the Flash update count of the security chip reaches the maximum value that can be carried by N1 bytes. When the Flash update count recorded in the Flash update count field reaches the maximum value that can be carried by N1 bytes, the Flash update count cumulative page is incremented by 1, and the Flash update count recorded in the Flash update count field is set to zero.
2. The security chip according to claim 1, characterized in that, In the Flash update count cumulative page, the maximum value that can be carried by N2 bytes is designed as the life threshold of the security chip. When the value recorded in the Flash update count cumulative page reaches the maximum value that can be carried by N2 bytes, a life termination warning for the security chip is issued.
3. The security chip according to claim 1 or 2, characterized in that, The address mapping table also includes a mapping table of logical addresses and physical addresses, and a data check code within the mapping table.
4. The security chip according to claim 3, characterized in that, The address mapping table adopts a file rolling storage method to achieve file rolling storage.
5. A method for counting the number of Flash updates of a security chip, characterized in that, The method includes: Each time the security chip performs a Flash erase and write operation, the Flash update count field in the address mapping table is updated. Determine whether the Flash update count field in the updated address mapping table reaches the storage maximum value of the Flash update count field. If so, update the Flash update count field and the Flash update count cumulative page; then, find the destination page and the mapping page for rolling, and update the destination data page and the address mapping table.
6. The method for counting the number of Flash updates of a security chip according to claim 5, characterized in that, The method also includes: If not, directly find the destination page and the mapping page for rolling, update the destination data page and the address mapping table, and end.
7. The method for counting the number of Flash updates of a security chip according to claim 5 or 6, characterized in that, For the operation of updating the Flash update count field and the Flash update count cumulative page, execute: Increment the Flash update count cumulative page by 1, and set the Flash update count recorded in the Flash update count field to zero.
8. The method for counting the number of Flash updates of a security chip according to claim 7, characterized in that, For the operation of updating the Flash update count field and the Flash update count cumulative page, also execute: After incrementing the Flash update count cumulative page by 1, also determine whether the value recorded in the latest Flash update count cumulative page reaches the storage maximum value of the Flash update count cumulative page. If so, issue a life termination warning for the security chip; then, set the Flash update count recorded in the Flash update count field to zero. If not, directly set the Flash update count recorded in the Flash update count field to zero.
9. The method for counting the number of Flash updates of a security chip according to claim 8, characterized in that, If N1 bytes are allocated to the Flash update count field, the storage maximum value of the Flash update count field is the maximum value that can be carried by N1 bytes.
10. The method for counting the number of Flash updates of a security chip according to claim 9, characterized in that, If N2 bytes are allocated to the Flash update count cumulative page, the storage maximum value of the Flash update count cumulative page is the maximum value that can be carried by N2 bytes.