Method, device, electronic terminal and storage medium for updating boot program
By constructing a hierarchical flash boot program structure, during the control program startup process, the flash boot program of the vehicle controller is updated based on the received stop request, which solves the cost problem of disassembling the controller for update in the existing technology and realizes an upgrade method without disassembly.
Patent Information
- Application Number
- CN202210176121.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-02-25
AI Technical Summary
In the prior art, updating the refresh boot program installed in the controller requires disassembling the controller, resulting in a waste of manpower and time costs.
By constructing a hierarchical flash boot program structure, during the startup of the control program, it stays in the first flash boot program of the target level based on the received stop request, erases and writes the corresponding program segments, and restarts the control program after verification until the update is completed.
This allows the bootloader to be upgraded without disassembling the controller, saving update costs.
Smart Images

Figure CN114546449B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to computer technology, and in particular to a method, device, electronic terminal and storage medium for updating a flash boot program. Background Art
[0002] In existing technology, vehicle controllers are generally equipped with a flashable bootloader, which is usually installed before the controller is packaged. Throughout the flashable bootloader's lifecycle, basic software, applications, calibration data, and other programs can be updated through protocols such as Unified Diagnostic Services (UDS) and the Universal Calibration Protocol (XCP). This allows for upgrades to vehicle functions after the controller is packaged or the vehicle rolls off the assembly line, without having to replace or disassemble the controller.
[0003] Nowadays, there is a need to update the flash boot program installed in the controller. For example: Scenario 1: Due to adjustments to the software update process, the flash boot program in the inventory controller needs to be updated; Scenario 2: The controller manufacturer supplies controllers to different vehicle assembly plants, and the flash boot programs installed by each assembly plant are incompatible.
[0004] However, in the prior art, in order to update the refresh boot program that has been installed in the controller, the controller needs to be disassembled and then the boot program needs to be updated and rewritten, which wastes a lot of manpower, time and other costs, and the update cost is high. Summary of the Invention
[0005] In view of this, an embodiment of the present invention provides a flash boot program update method, device, electronic terminal and storage medium, which can support upgrading the flash boot program without disassembling the controller after the controller is packaged or the vehicle is offline, thereby saving update costs.
[0006] In a first aspect, an embodiment of the present invention provides a method for updating a flash boot program, which is applied to an on-board controller, comprising:
[0007] During the control program startup process, the loop stops at the first flash boot program of the target level based on the received flash boot program stop request;
[0008] Erasing the first program segment in the second flash boot program of the sub-level of the target level according to the received erase instruction through the first flash boot program, and writing the second program segment into the second flash boot program according to the received write instruction;
[0009] When the writing of the second program segment is completed, the second flash boot program is verified, and when the verification passes, the control program is restarted until the flash boot program is updated.
[0010] In a second aspect, an embodiment of the present invention further provides an update device for flashing a boot program, which is applied to an on-board controller and includes:
[0011] a stay module, configured to stay in the first flash boot program of the target level based on a received stay request of the flash boot program during the control program startup process;
[0012] an update module configured to erase the first program segment in the second flash boot program of the sub-level of the target level according to the received erase instruction through the first flash boot program, and write the second program segment into the second flash boot program according to the received write instruction;
[0013] The verification module is used to verify the second flash boot program when the writing of the second program segment is completed, and restart the control program when the verification passes until the flash boot program is updated.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the update method of the flash boot program as provided in any embodiment of the present application is implemented.
[0015] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, characterized in that when the program is executed by a processor, it implements the update method of the flash boot program provided in any embodiment of the present application.
[0016] An embodiment of the present invention provides a flash boot program update method, device, electronic terminal and storage medium. The flash boot program update method can be applied to a vehicle-mounted controller and may include: cyclically stopping in a first flash boot program of a target level based on a stop request of a received flash boot program during the startup process of the control program; erasing a first program segment in a second flash boot program of a sub-level of the target level according to a received erase instruction through the first flash boot program, and writing a second program segment to the second flash boot program according to a received write instruction; when the writing of the second program segment is completed, verifying the second flash boot program, and restarting the control program when the verification passes, until the update of the flash boot program is completed.
[0017] By building a hierarchical flash boot program structure, the child-level flash boot program can be updated based on the parent-level flash boot program, thereby supporting the upgrade of the flash boot program without disassembling the controller after the controller is packaged or the vehicle is offline, saving update costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a flowchart of a method for updating a flash boot program provided in the first embodiment of the present invention;
[0019] Figure 2 This is a flow chart of controlling program startup in a method for updating a flash boot program provided in the second embodiment of the present invention;
[0020] Figure 3 This is an interface showing the process of verifying the second flashing boot program in a flashing boot program update method provided by the third embodiment of the present invention;
[0021] Figure 4 This is a schematic diagram of interaction with an external flashing device in a method for updating a flashing boot program provided in a fourth embodiment of the present invention;
[0022] Figure 5 This is a schematic diagram of the structure of an updating device for flashing a boot program provided by a fifth embodiment of the present invention;
[0023] Figure 6 This is a structural diagram of an electronic terminal provided in Example 6 of the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below through implementation methods with reference to the drawings in the embodiments 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 making creative work are within the scope of protection of the present invention. In the following embodiments, each embodiment provides optional features and examples at the same time. The various features recorded in the embodiments can be combined to form multiple optional solutions. Each numbered embodiment should not be regarded as just one technical solution.
[0025] Example 1
[0026] Figure 1This is a flowchart of a method for updating a flash boot program provided in a first embodiment of the present invention. This embodiment is applicable to updating a flash boot program in a vehicle-mounted controller. This method can be performed by a flash boot program update device provided in an embodiment of the present invention, which is implemented using software and / or hardware and can be configured in a vehicle-mounted controller.
[0027] See also Figure 1 The update method of flashing the boot program provided in this embodiment is applied to a vehicle controller and includes the following steps:
[0028] S110 , looping. During the control program startup process, based on the received request to stay in the flash boot program, staying in the first flash boot program of the target level.
[0029] In the embodiments of the present invention, an on-board controller may refer to a controller whose internal flash boot program cannot be upgraded without disassembling the controller. Examples of on-board controllers include an electronic control unit (ECU), a vehicle control unit (VCU), and a motor control unit (MCU), and the like, which are not exhaustive.
[0030] The vehicle controller may include a control program and a flash boot program. The control program may include, but is not limited to, basic software, application software, and calibration data. The flash boot program may include hierarchical flash boot programs. The control program and flash boot program are interrelated, rather than independent.
[0031] The relationship between the control program and the flash boot program can be reflected in the following: during the startup of the control program, the child-level flash boot program can be started based on the parent-level flash boot program, and when the flash boot program is started layer by layer to the last level (which can be considered as the last child level), the control program can be started based on the last-level flash boot program.
[0032] Furthermore, the connection between the control program and the flash boot program is also reflected in the fact that during the control program update process, the control program can also be updated based on the final flash boot program. It can be considered that the control program flash process can be executed based on the flash boot program, thus achieving a smooth control program update. If the control program flash process changes, the flash boot program needs to be updated to update the control program based on the new flash process.
[0033] The update method provided in this embodiment can implement the update of the flashable boot program, and the process of updating the flashable boot program can occur during the startup of the control program. For example, if the vehicle controller receives a flashable boot program dwell request sent by an external flashing device, the control program of the vehicle controller can, during the startup process, dwell at a target-level flashable boot program according to the dwell request. For the sake of convenience, the flashable boot program at the target-level currently dwelled can be referred to as the first flashable boot program.
[0034] Among them, the types of stay requests may include but are not limited to IO requests and communication requests. When the stay request is an IO request, the external flashing device can be connected to the on-board controller through an IO interface, and different IO interfaces can correspond to different levels of flashing boot programs. When a flashing boot program of a certain level needs to be updated, the external flashing device can set the IO pin corresponding to the flashing boot program of its parent level (i.e., the target level) to a different potential or state than the IO pin corresponding to the flashing boot program of other levels. Accordingly, when the on-board controller recognizes IO pins with different potentials or states, it can use it as a stay request to stay in the first flashing boot program of the target level according to the stay request. When the stay request is a communication request, the stay requests of flashing boot programs of different levels can be distinguished in at least one of the following ways: external requests of different communication buses, external requests of different channels of the same communication bus, communication requests of different messages of the same channel of the same bus, or external requests of the same message of the same channel of the same bus but with different message contents.
[0035] S120 , using the first flash boot program, erasing the first program segment in the second flash boot program of the sub-level of the target level according to the received erase instruction, and writing the second program segment into the second flash boot program according to the received write instruction.
[0036] The parent-level flash boot program can include the startup program segment and update program segment of the child-level flash boot program. Furthermore, based on the startup program segment, the parent-level flash boot program can start the child-level flash boot program; based on the update program segment, the parent-level flash boot program can update the child-level flash boot program.
[0037] In this embodiment, the first flashing boot program can be considered a parent-level flashing boot program, the second flashing boot program can be considered a child-level flashing boot program, and the second flashing boot program can be considered the program that needs to be updated during the current control program startup process. When using the first flashing boot program to update the second flashing boot program, the vehicle controller can execute the operations of erasing the first program segment in the second flashing boot program and writing the second program segment to the second flashing boot program according to the erase command and write command received from the external flashing device.
[0038] There's no strict order in which to erase the first program segment and write the second program segment; they can be performed based on the actual update scenario. For example, if the onboard controller has limited storage resources, the first program segment can be erased before writing the second. If storage resources are more plentiful, the second program segment can be written before erasing the first. This ensures that if an abnormality occurs in writing the second program segment, the boot program remains in its original state, preventing the introduction of abnormal program segments during the boot program update.
[0039] S130 , when the writing of the second program segment is completed, verifying the second flash boot program, and restarting the control program if the verification passes, until the flash boot program is updated.
[0040] When verifying the second flashed boot program, at least one of the following methods may be used: directly comparing the updated second flashed boot program with the target program; comparing the updated second flashed boot program with the target program using a CRC checksum algorithm; or comparing the updated second flashed boot program with the target program after encryption and decryption using an encryption algorithm such as MD5 or DES. Other verification methods may also be used, and are not exhaustive here.
[0041] Starting the control program after the second flash boot program passes verification allows for earlier program anomaly detection, ensuring normal startup compared to directly starting the control program. During the next control program startup, the second flash boot program that needs to be updated during the current startup process can be updated based on the first flash boot program at the target level in the current startup process, and the control program can be restarted in a loop. By restarting the control program in a loop, it is possible to update the flash boot program at one or more levels that require updating until all levels of the flash boot program are updated.
[0042] In this embodiment, by constructing the flashing boot program as a hierarchical program, the program corresponding to the flashing program update process can be divided into the first level (which can be considered the first level) of programs. Since the process of updating the flashing program usually does not change, the flashing boot program at the first level can be fixed and not updated. The flashing boot program corresponding to the update control program process can be divided into sub-level programs layer by layer, and the sub-level programs can be updated according to the parent level program. This can support the flashing boot program upgrade after the controller is packaged or after the vehicle is off the assembly line without disassembling the controller, saving update costs.
[0043] In some optional implementations, after the flash boot program is updated, the method further includes: refreshing and starting the control program based on the updated flash boot program.
[0044] In these optional implementations, when the updates of the flash boot programs at each level that need to be updated are completed, the control program can also be flashed and started based on the last level of the program in the updated flash boot program, thereby enabling the control program to be updated and started based on the new flash process.
[0045] A flash boot program update method provided by an embodiment of the present invention is applied to a vehicle-mounted controller and may include: cyclically stopping in a first flash boot program of a target level based on a stop request of a received flash boot program during the startup process of the control program; erasing a first program segment in a second flash boot program of a sub-level of the target level according to a received erase instruction through the first flash boot program, and writing a second program segment to the second flash boot program according to a received write instruction; when the writing of the second program segment is completed, verifying the second flash boot program, and restarting the control program when the verification passes, until the update of the flash boot program is completed.
[0046] By building a hierarchical flash boot program structure, the child-level flash boot program can be updated based on the parent-level flash boot program, thereby supporting the upgrade of the flash boot program without disassembling the controller after the controller is packaged or the vehicle is offline, saving update costs.
[0047] Example 2
[0048] The method for updating the flashing boot program provided in this embodiment can be combined with the various optional solutions in the flashing boot program update method provided in the above embodiments. The method for updating the flashing boot program provided in this embodiment describes in detail the steps for stopping at the target level of the flashing boot program. By determining whether to stop at the flashing boot program at the current level based on the stop request, the flashing boot program can ultimately stop at the target level, thereby completing the update of the flashing boot program at the target level's sub-levels.
[0049] In this embodiment, the flash boot program includes a basic program and 1st to Nth level extension programs; wherein the 1st level extension program is a sub-level program of the basic program; the nth level extension program is a sub-level program of the n-1th level extension program; wherein n∈[2,N].
[0050] Among them, the basic program can be considered as the first level flash boot program disclosed above. The first level extension program can be considered as a sub-level flash boot program of the basic program, the second level extension program can be considered as a sub-level flash boot program of the first level extension program, and so on. The nth level extension program can be considered as a sub-level flash boot program of the n-1th level extension program. In other words, the basic program is the parent-level flash boot program of the first level extension program, the first level extension program is the parent-level flash boot program of the second level extension program, and so on. The n-1th level extension program is the parent-level flash boot program of the nth level extension program. Among them, n can be a positive integer in the range of [2,N], and N can be a positive integer greater than or equal to 2.
[0051] The child-level flash boot program can be started through the startup program segment in the parent-level flash boot program; the child-level flash boot program can be updated through the update program segment in the parent-level flash boot program. It can be considered that the extension program of the level that needs to be updated can be updated only by relying on the update program segment in its parent-level program. For example, assuming that the flash boot program includes a basic program, a first-level extension program and a second-level extension program, if the second-level extension program needs to be updated, it can be achieved only by relying on the update program segment in the first-level extension program. At this time, even if the update program segment in the basic program is damaged, it will not affect the update of the second-level extension program.
[0052] For example, when the flash boot program includes a basic program and 1st to Nth level extension programs, Figure 2 This is a flow chart of the control program startup in a method for updating a flash boot program provided by the second embodiment of the present invention. Figure 2 The process of controlling program startup in the update method of flashing the boot program provided in this embodiment may include:
[0053] S201: The vehicle controller hardware is started.
[0054] S202: Basic program starts.
[0055] S203 : Based on the received stay request of the flash boot program, determine whether to jump to the sub-level program; if so, jump to S204 ; otherwise, jump to S205 .
[0056] The stay request may carry information indicating the target level. By determining whether the current level is equal to the target level, the user can determine whether to jump to a sub-level program. Specifically, if the current level is equal to the target level, the user does not jump to the sub-level program; if the current level is not equal to the target level, the user jumps to the sub-level program.
[0057] In some optional implementations, after the basic program is started, it is also possible to cyclically determine whether the sub-level programs are complete; if not, the current level program is used as the first flash boot program of the target level and stay there.
[0058] After starting the basic program, when making jump decisions for the program expansion layer by layer, the jump decisions can be made not only based on the stay request, but also based on the integrity of the sub-level program. Among them, making jump decisions based on the integrity of the sub-level program can include jumping to the sub-level program when the sub-level is complete, and not jumping to the sub-level program when the sub-level is incomplete, that is, staying in the program of the current level. Among them, when the current level is not equal to the target level in the stay request, and when the sub-level program is complete, it can be determined that it is possible to jump to the sub-level program. When the current level is equal to the target level in the stay request, and / or the sub-level program is incomplete, it is determined that it is not possible to jump to the sub-level program.
[0059] Among them, determining whether the sub-level program is complete may include: determining whether the sub-level program is complete based on the data verification method, or determining whether the sub-level program is complete based on the segment keyword matching method. Among them, determining the integrity based on the data verification method may include: using a specific algorithm to calculate the verification value of the program whose integrity needs to be determined, and comparing it with the pre-stored verification value. If they are equal, it has integrity, otherwise it does not. Among them, determining the integrity based on the segment keyword matching method may include: configuring a segment keyword for each program segment of the program that needs to be determined to be complete, and splicing all keywords into complete keywords in a fixed order; pre-storing keywords in program data at each level, when determining the integrity of the program, the pre-stored keywords can be combined in a fixed order to obtain segment keywords, and comparing the segment keywords with the complete keywords to see if they are equal; if they are equal, it has integrity, otherwise it does not. In addition, other program integrity verification methods can also be applied here, and they are not exhaustive here.
[0060] In these optional implementations, if both the stay request and the integrity of the sub-level program determine that the program is jumping to the sub-level program, the process jumps to S204; if either the stay request or the integrity of the sub-level program determines that the program is not jumping to the sub-level program, the process jumps to S205. Thus, even if the sub-level program is not originally a program that needs to be updated, an incomplete anomaly can be detected and treated as a program that needs to be updated.
[0061] S204, start the sub-level program and determine whether the current level program is the last level; if so, jump to S206, if not, jump to S203.
[0062] After starting the sub-level program, the original sub-level program becomes the current-level program. If the current-level program is the last-level program, the process can jump to S206 to flash or start the control program. If the current-level program is not the last-level program, the process can jump to S203 to loop based on the received request to flash the boot program and determine whether to jump to the sub-level program.
[0063] S205: Use the current level program as the first flash boot program of the target level and stay there.
[0064] When it is determined that the program at the current level should not be jumped to the sub-level program, the program at the current level can be used as the first flash boot program at the target level and stopped at. Furthermore, after stopping at the first flash boot program at the target level, the first flash boot program can erase the first program segment in the second flash boot program at the sub-level of the target level according to the received erase instruction, and write the second program segment to the second flash boot program according to the received write instruction. When the writing of the second program segment is completed, the second flash boot program is verified, and if the verification passes, the control program is restarted until the flash boot program update is completed.
[0065] S206 , based on the received stay request for flashing the boot program, determine whether to jump to the control program; if so, jump to S207 , otherwise jump to S205 .
[0066] When the current level program is the last level program, it is also possible to determine whether to jump to the control program based on a stay request and the integrity of the control program. For details, see Determining Whether to Jump to a Sub-Level Program Based on a Stay Request and the Integrity of a Sub-Level Program.
[0067] If it is determined that the jump is to the control program, the process can jump to S207 to start the control program; if it is determined that the jump is not to the control program, the process can jump to S205 to stay in the last level of the program. After staying in the last level of the flash boot program, the control program can also be updated through the last level of the flash boot program.
[0068] S207: Based on the final level program, start the control program.
[0069] The updating method of the flash boot program provided in the embodiment of the present invention describes in detail the steps of stopping the flash boot program at the target level. By determining whether to stop at the flash boot program of the current level layer by layer based on the stop request, it is possible to finally stop at the flash boot program of the target level to complete the update of the flash boot program of the sub-level of the target level. In addition, the updating method of the flash boot program provided in this embodiment and the updating method of the flash boot program provided in the above embodiment belong to the same technical concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and the same technical features have the same beneficial effects in this embodiment and the above embodiment.
[0070] Example 3
[0071] The flash boot program update method provided in this embodiment can be combined with the various optional solutions in the flash boot program update method provided in the above embodiments. The flash boot program update method provided in this embodiment provides a detailed description of the verification steps for the second flash boot program. By performing a correctness check on the currently written second program segment upon completion of each second program segment, and performing an integrity check on each second program segment upon completion of each second program segment, the accuracy of the second flash boot program update can be guaranteed.
[0072] For example, Figure 3 This is a flow chart interface for verifying the second flash boot program in a flash boot program update method provided by the third embodiment of the present invention. Figure 3 In the method for updating the flash boot program provided in this embodiment, the second program segment includes at least one segment. The process of verifying the second flash boot program may include:
[0073] S301 , using the first flash boot program, erasing the first program segment in the second flash boot program of the sub-level of the target level according to the received erase instruction.
[0074] S302 : Writing a second program segment into the second flash boot program according to the received write instruction.
[0075] In this embodiment, the second program segment to be written may include multiple segments, and the first program segment to be erased may also include multiple segments. In some cases, the erased first program segment may correspond to the written second program segment, for example, the program segments before and after a certain flashing step of the control program may be updated. In these cases, each time a first program segment is erased, the corresponding second program segment may be written.
[0076] S303: When each second program segment is written, perform a correctness check on the currently written second program segment.
[0077] In this embodiment, after each second program segment is written, the correctness of the currently written second program segment can be checked. For example, as mentioned above, the correctness of the written second program segment can be checked based on a simple direct comparison, a CRC check algorithm, or an encryption and decryption algorithm such as MD5 or DES.
[0078] S304, when the correctness check passes, determine whether there is an unwritten second program segment; if there is an unwritten second program segment, jump to S301, and when all the second program segments are written, jump to S305.
[0079] If the second program segment needs to be written, the process can jump to S301 to erase the first program segment corresponding to the second program segment to be written. Alternatively, if no corresponding first program segment exists, the process can jump directly to S302 to write the second program segment. When all the second program segments to be written are completed, the process can jump to S305 to perform an integrity check.
[0080] In addition, if the correctness check of the second program segment currently being written fails, the process of updating the flashing boot program can be stopped, and the program can be stopped at the target level, or a prompt indicating that the flashing boot program update failed can be given.
[0081] S305: Perform integrity check on each second program segment.
[0082] The integrity check of each second program segment may include at least two aspects: first, verifying that all required second program segments have been written; and second, verifying whether the program segment addresses of each written second program segment match the preset addresses. If both of these checks pass, each second program segment may be considered complete.
[0083] S306: When the verification passes, restart the control program until the flashing boot program is updated.
[0084] If the integrity check of each second program segment passes, the control program can be restarted until the flashing boot program is updated. The control program can then be flashed or restarted based on the updated flashing boot program. Furthermore, if the integrity check of each second program segment fails, the flashing boot program update process can be stopped, either stopping at the target level or displaying a prompt indicating that the flashing boot program update failed.
[0085] The updating method of the flash boot program provided in the embodiment of the present invention describes in detail the verification steps of the second flash boot program. By performing a correctness check on the currently written second program segment when each second program segment is written, and performing an integrity check on each second program segment when each second program segment is written, the accuracy of the update of the second flash boot program can be guaranteed. In addition, the updating method of the flash boot program provided in this embodiment and the updating method of the flash boot program provided in the above embodiment belong to the same technical concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and the same technical features have the same beneficial effects in this embodiment and the above embodiment.
[0086] Example 4
[0087] The flash boot program update method provided in this embodiment can be combined with the various optional solutions in the flash boot program update method provided in the above embodiments. The flash boot program update method provided in this embodiment provides a detailed description of some optional steps before the second flash boot program update. By adding operations such as verifying related requests, determining preprocessing conditions, and writing flash drivers, the flash boot program update process can be guaranteed to be compliant and normal. By adding an operation to record flash information, it can facilitate the retrospective processing of subsequent program exceptions.
[0088] For example, Figure 4 This is a schematic diagram of the interaction between the external flashing device and the flashing boot program update method provided by the fourth embodiment of the present invention. Figure 4 The step of interacting with the external flashing device in the flashing boot program update method provided in this embodiment may include:
[0089] S401: The external flashing device sends a stop request for flashing the boot program.
[0090] Usually when the control program needs to be updated, the user can manually initiate the host computer process, that is, send a stop request for flashing the boot program of the target level to the vehicle controller through an external flashing device.
[0091] S402: The vehicle controller restarts the control program.
[0092] S403 : During the startup process, based on the received request to stay in the flash boot program, stay in the first flash boot program of the target level.
[0093] S404: The external flash device initiates an access request.
[0094] The access request may be considered as a request for authentication of the external flash device, and the access request may carry a set of random numbers and a check value calculated based on a preset algorithm within the external flash device.
[0095] In some implementations, the external flashing device can directly initiate an access request without sending a dwell request to the vehicle controller. Accordingly, if no dwell request is received, the vehicle controller can use the parent of the last level as the target level and the parent of the last level as the first flashing boot program. By dwelling on the parent of the last level, the last level flashing boot program can be updated.
[0096] S405: The vehicle-mounted controller verifies the received access request.
[0097] Verifying the access request may include: calculating a set of random numbers in the access request according to a preset algorithm within the vehicle controller; verifying whether the calculated result is the same as the check value carried in the access request; if so, the access request is considered to have passed verification; otherwise, it is considered to have failed. The preset algorithm can be any verification algorithm, such as a CRC check algorithm, and the examples are not exhaustive.
[0098] S406: The external flash device initiates pre-processing before updating.
[0099] When the onboard controller reports that the access request has been verified, the external flash device can also initiate pre-update processing. The pre-update processing can vary depending on the update scenario. For example, when updating the flash boot program in the controller of a new energy electric vehicle, the pre-update processing can include powering down the entire vehicle.
[0100] In addition, when the vehicle controller fails to verify the access request, the update process can be stopped and a prompt can be given that the boot program update failed.
[0101] S407: The vehicle controller determines the pre-processing conditions before updating.
[0102] The vehicle controller can also determine whether the external flash device has performed pre-update pre-processing operations based on the specific update scenario.
[0103] S408: The external flashing device initiates a flashing request.
[0104] S409: The vehicle controller verifies the received flashing request.
[0105] A flash request can be considered a request to verify the flash permission of an external flash device, and it can also include a random number and a checksum. Accordingly, the vehicle controller can verify the flash request using the same process as the access request information verification process. The difference lies in that the two verification processes can use internal algorithms with different security levels. The algorithm used in the flash request verification process is generally more secure.
[0106] S410: An external flashing device writes flashing information; the flashing information includes a flashing device identifier and a flashing date.
[0107] The flash device identifier may be considered as a fingerprint of the external flash device, for example, a characteristic ID composed of at least one element such as numbers, letters, and special symbols; the flash date may be a timestamp when the refresh information is written.
[0108] S411. The vehicle controller records the flashing information.
[0109] By recording the flashing device ID and flashing date, it is easy to find the external flashing device used in this update, thereby facilitating the backtracking of abnormal flashing of the boot program.
[0110] S412: The external flashing device writes the flashing driver.
[0111] S413: The vehicle-mounted controller receives and writes a flash driver, wherein the flash driver is used to write the second program segment.
[0112] Since driver support is required when writing the second program segment to the second flash boot program, the external flash device can perform the flash driver writing operation to facilitate the flashing of the vehicle controller. In addition, before the external flash device writes the flash driver, the vehicle controller can also detect whether the flash driver exists internally. If not, step S412 can be executed; if so, step S414 can be directly executed without executing step S412.
[0113] S414: The external flash device sends an erase instruction.
[0114] S415 . The vehicle controller erases the first program segment in the second flash boot program of the sub-level of the target level according to the received erase instruction through the first flash boot program.
[0115] S416: The external flash device sends a write instruction.
[0116] S417 , the vehicle-mounted controller writes the second program segment into the second flashing boot program according to the received write instruction through the first flashing boot program.
[0117] S418. When the writing of the current second program segment is completed, the on-board controller performs a correctness check on the currently written second program segment.
[0118] S419: When the correctness check passes, the external flash device determines whether there is any unwritten second program segment; if so, the process jumps to S414; if not, the process jumps to S420.
[0119] S420: The external flashing device initiates an integrity determination request.
[0120] S421. The on-board controller performs integrity verification on each second program segment according to the integrity determination request.
[0121] S422: When the integrity check passes, the external flashing device initiates a restart command.
[0122] S423: The vehicle controller jumps to S402 according to the restart instruction until the flashing boot program update is completed.
[0123] S424: The external flash device initiates post-processing after the update.
[0124] S425: The vehicle controller performs post-update processing, and refreshes and starts the control program based on the updated flash boot program.
[0125] The updated post-processing can be considered as the processing operation corresponding to the pre-processing before the update. For example, if the current processing is to turn off the high voltage power supply to the new energy vehicle, the post-processing can be to turn on the high voltage power supply to the new energy vehicle.
[0126] Furthermore, after the post-processing operation, the vehicle controller can be flashed or started according to the updated flash boot program.
[0127] The update method of the flash boot program provided in the embodiment of the present invention describes in detail some optional steps before the second flash boot program is updated. By adding operations such as verifying related requests, judging preprocessing conditions, and writing flash drivers, it can ensure that the update process of the flash boot program can be carried out in compliance and normally, and by adding operations to record flash information, it can facilitate the backtracking of subsequent program exceptions. In addition, the update method of the flash boot program provided in this embodiment and the update method of the flash boot program provided in the above embodiment belong to the same technical concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and the same technical features have the same beneficial effects in this embodiment and the above embodiment.
[0128] Example 5
[0129] Figure 51 is a schematic diagram of a device for updating a flash boot program according to a fifth embodiment of the present invention. This embodiment is applicable to updating a flash boot program in a vehicle-mounted controller.
[0130] See also Figure 5 The updating device for flashing the boot program provided by the present invention is applied to a vehicle controller and may include:
[0131] A stay module 510 is configured to stay in the first flash boot program of a target level based on a received stay request of the flash boot program during the control program startup process;
[0132] An update module 520 is configured to erase the first program segment in the second flash boot program of the sub-level of the target level according to the received erase instruction through the first flash boot program, and write the second program segment into the second flash boot program according to the received write instruction;
[0133] The verification module 530 is used to verify the second flash boot program when the second program segment is written, and restart the control program if the verification passes until the flash boot program is updated.
[0134] In some optional implementations, the flashing boot program includes a basic program and 1st to Nth level extension programs; wherein the 1st level extension program is a sub-level program of the basic program; the nth level extension program is a sub-level program of the n-1th level extension program; wherein n∈[2,N];
[0135] Accordingly, the dwell module can be used to:
[0136] After the basic program is started, the loop determines whether to jump to the sub-level program based on the received stay request of the flash boot program;
[0137] If not, the current level program is used as the first flash boot program of the target level and the process stops.
[0138] In some optional implementations, the stay module may also be used to:
[0139] After the basic program is started, the loop determines whether the sub-level program is complete;
[0140] If not, the current level program is used as the first flash boot program of the target level and the process stops.
[0141] In some optional implementations, the second program segment includes at least one segment; accordingly, the verification module can be used to:
[0142] When each second program segment is written, the correctness of the second program segment currently being written is checked;
[0143] When the writing of each second program segment is completed, the integrity of each second program segment is checked.
[0144] In some optional implementations, the updating device for flashing the boot program may further include:
[0145] The control program refreshing module is used to refresh and start the control program based on the updated flash boot program after the flash boot program is updated.
[0146] In some optional implementations, the updating device for flashing a boot program may further perform at least one of the following steps after pausing in the first flashing boot program of the target level and before erasing the first program segment in the second flashing boot program of a sub-level of the target level according to at least one of the following modules:
[0147] An access verification module, used to verify the received access request;
[0148] A pre-processing condition judgment module is used to judge the pre-processing conditions before updating;
[0149] A refresh verification module is used to verify the received refresh request;
[0150] A recording module for recording flashing information, wherein the flashing information includes a flashing device identifier and a flashing date;
[0151] The driver writing module is used to receive and write a flash driver, wherein the flash driver is used to write the second program segment.
[0152] The apparatus for updating a flash boot program provided in the embodiment of the present invention can execute the method for updating a flash boot program provided in the embodiment of the present invention, and has the corresponding functional modules and beneficial effects. For technical details not described in detail, please refer to the method for updating a flash boot program provided in the embodiment of the present invention.
[0153] Example 6
[0154] Figure 6 This is a structural diagram of an electronic terminal provided in Example 6 of the present invention. Figure 6 A block diagram of an exemplary electronic terminal 600 suitable for implementing embodiments of the present invention is shown. Figure 6 The electronic terminal 600 shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention. The device 600 is typically an electronic terminal that performs the update function of flashing the boot program, such as any vehicle-mounted controller.
[0155] like Figure 6As shown, the electronic terminal 600 is implemented as a general-purpose computing device. Components of the electronic terminal 600 may include, but are not limited to, one or more processors or processing units 616, a memory 628, a bus 618 connecting various components (including the memory 628 and the processor 616), and a power supply system for supplying power to the various components.
[0156] Bus 618 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus. In this embodiment, bus 618 can be an in-vehicle bus, such as in-vehicle Ethernet, CAN bus, Flex Ray, Most or LIN bus, etc.
[0157] The electronic terminal 600 typically includes a variety of computer-readable media. These media can be any available media that can be accessed by the electronic terminal 600, including volatile and non-volatile media, removable and non-removable media.
[0158] The memory 628 may include computer-readable media in the form of volatile memory, such as random access memory (RAM) 630 and / or cache memory 632. The electronic terminal 600 may further include other removable / non-removable, volatile / non-volatile computer storage media. By way of example only, the storage system 634 may be used to read and write non-removable, non-volatile magnetic media ( Figure 6 Not shown, often called a "hard drive"). Although Figure 6Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (such as a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (such as a read-only optical disk (Compact Disc-Read Only Memory, CD-ROM), a digital video disk (Digital Video Disc-Read Only Memory, DVD-ROM) or other optical media) may be provided. In these cases, each drive can be connected to the bus 618 through one or more data medium interfaces. The memory 628 can store at least one program product, which program product includes, for example, a control program (which may include basic software, application software, calibration data), a flash boot program (which may include a basic program and 1st to Nth level extension programs) and a program that can execute the functions and / or methods of each embodiment of the present invention.
[0159] The electronic terminal 600 can also communicate with one or more external devices 614 (e.g., a keyboard, mouse, camera, and display), one or more devices that enable a user to interact with the electronic terminal 600, and / or any device that enables the electronic terminal 600 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). In this embodiment, the external device 614 can be an external flash device. The electronic terminal 600 can communicate with the external devices 614 via an input / output (I / O) interface 622. The electronic terminal 600 can also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network controller 620. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic terminal 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) devices, tape drives, and data backup storage devices.
[0160] The processor 616 executes various functional applications and data processing by running the programs stored in the memory 628, such as implementing the update method of flashing the boot program provided in the above embodiment of the present invention, including:
[0161] During the startup of the control program, the loop stops at the first flash boot program of the target level based on the stop request of the received flash boot program; through the first flash boot program, the first program segment in the second flash boot program of the sub-level of the target level is erased according to the received erase instruction, and the second program segment is written to the second flash boot program according to the received write instruction; when the writing of the second program segment is completed, the second flash boot program is verified, and the control program is restarted when the verification passes until the flash boot program update is completed.
[0162] Of course, those skilled in the art will appreciate that the processor may also implement the technical solution of the update method for flashing the boot program provided in the embodiment of the present invention.
[0163] Example 7
[0164] Embodiment 7 of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the updating method of flashing a boot program as provided in the embodiment of the present invention is implemented. The method includes:
[0165] During the startup of the control program, the loop stops at the first flash boot program of the target level based on the stop request of the received flash boot program; through the first flash boot program, the first program segment in the second flash boot program of the sub-level of the target level is erased according to the received erase instruction, and the second program segment is written to the second flash boot program according to the received write instruction; when the writing of the second program segment is completed, the second flash boot program is verified, and the control program is restarted when the verification passes until the flash boot program update is completed.
[0166] Of course, the computer-readable storage medium provided by the embodiment of the present invention stores a computer program which is not limited to the above method operation, and can also execute the update method of flashing the boot program provided by the embodiment of the present invention.
[0167] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor device, apparatus or component, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: 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 thereof. In this document, 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 device, apparatus or device.
[0168] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution apparatus, device, or component.
[0169] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0170] Computer program code for carrying out the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0171] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will appreciate that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments, and substitutions are possible for those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the scope of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for updating a boot program, characterized in that: Applied to vehicle controllers, including: During the control program startup process, the loop stops at the first flash boot program of the target level based on the received flash boot program stop request; Erasing the first program segment in the second flash boot program of the sub-level of the target level according to the received erase instruction through the first flash boot program, and writing the second program segment into the second flash boot program according to the received write instruction; When the writing of the second program segment is completed, the second flash boot program is verified, and if the verification passes, the control program is restarted until the flash boot program is updated; The flashing boot program is constructed as a hierarchical program, the program corresponding to the update flashing program process is divided into the first-level program, and the flashing boot program corresponding to the update control program process is divided into sub-level programs layer by layer; The flash boot program includes a basic program and 1st to Nth level extension programs; the basic program is the first level flash boot program; the 1st level extension program is a sub-level program of the basic program; the nth level extension program is a sub-level program of the n-1th level extension program; wherein n∈[2,N]; Accordingly, based on the received request to stay in the flash boot program, staying in the first flash boot program of the target level includes: After the basic program is started, the loop determines whether to jump to the sub-level program based on the received stay request of the flash boot program; wherein the stay request carries information representing the target level, and whether to jump to the sub-level program is determined by determining whether the current level is equal to the target level; If not, the current level program is used as the first flash boot program of the target level and the process stops.
2. The method according to claim 1, characterized in that Also includes: After the basic program is started, it is cyclically determined whether the sub-level programs are complete; If not, the current level program is used as the first flash boot program of the target level and the process stops.
3. The method according to claim 1, characterized in that The second program segment includes at least one segment; accordingly, when the writing of the second program segment is completed, the second flash boot program is verified, including: When each second program segment is written, the correctness of the second program segment currently being written is checked; When the writing of each second program segment is completed, the integrity of each second program segment is checked.
4. The method according to claim 1, wherein After the flash boot program update is completed, the method further includes: Based on the updated flash boot program, the control program is refreshed and started.
5. The method according to claim 1, wherein After staying in the first flash boot program of the target level and before erasing the first program segment in the second flash boot program of the sub-level of the target level, the method further includes at least one of the following steps: Verify received access requests; Determine the pre-processing conditions before updating; Verify the received flash request; Record the flashing information, where the flashing information includes the flashing device identifier and the flashing date; A flash driver is received and written, wherein the flash driver is used to write the second program segment.
6. A device for updating a boot program, characterized in that: Applied to vehicle controllers, including: a stay module, configured to stay in the first flash boot program of the target level based on a received stay request of the flash boot program during the control program startup process; an update module configured to erase the first program segment in the second flash boot program of the sub-level of the target level according to the received erase instruction through the first flash boot program, and write the second program segment into the second flash boot program according to the received write instruction; a verification module, configured to verify the second flash boot program when the writing of the second program segment is completed, and restart the control program if the verification passes, until the flash boot program is updated; The flashing boot program is constructed as a hierarchical program, the program corresponding to the update flashing program process is divided into the first-level program, and the flashing boot program corresponding to the update control program process is divided into sub-level programs layer by layer; The flash boot program includes a basic program and 1st to Nth level extension programs; the basic program is the first level flash boot program; the 1st level extension program is a sub-level program of the basic program; the nth level extension program is a sub-level program of the n-1th level extension program; wherein n∈[2,N]; Accordingly, the stop module is used to: After the basic program is started, the loop determines whether to jump to the sub-level program based on the received stay request of the flash boot program; wherein the stay request carries information representing the target level, and whether to jump to the sub-level program is determined by determining whether the current level is equal to the target level; If not, the current level program is used as the first flash boot program of the target level and the process stops.
7. An electronic terminal 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 program, the updating method for flashing the boot program as described in any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the updating method for flashing a boot program as claimed in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
A program updating method and device
CN106990982A
Method for updating and upgrading Bootloader software by automobile ECU (Electronic Control Unit) controller
CN112506535A