Universal vehicle-mounted controller upgrading method based on multiple partitions and storage medium
By introducing communication abstraction layer and flash abstraction layer, combined with multi-partition technology, the problem of single upgrade method of vehicle controller and large hardware differences is solved, and efficient and stable upgrade of vehicle controllers is achieved, and development efficiency and system stability are improved. .
Patent Information
- Application Number
- CN202411340322.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2024-11-12
AI Technical Summary
The upgrade method of existing on-board controllers is single, resulting in large differences in hardware between different chips and flashes, resulting in low development efficiency, difficult maintenance, and may affect the system stability of the vehicle under special operating conditions.
Adopt a universal vehicle controller upgrade method based on multi-partitions. By introducing communication abstraction layer and flash abstraction layer, multiple communication interfaces and unified flash read and write interfaces are supported to realize sensorless upgrades, and prevent data tampering through partition isolation and permission control. .
It improves the portability and system stability of the vehicle-mounted controller upgrade function, reduces development and maintenance costs, and realizes sensorless upgrades without interrupting the vehicle's work.
Smart Images

Figure CN118939298A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of vehicle-mounted controllers, and in particular to a method for upgrading a universal vehicle-mounted controller based on multiple partitions. Background Art
[0002] The functions of on-board controllers of current cars are becoming more and more abundant, and the equipment update cycle is fast, which also poses a challenge to the upgrade function of on-board controllers. At present, most on-board controllers receive data through the CAN bus and directly burn flash to complete program debugging and upgrades. The update method is single; for different types of chips and flash, the hardware differences are large, and the upgrade functions of different on-board controllers are repeatedly developed with poor portability, which easily leads to low development efficiency and difficulties in subsequent upgrades and maintenance.
[0003] In actual applications, the vehicle controller upgrade must also meet the vehicle upgrade conditions, such as ensuring that the vehicle is in a stopped state before the vehicle controller can be upgraded. Under special working conditions, this will cause high vehicle maintenance costs and poor system stability. Summary of the invention
[0004] The present invention proposes a universal vehicle-mounted controller upgrade method based on multi-partitions, which solves the problem that most of the current vehicle-mounted controllers in the prior art receive data through a CAN bus and directly burn flash to complete program debugging and upgrading, and the updating method is single; for different types of chips and flash, the hardware differences are large, and the upgrade functions of different vehicle-mounted controllers are repeatedly developed with poor portability, which easily leads to low development efficiency and difficulty in subsequent upgrades and maintenance.
[0005] The technical solution of the present invention is implemented as follows: a method for upgrading a universal vehicle-mounted controller based on multiple partitions, comprising the following steps:
[0006] A communication abstraction layer is introduced, and the communication abstraction layer communicates with the host computer through the XCP protocol; the communication abstraction layer supports multiple communication interfaces and allows the registration of specific interface driver functions, and vehicle controllers of different types of chips communicate with the communication abstraction layer through the registered specific interface driver functions; the firmware to be upgraded is downloaded through the XCP protocol;
[0007] Introduce a flash abstraction layer to provide a unified flash read and write interface. After accepting the registration of the flash device, the business code directly calls the operation interface of the flash abstraction layer to reduce the coupling between the driver and the business function.
[0008] The device table of the flash abstraction layer is defined as multiple virtual devices according to the internal flash distribution. The working spaces of different firmware are isolated through multiple partitions. At the same time, firmware downloading in the boot firmware area and app application partition is supported, and the on-board controller can be seamlessly upgraded without interrupting the operation of the vehicle.
[0009] As a preferred technical solution, it also includes preventing data tampering and improving system stability by setting read and write operation permissions of different partitions on other partitions.
[0010] As a preferred technical solution, the firmware download process via the XCP protocol includes the following steps:
[0011] 1) Establish a connection. During the connection establishment process, the Host sends a CONNECT command, waits for the ECU to connect, and then obtains the current firmware status of the ECU through the GET_STATUS command;
[0012] 2) Erase memory. During the memory erasing process, the ECU determines the erase base address of the partition where the new firmware is located through the SET_MTA command, and determines the erase length according to the PROGRAM_CLEAR command;
[0013] 3) Write data. During the data writing process, the ECU determines the write base address of the partition where the new firmware is located through the SET_MTA command, and programs the flash at the specified address and writes data according to the PROGRAM command.
[0014] As a preferred technical solution, the Host end is a PC, a central gateway, a data terminal or other equipment that can communicate with the ECU by wire.
[0015] As a preferred technical solution, the universal vehicle-mounted controller is MPC5744. After the introduction of the flash abstraction layer, the internal flash sizes are 16KB, 32KB, 64KB, and 256KB. Adjacent flash blocks of the same size are classified into a type of flash device, which are defined as 4 devices, namely 32KB devices, 16KB devices, 64KB devices, and 256KB devices; and multiple partitions are divided based on the device table.
[0016] As a preferred technical solution, the multiple partitions are:
[0017] Initialization parameter area: used to store system peripheral initialization configuration parameters, such as CAN baud rate, serial port baud rate, etc.
[0018] Boot application information area: saves the starting address of the boot firmware area in the flash. After the chip is powered on, it will automatically jump to this address to execute the boot application. In addition, this partition also saves the boot firmware encryption information to verify the integrity of the boot firmware;
[0019] App application information area: saves the starting address of the app_1 and app_2 application partitions to be started in the flash, as well as the app firmware encryption information;
[0020] Boot firmware area: stores system boot firmware, which is used to download firmware; verifies application partition firmware information, and can automatically switch to the previous version when verification fails to ensure normal vehicle functions; selects app running partition according to app application information area to achieve ECU non-sensing upgrade;
[0021] env environment variable area: saves the environment variables shared by different firmware in the current system, and is used by the boot firmware area, app_1 application partition, and app_2 application partition;
[0022] app_1 application partition, app_2 application partition: store ECU firmware. app_1 application partition and app_2 application partition will not run at the same time. When the boot firmware boots the app_1 application partition, the app_2 application partition will be used as the firmware download area. When the boot firmware boots the app_2 application partition, the app_1 application partition will be used as the firmware download area.
[0023] As a preferred technical solution, the system boot process is controlled by the last_start_part and next_start_part parameters stored in the env environment variable area and the app_start_loc parameter of the app application partition. Through these three parameters, the system boot path is divided into three: boot waiting for download boot, normal start boot, and upgrade switching boot; among them, boot waiting for download boot and normal start boot support downloading firmware in the boot firmware area, and upgrade switching boot supports downloading firmware in the app application partition.
[0024] As a preferred technical solution, the guidance processes of the three guidance paths are:
[0025] Boot waits for download boot: When the device is powered on, it is judged that last_start_part is none and app_start_loc is invalid, and the system will stop in the boot firmware area and wait for the host to send firmware data;
[0026] Normal boot process: When the device is powered on, it satisfies ① that last_start_part is none and app_start_loc is valid; ② that last_start_part is not none and next_start_part is none; if one of the conditions is met, the system will allow the host computer to initiate a connection within the countdown. If the connection is successful before the timeout, the system will wait for the host to send firmware data; after the timeout, it will enter the app partition;
[0027] Upgrade switching boot: When the device is powered on, it is determined that last_start_part is not none and next_start_part is not none, then the corresponding app partition is entered according to the value of next_start_part;
[0028] As a preferred technical solution, the following method is used to set read and write operation permissions to prevent data tampering: the boot firmware area has read and write permissions for the app application information area, the env environment variable area, the app_1 application partition, and the app_2 application partition, wherein the read and write permissions for the app_1 and app_2 application partitions are dynamically adjusted according to last_start_part; the app_1 and app_2 application partitions have read and write permissions for the env environment variable area, and have read and write permissions for each other's application partitions.
[0029] A non-temporary storage medium, when the instructions in the storage medium are executed by a universal vehicle controller, enables the universal vehicle controller to execute any of the above-mentioned universal vehicle controller upgrade methods based on multiple partitions.
[0030] Compared with the prior art, this solution has the following beneficial effects:
[0031] 1) The communication abstraction layer is introduced, and the XCP protocol is used as the protocol for communicating with the host computer, supporting multiple communication interfaces. Vehicle controllers with different types of chips only need to write the sending and receiving interface driver functions of the corresponding communication interface and register the interface driver functions to the communication abstraction layer, which improves the portability of the upgrade functions of different vehicle controllers.
[0032] 2) Introduce the flash abstraction layer (FAL) to provide a unified flash read and write interface. By introducing FAL, the flash device is registered to FAL, and the business code directly calls the FAL operation interface to reduce the coupling between the driver and the business function. Through FAL, adjacent flash blocks of the same size are classified into a type of flash device. When the application layer writes the business logic, there is no need to care about the hardware bottom layer, which greatly improves the portability of the upgrade function.
[0033] 3) Prevent data tampering and improve system stability by granting different partitions read and write permissions to other partitions. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention 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, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 This is a structural block diagram of the communication between the communication abstraction layer host computer and the vehicle controller of the present invention;
[0036] Figure 2 A flowchart of downloading firmware using the XCP protocol of the present invention;
[0037] Figure 3 This is the device partition map after the flash abstraction layer is introduced;
[0038] Figure 4 is a flow chart of each guiding path of the present invention;
[0039] Figure 5 This is the flowchart of automatic system upgrade. DETAILED DESCRIPTION
[0040] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] The technical purpose of the present invention is to provide a universal vehicle controller upgrade method, and through multi-partition technology, the vehicle controller firmware is downloaded in the background without interfering with the use of the vehicle. The specific technical solution is as follows:
[0042] 1. Introduce the communication abstraction layer, and use the XCP protocol as the protocol for communicating with the host computer, supporting multiple communication interfaces.
[0043] The on-board controllers of different types of chips only need to write the sending and receiving interface driver functions of the corresponding communication interface and register the interface driver functions to the communication abstraction layer, such as Figure 1 ,The differences of the communication interfaces of different chips are shielded through the ,abstraction layer and provided to the protocol layer as the only ,communication interface.
[0044] The process of downloading firmware through the XCP protocol is as follows: Figure 2, which is divided into three parts: establishing connection, erasing memory, and writing data. The Host end can be a PC, central gateway, data terminal, or other device that can communicate with the ECU by wire.
[0045] During the connection establishment process, the Host sends a CONNECT command, waits for the ECU to connect, and then obtains the current firmware status of the ECU through the GET_STATUS command.
[0046] During the memory erasing process, the ECU determines the erase base address of the partition where the new firmware is located through the SET_MTA command, and determines the erase length based on the PROGRAM_CLEAR command.
[0047] During the data writing process, the ECU determines the write base address of the partition where the new firmware is located through the SET_MTA command, and programs the flash at the specified address and writes data according to the PROGRAM command.
[0048] 2. Introduce the flash abstraction layer (FAL) to provide a unified flash read and write interface.
[0049] Flash erase operations are usually performed based on pages, sectors, or blocks, and the block sizes of flash inside some chips are different. This results in the need to write different flash driver operations based on different flash models when writing business logic at the application layer, resulting in a high coupling between the driver and business functions. By introducing FAL, the flash device is registered to FAL, and the business code directly calls the FAL operation interface to reduce the coupling between the driver and business functions, such as Figure 3 The flash partition map after FAL is introduced for MPC5744. The internal flash block sizes are 16KB, 32KB, 64KB, and 256KB. Adjacent flash blocks of the same size are classified into one type of flash device through FAL. When the application layer writes the business logic, there is no need to care about the hardware bottom layer, which greatly improves the portability of the upgrade function.
[0050] Among them, MPC5744 defines 4 devices in the FAL device table according to the internal flash distribution, namely 32KB device, 16KB device, 64KB device, and 256KB device; and divides 7 partitions based on the device table, namely initialization parameter area, boot application information area, app application information area, boot firmware area, env environment variable area, app_1 application partition, and app_2 application partition. The functions of each partition are as follows:
[0051] Initialization parameter area: used to store system peripheral initialization configuration parameters, such as CAN baud rate, serial port baud rate, etc.
[0052] Boot application information area: saves the starting address of the boot firmware area in the flash. After the chip is powered on, it will automatically jump to this address to execute the boot application. In addition, this partition also saves the boot firmware encryption information to verify the integrity of the boot firmware;
[0053] App application information area: saves the starting address of the app_1 and app_2 application partitions to be started in the flash, as well as the app firmware encryption information;
[0054] Boot firmware area: stores system boot firmware. The main functions of this partition are: ① download firmware; ② verify application partition firmware information, and automatically switch to the previous version when verification fails to ensure normal vehicle functions; ③ select app running partition according to app application information area to achieve ECU non-sensing upgrade;
[0055] env environment variable area: saves the environment variables shared by different firmware in the current system, and is used by the boot firmware area, app_1 application partition, and app_2 application partition;
[0056] app_1 application partition, app_2 application partition: store ECU firmware. app_1 application partition and app_2 application partition will not run at the same time. When the boot firmware starts the app_1 application partition, the app_2 application partition will be used as the firmware download area, and vice versa.
[0057] 3. Isolate the working space of different firmware through multiple partitions, and support downloading firmware in the boot firmware area and app application partition at the same time, so as to upgrade the vehicle controller without interrupting the operation of the vehicle.
[0058] The system boot process is controlled by the last_start_part and next_start_part parameters stored in the env environment variable area and the app_start_loc parameter of the app application partition. Through these three parameters, the system boot path is divided into three: boot waiting for download boot, normal start boot, and upgrade switch boot. Among them, boot waiting for download boot and normal start boot support downloading firmware in the boot firmware area, and upgrade switch boot supports downloading firmware in the app application partition.
[0059] Figure 4 Flowcharts for each guide path:
[0060] Boot waits for download boot: When the device is powered on, it is judged that last_start_part is none and app_start_loc is invalid, and the system will stop in the boot firmware area and wait for the host to send firmware data;
[0061] Normal boot: When the device is powered on, if ①last_start_part is none and app_start_loc is valid; ②last_start_part is not none and next_start_part is none; if one of the conditions is met, the system will allow the host computer (Host) to initiate a connection within the countdown. If the connection is successful before the timeout, the system will wait for the Host to send firmware data. After the timeout, the system will enter the app partition.
[0062] Upgrade switching boot: When the device is powered on, if last_start_part is not none and next_start_part is not none, then enter the corresponding app partition according to the value of next_start_part (app_1 or app_2);
[0063] System automatic upgrade process see Figure 5 :
[0064] ①When the device is powered on, it automatically jumps to the boot firmware area according to the boot application partition;
[0065] ②Use last_start_part to determine that the system is running for the first time, obtain the value of app_start_loc from the app application information area as the app_1 address, and jump to the app_1 application partition after verification;
[0066] ③ Enter the app_1 application partition and first set last_start_part = app_1 in the env environment variable area;
[0067] ④ When the system is in the app_1 application partition, the vehicle runs normally. At this time, the host sends a CONNECT command to request firmware download, and the XCP protocol download task of the app_1 application partition downloads the firmware through the background;
[0068] ⑤After the firmware download is completed, query the app_update_method in the env environment variable area to auto, then immediately set next_start_part to app_2;
[0069] ⑥When the vehicle stops working and is powered on again, it automatically jumps to the boot firmware area according to the boot application partition;
[0070] ⑦Query the last_start_part in the env environment variable area to determine whether the system is running for the first time;
[0071] ⑧Query next_start_part in the env environment variable area to determine that the system is currently in upgrade switching boot, set app_start_loc in the app application information partition to app_2, and jump to the app_2 application partition after verification;
[0072] ⑨ Enter the app_2 application partition and first set last_start_part = app_2 in the env environment variable area;
[0073] ⑩At this point, the system automatic upgrade process ends;
[0074] 4. Prevent data tampering and improve system stability by granting different partitions read and write permissions to other partitions.
[0075] like Figure 5 , where the boot firmware area has read and write permissions for the app application information area, env environment variable area, app_1 application partition, and app_2 application partition. The read and write permissions for app_1 and app_2 application partitions are dynamically adjusted based on last_start_part;
[0076] The app_1 and app_2 application partitions have read and write permissions for the env environment variable area, and each has read and write permissions for the other application partition.
[0077] Compared with the prior art, this solution has the following beneficial effects:
[0078] 1) The communication abstraction layer is introduced, and the XCP protocol is used as the protocol for communicating with the host computer, supporting multiple communication interfaces. Vehicle controllers with different types of chips only need to write the sending and receiving interface driver functions of the corresponding communication interface and register the interface driver functions to the communication abstraction layer, which improves the portability of the upgrade functions of different vehicle controllers.
[0079] 2) Introduce the flash abstraction layer (FAL) to provide a unified flash read and write interface. By introducing FAL, the flash device is registered to FAL, and the business code directly calls the FAL operation interface to reduce the coupling between the driver and the business function. Through FAL, adjacent flash blocks of the same size are classified into a type of flash device. When the application layer writes the business logic, there is no need to care about the hardware bottom layer, which greatly improves the portability of the upgrade function.
[0080] 3) Prevent data tampering and improve system stability by granting different partitions read and write permissions to other partitions.
[0081] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for upgrading a universal vehicle controller based on multiple partitions, characterized in that: The following steps are involved: A communication abstraction layer is introduced, and the communication abstraction layer communicates with the host computer through the XCP protocol; the communication abstraction layer supports multiple communication interfaces and allows the registration of specific interface driver functions, and vehicle controllers of different types of chips communicate with the communication abstraction layer through the registered specific interface driver functions and download the firmware to be upgraded through the XCP protocol; Introduce a flash abstraction layer to provide a unified flash read and write interface. After accepting the registration of the flash device, the business code directly calls the operation interface of the flash abstraction layer to reduce the coupling between the driver and the business function. The device table of the flash abstraction layer is partitioned into multiple virtual devices according to the internal flash distribution. The working spaces of different firmware are isolated through multiple partitions. At the same time, firmware downloading in the boot firmware area and app application partition is supported, and the on-board controller can be seamlessly upgraded without interrupting the operation of the vehicle.
2. A method for upgrading a universal vehicle controller based on multiple partitions as claimed in claim 1, characterized in that: It also includes preventing data tampering and improving system stability by setting read and write operation permissions of different partitions on other partitions.
3. A method for upgrading a universal vehicle controller based on multiple partitions as claimed in claim 1, characterized in that: Downloading firmware via the XCP protocol includes the following steps: 1) Establish a connection. During the connection establishment process, the Host sends a CONNECT command, waits for the ECU to connect, and then obtains the current firmware status of the ECU through the GET_STATUS command; 2) Erase memory. During the memory erasing process, the ECU determines the erase base address of the partition where the new firmware is located through the SET_MTA command, and determines the erase length according to the PROGRAM_CLEAR command; 3) Write data. During the data writing process, the ECU determines the write base address of the partition where the new firmware is located through the SET_MTA command, and programs the flash at the specified address and writes data according to the PROGRAM command.
4. A method for upgrading a universal vehicle controller based on multiple partitions as claimed in claim 3, characterized in that: The Host terminal is a PC, a central gateway, a data terminal or other equipment that can communicate with the ECU via wire.
5. A method for upgrading a universal vehicle controller based on multiple partitions as claimed in claim 1, characterized in that: The general vehicle controller is MPC5744. After the introduction of the flash abstraction layer, the internal flash sizes are 16KB, 32KB, 64KB, and 256KB. Adjacent flash blocks of the same size are classified into a type of flash device, which are defined as 4 devices, namely 32KB devices, 16KB devices, 64KB devices, and 256KB devices; and multiple partitions are divided based on the device table.
6. A method for upgrading a universal vehicle controller based on multiple partitions as claimed in claim 5, characterized in that: The multiple partitions are: Initialization parameter area: used to store system peripheral initialization configuration parameters, including CAN baud rate and serial port baud rate; Boot application information area: saves the starting address of the boot firmware area in the flash. After the chip is powered on, it will automatically jump to this address to execute the boot application. In addition, this partition also saves the boot firmware encryption information to verify the integrity of the boot firmware; App application information area: saves the starting address of the app_1 and app_2 application partitions to be started in the flash, as well as the app firmware encryption information; Boot firmware area: stores system boot firmware, which is used to download firmware; verifies application partition firmware information, and can automatically switch to the previous version when verification fails to ensure normal vehicle functions; selects app running partition according to app application information area to achieve ECU non-sensing upgrade; env environment variable area: saves the environment variables shared by different firmware in the current system, and is used by the boot firmware area, app_1 application partition, and app_2 application partition; app_1 application partition, app_2 application partition: store ECU firmware. app_1 application partition and app_2 application partition will not run at the same time. When the boot firmware boots the app_1 application partition, the app_2 application partition will be used as the firmware download area; when the boot firmware boots the app_2 application partition, the app_1 application partition will be used as the firmware download area.
7. A method for upgrading a universal vehicle controller based on multiple partitions as claimed in claim 1, characterized in that: The system boot process is controlled by the last_start_part and next_start_part parameters stored in the env environment variable area and the app_start_loc parameter of the app application partition. Through these three parameters, the system boot path is divided into three: boot waiting for download boot, normal start boot, and upgrade switching boot; among them, boot waiting for download boot and normal start boot support downloading firmware in the boot firmware area, and upgrade switching boot supports downloading firmware in the app application partition.
8. A method for upgrading a universal vehicle controller based on multiple partitions as claimed in claim 7, characterized in that: The guidance processes of the three guidance paths are respectively: Boot waits for download boot: When the device is powered on, it is judged that last_start_part is none and app_start_loc is invalid, and the system will stop in the boot firmware area and wait for the host to send firmware data; Normal boot process: When the device is powered on, it satisfies ① that last_start_part is none and app_start_loc is valid; ② that last_start_part is not none and next_start_part is none; if one of the conditions is met, the system will allow the host computer to initiate a connection within the countdown. If the connection is successful before the timeout, the system will wait for the host to send firmware data; after the timeout, it will enter the app partition; Upgrade switching boot: When the device is powered on, it is determined that last_start_part is not none and next_start_part is not none, then the corresponding app partition is entered according to the value of next_start_part.
9. A method for upgrading a universal vehicle controller based on multiple partitions as claimed in claim 2, characterized in that: The read and write operation permissions are set in the following way to prevent data tampering: the boot firmware area is divided into the app application information area, the env environment variable area, the app_1 application partition, and the app_2 application partition's read and write permissions. The read and write permissions for the app_1 and app_2 application partitions are dynamically adjusted according to last_start_part; the app_1 and app_2 application partitions have the read and write permissions for the env environment variable area, and have the read and write permissions for each other's application partitions.
10. A non-temporary storage medium, characterized in that: When the instructions in the storage medium are executed by a universal vehicle controller, the universal vehicle controller is enabled to execute any one of the universal vehicle controller upgrade methods based on multi-partitions in claims 1 to 9.
Citation Information
Cited By
Electric steering engine maintenance method capable of resisting high overload and strong magnetic interference
CN120031551A
