Hierarchical starting method and device of chip, equipment and storage medium
By executing the hierarchical startup method of the boot program and the user program when the chip is powered on, the locking problem caused by the unstable situation of the chip is solved, and the reliable connection of the chip and the improvement of the development efficiency are achieved.
Patent Information
- Application Number
- CN202411190596.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-06
AI Technical Summary
During product development and debugging, the chip is abnormally locked due to unstable conditions such as abnormal communication interruption or system power failure, and cannot be connected or erased again, resulting in high development costs and low efficiency.
When the chip is powered on, the boot program will be executed to erase the data on the storage area of the user program, and determine whether the current state meets the preset program jump conditions. If it is satisfied, it will be re-errored, and the boot program will be used and The user program's hierarchical startup method prevents locking.
It avoids accidental chip locking, allows reuse of chips, shortens product development cycle and cost, and improves development efficiency.
Smart Images

Figure CN119088473A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of chip design, and in particular to a hierarchical startup method, device, equipment and storage medium for a chip. Background Art
[0002] During the early stage of product development and debugging, the target firmware data will be frequently downloaded to the target chip through a computer host or main control chip and other devices connected to the target chip based on the agreed communication interface.
[0003] During firmware download, due to some unstable conditions, the chip program may be abnormally locked. For example, communication is abnormally interrupted or the system is powered off. When the chip program is abnormally locked, the chip cannot be connected to the communication or erased again.
[0004] At this time, it is usually necessary to replace the chip to continue developing and debugging the product, which results in high product development costs, prolonged program development cycles, and reduced program development efficiency. Summary of the invention
[0005] The present invention provides a hierarchical startup method, device, equipment and storage medium for a chip to prevent the chip from being accidentally locked and unable to connect.
[0006] According to one aspect of the present invention, a hierarchical startup method of a chip is provided, the method comprising:
[0007] When the chip is powered on, the boot program is executed to erase and write data in the storage area of the user program;
[0008] During the execution of the boot program, determining whether the current state of the chip satisfies a preset program jump condition;
[0009] When the current state of the chip meets the preset program jump condition, jump to the user program;
[0010] Otherwise, re-execute the boot program to erase and write data in the storage area of the user program.
[0011] Optionally, the method includes:
[0012] During the execution of the boot program, determining whether the chip receives an instruction to stop starting a user program;
[0013] When the chip receives the instruction to stop starting the user program, it is determined that the current state of the chip does not meet the preset program jump condition.
[0014] Optionally, the method includes:
[0015] During the execution of the boot program, determining whether the execution time of the boot program reaches a preset time threshold;
[0016] During the period from when the boot program starts to execute until the execution time reaches the preset time threshold, it is determined whether the chip receives an instruction to stop starting the user program.
[0017] Optionally, the method includes:
[0018] During the period from when the boot program starts to execute until the execution time reaches the preset time threshold, the chip does not receive the instruction to stop starting the user program, and determines that the current state of the chip meets the preset program jump condition.
[0019] Optionally, the method further includes:
[0020] Verifying the user program;
[0021] When the user program fails to pass the verification, it is determined that the current state of the chip does not satisfy the preset program jump condition.
[0022] Optionally, the method includes:
[0023] Obtaining a program end address of the user program, and determining the size of the user program according to the program end address;
[0024] Calculate a first digest value of the user program using a digest algorithm according to the size of the user program;
[0025] Reading the stored asymmetric algorithm public key hash value, and when determining that the public key verification is passed according to the public key hash value, verifying the user program signature value to obtain a second summary value of the user program;
[0026] When the first digest value is consistent with the second digest value, it is determined that the user program has passed the verification; otherwise, it is determined that the user program has failed the verification.
[0027] Optionally, the boot program is solidified in a non-volatile memory, the permission is set to read-only, and the boot program entry is set at the memory start address of the chip.
[0028] According to another aspect of the present invention, a hierarchical startup device for a chip is provided, the device comprising:
[0029] The data erasing module is used to execute the boot program to erase the data in the storage area of the user program when the chip is powered on;
[0030] A program jump judgment module, used to judge whether the current state of the chip meets a preset program jump condition during the execution of the boot program;
[0031] The program jump module is used to jump to the user program when the current state of the chip meets the preset program jump condition.
[0032] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0033] at least one processor; and
[0034] a memory communicatively connected to the at least one processor; wherein,
[0035] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the hierarchical startup method of a chip described in any embodiment of the present invention.
[0036] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, wherein the computer instructions are used to enable a processor to implement the hierarchical startup method of a chip described in any embodiment of the present invention when executed.
[0037] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the hierarchical startup method of a chip according to any embodiment of the present invention is implemented.
[0038] The technical solution of the embodiment of the present invention is to execute a boot program to erase data in the storage area of the user program when the chip is powered on; in the process of executing the boot program, it is determined whether the current state of the chip meets the preset program jump condition; when the current state of the chip meets the preset program jump condition, it jumps to the user program, thereby solving the problem of accidental locking of the chip and inability to connect when unstable situations occur during product development. Accidental locking of the chip can be avoided during the product development process, so that the chip can be reused, the product development cycle and cost can be shortened, and the product development efficiency can be improved.
[0039] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0041] Figure 1 is a flow chart of a hierarchical startup method of a chip provided in an embodiment of the present invention;
[0042] Figure 2 is a schematic diagram of program storage provided according to an embodiment of the present invention;
[0043] Figure 3 is a flow chart of another chip hierarchical startup method provided in an embodiment of the present invention;
[0044] Figure 4 It is a schematic diagram of a program jump flow in a hierarchical startup method of a chip provided according to an embodiment of the present invention;
[0045] Figure 5 is a flow chart of a hierarchical startup method of another chip provided in an embodiment of the present invention;
[0046] Figure 6 A flowchart of user program verification in a hierarchical startup method of a chip provided according to an embodiment of the present invention;
[0047] Figure 7 is a flow chart of another hierarchical startup method of a chip provided in an embodiment of the present invention;
[0048] Figure 8 is a schematic structural diagram of a hierarchical startup device of a chip provided in an embodiment of the present invention;
[0049] Fig. 9 It is a structural schematic diagram of an electronic device for implementing the hierarchical startup method of a chip according to an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0051] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0052] Figure 1 This is a flowchart of a hierarchical startup method of a chip provided according to an embodiment of the present invention. This embodiment can be applied to the situation where the chip is accidentally locked and cannot be connected during product debugging. The method can be executed by a hierarchical startup device of the chip. The hierarchical startup device of the chip can be implemented in the form of hardware and / or software. The hierarchical startup device of the chip can be configured in an electronic device such as a chip. Figure 1 As shown, the method includes:
[0053] Step 110: When the chip is powered on, the boot program is executed to erase and write data in the storage area of the user program.
[0054] Among them, the chip can be a smart card or a microcontroller (Microprogrammed Control Unit, MCU), etc. The user program can be a software function used to implement a specific function in the product. For example, the user program can be an encryption algorithm or a fingerprint algorithm, etc. The user program can be pre-stored in the chip memory. For example, the user program can be pre-stored in the non-volatile memory (Non-Volatile Memory, NVM) of the chip. The use of NVM can prevent the stored data from disappearing when the chip loses power. The storage format of the user program can be hexadecimal (Hex). During the debugging of the product, the user program can erase and write data.
[0055] The boot program is the first code executed by the embedded system after power-on. It is used to download the user program and update the user program by erasing and writing data in the storage area of the user program to boot the user program.
[0056] Exemplarily, the chip in the embodiment of the present invention may be a security chip. The security chip may be a high-performance, low-power chip with an internal coprocessor and a rich external interface. The security chip may be applied to the following scenarios with high requirements for information security: payment terminals, password keyboards, fingerprint applications, commercial password dedicated algorithm applications, online banking applications, payment applications, etc.
[0057] By always executing the boot program first when the chip is powered on and erasing the data in the storage area of the user program, it is possible to avoid the situation where the security chip is locked when the user program is abnormal or incomplete.
[0058] In order to achieve the goal of always executing the boot program first when the chip is powered on, a program forced execution implementation method can be adopted. Alternatively, in an optional implementation of the embodiment of the present invention, the boot program is solidified in a non-volatile memory, the permission is set to read-only, and the boot program entry is set at the memory start address of the chip.
[0059] By solidifying the boot program in a non-volatile memory, the boot program can be prevented from being lost when the chip loses power unexpectedly. Setting the boot program's permissions to read-only can prevent the boot program from being erased and written when the firmware is downloaded to the chip, causing the boot program to be changed. Among them, setting the boot program's permissions to read-only can be achieved by using a memory protection mechanism to protect the boot program. Specifically, the memory protection mechanism can protect both the boot program entry and the code area to ensure that the boot program is read-only, the user program cannot erase the boot program, the boot program will not be damaged, and the boot program can always be executed when the chip is powered on.
[0060] The boot program entry is set at the chip's memory start address, which can ensure that the boot program can always be executed when the chip is powered on. Figure 2 1 is a schematic diagram of a program storage provided according to an embodiment of the present invention. Figure 2 As shown, the boot program entry can be set at the starting address of the memory so that the boot program is executed when the chip is powered on and reset. The code area of the boot program can be at the end address of the memory. The user program entry can be adjacent to the boot program entry to facilitate program jump. The code area of the user program can be set at the middle address of the memory.
[0061] Step 120: During the execution of the boot program, determine whether the current state of the chip meets the preset program jump condition.
[0062] Among them, whether the current state of the chip meets the preset program jump condition can be to perform multiple tests on the chip to avoid accidental locking when the chip jumps to the user program. For example, the preset program jump condition is used to determine whether the user program in the chip is executable.
[0063] For example, during a firmware update, when the chip loses power unexpectedly, the user program may be incomplete or illegal. When the user program is incomplete or illegal, the user program in the chip cannot be executed. In another example, the user program is complete and legal, but the user program is abnormal, and the user program in the chip cannot be executed. For example, when the user program execution falls into an infinite loop, the user program in the chip cannot be executed.
[0064] One or more of the above situations can be judged by presetting the program jump conditions to ensure that the user program can be executed and avoid accidental locking of the chip.
[0065] Step 130: When the current state of the chip meets the preset program jump condition, jump to the user program.
[0066] When the current state of the chip meets the preset program jump condition, it means that the user program is trustworthy and executable. The boot program can restore the chip to the reset state and jump to the user program to execute the user program.
[0067] Step 140: When the current state of the chip does not satisfy the preset program jump condition, re-execute the boot program to erase data in the storage area of the user program.
[0068] When the current state of the chip does not meet the preset program jump conditions, the boot program is re-executed to erase the data in the storage area of the user program, and the firmware can be updated again to avoid accidental locking caused by the chip executing an unexecutable user program.
[0069] The technical solution of this embodiment is to execute the boot program to erase data in the storage area of the user program when the chip is powered on; in the process of executing the boot program, it is determined whether the current state of the chip meets the preset program jump condition; when the current state of the chip meets the preset program jump condition, it jumps to the user program. The hierarchical startup method of first boot program and then user program solves the problem of accidental locking of the chip and inability to connect when unstable situations occur during product development. Accidental locking of the chip can be avoided during the product development process, so that the chip can be reused, the product development cycle and cost can be shortened, and the product development efficiency can be improved.
[0070] Figure 3 1 is a flowchart of another chip hierarchical startup method provided according to an embodiment of the present invention. This embodiment is a further refinement of the above technical solution. The technical solution in this embodiment can be combined with various optional solutions in one or more of the above embodiments. Figure 3 As shown, the method includes:
[0071] Step 310: When the chip is powered on, the boot program is executed to erase and write data in the storage area of the user program.
[0072] Step 320: During the execution of the boot program, determine whether the chip receives an instruction to stop starting the user program.
[0073] The stop-start user program instruction may be transmitted to the chip by the user through the communication interface. When the user determines that the chip is abnormal, the stop-start user program instruction may be sent to the chip through the communication interface. For example, when the user detects that the user program is abnormal, such as a dead loop, the stop-start user program instruction may be sent to the chip through the communication interface to avoid the chip jumping to the user program and causing execution deadlock.
[0074] In order to avoid unlimited waiting for the stop-start user program instruction, a timing mechanism can be set in the boot program to determine whether the chip has received the stop-start user program instruction within the preset time threshold. For example, the chip receives the stop-start user program instruction within the preset time threshold, and determines that the current state of the chip does not meet the preset program jump condition; the chip does not receive the stop-start user program instruction within the preset time threshold, and determines that the current state of the chip meets the preset program jump condition. Alternatively, it can be determined whether the chip receives the stop-start user program instruction during the user program erasure. For example, during the user program erasure, the chip receives the stop-start user program instruction, and determines that the current state of the chip does not meet the preset program jump condition; during the user program erasure, the chip does not receive the stop-start user program instruction, and determines that the current state of the chip meets the preset program jump condition.
[0075] Specifically, in an optional implementation of an embodiment of the present invention, the method includes: during the execution of the boot program, determining whether the execution time of the boot program reaches a preset time threshold; during the period from the start of the boot program execution until the execution time reaches the preset time threshold, determining whether the chip receives an instruction to stop starting the user program.
[0076] The preset time threshold can be set according to specific requirements. For example, the preset time threshold can be 2 seconds. The preset time threshold can be stored in a register of the chip.
[0077] Step 330: during the period from when the boot program starts to execute until the execution time reaches a preset time threshold, when the chip receives an instruction to stop starting the user program, it is determined that the current state of the chip does not meet the preset program jump condition.
[0078] Step 340: During the period from when the boot program starts to execute until the execution time reaches a preset time threshold, the chip does not receive an instruction to stop starting the user program, and determines that the current state of the chip meets the preset program jump condition.
[0079] Step 350: When the current state of the chip meets the preset program jump condition, jump to the user program.
[0080] Step 360: When the current state of the chip does not satisfy the preset program jump condition, re-execute the boot program to erase data in the storage area of the user program.
[0081] Figure 4 FIG. 1 is a schematic diagram of a program jump flow in a hierarchical startup method of a chip according to an embodiment of the present invention. Figure 4 As shown, when the boot program starts to execute, the timing is started by the timing mechanism in the boot program. The boot program reads the preset time threshold from the storage area of the chip, such as the register, and determines whether the boot program execution time reaches the preset time threshold. If the boot program execution time does not reach the preset time threshold, it is determined whether the chip receives a stop-start user program instruction. If the chip receives a stop-start user program instruction during the period from when the boot program starts to execute until the execution time reaches the preset time threshold, it is determined that the current state of the chip does not meet the preset program jump condition, and the boot program is re-executed.
[0082] If the boot program execution time reaches the preset time threshold, and the chip does not receive the stop starting user program instruction during the period from the start of the boot program execution until the execution time reaches the preset time threshold, it is determined that the current state of the chip meets the preset program jump condition, and the chip can exit the boot program and jump to the user program.
[0083] In an optional implementation of an embodiment of the present invention, during the period from when the boot program starts executing until the execution time reaches a preset time threshold, the chip does not receive an instruction to stop starting the user program, and the boot program can set the startup mark of the user program to safe startup to jump to the user program.
[0084] The technical solution of the embodiment of the present invention is to execute a boot program to erase data in a storage area of a user program when the chip is powered on; in the process of executing the boot program, determine whether the chip has received an instruction to stop starting the user program; when the chip receives the instruction to stop starting the user program, determine that the current state of the chip does not meet the preset program jump condition; during the period from the start of the boot program execution to the execution time reaching a preset time threshold, the chip does not receive an instruction to stop starting the user program, and determine that the current state of the chip meets the preset program jump condition; when the current state of the chip meets the preset program jump condition, jump to the user program; when the current state of the chip does not meet the preset program jump condition, re-execute the boot program to erase data in the storage area of the user program, thereby solving the problem of accidental locking of the chip and inability to connect when unstable conditions occur during product development, and avoiding accidental locking of the chip caused by user program abnormalities during product development, so as to reuse the chip, shorten the product development cycle and cost, and improve product development efficiency.
[0085] Figure 5 1 is a flowchart of another chip hierarchical startup method provided according to an embodiment of the present invention. This embodiment is a further refinement of the above technical solution. The technical solution in this embodiment can be combined with various optional solutions in one or more of the above embodiments. Figure 5 As shown, the method includes:
[0086] Step 510: When the chip is powered on, the boot program is executed to erase and write data in the storage area of the user program.
[0087] Step 520: Verify the user program.
[0088] Among them, the verification of the user program can include multiple aspects of verification such as the integrity and legality of the user program. In an optional implementation of the embodiment of the present invention, the method includes: obtaining the program end address of the user program, and determining the size of the user program according to the program end address; according to the size of the user program, using a digest algorithm to calculate the first digest value of the user program; reading the stored asymmetric algorithm public key hash value, and when the public key verification is determined to be passed according to the public key hash value, verifying the user program signature value to obtain the second digest value of the user program; when the first digest value is consistent with the second digest value, determining that the user program verification is passed; otherwise, determining that the user program verification is not passed.
[0089] Figure 6 The present invention is a flowchart of user program verification in a hierarchical startup method of a chip provided according to an embodiment of the present invention. The program start address of the user program is usually fixed. The chip can store the downloaded user program and determine the program end address of the user program. According to the program start address and program end address of the user program, the chip can determine the size of the user program. The size of the user program can be used by the user to verify the integrity and legality of the user program. For example, the size of the user program can directly determine whether the user program is complete.
[0090] The digest algorithm can convert the user program into the first digest value of a fixed-length digital string through a hash function. The digest algorithm encryption process does not require a key, and the first digest value generated by encryption cannot be decrypted. Only by inputting the same plaintext data and passing the same message digest algorithm can the same ciphertext be obtained, which can ensure the security and reliability of user program verification.
[0091] The public key hash value of the asymmetric algorithm can be stored in a one-time programmable area (One Time Programmable, OTP) to be dynamically updated when different user programs are downloaded, and the currently downloaded user program can be verified. The public key hash value of the asymmetric algorithm can be a public key hash value generated by a hash function. In an asymmetric encryption algorithm, the public key and the private key appear in pairs, and the public key and the private key together constitute the basis of encryption and decryption. The public key is used to encrypt data, and the private key is used to decrypt data. In order to verify the validity of the public key and facilitate storage and transmission, the public key is hashed to generate a public key hash value. The hashing process of the public key is irreversible, that is, the original public key cannot be deduced from the hash value. When the public key hash value determines that the public key verification has passed, the public key can be used to verify the signature value of the user program to determine whether the sender of the user program is legal. When the signature verification passes, the data is decrypted by the private key to obtain a second digest value that is pre-generated and stored according to the digest algorithm after the user program is generated. When the first digest value and the second digest value are consistent, it is determined that the integrity and legality of the user program have been verified. The user program verification passes, indicating that the user program is now trusted and executable. The boot program can restore the chip to the reset state and jump to the user program to execute the user program.
[0092] The embodiment of the present invention can detect incomplete or illegal user programs well through the above verification method when communication is interrupted or the chip is abnormally powered off. Figure 6 As shown, when the user program verification fails, it can be determined that the current state of the chip does not meet the preset program jump conditions, and the boot program continues to execute. The instructions can be used to interact with the chip to operate the chip's non-volatile memory to erase and write data to avoid chip locking.
[0093] Step 530: When the user program fails to be verified, it is determined that the current state of the chip does not satisfy the preset program jump condition.
[0094] Step 540: When the user program passes verification, determine whether the current state of the chip meets the preset program jump condition.
[0095] It should be noted that when determining whether the current state of the chip meets the preset program jump condition, the user program check can be combined with whether the chip in the aforementioned embodiment receives the stop start user program instruction to jointly determine whether the current state of the chip meets the preset program jump condition. Figure 6 As shown, within the preset time threshold, when the chip does not receive the instruction to stop starting the user program, the boot program can set the chip's user program startup flag to safe startup, indicating that a user program check needs to be performed before starting the user program. When the chip's startup flag is safe startup, the boot program can perform a user program check.
[0096] Specifically, if the chip receives a command to stop starting the user program during the period from when the boot program starts to execute until the execution time reaches the preset time threshold, it is determined that the current state of the chip does not meet the preset program jump condition. If the chip does not receive a command to stop starting the user program during the period from when the boot program starts to execute until the execution time reaches the preset time threshold, but jumps to the user program, and the user program fails to be verified, it is determined that the current state of the chip does not meet the preset program jump condition. If the chip does not receive a command to stop starting the user program during the period from when the boot program starts to execute until the execution time reaches the preset time threshold, and jumps to the user program, and the user program passes the verification, it is determined that the current state of the chip meets the preset program jump condition.
[0097] Step 550: When the current state of the chip meets the preset program jump condition, jump to the user program.
[0098] Step 560: When the current state of the chip does not satisfy the preset program jump condition, re-execute the boot program to erase data in the storage area of the user program.
[0099] The technical solution of the embodiment of the present invention is to execute a boot program to erase data in a storage area of a user program when the chip is powered on; verify the user program; when the user program verification fails, determine that the current state of the chip does not meet the preset program jump condition; when the user program verification passes, determine that the current state of the chip meets the preset program jump condition; jump to the user program when the current state of the chip meets the preset program jump condition; when the current state of the chip does not meet the preset program jump condition, re-execute the boot program to erase data in the storage area of the user program, thereby solving the problem of accidental locking of the chip and inability to connect when unstable conditions occur during product development, and avoiding accidental locking of the chip caused by power failure of the chip, incomplete or illegal user program during the product development process; the chip can be reused to shorten the product development cycle and cost, and improve product development efficiency.
[0100] Figure 7 FIG. 1 is a flow chart of another chip hierarchical startup method provided according to an embodiment of the present invention. Figure 7 As shown, a use process of the hierarchical startup method of the chip provided by the embodiment of the present invention may be:
[0101] Step 710: Power on the chip.
[0102] Step 720: Execute the boot program to erase data in the storage area of the user program and start timing.
[0103] Step 730: During the execution of the boot program, a preset time threshold is set.
[0104] Step 740: During the period from when the boot program starts to execute until the execution time reaches a preset time threshold, determine whether the chip receives an instruction to stop starting the user program.
[0105] Step 750 : If the chip receives an instruction to stop starting the user program, return to step 720 .
[0106] Step 760: During the period from when the boot program starts to execute until the execution time reaches a preset time threshold, if the chip does not receive an instruction to stop starting the user program, the user program is verified.
[0107] Step 770: If the user program verification fails, return to step 720.
[0108] Step 780: When the user program passes the verification, jump to the user program and execute the user program.
[0109] The technical solution of the embodiment of the present invention adopts a boot program to judge whether the chip has received the instruction to stop starting the user program and to verify the user program, and then starts the chip in a hierarchical manner using the user program, thereby solving the problem that the chip cannot be communicated or erased again after being locked due to an abnormal user program; the problem that the chip cannot be communicated or erased again after being locked due to abnormal power failures is solved by starting with user program verification, and the reliability of the user program is increased; it is achieved that after the chip is locked, there is no need to replace the chip again, and the product debugging system can work normally, thereby saving development costs and improving program development efficiency.
[0110] Figure 8 1 is a schematic diagram of the structure of a hierarchical startup device of a chip according to an embodiment of the present invention. Figure 8 As shown, the device includes: a data erasing module 810, a program jump determination module 820 and a program jump module 830. Among them:
[0111] The data erasing module 810 is used to execute the boot program to erase the data in the storage area of the user program when the chip is powered on;
[0112] The program jump determination module 820 is used to determine whether the current state of the chip meets the preset program jump condition during the execution of the boot program;
[0113] The program jump module 830 is used to jump to the user program when the current state of the chip meets the preset program jump condition.
[0114] Optionally, the data erasing module 810 is further used to re-execute the boot program to erase the data in the storage area of the user program when the current state of the chip does not meet the preset program jump condition.
[0115] Optionally, the device comprises:
[0116] An instruction receiving judgment unit is used to judge whether the chip receives an instruction to stop starting the user program during the execution of the boot program;
[0117] The first program jump judgment unit is used to determine that the current state of the chip does not meet the preset program jump condition when the chip receives the instruction to stop starting the user program.
[0118] Optionally, the device comprises:
[0119] An execution time judgment subunit is used to judge whether the execution time of the boot program reaches a preset time threshold during the execution of the boot program;
[0120] The instruction reception judgment subunit is used to judge whether the chip receives an instruction to stop starting the user program during the period from when the boot program starts to execute until the execution time reaches a preset time threshold.
[0121] Optionally, the device comprises:
[0122] The second program jump judgment unit is used to determine that the current state of the chip meets the preset program jump condition if the chip does not receive the instruction to stop starting the user program during the period from when the boot program starts to execute until the execution time reaches the preset time threshold.
[0123] Optionally, the device comprises:
[0124] A user program verification unit, used for verifying the user program;
[0125] The third program jump judgment unit is used to determine whether the current state of the chip does not meet the preset program jump condition when the user program fails to pass the verification.
[0126] Optionally, the device comprises:
[0127] A user program size determination subunit is used to obtain a program end address of the user program and determine the user program size according to the program end address;
[0128] A first digest value determining subunit, configured to calculate a first digest value of the user program using a digest algorithm according to the size of the user program;
[0129] A second digest value acquisition subunit is used to read the stored asymmetric algorithm public key hash value, and when it is determined that the public key verification passes according to the public key hash value, verify the user program signature value to obtain a second digest value of the user program;
[0130] The user program verification subunit is used to determine that the user program verification has passed when the first digest value is consistent with the second digest value; otherwise, determine that the user program verification has failed.
[0131] Optionally, the boot program is solidified in a non-volatile memory, the permission is set to read-only, and the boot program entry is set at the memory start address of the chip.
[0132] The hierarchical startup device for a chip provided in the embodiment of the present invention can execute the hierarchical startup method for a chip provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0133] Fig. 9 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0134] like Fig. 9 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0135] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0136] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a hierarchical startup method of a chip.
[0137] In some embodiments, the hierarchical startup method of the chip may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the hierarchical startup method of the chip described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the hierarchical startup method of the chip in any other appropriate manner (e.g., by means of firmware).
[0138] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0139] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0140] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0141] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0142] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0143] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0144] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0145] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A hierarchical startup method for a chip, characterized in that: include: When the chip is powered on, the boot program is executed to erase and write data in the storage area of the user program; During the execution of the boot program, determining whether the current state of the chip satisfies a preset program jump condition; When the current state of the chip meets the preset program jump condition, jump to the user program; Otherwise, re-execute the boot program to erase and write data in the storage area of the user program.
2. The method according to claim 1, characterized in that include: During the execution of the boot program, determining whether the chip receives an instruction to stop starting a user program; When the chip receives the instruction to stop starting the user program, it is determined that the current state of the chip does not meet the preset program jump condition.
3. The method according to claim 2, characterized in that include: During the execution of the boot program, determining whether the execution time of the boot program reaches a preset time threshold; During the period from when the boot program starts to execute until the execution time reaches the preset time threshold, it is determined whether the chip receives an instruction to stop starting the user program.
4. The method according to claim 3, characterized in that include: During the period from when the boot program starts to execute until the execution time reaches the preset time threshold, the chip does not receive the instruction to stop starting the user program, and determines that the current state of the chip meets the preset program jump condition.
5. The method according to any one of claims 1 to 4, characterized in that: include: Verifying the user program; When the user program fails to pass the verification, it is determined that the current state of the chip does not satisfy the preset program jump condition.
6. The method according to claim 5, characterized in that include: Obtaining a program end address of the user program, and determining the size of the user program according to the program end address; Calculate a first digest value of the user program using a digest algorithm according to the size of the user program; Reading the stored asymmetric algorithm public key hash value, and when determining that the public key verification is passed according to the public key hash value, verifying the user program signature value to obtain a second summary value of the user program; When the first digest value is consistent with the second digest value, it is determined that the user program has passed the verification; otherwise, it is determined that the user program has failed the verification.
7. The method according to claim 1, characterized in that The boot program is solidified in the non-volatile memory, the permission is set to read-only, and the boot program entry is set at the memory start address of the chip.
8. A hierarchical startup device for a chip, characterized in that: include: The data erasing module is used to execute the boot program to erase the data in the storage area of the user program when the chip is powered on; A program jump judgment module, used to judge whether the current state of the chip meets a preset program jump condition during the execution of the boot program; The program jump module is used to jump to the user program when the current state of the chip meets the preset program jump condition.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the hierarchical startup method of a chip according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the hierarchical startup method of a chip according to any one of claims 1 to 7 when executed.
