ECU starting method and device, electronic equipment, storage medium and vehicle
By using a hash verification algorithm to determine the hash value when the car ECU is powered on, redundant startup is achieved, which solves the problem of inability to start under key security restrictions, simplifies the development process and shortens the development cycle.
Patent Information
- Application Number
- CN202310539114.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-12
- Publication Date
- 2024-11-12
AI Technical Summary
During the development stage of automotive ECU, due to the environment and method limitations of key security and key injection, the public key cannot be written to efuse, resulting in the inability to implement a secure boot method, and additional BootLoader is needed, which increases the development cycle.
When the ECU is powered on, the hash value is determined based on the hash verification algorithm of the target image file. If the hash value matches the preset value, copy the image file content in the corresponding partition and start the ECU to achieve redundant startup and avoid The dependence of public keys and keys has been reduced, and the development needs of BootLoader are reduced.
It simplifies the development process of ECU, shortens the development cycle, reduces the R&D time, and does not increase the software startup time of the ECU.
Smart Images

Figure CN118939324A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automobile technology, and in particular to an ECU startup method, device, electronic device, storage medium and vehicle. Background Art
[0002] At present, the chip (BootROM) of the electronic control unit (ECU) of the car has the ability of redundant boot by supporting the secure boot (signature verification) method. Among them, the secure boot method is to perform signature verification on the image file in the boot device. Redundant boot means that if the signature verification of the main partition fails, the signature of the backup partition will continue to be verified. After the signature verification of the backup partition succeeds, the backup partition will be started.
[0003] The signature verification corresponding to the secure boot method requires a public key, which generally needs to be burned into a one-time burn register (efuse). However, during the development phase of the ECU, due to limitations in key security, the environment and methods of key injection, etc., it is often not possible to burn the public key into efuse and enable the secure boot method. This will result in the ECU in the development phase not having the ability to redundantly boot with BootROM. Therefore, it is necessary to additionally develop a bootloader (BootLoader) to support redundant boot, and the development of BootLoader will increase the development cycle of the ECU.
[0004] Therefore, the existing startup method of supporting redundant startup through BootLoader will increase the development cycle in the automotive ECU development phase. Summary of the invention
[0005] The present application provides an ECU startup method, device, electronic device, storage medium and vehicle, which can effectively reduce the development cycle of the automobile ECU development stage.
[0006] In a first aspect, an embodiment of the present application provides an ECU startup method, comprising: when the ECU is powered on, determining a first hash value of the target image file based on a target hash algorithm indicated by a hash check algorithm field included in the target image file in a first partition, the target image file also including an image file hash value field, an image header file field, and an image file content field; when the first hash value is the same as a preset hash value indicated by the image file hash value field, copying the image file content field based on the indication of the image header file field in the first partition and starting the ECU at a target startup address; wherein the target startup address is stored in the image header file field; when the first hash value is different from the preset hash value, determining a second hash value of the target image file based on the target hash algorithm in a second partition; when the second hash value is the same as the preset hash value, copying the image file content field based on the indication of the image header file field in the second partition and starting the ECU at the target startup address.
[0007] In some embodiments of the present application, when the hash check algorithm field includes a first algorithm identifier, the target hash algorithm is a first hash algorithm corresponding to the first algorithm identifier; when the hash check algorithm field includes a second algorithm identifier, the target hash algorithm is a second hash algorithm corresponding to the second algorithm identifier; when the hash check algorithm field includes a third algorithm identifier, the target hash algorithm is a third hash algorithm corresponding to the third algorithm identifier; when the hash check algorithm field includes a fourth algorithm identifier, the target hash algorithm is a fourth hash algorithm corresponding to the fourth algorithm identifier.
[0008] In some embodiments of the present application, the target image file also includes a startup mode field; when the ECU is powered on, the first hash value of the target image file is determined based on the target hash algorithm indicated by the hash verification algorithm field included in the target image file in the first partition, including: when the ECU is powered on, obtaining the startup mode field; when the startup mode field indicates a hash verification startup mode, determining the first hash value based on the target hash algorithm in the first partition.
[0009] In some embodiments of the present application, the target image file also includes a partition identification field; when the boot mode field indicates a hash check boot mode, determining the first hash value based on the target hash algorithm under the first partition includes: when the boot mode field indicates the hash check boot mode, obtaining the partition identification field; when the partition identification field indicates the first partition, determining the first hash value based on the target hash algorithm under the first partition.
[0010] In some embodiments of the present application, when the ECU is powered on, after obtaining the startup mode field, the method also includes: when the startup mode field indicates a startup mode without verification, based on the indication of the image header file field, copying the image file content field and starting the ECU at the target startup address.
[0011] In some embodiments of the present application, the target image file also includes a public key field and a signature field for a security verification startup mode; when the ECU is powered on, after obtaining the startup mode field, the method also includes: when the startup mode field indicates the security verification startup mode, based on the public key indicated by the public key field and the target hash value, a signature verification is performed on the signature indicated by the signature field in the first partition, and the target hash value is the preset hash value or the hash value of the target image file determined according to the target hash algorithm; when the signature verification is successfully performed in the first partition, based on the indication of the image header file field in the first partition, the image file content field is copied and the ECU is started at the target startup address; when the signature verification fails in the first partition, based on the public key and the target hash value, a signature verification is performed on the signature indicated by the signature field in the second partition; when the signature verification is successfully performed in the second partition, based on the indication of the image header file field, the image file content field is copied and the ECU is started at the target startup address.
[0012] In some embodiments of the present application, when the startup mode field indicates a hash check startup mode, the hash check algorithm field is valid; when the startup mode field indicates a startup mode other than the hash check startup mode, the hash check algorithm field is invalid.
[0013] In a second aspect, an embodiment of the present application provides an ECU starting device, comprising: a determination module, for determining a first hash value of a target image file based on a target hash algorithm indicated by a hash check algorithm field included in the target image file in a first partition when the electronic control unit ECU is powered on, the target image file also comprising an image file hash value field, an image header file field and an image file content field; a copy and start module, for copying the image file content field and starting the ECU at a target startup address based on an indication of the image header file field in a first partition when the first hash value is the same as a preset hash value indicated by the image file hash value field; wherein the target startup address is stored in the image header file field; the determination module is also used to determine a second hash value of the target image file based on the target hash algorithm in a second partition when the first hash value is different from the preset hash value; the copy and start module is also used to copy the image file content field and start the ECU at the target startup address in a second partition based on an indication of the image header file field when the second hash value is the same as the preset hash value.
[0014] In some embodiments of the present application, when the hash check algorithm field includes a first algorithm identifier, the target hash algorithm is a first hash algorithm corresponding to the first algorithm identifier; when the hash check algorithm field includes a second algorithm identifier, the target hash algorithm is a second hash algorithm corresponding to the second algorithm identifier; when the hash check algorithm field includes a third algorithm identifier, the target hash algorithm is a third hash algorithm corresponding to the third algorithm identifier; when the hash check algorithm field includes a fourth algorithm identifier, the target hash algorithm is a fourth hash algorithm corresponding to the fourth algorithm identifier.
[0015] In some embodiments of the present application, the target image file also includes a startup mode field; the determination module is specifically used to obtain the startup mode field when the ECU is powered on; when the startup mode field indicates a hash check startup mode, determine the first hash value based on the target hash algorithm under the first partition.
[0016] In some embodiments of the present application, the target image file also includes a partition identification field; the determination module is specifically used to obtain the partition identification field when the boot mode field indicates the hash verification boot mode; when the partition identification field indicates the first partition, determine the first hash value based on the target hash algorithm under the first partition.
[0017] In some embodiments of the present application, the copy and start module is also used to, when the ECU is powered on, after obtaining the start mode field, and when the start mode field indicates a start mode without verification, copy the image file content field based on the indication of the image header file field and start the ECU at the target start address.
[0018] In some embodiments of the present application, the target image file also includes a public key field and a signature field for securely verifying the startup mode;
[0019] The copy and start module is also used for, when the ECU is powered on, after obtaining the start mode field, when the start mode field indicates the security verification start mode, performing signature verification on the signature indicated by the signature field in the first partition based on the public key indicated by the public key field and the target hash value, and the target hash value is the preset hash value or the hash value of the target image file determined according to the target hash algorithm; when the signature verification is successfully performed in the first partition, based on the indication of the image header file field, copying the image file content field in the first partition and starting the ECU at the target start address; when the signature verification fails in the first partition, performing signature verification on the signature indicated by the signature field in the second partition based on the public key and the target hash value; when the signature verification is successfully performed in the second partition, copying the image file content field in the second partition based on the indication of the image header file field and starting the ECU at the target start address.
[0020] In some embodiments of the present application, when the startup mode field indicates a hash check startup mode, the hash check algorithm field is valid; when the startup mode field indicates a startup mode other than the hash check startup mode, the hash check algorithm field is invalid.
[0021] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, wherein the processor is used to execute a computer program stored in a memory, and when the computer program is executed by the processor, the steps of any one of the ECU startup methods provided in the first aspect are implemented.
[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any one of the ECU startup methods provided in the first aspect are implemented.
[0023] In a fifth aspect, an embodiment of the present application provides a vehicle, comprising: an ECU starting device as described in the second aspect, or an electronic device as described in the third aspect, or a computer-readable storage medium as described in the fourth aspect.
[0024] In a sixth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a computer program or instructions. When the computer program product runs on a processor, the processor executes the computer program or instructions to implement the steps of the ECU startup method as described in the first aspect.
[0025] In the seventh aspect, an embodiment of the present application provides a chip, which includes a processor, a memory and a communication interface, the communication interface is coupled to the processor, the memory is used to store programs or instructions that can be run on the processor, and the processor is used to execute the program or instructions to implement the steps of the ECU startup method as described in the first aspect.
[0026] The technical solution provided by the embodiment of the present application has the following advantages over the prior art: in the embodiment of the present application, when the ECU is powered on, the first hash value of the target image file is determined by the first partition based on the target hash algorithm indicated by the hash verification algorithm field included in the target image file; when the first hash value is the same as the preset hash value indicated by the image file hash value field included in the target image file (that is, the first partition hash verification is successful), the image file content field included in the target image file is copied by the first partition based on the image header file field included in the target image file, and the ECU is started based on the target startup address; when the first hash value is different from the preset hash value (that is, the first partition hash verification fails), the second hash value of the target image file is determined by the second partition based on the target hash algorithm; when the second hash value is the same as the preset hash value (that is, the second partition hash verification is successful), the image file content field is copied by the second partition based on the image header file field, and the ECU is started based on the target startup address. In this way, the redundant startup of ECU (BootROM) is realized through hash verification. The code corresponding to hash verification is relatively mature and can be quickly implanted. Compared with the redundant startup method using signature verification, it does not require public key, key security and key injection, nor does it require additional development of BootLoader to support BootROM redundant startup, which can greatly shorten the R&D time. The hash verification method will not seriously increase the development cycle of ECU, thereby effectively reducing the development cycle of automotive ECU development stage. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0028] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0029] Figure 1 A flowchart of an ECU startup method provided in this application;
[0030] Figure 2 A schematic diagram of the architecture of an ECU provided for this application;
[0031] Figure 3 A schematic diagram of a hash verification startup method provided for this application;
[0032] Figure 4 A schematic diagram of the structure of an ECU starting device provided in this application;
[0033] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0034] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0035] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.
[0036] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more.
[0037] Currently, the chip startup of the automotive electronic control unit (ECU) usually supports two startup verification methods: no-verification startup and secure startup (signature verification).
[0038] Among them, there is no verification startup, that is, no integrity or authenticity verification is performed on the program image file (Image), and the program image file in the startup device such as Flash, Embedded Multi Media Card (EMMC) or Secure Digital Memory Card (SD) is directly copied to the startup address for jump startup. Secure startup, that is, signature verification is performed on the program image file in the startup device. And the secure startup method supports redundant startup of the main and backup partitions of the chip boot read-only memory (BootROM). Among them, redundant startup means that if the signature verification of the main partition fails, the signature of the backup partition will continue to be verified, and the backup partition will be started after the signature verification of the backup partition succeeds. At present, in order to avoid power failure of the main partition during flashing (updating), resulting in the inability of the main partition to start after power-on again, it is necessary to support redundant startup of the main and backup partitions.
[0039] However, the public key of the secure boot method generally needs to be burned into a one-time burn register (efuse, efuse only supports burning once, that is, once burned, it cannot be modified later). If the public key is not burned into efuse, secure boot cannot be enabled, and redundant boot of the primary and backup partitions cannot be achieved. In the development stage of ECU, due to restrictions such as key security, key injection environment and methods, it is often not possible to burn the public key into efuse and enable secure boot. This will result in the ECU in the development stage not having the ability to redundantly boot with BootROM, and it is necessary to additionally develop a boot program (BootLoader) to support redundant boot. The development of BootLoader will increase the software startup time of ECU and the development cycle of ECU.
[0040] In an embodiment of the present application, when the ECU is powered on, a first hash value of the target image file is determined by the first partition based on the target hash algorithm indicated by the hash verification algorithm field included in the target image file; when the first hash value is the same as the preset hash value indicated by the image file hash value field included in the target image file (that is, the first partition hash verification is successful), the image file content field included in the target image file is copied by the first partition based on the image header file field included in the target image file, and the ECU is started based on the target startup address; when the first hash value is different from the preset hash value (that is, the first partition hash verification fails), a second hash value of the target image file is determined by the second partition based on the target hash algorithm; when the second hash value is the same as the preset hash value (that is, the second partition hash verification is successful), the image file content field is copied by the second partition based on the image header file field, and the ECU is started based on the target startup address. In this way, the redundant startup of ECU (BootROM) is realized through hash verification. The code corresponding to hash verification is relatively mature and can be quickly implanted. Compared with the redundant startup method using signature verification, it does not require public key, key security and key injection, nor does it require additional development of BootLoader to support BootROM redundant startup, which can greatly shorten the R&D time. The hash verification method will not seriously increase the development cycle of ECU, thereby effectively reducing the development cycle of automotive ECU development stage.
[0041] The present application is applied to the startup scenario after the automobile ECU is powered on. The electronic device in the embodiment of the present application can be a vehicle-mounted terminal, or a mobile phone, notebook, computer, etc. that is connected to the vehicle for communication. The specific details can be determined based on actual conditions and are not limited here.
[0042] The technical solution of the present application is explained in detail below through several specific embodiments.
[0043] Figure 1 A flowchart of an ECU startup method provided in this application is shown in FIG. Figure 1 As shown, the ECU startup method may include the following steps 101 to 104.
[0044] 101. When the ECU is powered on, determine a first hash value of the target image file in a first partition based on a target hash algorithm indicated by a hash verification algorithm field included in the target image file.
[0045] The target image file also includes an image file hash value field, an image header file field and an image file content field.
[0046] The target image file may be stored in a storage device other than the first partition and the second partition, such as the target image file is stored in Flash, EMMC or SD.
[0047] 102. When the first hash value is the same as the preset hash value indicated by the hash value field of the image file, based on the indication of the image header file field, copy the image file content field under the first partition and start the ECU at the target startup address.
[0048] The image header file field stores the target startup address, and the image header file field is used to indicate how to copy the image file content field and obtain the startup address.
[0049] 103. When the first hash value is different from the preset hash value, determine a second hash value of the target image file based on the target hash algorithm in the second partition.
[0050] 104. When the second hash value is the same as the preset hash value, based on the instruction of the image header file field, copy the image file content field in the second partition and start the ECU at the target startup address.
[0051] In some embodiments of the present application, the first partition and the second partition are two independent operating systems. The first partition and the second partition can be two different operating systems or two identical operating systems. Among them, the first partition can be the main partition and the second partition can be the backup partition, or the first partition and the second partition can be the main and backup partitions of each other. The specific details can be determined according to the actual situation and are not limited here. Both the first partition and the second partition can start the ECU, and the combination of the two is used to realize the redundant startup of the ECU.
[0052] It can be understood that when the electronic control unit ECU is powered on, a hash check is performed based on the image file hash value field and the hash check algorithm field in the target image file in the first partition (the hash check is used to check whether the hash value of the target image file obtained based on the target hash algorithm is the same as the preset hash value); when the hash check is successfully performed in the first partition (the first hash value is the same as the preset hash value), the image file content field is copied based on the indication of the image header file field in the first partition and the ECU is started at the target startup address; when the hash check fails to be performed in the first partition (the first hash value is different from the preset hash value), the hash check is performed based on the image file hash value field and the hash check algorithm field in the second partition; when the hash check is successfully performed in the second partition (the second hash value is the same as the preset hash value), the image file content field is copied based on the indication of the image header file field in the second partition and the ECU is started at the target startup address. In the case where the hash check fails to be performed in the second partition (the second hash value is different from the preset hash value), a prompt message is reported (the prompt message is used to indicate that the ECU cannot be started) so that the ECU can be repaired.
[0053] Among them, the image file hash value field is used to indicate the preset hash value of the target image file used for hash verification, the hash verification algorithm field is used to indicate the target hash algorithm used for hash verification, the image header file field is used to indicate how to copy the image file content field and the startup address for executing startup based on the copied image file content field, the image header file field mainly includes the storage address and length of the image file content field in the startup device, and the starting address, length and startup address copied to the RAM, etc., wherein the storage address and length of the image file content field in the startup device included in the image header file field, and the starting address and length copied to the RAM are used to determine how to copy the image file content field from the startup device to the RAM, and the startup address included in the image header file field is used to indicate the startup address for executing ECU startup based on the copied image file content field, which is not limited here. The image file content field stores the specific content of the image file, which is an important content for supporting ECU startup.
[0054] Exemplarily, the above steps 101 to 104 may specifically be: when the electronic control unit ECU is powered on, the image file hash value field and the hash verification algorithm field are obtained from the target image file saved in the boot device in the first partition; based on the target hash algorithm, the first hash value of the target image file is calculated in the first partition; when the first hash value is the same as the preset hash value, the image header file field is obtained from the target image file in the first partition; based on the image header file field, the target image file is copied to the target boot address in the first partition to jump start the ECU; when the first hash value is different from the preset hash value, the image file hash value field and the hash verification algorithm field are obtained in the second partition (the second partition is obtained from the target image file or the second partition is obtained from the first partition), and the second hash value of the target image file is calculated in the second partition based on the target hash algorithm; when the second hash value is the same as the preset hash value, the image header file field is obtained from the target image file in the second partition; based on the image header file field, the target image file is copied to the target boot address in the second partition to jump start the ECU.
[0055] For example, Figure 2 As shown, it is a possible ECU architecture diagram of an embodiment of the present application, and ECU 20 includes at least one boot device 201 and at least one chip 202 (a boot device 201 and a chip 202 are shown as an example in the figure). Among them, each boot device 201 can be a flash memory (Flash), an embedded multimedia card (EMMC) or a secure digital memory card (SD), etc., which can be determined according to actual conditions and is not limited here. An image file is stored in the boot device 201. A program image file is stored in the boot device 201. Among them, each chip 202 may include BootROM 202a and SRAM 202b. BootROM 202a includes a main partition and a backup partition. BootROM performs hash verification on the target image file through the main partition or the backup partition, and when the hash verification is successful, based on the image header file in the target image file, the image file content field is copied to SARM, and the ECU is started based on the target boot address.
[0056] In the embodiment of the present application, the redundant startup of ECU (BootROM) is realized by hash verification. The code corresponding to hash verification is relatively mature and can be quickly implanted. Compared with the redundant startup method using signature verification, it does not require public key, key security and key injection, and does not require additional development of BootLoader to support BootROM redundant startup, which can greatly shorten the research and development time. The hash verification method will not seriously increase the development cycle of ECU, thereby effectively reducing the development cycle of automobile ECU development stage. Moreover, there is no need to develop BootLoader, and the hash verification method will not increase the software startup time of ECU.
[0057] In some embodiments of the present application, when the hash check algorithm field includes a first algorithm identifier, the target hash algorithm is the first hash algorithm corresponding to the first algorithm identifier; when the hash check algorithm field includes a second algorithm identifier, the target hash algorithm is the second hash algorithm corresponding to the second algorithm identifier; when the hash check algorithm field includes a third algorithm identifier, the target hash algorithm is the third hash algorithm corresponding to the third algorithm identifier; when the hash check algorithm field includes a fourth algorithm identifier, the target hash algorithm is the fourth hash algorithm corresponding to the fourth algorithm identifier. Among them, the hash check algorithm field may also include other algorithm identifiers, and the target hash algorithm is the hash algorithm corresponding to the other algorithm identifiers, which can be determined according to actual conditions and is not limited here.
[0058] In an embodiment of the present application, the hash verification algorithm field may include different algorithm identifiers, and different algorithm identifiers correspond to different hash algorithms. In this way, the algorithm identifier included in the hash verification algorithm field can be set according to actual conditions, and hash verification can be performed according to different hash algorithms to ensure data security.
[0059] Exemplarily, the first algorithm identifier can be MD5, and the first hash algorithm is the MD5 algorithm; the second algorithm identifier can be SHA-256, and the second hash algorithm is the SHA-256 algorithm; the third algorithm identifier can be SHA-384, and the third hash algorithm is the SHA-384 algorithm; the fourth algorithm identifier can be SHA-512, and the fourth hash algorithm is the SHA-512 algorithm.
[0060] In some embodiments of the present application, the target image file also includes a startup mode field; the above step 101 can be specifically implemented through the following steps 101a and 101b.
[0061] 101a. When the ECU is powered on, obtain the startup mode field.
[0062] 101b. When the startup mode field indicates a hash check startup mode, determine a first hash value based on the target hash algorithm in the first partition.
[0063] Exemplarily, when the boot mode field includes HASH_BOOT, the boot mode field indicates a hash check boot mode.
[0064] In the embodiment of the present application, when the startup mode field includes different mode identifiers, the corresponding startup modes of the ECU startup are different. In this way, the ECU can be started in different startup modes by setting different mode identifiers of the startup mode field according to actual needs.
[0065] Exemplarily, when the startup mode field includes a first mode identifier, the startup mode of the ECU is a non-verification startup mode corresponding to the first mode identifier; when the startup mode field includes a second mode identifier, the startup mode of the ECU is a signature verification startup mode corresponding to the second mode identifier; when the startup mode field includes a third mode identifier, the startup mode of the ECU is a hash verification startup mode corresponding to the third mode identifier; the startup mode field may also include a mode identifier for indicating other startup modes, which may be determined based on actual conditions and is not limited here.
[0066] In some embodiments of the present application, the first partition is the main partition, the second partition is the backup partition, and the ECU is started by default. The hash check is performed through the main partition first. If the hash check of the main partition fails, the hash check is performed through the backup partition to ensure that the ECU can be successfully started through redundant startup.
[0067] In some embodiments of the present application, the first partition and the second partition may be the primary partition and the backup partition respectively. For example, when the first partition is the primary partition, the second partition may be the backup partition; when the first partition is the backup partition, the second partition may be the primary partition. The specific information may be determined according to the actual situation and is not limited here. In this case, the primary partition and the backup partition may back up each other. When the ECU is started, a hash check may be performed first through the primary partition. If the hash check of the primary partition fails, a hash check may be performed through the backup partition to ensure that the ECU can be successfully started by means of redundant startup. A hash check may be performed first through the backup partition. If the hash check of the backup partition fails, a hash check may be performed through the primary partition to ensure that the ECU can be successfully started by means of redundant startup.
[0068] In some embodiments of the present application, the target image file also includes a partition identification field; the above step 101b can be specifically implemented through the following steps 101b1 and 101b2.
[0069] 101b1. When the startup mode field indicates the hash verification startup mode, obtain the partition identification field.
[0070] 101b2. When the partition identification field indicates the first partition, determine a first hash value based on the target hash algorithm in the first partition.
[0071] The partition identification field may be an identifier 1 or 0. If the partition identifier field is an identifier 1, it indicates the first partition. If the partition identifier field is an identifier 0, it indicates the second partition.
[0072] When the first hash value is different from the preset hash value, the partition identification field is updated from indicating the first partition to indicating the second partition (i.e., the partition identification field is updated from identifier 1 to identifier 0), thereby determining the second hash value of the target image file based on the target hash algorithm through the second partition indicated by the partition identification field.
[0073] In an embodiment of the present application, by setting a partition identification field in the target image file, it is possible to determine whether the partition currently used for hash verification is the first partition or the second partition based on the partition identification field. In this way, the appropriate partition can be selected according to actual needs to prioritize hash verification to start the ECU.
[0074] In some embodiments of the present application, after the above step 101a, the ECU startup method provided by the embodiment of the present application may further include the following step 105.
[0075] 105. When the startup mode field indicates a startup mode without verification, based on the instruction of the image header file field, copy the image file content field and start the ECU at the target startup address.
[0076] In the embodiment of the present application, the startup mode of the ECU can be set to a non-verification startup mode through the startup mode field. In this way, both the non-verification startup mode and the hash verification startup mode can be supported at the same time.
[0077] In some embodiments of the present application, the target image file also includes a public key field and a signature field for securely verifying the startup mode; after the above step 101a, the ECU startup method provided in the embodiment of the present application may also include the following steps 106 to 109.
[0078] 106. When the startup mode field indicates the security verification startup mode, perform signature verification on the signature indicated by the signature field based on the public key indicated by the public key field and the target hash value in the first partition.
[0079] The target hash value is the preset hash value or a hash value of the target image file determined according to the target hash algorithm.
[0080] In some embodiments of the present application, when the target hash value is the preset hash value, the hash verification algorithm field in the target image file is invalid. In this way, it is possible to avoid the signature verification from mistakenly using the target hash algorithm indicated by the hash verification algorithm field to calculate the hash value of the target image file, thereby increasing the signature verification time or causing the signature verification to fail, thereby improving the efficiency of the signature verification.
[0081] In some embodiments of the present application, when the target hash value is the hash value of the target image file determined by the target hash algorithm, the hash value field is invalid. In this way, the signature verification can be avoided from using the preset hash value indicated by the hash value field, thereby avoiding the failure of the signature verification due to the use of the preset hash value. In addition, using the target hash algorithm indicated by the hash verification algorithm field to calculate the hash value of the target image file can ensure data security to a certain extent.
[0082] 107. When the signature verification is successfully performed in the first partition, based on the instruction of the image header file field, the image file content field is copied in the first partition and the ECU is started at the target startup address.
[0083] 108. When the signature verification fails in the first partition, a signature verification is performed on the signature indicated by the signature field based on the public key and the target hash value in the second partition.
[0084] 109. When the signature verification is successfully performed in the second partition, based on the instruction of the image header file field, the image file content field is copied in the second partition and the ECU is started at the target startup address.
[0085] In the embodiment of the present application, the startup mode of the ECU can be set to a safety verification startup mode through the startup mode field. In this way, both the safety verification startup mode and the hash verification startup mode can be supported at the same time.
[0086] In some embodiments of the present application, when the startup mode field indicates a hash check startup mode, the hash check algorithm field is valid; when the startup mode field indicates a startup mode other than the hash check startup mode, the hash check algorithm field is invalid.
[0087] In an embodiment of the present application, setting the hash verification algorithm field is effective only when the startup mode field indicates a hash verification startup mode, thereby avoiding the mistaken use of the hash verification algorithm field when the startup mode field indicates a startup mode other than the hash verification startup mode, thereby causing a verification error.
[0088] Exemplarily, in the embodiment of the present application, based on the traditional boot method of the BootROM of the automobile ECU chip, a new hash check boot method that does not rely on efuse to achieve redundant boot is designed. In addition, the fields of the image file that supports the hash boot method and is compatible with the non-check boot method and the secure boot method, as well as the process of the hash check boot method are designed. After applying the ECU boot method provided in the embodiment of the present application, the BootROM of the automobile ECU chip can achieve redundant boot without relying on efuse, nor on BootLoader to achieve redundant boot, and can be applied in the early stage of automobile ECU development. While ensuring the boot security, it can also effectively shorten the ECU software startup time and shorten the ECU development cycle.
[0089] In the embodiment of the present application, the fixed address field in the image file of the boot device (Flash / EMMC / SD) is designed as the BootCFGWord field to indicate different boot modes, and the Hash algorithm field is designed to indicate the hash check algorithm that BootROM should select when BootCFGWord==HASH_BOOT.
[0090] The present invention designs an image file that is compatible with the non-check boot mode, the secure boot mode, and the hash check boot mode. Figure 3 As shown, the specific design of each field of the image file is as follows:
[0091] Image Header (image header file field): mainly includes the storage address and length of the image file content field in the boot device, as well as the starting address, length and boot address copied to RAM (such as SRAM).
[0092] BootCFGWord (boot mode field): identifies the boot mode. For example, the specific enumeration design of the BootCFGWord field is as follows: NO_SEC_BOOT: no verification boot; SEC_BOOT: secure boot; HASH_BOOT: hash verification boot.
[0093] Image TAG (partition identification field): Identifies whether it is a primary partition or a backup partition.
[0094] Hash algorithm (Hash check algorithm field): When the startup mode is hash check startup, this field is valid and identifies the algorithm used for hash check. For example, the specific enumeration algorithm design of the Hash algorithm is as follows: MD5: Hash check uses the MD5 algorithm; SHA-256: Hash check uses the SHA-256 algorithm; SHA-384: Hash check uses the SHA-384 algorithm; SHA-512: Hash check uses the SHA-512 algorithm.
[0095] Image Hash (hash value field): identifies the hash value of the image file. When the hash check is started, the hash value of the image file should be calculated separately according to the hash algorithm, and then compared with this value to determine whether the hash verification is successful.
[0096] Public Key (public key field): identifies the public key.
[0097] Signature (Signature field): identifies the signature.
[0098] Image: image file content field.
[0099] Among them, Figure 3 As shown, the hash verification startup method is: hash verification is performed according to BootCFGWord, Image TAG, Hashalgorithm and Image Hash. If the verification is successful, the Image is copied to SRAM based on the Image Header, and the ECU is started based on the startup address.
[0100] The present application also provides an ECU starting device, Figure 4 A schematic diagram of the structure of an ECU starting device provided in this application, such as Figure 4As shown, the ECU startup device includes: a determination module 401, which is used to determine the first hash value of the target image file based on the target hash algorithm indicated by the hash check algorithm field included in the target image file in the first partition when the electronic control unit ECU is powered on, and the target image file also includes an image file hash value field, an image header file field and an image file content field; a copy and start module 402, which is used to copy the image file content field and start the ECU at the target startup address based on the indication of the image header file field in the first partition when the first hash value is the same as the preset hash value indicated by the image file hash value field; wherein the target startup address is stored in the image header file field; the determination module 401 is also used to determine the second hash value of the target image file based on the target hash algorithm in the second partition when the first hash value is different from the preset hash value; the copy and start module 402 is also used to copy the image file content field and start the ECU at the target startup address in the second partition based on the indication of the image header file field when the second hash value is the same as the preset hash value.
[0101] In some embodiments of the present application, when the hash check algorithm field includes a first algorithm identifier, the target hash algorithm is a first hash algorithm corresponding to the first algorithm identifier; when the hash check algorithm field includes a second algorithm identifier, the target hash algorithm is a second hash algorithm corresponding to the second algorithm identifier; when the hash check algorithm field includes a third algorithm identifier, the target hash algorithm is a third hash algorithm corresponding to the third algorithm identifier; when the hash check algorithm field includes a fourth algorithm identifier, the target hash algorithm is a fourth hash algorithm corresponding to the fourth algorithm identifier.
[0102] In some embodiments of the present application, the target image file also includes a startup mode field; the determination module 401 is specifically used to obtain the startup mode field when the ECU is powered on; when the startup mode field indicates a hash check startup mode, determine the first hash value based on the target hash algorithm under the first partition.
[0103] In some embodiments of the present application, the target image file also includes a partition identification field; the determination module 401 is specifically used to obtain the partition identification field when the boot mode field indicates the hash verification boot mode; when the partition identification field indicates the first partition, determine the first hash value based on the target hash algorithm under the first partition.
[0104] In some embodiments of the present application, the copy and start module 402 is also used to, when the ECU is powered on, after obtaining the start mode field, and when the start mode field indicates a start mode without verification, copy the image file content field based on the indication of the image header file field and start the ECU at the target start address.
[0105] In some embodiments of the present application, the target image file also includes a public key field and a signature field for securely verifying the startup mode;
[0106] The copy and start module 402 is also used for, when the ECU is powered on, after obtaining the start mode field, when the start mode field indicates the security verification start mode, performing signature verification on the signature indicated by the signature field in the first partition based on the public key indicated by the public key field and the target hash value, and the target hash value is the preset hash value or the hash value of the target image file determined according to the target hash algorithm; when the signature verification is successfully performed in the first partition, based on the indication of the image header file field, copying the image file content field and starting the ECU at the target start address in the first partition; when the signature verification fails in the first partition, performing signature verification on the signature indicated by the signature field in the second partition based on the public key and the target hash value; when the signature verification is successfully performed in the second partition, copying the image file content field and starting the ECU at the target start address in the second partition based on the indication of the image header file field.
[0107] In some embodiments of the present application, when the startup mode field indicates a hash check startup mode, the hash check algorithm field is valid; when the startup mode field indicates a startup mode other than the hash check startup mode, the hash check algorithm field is invalid.
[0108] It should be noted that the above-mentioned ECU starting device can be the electronic device in the above-mentioned method embodiment of the present application, or it can be a functional module and / or functional entity in the electronic device that can realize the function of the device embodiment, and the embodiment of the present application is not limited.
[0109] In the embodiment of the present application, each module can implement the ECU startup method provided in the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0110] Figure 5 The structural schematic diagram of an electronic device provided in an embodiment of the present application is used to exemplify the electronic device that implements any ECU startup method in the embodiment of the present application, and should not be understood as a specific limitation on the embodiment of the present application.
[0111] like Figure 5As shown, the electronic device 500 may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processor 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0112] Typically, the following devices may be connected to the I / O interface 505: input devices 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 508 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 509. The communication devices 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although the electronic device 500 is shown with various devices, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have instead.
[0113] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processor 501, the functions defined in any ECU startup method provided in the embodiment of the present application can be executed.
[0114] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0115] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with 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"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0116] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0117] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: when the ECU is powered on, based on the target hash algorithm indicated by the hash check algorithm field included in the target image file, determine the first hash value of the target image file in the first partition, the target image file also includes an image file hash value field, an image header file field and an image file content field; when the first hash value is the same as the preset hash value indicated by the image file hash value field, based on the indication of the image header file field in the first partition, copy the image file content field and start the ECU at the target startup address; when the first hash value is different from the preset hash value, based on the target hash algorithm in the second partition, determine the second hash value of the target image file; when the second hash value is the same as the preset hash value, based on the indication of the image header file field in the second partition, copy the image file content field and start the ECU at the target startup address.
[0118] In an embodiment of the present application, a computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, and the above-mentioned programming languages include but are not limited to object-oriented programming languages, such as Java, Smalltalk, C++, and also include conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed completely on the computer, partially on the computer, as an independent software package, partially on the computer and partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0119] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0120] The units involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of a unit does not, in some cases, constitute a limitation on the unit itself.
[0121] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0122] In the context of the present application, a computer-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable 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. A more specific example of a computer-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.
[0123] An embodiment of the present application also provides a vehicle, comprising: the above-mentioned ECU starting device, or the above-mentioned electronic device, or the above-mentioned computer-readable storage medium.
[0124] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
[0125] In addition, although each operation is described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or to be performed in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the application. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0126] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. An ECU startup method, characterized in that: The method comprises: When the ECU is powered on, determining a first hash value of the target image file based on a target hash algorithm indicated by a hash check algorithm field included in the target image file under the first partition, wherein the target image file further includes an image file hash value field, an image header file field, and an image file content field; When the first hash value is the same as the preset hash value indicated by the image file hash value field, copy the image file content field and start the ECU at the target startup address based on the indication of the image header file field under the first partition; wherein the target startup address is stored in the image header file field; When the first hash value is different from the preset hash value, determining a second hash value of the target image file based on the target hash algorithm in the second partition; When the second hash value is the same as the preset hash value, the image file content field is copied based on the instruction of the image header file field in the second partition and the ECU is started at the target startup address.
2. The method according to claim 1, characterized in that In a case where the hash check algorithm field includes a first algorithm identifier, the target hash algorithm is a first hash algorithm corresponding to the first algorithm identifier; In the case where the hash check algorithm field includes a second algorithm identifier, the target hash algorithm is a second hash algorithm corresponding to the second algorithm identifier; In the case where the hash check algorithm field includes a third algorithm identifier, the target hash algorithm is a third hash algorithm corresponding to the third algorithm identifier; When the hash check algorithm field includes a fourth algorithm identifier, the target hash algorithm is a fourth hash algorithm corresponding to the fourth algorithm identifier.
3. The method according to claim 1 or 2, characterized in that: The target image file also includes a startup mode field; The method of determining, in the first partition, a first hash value of the target image file based on a target hash algorithm indicated by a hash check algorithm field included in the target image file when the ECU is powered on, comprises: When the ECU is powered on, obtaining the startup mode field; In a case where the startup mode field indicates a hash check startup mode, the first hash value is determined based on the target hash algorithm in the first partition.
4. The method according to claim 3, characterized in that The target image file further includes a partition identification field; when the startup mode field indicates a hash check startup mode, determining the first hash value based on the target hash algorithm in the first partition includes: When the startup mode field indicates the hash verification startup mode, obtaining the partition identification field; When the partition identification field indicates the first partition, the first hash value is determined based on the target hash algorithm under the first partition.
5. The method according to claim 3, characterized in that: When the ECU is powered on, after obtaining the startup mode field, the method further includes: In the case where the startup mode field indicates a startup mode without verification, based on the instruction of the image header file field, the image file content field is copied and the ECU is started at the target startup address.
6. The method according to claim 3, characterized in that The target image file also includes a public key field and a signature field for securely verifying the startup mode; When the ECU is powered on, after obtaining the startup mode field, the method further includes: In a case where the startup mode field indicates the security verification startup mode, performing signature verification on the signature indicated by the signature field based on the public key indicated by the public key field and the target hash value under the first partition, where the target hash value is the preset hash value or the hash value of the target image file determined according to the target hash algorithm; In the case where the signature verification is successfully performed in the first partition, based on the instruction of the image header file field, the image file content field is copied in the first partition and the ECU is started at the target startup address; In the case where the signature verification in the first partition fails, performing signature verification on the signature indicated by the signature field based on the public key and the target hash value in the second partition; In the case where the signature verification is successfully performed in the second partition, the image file content field is copied based on the instruction of the image header file field in the second partition and the ECU is started at the target startup address.
7. The method according to claim 3, characterized in that In the case where the startup mode field indicates a hash check startup mode, the hash check algorithm field is valid; In the case where the startup mode field indicates a startup mode other than the hash verification startup mode, the hash verification algorithm field is invalid.
8. An ECU starting device, characterized in that: include: A determination module, configured to determine a first hash value of a target image file based on a target hash algorithm indicated by a hash verification algorithm field included in the target image file under a first partition when the electronic control unit ECU is powered on, wherein the target image file further includes an image file hash value field, an image header file field, and an image file content field; a copy and start module, configured to copy the image file content field and start the ECU at a target start address under the first partition based on the indication of the image header file field when the first hash value is the same as the preset hash value indicated by the image file hash value field; wherein the image header file field stores the target start address; The determining module is further configured to determine, in a case where the first hash value is different from the preset hash value, a second hash value of the target image file based on the target hash algorithm in the second partition; The copy and start module is also used to copy the image file content field and start the ECU at the target startup address based on the indication of the image header file field in the second partition when the second hash value is the same as the preset hash value.
9. An electronic device, characterized in that: include: A processor, the processor is used to execute a computer program stored in a memory, and the computer program, when executed by the processor, implements the steps of the ECU startup method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the ECU startup method according to any one of claims 1 to 7 are implemented.
11. A vehicle, characterized in that: include: The ECU starting device as claimed in claim 8, or the electronic device as claimed in claim 9, or including the computer-readable storage medium as claimed in claim 10.
