Method for calibrating bootloader upgrade ID in automobile electronic system
By initializing and verifying the upgrade ID of the controller in the automotive electronic system, and making changes without affecting system stability, the problem of needing to disassemble the casing for programming when the controller function is changed is solved, achieving a more efficient The bootloader and APP programs have been updated to improve the ease of use and security of the system.
Patent Information
- Application Number
- CN202410707843.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-09-24
AI Technical Summary
In automotive electronic systems, the bootloader upgrade ID needs to be replaced when the controller function is changed. However, it is difficult to simplify this process with existing technology. It is usually necessary to disassemble the controller shell for programming, which is inefficient.
Implement the bootloader by initializing the controller chip and non-volatile memory, using a hash algorithm or user-defined rules to verify the correctness of the upgrade ID, and using diagnostic services to change or write a new upgrade ID without affecting system stability. Synchronous updates with the APP program.
It simplifies the controller function change process, avoids the tedious steps of disassembling the casing and burning, improves work efficiency, and ensures the correct response of the bootloader and APP program, ensuring the success and safety of the system upgrade.
Smart Images

Figure CN118689504A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automobile control, and in particular to a method for calibrating a bootloader upgrade ID in an automobile electronic system. Background Art
[0002] In automotive electronic systems, the bootloader is an extremely important component that is responsible for loading applications from external memory into the system and executing them.
[0003] The bootloader for upgrading automotive electronic software is a special boot loader, which is generally stored in a specific address of a component controller control chip in the form of firmware. Its main function is to start firmware and software programs. A good bootloader must have good fault tolerance, reliability, security and ease of use. It should ensure the integrity of firmware and software. The present invention is implemented using the CAN protocol, a communication protocol commonly used in the automotive electronics industry.
[0004] In order to solve the problems that may occur during the bootloader upgrade process, a common method is to assign a unique ID to each bootloader, that is, to calibrate the bootloader upgrade ID. This ID can be in the form of a number, a string, etc., which is used to uniquely identify each controller information. By calibrating the bootloader upgrade ID, you can ensure that the correct bootloader version is selected when the system is upgraded to avoid unnecessary problems. At the same time, for some systems that require specific functions, different IDs can be assigned to different versions of bootloaders so that they can be selected according to needs.
[0005] Taking the motor controller as an example, in heavy-duty engineering machinery, it may be necessary to install a driving power system controller and multiple execution operation controllers. At this time, there are greater than or equal to two controllers on a vehicle. Assume that the vehicle needs to replace the controller spare parts of the driving power system function, and only the execution operation controller is left. Because the upgrade and diagnostic ID of each controller is different, the execution operation controller software needs to be replaced with the driving power system function controller. At this time, it is necessary to replace the bootloader upgrade ID, and then upgrade the corresponding function, such as the driving power system function application in this example. Summary of the invention
[0006] The purpose of the present invention is to overcome the difficulty that the controller function change requires opening the controller and burning the bootloader through a burner, and provide a method for calibrating the bootloader upgrade ID in an automotive electronic system. The uniqueness of the present invention is that the bootloader upgrade ID can be changed at any time, and the user can easily change the upgrade ID to adapt to different application scenarios.
[0007] The technical solution adopted by the present invention is: a method for calibrating a bootloader upgrade ID in an automotive electronic system, comprising the following steps: Step 1: Initialize the controller chip CPU module and non-volatile memory and enter the bootloader; Step 2, by reading the upgrade ID in the non-volatile memory and verifying the correctness of the upgrade ID through a hash algorithm or a user-defined rule, detecting whether the bootloader ID in the controller is a valid upgrade ID; When the upgrade ID valid flag in the controller is TRUE, go to step 3, if it is FLASE, go to step 4; Step 3, initialize the controller driver, use the upgrade ID with the valid flag bit set to TRUE or the default bootloader upgrade ID; Step 4, check whether the APP in the controller is valid; obtain the APP valid flag through the non-volatile memory interface; When the APP valid bit in the controller is FALSE, go to step 5; When the APP valid bit in the controller is TRUE, and the host computer does not refresh the APP action for more than 10ms, go to step 6; When the APP valid bit in the controller is TRUE, the host computer refreshes the APP action within 10ms, clears the APP valid bit, and the refresh ends. The ECU is reset and enters step 1; Step 5, APP is invalid, the controller runs in bootloader; Read the upgrade ID through diagnostic service 0x22; When the host computer does not need to calibrate the upgrade ID, the controller continues to run in the current state, otherwise it goes to step 7; Whether the upgrade ID calibration is required is determined by the controller customer needs or the application scenario; Step 6: If the APP is valid, the controller jumps to the APP operation; Read the upgrade ID through diagnostic service 0x22; When the host computer does not need to calibrate the upgrade ID, the controller continues to run in the current state, otherwise it goes to step 7; Whether the upgrade ID calibration is required is determined by the controller customer needs or the application scenario; Step 7: The controller performs calibration. After calibration is completed, the ECU is reset and the process goes to step 1.
[0008] Further, the step 2 comprises: Step 201: Obtaining an upgrade ID through a non-volatile memory interface; Step 202: Verify the correctness of the upgrade ID through a hash algorithm or user-defined rules. If the verification passes, use this ID; if the verification fails, use the default bootloader upgrade ID.
[0009] Further, the step 7 comprises: Step 701: the controller receives a diagnostic command sent by the host computer and enters an extended session request, because the calibration prerequisite requires the definition to be executed under the extended session; Step 702: security access verification. If the verification succeeds, continue to receive diagnostic services. If the verification fails, respond with a negative response code. Step 703: The host computer sends a diagnostic command to calibrate the write data information request; Step 704: The controller determines whether the received write data information, i.e., the upgrade ID, meets the custom verification rules. If it meets the custom verification rules, step 705 is executed. Otherwise, the host computer issues a negative response code, indicating that the calibration fails and exits. Step 705: calling the non-volatile memory interface to write the upgrade ID into the controller non-volatile memory; Step 706: Set the APP valid bit to FALSE to prevent the upgrade failure caused by the inconsistency between the bootloader upgrade ID and the APP.
[0010] Further, the step 702 is specifically as follows: the host computer sends a diagnostic request 27 01 to request a seed, and the controller responds to the host computer with a seed generated by a custom algorithm. Then the host computer calculates the value of the key according to the custom algorithm based on the received seed, and sends the key to the controller through a diagnostic request 27 02. The controller calculates the key according to the custom algorithm and compares the received key. If the keys are consistent, the verification is successful, otherwise it fails. If the verification is successful, the diagnostic service continues to be received. If the verification fails, a negative response code is responded to, and the host computer prompts failure and exits.
[0011] Further, after step 1 is completed, if the host computer diagnostic command is used to request to enter the programming session command, it is detected whether the bootloader upgrade ID in the controller is consistent with the APP; When the bootloader upgrade ID is consistent with the APP, the host computer executes the app program upgrade according to the UDS protocol specification upgrade process, and performs a soft reset after the upgrade is completed; When the bootloader upgrade ID is inconsistent with the APP, the host computer prompts a response timeout, and the programming session service fails and exits.
[0012] The beneficial effects produced by the present invention are: (1) When the APP valid flag in the controller is FALSE, that is, only the bootloader exists in the scenario, the controller program is always executed in the bootloader, and the diagnostic session mode is in the default session. It is necessary to enter the extended session and read the upgrade ID through the diagnostic service 0x22. Assuming it is required by the application scenario, no calibration is required. Assuming it is not required by the application scenario, the diagnostic service 0x2E is used to change it to the bootloader upgrade ID required by the application scenario. The upgrade diagnostic ID used for the first operation is the unified default bootloader upgrade ID of the bootloader itself, which is user-defined.
[0013] (2) When the APP valid flag in the controller is TRUE, that is, there is a bootloader and APP scenario, this is a complete controller program. When it needs to be changed to an application program for another application scenario, the controller is always running in the APP program. First, enter the extended session of the APP. The upgrade ID used by the current APP is consistent with the bootloader. Different from the scenario where only the bootloader exists or the bootloader and APP exist at the same time, this ID is the upgrade ID uniquely identified by the current application scenario. In the APP, the upgrade ID of the required application scenario is calibrated into the non-volatile memory through this ID, and then the corresponding application scenario APP program is upgraded through the calibrated upgrade ID, so as to achieve the purpose of replacing the upgrade ID and the application scenario APP.
[0014] (3) The reason why the required application scenario APP file cannot be upgraded directly is that once an APP program that is inconsistent with the effective upgrade ID required by the bootloader is upgraded, the next time the upgrade program jumps into the bootloader, it will not be able to correctly respond to the request, which will cause the upgrade to fail. In this abnormal situation, the controller shell can only be disassembled and burned through a burner. Therefore, changing the application scenario directly changes the upgrade ID, and then changing the APP program will save the tedious process of disassembling the controller shell, making the work process more efficient and simpler. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is a schematic diagram of program operation; Figure 2 This is a schematic diagram of the upgrade ID function. Figure 3This is a schematic diagram of abnormal scenarios when directly upgrading the APP. DETAILED DESCRIPTION
[0016] The present invention will be further described below in conjunction with the accompanying drawings.
[0017] The present invention provides a method and system for calibrating a bootloader upgrade ID in an automotive electronic system. Through the write data information service of the ISO-14229-1 standard protocol, the upgrade ID required by the user is written into the non-volatile memory of the controller, thereby achieving both modifiable and permanent storage; through the read data information service of the ISO-14229-1 standard protocol, the data information stored in the non-volatile memory of the controller is read out for user identification and confirmation.
[0018] like Figure 1 As shown, the program operation process and calibration steps are as follows: Step 1: Initialize the controller chip CPU module and non-volatile memory and enter the bootloader; Step 2, by reading the upgrade ID in the non-volatile memory, and verifying the correctness of the upgrade ID through a hash algorithm or a user-defined rule, using this ID if the verification passes, and using the default bootloader upgrade ID if the verification fails; checking whether the bootloader ID in the controller is a valid upgrade ID; When the upgrade ID valid flag in the controller is TRUE, go to step 3, if it is FLASE, go to step 4; Step 3, initialize the controller driver, use the upgrade ID with the valid flag bit set to TRUE or the default bootloader upgrade ID; Step 4, check whether the APP in the controller is valid; obtain the APP valid flag through the non-volatile memory interface; When the APP valid bit in the controller is FALSE, go to step 5; When the APP valid bit in the controller is TRUE, and the host computer does not refresh the APP action for more than 10ms, go to step 6; When the APP valid bit in the controller is TRUE, the host computer refreshes the APP action within 10ms, clears the APP valid bit, and the refresh ends. The ECU is reset and enters step 1; Step 5, APP is invalid, the controller runs in bootloader; Read the upgrade ID through diagnostic service 0x22; When the host computer does not need to calibrate the upgrade ID, the controller continues to run in the current state, otherwise it goes to step 7; Whether the upgrade ID calibration is required is determined by the controller customer needs or the application scenario; Step 6: If the APP is valid, the controller jumps to the APP operation; Read the upgrade ID through diagnostic service 0x22; When the host computer does not need to calibrate the upgrade ID, the controller continues to run in the current state, otherwise it goes to step 7; Whether the upgrade ID calibration is required is determined by the controller customer needs or the application scenario; Step 7: The controller performs calibration. After calibration is completed, the ECU is reset and the process goes to step 1.
[0019] like Figure 2 As shown, the steps of the calibration upgrade ID function process are as follows: Step 701: the controller receives the diagnostic request command 10 03 sent by the host computer and enters the extended session, because the calibration prerequisite requires the definition to be executed under the extended session; Step 702: The host computer sends a diagnostic request 27 01 to request a seed. The controller responds to the host computer with the seed generated by the custom algorithm. Then the host computer calculates the value of the key according to the custom algorithm based on the received seed, and sends the key to the controller through a diagnostic request 27 02. The controller calculates the key according to the custom algorithm and compares the received key. If the keys are consistent, the verification is successful, otherwise it fails. If the verification is successful, the diagnostic service continues to be received. If the verification fails, a negative response code is responded to. The host computer prompts failure and exits.
[0020] Step 703: The host computer sends a diagnostic request 2E to write data to calibrate the upgrade ID.
[0021] Step 704: The controller determines whether the received write data information, i.e., the upgrade ID, meets the custom verification rules. If it meets the custom verification rules, step 705 is executed. Otherwise, the host computer issues a negative response code, indicating that the calibration fails and exits. Step 705: calling the non-volatile memory interface to write the upgrade ID into the controller non-volatile memory; Step 706: Set the APP valid bit to FALSE to prevent entry Figure 3 The upgrade failed because the bootloader upgrade ID of the process is inconsistent with the APP.
[0022] Step 707: The host computer sends a diagnostic request 11 01 to request a software reset, the ECU executes the software reset, and the calibration ends.
[0023] like Figure 3 As shown, the steps to upgrade the abnormal scenario of APP are as follows: Step 1: Initialize the controller chip CPU module and non-volatile memory and enter the bootloader; Step 2: Check whether the bootloader upgrade ID in the controller is consistent with the APP. Specifically: Step 201: Enter the programming session command through the host computer diagnostic command request. If the controller responds with a positive response, execute step 202. If the controller responds with a negative response or the response times out, the host computer prompts failure and exits.
[0024] Step 202: The host computer executes the app program upgrade according to the UDS protocol specification upgrade process.
[0025] Step 203: After the upgrade is completed, the controller performs a soft reset.
[0026] This step is an exception for directly upgrading APP programs in other application scenarios. Currently, other application scenario APP programs are upgraded through the bootloader with a unique identification upgrade ID that has been calibrated. At this time, the upgrade ID of the APP program in other application scenarios is inconsistent with the upgrade ID of the bootloader. After the upgrade is successful, the response of the programming session is placed in the bootloader for response. The next time the APP program is upgraded, the bootloader cannot recognize the upgrade ID of the APP in other application scenarios, resulting in the inability to perform normal response diagnostic services and causing the upgrade to fail. Therefore, it is necessary to set the upgrade ID of the bootloader to be changed first, and then perform the implementation method of the APP upgrade.
Claims
1. A method for calibrating bootloader upgrade ID in automotive electronic systems, It is characterized in that The following steps are involved: Step 1: Initialize the controller chip CPU module and non-volatile memory and enter the bootloader; Step 2, by reading the upgrade ID in the non-volatile memory and verifying the correctness of the upgrade ID through a hash algorithm or a user-defined rule, detecting whether the bootloader ID in the controller is a valid upgrade ID; When the upgrade ID valid flag in the controller is TRUE, go to step 3, if it is FLASE, go to step 4; Step 3, initialize the controller driver, use the upgrade ID with the valid flag bit set to TRUE or the default bootloader upgrade ID; Step 4, check whether the APP in the controller is valid; obtain the APP valid flag through the non-volatile memory interface; When the APP valid bit in the controller is FALSE, go to step 5; When the APP valid bit in the controller is TRUE, and the host computer does not refresh the APP action for more than 10ms, go to step 6; When the APP valid bit in the controller is TRUE, the host computer refreshes the APP action within 10ms, clears the APP valid bit, and the refresh ends. The ECU is reset and enters step 1; Step 5, APP is invalid, the controller runs in bootloader; Read the upgrade ID through diagnostic service 0x22; When the host computer does not need to calibrate the upgrade ID, the controller continues to run in the current state, otherwise it goes to step 7; Whether the upgrade ID calibration is required is determined by the controller customer needs or the application scenario; Step 6: If the APP is valid, the controller jumps to the APP operation; Read the upgrade ID through diagnostic service 0x22; When the host computer does not need to calibrate the upgrade ID, the controller continues to run in the current state, otherwise it goes to step 7; Whether the upgrade ID calibration is required is determined by the controller customer needs or the application scenario; Step 7: The controller performs calibration. After calibration is completed, the ECU is reset and the process goes to step 1.
2. A method for calibrating a bootloader upgrade ID in an automotive electronic system according to claim 1, It is characterized in that The step 2 comprises: Step 201: Obtaining an upgrade ID through a non-volatile memory interface; Step 202: Verify the correctness of the upgrade ID through a hash algorithm or user-defined rules. If the verification passes, use this ID; if the verification fails, use the default bootloader upgrade ID.
3. A method for calibrating a bootloader upgrade ID in an automotive electronic system according to claim 1, It is characterized in that The step 7 comprises: Step 701: the controller receives a diagnostic command sent by the host computer and enters an extended session request, because the calibration prerequisite requires the definition to be executed under the extended session; Step 702: security access verification. If the verification succeeds, continue to receive diagnostic services. If the verification fails, respond with a negative response code. Step 703: The host computer sends a diagnostic command to calibrate the write data information request; Step 704: The controller determines whether the received write data information, i.e., the upgrade ID, meets the custom verification rules. If it meets the custom verification rules, step 705 is executed. Otherwise, the host computer issues a negative response code, indicating that the calibration fails and exits. Step 705: calling the non-volatile memory interface to write the upgrade ID into the controller non-volatile memory; Step 706: Set the APP valid bit to FALSE to prevent the upgrade failure caused by the inconsistency between the bootloader upgrade ID and the APP.
4. A method for calibrating a bootloader upgrade ID in an automotive electronic system according to claim 3, It is characterized in that The step 702 is specifically as follows: the host computer sends a diagnostic request 27 01 to request a seed, and the controller responds to the host computer with a seed generated by a custom algorithm. Then the host computer calculates the value of the key according to the custom algorithm based on the received seed, and sends the key to the controller through a diagnostic request 27 02. The controller calculates the key according to the custom algorithm and compares the received key. If the keys are consistent, the verification is successful, otherwise it fails. If the verification is successful, the diagnostic service continues to be received. If the verification fails, a negative response code is responded to, and the host computer prompts failure and exits.
5. The method for calibrating a bootloader upgrade ID in an automotive electronic system according to claim 1, Features: After step 1 is completed, if the host computer diagnostic command is used to request to enter the programming session command, the bootloader upgrade ID in the controller is checked to see if it is consistent with the APP; When the bootloader upgrade ID is consistent with the APP, the host computer executes the app program upgrade according to the UDS protocol specification upgrade process, and performs a soft reset after the upgrade is completed; When the bootloader upgrade ID is inconsistent with the APP, the host computer prompts a response timeout, and the programming session service fails and exits.
