Chip starting method and device, equipment, storage medium and program product
By determining and loading the target boot loader of the memory start address during the chip startup process, the problem of large demand for storage space of the chip is solved, the storage space is reused and cost reduction is achieved, and the startup efficiency and performance are improved.
Patent Information
- Application Number
- CN202411199180.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-11-29
AI Technical Summary
The existing chip startup method has a large demand for memory storage space, resulting in an expansion of chip area and high hardware costs.
By determining the target bootloader from the multi-stage bootloader to be executed and loading it to the start address of the memory, ensuring that only one bootloader is executed in the memory at each stage, multiplexing of the storage space is achieved.
Reduces the memory storage space requirement of chips, reduces chip area and hardware costs, and improves startup efficiency and performance.
Smart Images

Figure CN119045902A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of integrated circuit technology, and in particular to a chip startup method, device, equipment, storage medium and program product. Background Art
[0002] Most chips use a multi-stage boot operation mode, which usually includes multiple stages, each stage has its own specific tasks and goals. Each stage in the multi-stage boot operation mode is only responsible for completing a specific task, thereby increasing the startup speed of the chip and facilitating partial firmware updates.
[0003] In related technologies, multi-level startup of a chip is usually implemented by single chain loading. Figure 1 , Figure 1 It is a flow chart of a single chain loading method for multi-stage startup provided by the prior art.
[0004] Existing chips are usually provided with different storage media, such as ROM (Read-Only Memory), RAM (Random Access Memory), non-volatile storage media, etc. Different storage media are used to store different programs.
[0005] by Figure 1 For example, the chip can be provided with bootROM (Boot Read-Only Memory, a read-only memory for storing the boot program) and RAM; wherein, bootROM is Figure 1 It is abbreviated as ROM in Chinese.
[0006] The bootROM stores the startup program (i.e., the bootROM code), and the non-volatile storage medium stores multiple bootloaders (i.e., boot loaders). Each bootloader is responsible for completing only one specific task. Different bootloaders need to be loaded into specific memory (e.g., Figure 1 The loading and execution of each bootloader segment can be considered as a first-level startup. Similarly, the execution of the startup program in the bootROM can also be considered as a first-level startup.
[0007] After the chip is powered on, the startup program stored in the bootROM is automatically executed, loading each bootloader into RAM one by one and executing it until all bootloaders are executed, completing the startup of the chip.
[0008] Specifically, Figure 1As shown in the figure, assuming that the chip is a 4-level boot, A represents the boot program, B, C, and D represent different bootloaders, and different bootloaders need to be loaded and executed in a preset order. After the chip is powered on, the boot program A stored in the bootROM is automatically executed. The boot process of the chip is: the boot program A (i.e., bootROM A) loads bootloader B into RAM; after bootloader B in RAM is executed, bootloader B loads bootloader C into RAM; after bootloader C in RAM is executed, bootloader C loads bootloader D into RAM; finally, bootloader D is executed.
[0009] In the above process, since bootloader B, bootloader C, and bootloader D adopt a single-chain loading method, bootloader B, bootloader C, and bootloader D need to jointly occupy the storage space of the RAM in the microprocessor unit (MPU), that is, they need to satisfy the equation: sizeB + sizeC +sizeD ≤ sizeRAM; where sizeB represents the storage space required by bootloader B, size C represents the storage space required by bootloader C, sizeD represents the storage space required by bootloader D, and sizeRAM represents the storage space of RAM.
[0010] It can be seen from this that when a single-chain loading method is used in the multi-level startup process of a chip, multiple bootloaders need to occupy the storage space of the same memory together. Therefore, the existing chip startup method requires a large amount of memory storage space, which in turn leads to an increase in the chip area and a high hardware cost of the chip. Summary of the invention
[0011] The present invention provides a chip startup method, device, equipment, storage medium and program product, which are used to solve the defects of the chip startup method in the prior art that the storage space of the memory is large, which leads to the expansion of the chip area and the high hardware cost of the chip.
[0012] The present invention provides a chip startup method, comprising: determining a target boot loader program from multiple segments of boot loader programs to be executed; loading the target boot loader program into a first memory based on a startup program; storing the target boot loader program from a starting address of the first memory; executing the target boot loader program; returning to the step of determining the target boot loader program from multiple segments of boot loader programs to be executed, until all boot loader programs to be executed are executed, and the chip startup is completed.
[0013] According to a chip startup method provided by the present invention, the startup program includes common code, the boot loader to be executed does not include common code, and the common code is the same code required for the startup program and at least one boot loader to be executed; before determining the target boot loader from multiple boot loaders to be executed, the method further includes: extracting code from multiple initial boot loaders to obtain common code and the boot loader to be executed corresponding to each initial boot loader; the initial boot loader includes common code; and compiling the startup program including the common code and burning it to a second memory.
[0014] According to a chip startup method provided by the present invention, executing a target boot loader includes: if the target boot loader needs to call a common code when executing, calling the common code from a second memory; and executing the target boot loader based on the common code.
[0015] According to a chip startup method provided by the present invention, after loading a target boot loader into a first memory based on a startup program, the method further includes: performing security verification on the target boot loader; if it is determined that the target boot loader passes the security verification, then determining that the target boot loader can be executed normally.
[0016] According to a chip startup method provided by the present invention, after loading a target boot loader program into a first memory based on a startup program, the method further includes: performing security verification on the target boot loader program; if it is determined that the target boot loader program fails the security verification, terminating the execution of the target boot loader program.
[0017] According to a chip startup method provided by the present invention, the common code includes a cryptographic algorithm code, and the cryptographic algorithm code is used to perform security verification on a target boot loader; based on the startup program, after the target boot loader is loaded into a first memory, it also includes: calling the cryptographic algorithm code from a second memory; based on the cryptographic algorithm code, performing security verification on the target boot loader; if it is determined that the target boot loader passes the security verification, it is determined that the target boot loader can be executed normally.
[0018] The present invention also provides a chip startup device, comprising: a determination module, used to determine a target boot loader program from multiple segments of boot loader programs to be executed; a loading module, used to load the target boot loader program into a first memory based on the startup program; the target boot loader program is stored starting from the starting address of the first memory; an execution module, used to execute the target boot loader program; and a startup module, used to return to the step of determining the target boot loader program from multiple segments of boot loader programs to be executed, until all boot loaders to be executed are executed and the chip startup is completed.
[0019] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any one of the above chip startup methods is implemented.
[0020] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned chip startup methods is implemented.
[0021] The present invention also provides a computer program product, including a computer program, and when the computer program is executed by a processor, any of the above chip startup methods is implemented.
[0022] The chip startup method, device, equipment, storage medium and program product provided by the present invention determine a target boot loader from multiple segments of boot loaders to be executed; based on the startup program, load the target boot loader into a first memory; store the target boot loader from the start address of the first memory; execute the target boot loader; return to the step of determining the target boot loader from multiple segments of boot loaders to be executed, until all boot loaders to be executed are executed, completing the chip startup. Through the above method, a target boot loader is determined from multiple sections of boot loaders to be executed, and based on the startup program, the target boot loader is loaded into the first memory, and the target boot loader is stored from the starting address of the first memory, so that the target boot loader can exclusively occupy the storage space of the first memory. After the target boot loader is executed, the startup program loads the next section of the target boot loader into the first memory. Since the next section of the target boot loader is also stored from the starting address of the first memory, the next section of the target boot loader can overwrite the previous section of the target boot loader, and the next section of the target boot loader can still exclusively occupy the storage space of the first memory, ensuring that only one section of the boot loader can be executed in the first memory in each stage of the multi-level startup of the chip, and realizing the reuse of the storage space of the first memory. Therefore, the storage space of the first memory actually required by the chip is the storage space required by the boot loader with the largest storage space required among the multiple sections of the boot loaders, which can minimize the chip's demand for the storage space of the first memory, thereby reducing the chip area and the hardware cost of the chip. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 It is a flow chart of a single chain loading method for multi-stage startup provided by the prior art.
[0025] Figure 2 This is one of the flow charts of the chip startup method provided by the present invention.
[0026] Figure 3 This is the second flow chart of the chip startup method provided by the present invention.
[0027] Figure 4 It is a structural schematic diagram of the chip starting device provided by the present invention.
[0028] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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 are within the scope of protection of the present invention.
[0030] See also Figure 2 , Figure 2 This is one of the flow charts of the chip startup method provided by the present invention. In this embodiment, the chip startup method includes steps S210 to S240, and each step is specifically as follows: S210: Determine a target boot loader program from multiple boot loader programs to be executed.
[0031] Specifically, after the chip is powered on, the startup program is automatically executed; after the startup program is executed, a target boot loader (ie, target bootloader) can be determined from multiple boot loaders to be executed (ie, bootloaders to be executed).
[0032] The startup program can be stored in the second memory, and the second memory is the bootROM.
[0033] It can be understood that the multiple sections of the boot loader programs to be executed need to be loaded into the first memory and executed in sequence according to a preset execution order.
[0034] Among them, the first memory is RAM.
[0035] S220: Based on the startup program, load the target boot loader program into the first memory.
[0036] The target boot loader is stored starting from the start address of the first memory.
[0037] Specifically, after determining the target boot loader, the startup program may load the target boot loader to the start address of the first memory, so that the target boot loader may be stored starting from the start address of the first memory and exclusively occupy all storage space of the first memory.
[0038] S230: Execute the target boot loader.
[0039] S240: Return to the step of determining a target boot loader from the plurality of boot loader programs to be executed, until all the boot loader programs to be executed are executed and the chip startup is completed.
[0040] Specifically, after the target boot loader is executed, it will return to the startup program in the second memory. The startup program can determine the next segment of the target boot loader according to the preset execution order, and load the next segment of the target boot loader to the starting address of the first memory, so that the next segment of the target boot loader can be stored starting from the starting address of the first memory.
[0041] It should be noted that when the next target boot loader program is stored from the starting address of the first memory, the next target boot loader program will overwrite the previous target boot loader program, that is, the code segment of the previous target boot loader program will be replaced by the code segment of the next target boot loader program, and the code segment of the previous target boot loader program will not be retained in the first memory, so that the next target boot loader program can still exclusively occupy the storage space of the first memory, ensuring that only one boot loader program can be executed in the first memory in each stage of the multi-level startup of the chip, thereby realizing the reuse of the storage space of the first memory.
[0042] Further, the next section of the target boot loader is executed.
[0043] After the execution of the next target boot loader is completed, the startup program in the second memory will be returned again. The startup program can continue to determine the next target boot loader according to the preset execution order, load the next target boot loader to the starting address of the first memory, and execute the next target boot loader until all boot loaders to be executed are executed and the chip startup is completed.
[0044] The chip startup method provided in this embodiment determines a target boot loader from multiple boot loader programs to be executed; based on the startup program, loads the target boot loader into a first memory; stores the target boot loader from the start address of the first memory; executes the target boot loader; returns to the step of determining the target boot loader from multiple boot loader programs to be executed, until all boot loader programs to be executed are executed, and the chip startup is completed. Through the above method, a target boot loader is determined from multiple sections of boot loaders to be executed, and based on the startup program, the target boot loader is loaded into the first memory, and the target boot loader is stored from the starting address of the first memory, so that the target boot loader can exclusively occupy the storage space of the first memory. After the target boot loader is executed, the startup program loads the next section of the target boot loader into the first memory. Since the next section of the target boot loader is also stored from the starting address of the first memory, the next section of the target boot loader can overwrite the previous section of the target boot loader, and the next section of the target boot loader can still exclusively occupy the storage space of the first memory, ensuring that only one section of the boot loader can be executed in the first memory in each stage of the multi-level startup of the chip, and realizing the reuse of the storage space of the first memory. Therefore, the storage space of the first memory actually required by the chip is the storage space required by the boot loader with the largest storage space required among the multiple sections of the boot loaders, which can minimize the chip's demand for the storage space of the first memory, thereby reducing the chip area and the hardware cost of the chip.
[0045] In some embodiments, the startup program includes common code, and the boot loader to be executed does not include common code, and the common code is the same code required for the execution of the startup program and at least one boot loader to be executed; before determining the target boot loader from multiple boot loaders to be executed, it also includes: extracting code from multiple initial boot loaders to obtain common code and the boot loader to be executed corresponding to each initial boot loader; the initial boot loader includes common code; and compiling the startup program including the common code and burning it to the second memory.
[0046] Generally, a startup program (i.e., bootROM code) is stored in the second memory, and multiple boot loaders are stored in the non-volatile storage medium. The startup program and some boot loaders may require some of the same code when they are executed; the same code required for the startup program and at least one boot loader to be executed is used as a common code. At this time, since the boot loader of each stage of the chip's multi-level startup is loaded into the first memory after compilation, and the code of the startup program is also burned into the second memory after compilation, the common code required by the startup program and the boot loader of each stage cannot be dynamically reused, so the common code must be included in the startup program and the boot loader of each stage. The repeated loading of the common code will not only affect the startup efficiency of the chip, but also occupy part of the storage space of the first memory.
[0047] Based on this, this embodiment needs to further improve the existing chip startup method.
[0048] Specifically, before starting the chip, code extraction is performed on multiple initial boot loaders to obtain common code and a boot loader to be executed corresponding to each initial boot loader.
[0049] The initial boot loader includes common code. In this embodiment, the initial boot loader can be understood as a boot loader for each stage of multi-stage startup of a chip in the prior art.
[0050] Furthermore, the common code is only retained in the startup program, and no longer retained in the boot loader to be executed. The startup program containing the common code is compiled and burned into the second memory.
[0051] The startup program includes common code, and the boot loader to be executed does not include common code. When the boot loader to be executed is loaded into the first memory as the target boot loader for execution, if the target boot loader needs to use the common code during execution, the common code can be called from the second memory without retaining the common code in the first memory, thereby further reducing the storage space of the first memory occupied by the boot loader, thereby further reducing the chip area and the hardware cost of the chip.
[0052] In addition, since the common code does not need to be repeatedly loaded into the first memory, the loading efficiency of the boot loader at each stage of the chip's multi-level startup process can be effectively improved, while reducing the boot loader's occupancy of the storage space of the first memory and further improving the chip's startup efficiency and performance.
[0053] The chip startup method provided in this embodiment uses the same code required for the execution of the startup program and the boot loader to be executed as the common code, retains the common code only in the startup program, compiles the startup program containing the common code and burns it to the second memory, and no longer retains the common code in the boot loader to be executed. When the target boot loader is loaded into the first memory as the target boot loader for execution, if the target boot loader needs to use the common code when executing, the common code can be called from the second memory without retaining the common code in the first memory, thereby further reducing the boot loader's occupation of the first memory storage space, thereby further reducing the chip area and the hardware cost of the chip, and at the same time, it can also improve the startup efficiency and performance of the chip.
[0054] In some embodiments, executing the target boot loader includes: if the target boot loader needs to call the common code when executing, calling the common code from the second memory; and executing the target boot loader based on the common code.
[0055] Some target bootloaders execute with and without the common code, and some target bootloaders execute without the common code.
[0056] If the target boot loader needs to call the common code when executing, the common code can be directly called from the second memory, and the target boot loader is executed based on the common code.
[0057] The chip startup method provided in this embodiment only reserves the common code in the startup program, compiles the startup program containing the common code and burns it to the second memory, and no longer reserves the common code in the boot loader to be executed. When the target boot loader is loaded into the first memory as the target boot loader for execution, if the target boot loader needs to use the common code during execution, the common code can be called from the second memory without retaining the common code in the first memory, thereby further reducing the boot loader's occupation of the first memory storage space, thereby further reducing the chip area and the hardware cost of the chip, and at the same time, it can also improve the startup efficiency and performance of the chip.
[0058] In some embodiments, after the target boot loader is loaded into the first memory based on the startup program, the method further includes: performing security verification on the target boot loader; if it is determined that the target boot loader passes the security verification, determining that the target boot loader can be executed normally.
[0059] During the multi-level startup process of the chip, security mechanisms such as encryption verification and signature verification can be used to ensure the credibility of the chip startup process and avoid the intrusion and tampering of malicious code.
[0060] Specifically, for each target boot loader, after the target boot loader is loaded into the first memory, security verification may be performed on the target boot loader through an encryption mechanism or a signature mechanism.
[0061] If it is determined that the target boot loader passes the security verification, it means that the target boot loader has not been invaded and tampered with by malicious code, so it can be determined that the target boot loader can be executed normally.
[0062] In some embodiments, after the target boot loader is loaded into the first memory based on the startup program, the method further includes: performing security verification on the target boot loader; if it is determined that the target boot loader fails the security verification, terminating the execution of the target boot loader.
[0063] Specifically, for each target boot loader, after the target boot loader is loaded into the first memory, security verification may be performed on the target boot loader through an encryption mechanism or a signature mechanism.
[0064] If it is determined that the target boot loader fails the security verification, it means that the target boot loader may be invaded and tampered with by malicious code. Therefore, to ensure the security of the chip or system, the execution of the target boot loader is terminated.
[0065] The chip startup method provided in this embodiment introduces a security verification mechanism in the multi-level startup process of the chip. For each target boot loader, security verification must be performed before execution. The target boot loader will be executed only after it passes the security verification. The target boot loader that fails the security verification will terminate execution, thereby preventing the chip or system from being invaded and tampered with by malicious code, thereby ensuring the security of the chip or system.
[0066] In some embodiments, the common code includes a cryptographic algorithm code, which is used to perform security verification on a target boot loader; based on a startup program, after the target boot loader is loaded into a first memory, it also includes: calling the cryptographic algorithm code from a second memory; based on the cryptographic algorithm code, performing security verification on the target boot loader; if it is determined that the target boot loader passes the security verification, it is determined that the target boot loader can be executed normally.
[0067] It can be understood that in order to ensure the security of the chip or system, each target boot loader must be security verified before execution, that is, each target boot loader needs to call the code that implements the security verification mechanism. Therefore, the code used to perform security verification on the target boot loader can be used as public code.
[0068] Based on this, the cryptographic algorithm code used for security verification of the target boot loader can be taken as a part of the public code, and the code can be compiled and burned into the second memory.
[0069] Specifically, based on the startup program, after the target boot loader is loaded into the first memory, the cryptographic algorithm code can be directly called from the second memory, and the target boot loader is security verified based on the cryptographic algorithm code.
[0070] Optionally, security verification includes integrity verification, identity verification, and confidentiality verification, such as signature verification.
[0071] Optionally, the signature verification mechanism can be implemented based on a digital signature algorithm, and each target boot loader can be encrypted using the digital signature algorithm, that is, each target boot loader is an encryption program; after the target boot loader is loaded into the first memory, the cryptographic algorithm code can be directly called from the second memory, and the target boot loader can be decrypted and verified based on the cryptographic algorithm code, for example, verifying the digital signature of the target boot loader; if the target boot loader can be correctly decrypted based on the cryptographic algorithm code, the target boot loader passes the security verification.
[0072] If it is determined that the target boot loader passes the security verification, it means that the target boot loader has not been invaded and tampered with by malicious code, so it can be determined that the target boot loader can be executed normally.
[0073] If it is determined that the target boot loader fails the security verification, it means that the target boot loader may be invaded and tampered with by malicious code. Therefore, to ensure the security of the chip or system, the execution of the target boot loader is terminated.
[0074] The chip startup method provided in this embodiment introduces a security verification mechanism in the multi-level startup process of the chip, and uses the cryptographic algorithm code for implementing security verification as part of the common code, which is compiled and burned into the second memory. After the target boot loader is loaded into the first memory, the cryptographic algorithm code can be directly called from the second memory to perform security verification on the target boot loader. Under the premise of ensuring the secure startup of the chip, the repeated occupation of the storage space of the first memory by the boot loader can be further reduced, thereby further reducing the chip area and the hardware cost of the chip.
[0075] The present invention also provides a specific example of a chip startup method. Figure 3 , Figure 3 FIG. 2 is a flow chart of the chip startup method provided by the present invention. Figure 1 The existing technology and Figure 3The improved chip startup method in is used as a control. Figure 3 The scheme shown is for Figure 1 Improvements of the scheme shown.
[0076] Among them, Figure 1 and Figure 3 In the embodiment, the first memory is ROM and the second memory is bootROM.
[0077] like Figure 1 As shown in the figure, assuming that the chip is a 4-level boot, A represents the boot program, B, C, and D represent different bootloaders (boot loaders), and different bootloaders need to be loaded and executed in sequence according to the preset order. After the chip is powered on, the boot program A stored in the bootROM is automatically executed. The startup process of the chip is: the boot program A (i.e., bootROM A) loads bootloader B into RAM; after bootloader B in RAM is executed, bootloader B loads bootloader C into RAM; after bootloader C in RAM is executed, bootloader C loads bootloader D into RAM; finally, bootloader D is executed.
[0078] Assume that the 4-level boot process involves common code (i.e., common module). This common code needs to be executed in the boot program A of the bootROM and needs to be executed in each subsequent intermediate bootloader. Since the bootloader of each stage is loaded into RAM only after compilation is completed, and the code of the boot program A is also burned into the bootROM only after compilation is completed, the common code required by the boot program A and the bootloader of each stage cannot be dynamically reused. Therefore, the common code must be included in the boot program A and the bootloader of each stage.
[0079] Figure 1 The crypto lib (software cryptographic library code) in is a public code. Under the requirement of secure boot, in the scenario where there is no hardware encryption and decryption engine, crypto lib is used to verify the signature of each loaded bootloader. Crypto lib needs to be included in at least one copy of bootloader A, bootloader B, and bootloader C, and it needs to occupy some additional RAM storage space.
[0080] During the chip startup process, since bootloader B, bootloader C, and bootloader D use a single-chain loading method, bootloader B, bootloader C, and bootloader D need to jointly occupy the RAM storage space in the microprocessor unit (MPU), that is, they need to satisfy the equation: sizeB + sizeC +sizeD ≤ sizeRAM; where sizeB represents the storage space required for bootloader B, size C represents the storage space required for bootloader C, sizeD represents the storage space required for bootloader D, and sizeRAM represents the storage space of RAM; in addition, since bootloader B and bootloader C both contain crypto lib, they need to further occupy part of the RAM storage space.
[0081] Using the chip startup method of this application ( Figure 3 The solution shown here can effectively solve Figure 1 The existing chip startup method takes up a lot of RAM storage space.
[0082] Specifically, before starting the chip, extract the common codes contained in the boot program A, bootloader B, and bootloader C to obtain crypto lib, bootloader B without crypto lib, and bootloader C without crypto lib; only retain crypto lib in the boot program A, and no longer retain crypto lib in bootloader B and bootloader C; compile the boot program A containing crypto lib, and burn it to bootROM.
[0083] like Figure 3 As shown, after the chip is powered on, the boot program A stored in the bootROM is automatically executed. The boot program A is based on the preset execution order (i.e. Figure 1 In the process, bootloader B is loaded and executed first, bootloader C is loaded and executed second, and bootloader D is loaded and executed last. The target boot loader is determined to be bootloader B, and bootloader B is loaded to the starting address of RAM, so that bootloader B can be stored from the starting address of RAM and occupy all the storage space of RAM.
[0084] Furthermore, after bootloader B is loaded into RAM, crypto lib in startup program A is called, and security verification of bootloader B is performed based on crypto lib; if bootloader B passes the security verification, bootloader B is executed.
[0085] Furthermore, after bootloader B is executed, it returns to bootloader A of bootROM; based on the preset execution order, bootloader A determines that the target boot loader is bootloader C, and loads bootloader C to the starting address of RAM, so that bootloader C can be stored starting from the starting address of RAM and occupy all storage space of RAM.
[0086] It should be noted that when bootloader C starts storing from the starting address of RAM, bootloader C will overwrite bootloader B, that is, the code segment of bootloader B will be replaced by the code segment of bootloader C, and the code segment of bootloader B will not be retained in RAM, so that bootloader C can still monopolize the storage space of RAM, ensuring that only one bootloader can be executed in RAM at each stage of the chip's multi-level startup, realizing the reuse of RAM storage space.
[0087] Furthermore, after bootloader C is loaded into RAM, crypto lib in startup program A is called, and security verification of bootloader C is performed based on crypto lib; if bootloader C passes the security verification, bootloader C is executed.
[0088] Furthermore, after bootloader C is executed, it returns to the boot program A of the bootROM; based on the preset execution order, boot program A determines that the target boot loader is bootloader D, and loads bootloader D to the starting address of the RAM, so that bootloader D can be stored starting from the starting address of the RAM and monopolizes all the storage space of the RAM.
[0089] Similarly, when bootloader D starts storing from the starting address of RAM, bootloader D will overwrite bootloader C, that is, the code segment of bootloader C will be replaced by the code segment of bootloader D, and the code segment of bootloader C will not be retained in RAM, so that bootloader D can still monopolize the storage space of RAM.
[0090] Optionally, after bootloader D is loaded into RAM, crypto lib in startup program A is called, and security verification of bootloader D is performed based on crypto lib; if bootloader D passes the security verification, bootloader D is executed.
[0091] exist Figure 3 In the process shown, since bootloader B, bootloader C, and bootloader D are independent of each other, they can all be directly loaded into the starting address of RAM, that is, bootloader B, bootloader C, and bootloader D can all occupy all the storage space of RAM. Figure 1 Compared with the solution, for bootloader B, bootloader C, and bootloader D with the same required storage space, Figure 3 The actual RAM storage space required is smaller. Figure 3 The actual RAM storage space required is the storage space of the bootloader with the largest storage space required.
[0092] For example, Figure 3 In the figure, bootloader B, bootloader C, and bootloader D require different RAM storage spaces. Bootloader D requires the largest storage space, and bootloader B requires the smallest storage space. At this time, since each bootloader can occupy all the RAM storage space, it is only necessary to ensure that the RAM storage space is ≥ the storage space required by bootloader D.
[0093] At the same time, Figure 3In the process shown, a centralized multi-level boot operation mode is adopted, with the boot program A of bootROM as the center. Only the public code crypto lib is retained in the boot program A, and crypto lib is no longer retained in bootloader B and bootloader C. When bootloader B and bootloader C are executed, crypto lib can be directly called from the boot program A, thereby reducing the repeated occupation of RAM space by public codes, thereby further reducing the chip area and the hardware cost of the chip, and at the same time, it can also improve the startup efficiency and performance of the chip.
[0094] The chip startup method provided in this embodiment provides a centralized multi-level startup operation mode. Under the premise of ensuring the secure startup function, by adjusting the original single-chain multi-level startup logic, the loading address of the bootloader at each level is adjusted so that the bootloader at each level can monopolize all the storage space of the RAM; in addition, by extracting and retaining the common code in the startup program, the common code is no longer retained in the bootloader at each level, which can reduce the repeated occupation of the RAM space by the common code, further reduce the demand for RAM storage space, and reduce the chip area and the hardware cost of the chip while improving the startup efficiency and performance of the chip.
[0095] The present invention also provides a chip startup device. Figure 4 , Figure 4 4 is a schematic diagram of the structure of the chip startup device provided by the present invention. In this embodiment, the chip startup device includes a determination module 410 , a loading module 420 , an execution module 430 and a startup module 440 .
[0096] The determination module 410 is used to determine a target boot loader program from multiple boot loader programs to be executed.
[0097] The loading module 420 is configured to load the target boot loader program into the first memory based on the startup program.
[0098] The target boot loader is stored starting from a start address of the first memory.
[0099] The execution module 430 is configured to execute the target boot loader.
[0100] The startup module 440 is used to return to the step of determining a target boot loader from multiple boot loader programs to be executed, until all the boot loader programs to be executed are executed, and the chip startup is completed.
[0101] In some embodiments, the boot program includes common code, and the boot loader to be executed does not include common code, and the common code is the same code required for the boot program and at least one boot loader to be executed.
[0102] The determination module 410 is also used to extract codes from multiple initial boot loaders to obtain common codes and a boot loader to be executed corresponding to each initial boot loader; the initial boot loader includes the common code; and the startup program including the common code is compiled and burned into the second memory.
[0103] In some embodiments, the execution module 430 is configured to call the common code from the second memory if the target boot loader needs to call the common code during execution; and execute the target boot loader based on the common code.
[0104] In some embodiments, the execution module 430 is further used to perform security verification on the target boot loader; if it is determined that the target boot loader passes the security verification, it is determined that the target boot loader can be executed normally.
[0105] In some embodiments, the execution module 430 is further configured to perform security verification on the target boot loader; if it is determined that the target boot loader fails the security verification, the execution of the target boot loader is terminated.
[0106] In some embodiments, the common code includes a cryptographic algorithm code, and the cryptographic algorithm code is used to perform security verification on the target boot loader.
[0107] The execution module 430 is further used to call the cryptographic algorithm code from the second memory; perform security verification on the target boot loader based on the cryptographic algorithm code; if it is determined that the target boot loader passes the security verification, then determine that the target boot loader can be executed normally.
[0108] The present invention also provides an electronic device, Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the chip startup method.
[0109] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0110] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the chip startup method provided by the above methods is implemented.
[0111] The present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the chip startup method provided by the above methods.
[0112] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0113] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A chip startup method, characterized in that: include: Determine a target boot loader from among multiple boot loaders to be executed; Based on the startup program, loading the target boot loader program into the first memory; The target boot loader is stored starting from a starting address of the first memory; executing the target boot loader; Return to the step of determining a target boot loader program from the plurality of boot loader programs to be executed, until all the boot loader programs to be executed are executed, and the chip startup is completed.
2. The chip startup method according to claim 1, characterized in that: The startup program includes common code, and the boot loader program to be executed does not include the common code, and the common code is the same code required for the startup program and at least one of the boot loader programs to be executed; Before determining the target boot loader program from the plurality of boot loader programs to be executed, the method further comprises: Extracting codes from a plurality of initial boot loaders to obtain the common code and a boot loader to be executed corresponding to each of the initial boot loaders; the initial boot loaders include the common code; The startup program including the common code is compiled and burned into the second memory.
3. The chip startup method according to claim 2, characterized in that: The executing the target boot loader comprises: If the target boot loader needs to call the common code when executing, calling the common code from the second memory; Based on the common code, the target boot loader is executed.
4. The chip startup method according to claim 2, characterized in that: After the target boot loader is loaded into the first memory based on the startup program, the method further comprises: Performing security verification on the target boot loader; If it is determined that the target boot loader program passes the security verification, it is determined that the target boot loader program can be executed normally.
5. The chip startup method according to claim 2, characterized in that: After the target boot loader is loaded into the first memory based on the startup program, the method further comprises: Performing security verification on the target boot loader; If it is determined that the target boot loader program fails the security verification, the execution of the target boot loader program is terminated.
6. The chip startup method according to claim 2, characterized in that: The common code includes a cryptographic algorithm code, and the cryptographic algorithm code is used to perform security verification on the target boot loader; After the target boot loader is loaded into the first memory based on the startup program, the method further comprises: Calling the cryptographic algorithm code from the second memory; Based on the cryptographic algorithm code, performing security verification on the target boot loader; If it is determined that the target boot loader program passes the security verification, it is determined that the target boot loader program can be executed normally.
7. A chip startup device, characterized in that: include: A determination module, used for determining a target boot loader from multiple boot loader programs to be executed; A loading module, configured to load the target boot loader program into the first memory based on a startup program; The target boot loader is stored starting from a starting address of the first memory; An execution module, used for executing the target boot loader; The startup module is used to return to the step of determining a target boot loader from multiple boot loader programs to be executed until all the boot loader programs to be executed are executed and the chip startup is completed.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the chip startup method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the chip startup method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the chip startup method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Multistage startup system management method, device, equipment, program product and medium
CN119987882A
HSM firmware starting method and device, equipment and storage medium
CN120469729A
HSM firmware startup method, device, equipment and storage medium
CN120469729B
