Firmware updating method and device, electronic equipment and vehicle

Through the collaborative work between the OTA server and the car controller, the application backup area is used for firmware updates, which solves the problems of low firmware update efficiency and large resource occupation in the existing technology, achieves safe and reliable firmware updates, and maintains ensure the normal operation of the system.

CN118540219AActive Publication Date: 2024-08-23BYD CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311281929.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-28
Publication Date
2024-08-23
Estimated Expiration
2043-09-28

AI Technical Summary

Technical Problem

The existing technology has problems of low efficiency and large resource usage during the firmware update process in automobile controllers. Especially when the Bootloader is upgraded, a lot of Flash resources are occupied and the MCU cannot respond to application services normally during the upgrade process, affecting the user experience.

Method used

Using Over-the-Air (OTA) communication between the server and the electronic device, through the collaborative work of the first controller and the second controller, the application backup area is used as a public backup area to securely store the firmware data to be updated. Write to the firmware area of ​​the controller to avoid additional occupation of Flash resources and keep the system running normally during the upgrade process.

Benefits of technology

It achieves the security, reliability and efficiency of firmware updates, avoids waste of resources, improves user experience, and ensures that the system is not affected during the upgrade process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118540219A
    Figure CN118540219A
Patent Text Reader

Abstract

The embodiment of the invention discloses a firmware updating method and device, electronic equipment and a vehicle, and the method comprises the steps: obtaining to-be-updated firmware data information when a first controller application program runs; and writing the firmware data information to be updated into the firmware area of the first controller according to the size of the first preset framing data block, so that the firmware data information to be updated can be safely and reliably written into the firmware area of the controller, and the firmware updating efficiency and effectiveness are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automotive electronic technology, and in particular to a firmware updating method, device, electronic equipment and vehicle. Background Art

[0002] With the development of automotive electronic technology, automotive controllers have more and more functions. In the software development process and released versions, there will inevitably be loopholes and new required functions. It is inevitable that the software must be upgraded and updated. Therefore, Bootloader firmware is designed in the automotive controller for upgrading and updating the APP program. As a program of the MCU, Bootloader inevitably has loopholes or needs to be optimized. In the controller development stage, the program can be flashed with a burner through the debugging interface. If the hardware circuit has been installed in the mechanical shell and installed on the car, it is impossible to upgrade the controller's Bootloader through the burner. The existing solution is that the field engineer uses the host computer to upgrade and update the Bootloader program. Since the car is delivered to the user in large quantities, the field engineer's local upgrade and update of the Bootloader through the host computer is complicated and the update efficiency is low. Summary of the invention

[0003] The embodiments of the present application provide a firmware update method, device, electronic device and vehicle, which can safely and reliably write firmware data information to be updated into the firmware area of ​​the controller, thereby improving the efficiency and effectiveness of the firmware update.

[0004] In a first aspect, an embodiment of the present application provides a firmware update method, which is applied to a first controller, and the method includes:

[0005] When the first controller application is running, obtaining firmware data information to be updated;

[0006] The firmware data information to be updated is written into the firmware area of ​​the first controller according to a first preset framing data block size.

[0007] In a second aspect, an embodiment of the present application provides another firmware update method, which is applied to a second controller, and the method includes:

[0008] Obtain the firmware data information to be updated;

[0009] The firmware data information to be updated is sent to the first controller, so that the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size when the application is running.

[0010] In a third aspect, an embodiment of the present application provides a firmware update device, the firmware update device is arranged in a first controller, and the device includes:

[0011] An acquisition unit, configured to acquire firmware data information to be updated when the first controller application is running;

[0012] The writing unit is used to write the firmware data information to be updated into the firmware area of ​​the first controller according to a first preset framing data block size.

[0013] In a fourth aspect, an embodiment of the present application provides another firmware update device, which is arranged in a controller and includes:

[0014] An acquisition unit, used for acquiring firmware data information to be updated;

[0015] The sending unit is used to send the firmware data information to be updated to the first controller, so that the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size when the application is running.

[0016] In a fifth aspect, an embodiment of the present application provides an electronic device, the electronic device comprising a processor, a memory, a bus and a communication interface, the processor, the communication interface and the memory being connected via the bus;

[0017] The memory is used to store programs;

[0018] The processor is used to call the program stored in the memory through the bus to execute the method described in the first aspect.

[0019] In a sixth aspect, an embodiment of the present application provides another electronic device, the electronic device comprising a processor, a memory, a bus and a communication interface, wherein the processor, the communication interface and the memory are connected via the bus;

[0020] The memory is used to store programs;

[0021] The processor is used to call the program stored in the memory through the bus to execute the method described in the second aspect.

[0022] In the seventh aspect, an embodiment of the present application provides a vehicle, comprising a vehicle body and an electronic device, wherein the electronic device comprises a first controller and a second controller, wherein the first controller is used to execute the method described in the first aspect to update the firmware of the first controller of the vehicle, and the second controller is used to execute the method described in the second aspect to update the firmware of the first controller of the vehicle.

[0023] The embodiment of the present application obtains the firmware data information to be updated when the first controller application is running; and writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size. The firmware data information to be updated can be safely and reliably written into the firmware area of ​​the controller, thereby improving the efficiency and effectiveness of firmware updates. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0025] Figure 1 It is a structural diagram of a firmware update system provided in an embodiment of the present application;

[0026] Figure 2 It is a flowchart of a firmware update interaction method provided in an embodiment of the present application;

[0027] Figure 3 It is a schematic diagram of an APP operation process of an MCU provided in an embodiment of the present application;

[0028] Figure 4 It is a flowchart of a firmware update method provided in an embodiment of the present application;

[0029] Figure 5 It is a schematic diagram of memory space distribution of a controller provided in an embodiment of the present application;

[0030] Figure 6 It is a flowchart of another firmware update method provided in an embodiment of the present application;

[0031] Figure 7 It is a flowchart of another firmware update method provided in an embodiment of the present application;

[0032] Figure 8 This is a schematic diagram of a MCU startup process provided by an embodiment of the present application;

[0033] Fig. 9 It is a structural diagram of a firmware update device provided in an embodiment of the present application;

[0034] Fig.10 is a structural diagram of another firmware update device provided in an embodiment of the present application;

[0035] Fig.11 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0036] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0037] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0038] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0039] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0040] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0041] In a specific implementation, the electronic devices described in the embodiments of the present application include, but are not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers with a touch surface (e.g., a touch screen display and / or a touch pad). It should also be understood that in some embodiments, the device is not a portable communication device, but a desktop computer with a touch surface (e.g., a touch screen display and / or a touch pad).

[0042] In the following discussion, a terminal including a display and a touch surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse and / or joystick.

[0043] The terminal supports various applications, such as one or more of the following: a drawing application, a presentation application, a word processing application, a website creation application, a disk burning application, a spreadsheet application, a game application, a telephone application, a video conferencing application, an email application, an instant messaging application, a workout support application, a photo management application, a digital camera application, a digital camcorder application, a web browsing application, a digital music player application, and / or a digital video player application.

[0044] Various applications that can be executed on the terminal can use at least one common physical user interface device such as a touch surface. One or more functions of the touch surface and corresponding information displayed on the terminal can be adjusted and / or changed between applications and / or within corresponding applications. In this way, the common physical architecture of the terminal (e.g., the touch surface) can support various applications with user interfaces that are intuitive and transparent to the user.

[0045] At present, in order to ensure the safety and reliability of upgrading (i.e. updating) the firmware Bootloader in the case of updating the firmware in the automobile controller, the existing technical solution designs the first Bootloader area and the second Bootloader area. The updated Bootloader is first written into the backup area, and the one that is valid is executed during execution. The disadvantage of this solution is that an extra Bootloader area is used, which occupies a certain amount of FLash resources. In addition, in the existing technical solution, after power-on or reset, the program runs in the Bootloader main storage area. Get the Bootloader update code, erase the Bootloader backup area, and write the update code into the backup area. In this technical solution, the MCU runs in the Bootloader to perform the upgrade task, and the controller cannot respond to the application business normally.

[0046] An embodiment of the present application proposes a firmware update method, which is applied to a firmware update system. The firmware update system includes an Over-the-Air Technology (OTA) server and an electronic device. The electronic device includes a first controller and a second controller, wherein the first controller may include a microcontroller (Micro Control Unit, MCU), and the second controller may include a system on chip (System on Chip, SOC).

[0047] The OTA server can obtain an OTA upgrade package and send the OTA upgrade package to the second controller, wherein the OTA upgrade package is obtained by encapsulating an upgrade file in a specified format, and the upgrade file includes firmware data information to be updated; the second controller receives the OTA upgrade package sent by the OTA server, and parses the OTA upgrade package to obtain the firmware data information to be updated, and the firmware data information to be updated includes the firmware data to be updated and the firmware data address to be updated; the second controller sends the firmware data to be updated to the first controller, and the first controller writes the firmware data to be updated to the data backup area of ​​the first controller; after determining that the firmware data to be updated is completely written to the data backup area, the firmware data to be updated is read from the data backup area, and the read firmware data to be updated is written into the firmware area of ​​the first controller according to the firmware address to be updated, so as to update the firmware in the first controller.

[0048] The firmware update method proposed in the embodiment of the present application can use the backup area of ​​the application (i.e., software) APP as the public backup area, and use the public backup area as the data backup area of ​​the Bootloader when upgrading the Bootloader. After the upgrade of the Bootloader is completed and verified successfully, the Bootloader program in the public backup area is moved to the Bootloader area, which not only realizes the backup upgrade and ensures the reliability of the upgrade, but also does not occupy additional Flash resources. The controller proposed in the embodiment of the present application runs in the APP program, and a submodule is designed in the APP program specifically for upgrading the Bootloader. The submodule is called when upgrading the Bootloader. During the upgrade process, other submodules in the APP still operate normally and respond to various application services, without affecting the normal operation of the entire controller system, thereby improving the user experience.

[0049] The firmware update method provided in an embodiment of the present application is applied to a firmware update system, which includes an OTA server and an electronic device, the electronic device includes a first controller and a second controller, the OTA server and the electronic device are communicatively connected, and the first controller and the second controller are communicatively connected.

[0050] For details, please see Figure 1 , Figure 1 is a schematic diagram of the structure of a firmware update system provided in an embodiment of the present application, such as Figure 1As shown, the firmware update system includes an OTA server 11 and an electronic device 12, wherein the electronic device 12 includes a first controller 121 and a second controller 122. Specifically, the OTA server 11 can obtain an OTA upgrade package and send the OTA upgrade package to the second controller 122. The second controller 122 parses the OTA upgrade package to obtain the firmware data information to be updated, and sends the firmware data information to be updated to the first controller 121. The first controller 121 writes the firmware data information to be updated into the firmware area of ​​the first controller 121. In some embodiments, the OTA upgrade package is obtained by encapsulating an upgrade file in a specified format, and the upgrade file includes the firmware data information to be updated.

[0051] The firmware update method provided in the embodiment of the present application can be applied to scenarios including but not limited to firmware update on terminals such as vehicles (such as cars, motorcycles, etc.), ships, and airplanes. The firmware update method provided in the embodiment of the present application is described by taking the scenario of firmware update applied to a vehicle as an example.

[0052] See also Figure 2 , Figure 2 is a flowchart of a firmware update interaction method provided in an embodiment of the present application. The firmware update interaction method is applied to a firmware update system. The firmware update system includes an OTA server and a controller. The controller includes a first controller and a second controller. Figure 2 The firmware update method in this embodiment may at least include the following steps:

[0053] S201: The OTA server obtains an OTA upgrade package, which is obtained by encapsulating an upgrade file in a specified format, and the upgrade file includes firmware data information to be updated.

[0054] In an embodiment of the present application, an OTA server can obtain an OTA upgrade package, which is obtained by encapsulating an upgrade file in a specified format, and the upgrade file includes firmware data information to be updated. Among them, the upgrade file in the specified format is obtained by converting the upgrade file according to the specified format, and the upgrade file is an executable file generated by compiling a firmware (such as a boot loader Bootloader) project. In some embodiments, the specified format can be an xcd file format.

[0055] S202: The OTA server sends the OTA upgrade package to the second controller.

[0056] S203: The second controller parses the OTA upgrade package to obtain firmware data information to be updated, and sends the firmware data information to be updated obtained by parsing to the first controller.

[0057] In the embodiment of the present application, the OTA server can send the OTA upgrade package to the second controller, and the second controller can parse the OTA upgrade package to obtain the firmware data information to be updated, and send the firmware data information to be updated obtained by parsing to the first controller. Figure 1 For example, the OTA server 11 pushes the OTA upgrade package to the second controller 122 in the controller 12 . The second controller 122 parses the upgrade package file and sends the firmware data information to be updated obtained by the parsing to the first controller 121 in the controller 12 .

[0058] In some embodiments, the firmware data information to be updated includes at least the firmware data to be updated. In other embodiments, the firmware data information to be updated may also include one or more of the firmware data address to be updated, the software coding information to be updated, the firmware version information to be updated, etc.

[0059] The first controller may be an MCU. For details, see Figure 3 Explain the operation process of MCU APP. Figure 3 It is a schematic diagram of the APP operation process of an MCU provided in an embodiment of the present application. In the APP of the MCU, each business is divided into various sub-modules, for example, a network management sub-module, a power management sub-module, a cloud service sub-module, etc. The data of the MCU is driven by the SPI to interact with the SOC, and is driven by the CAN to interact with other ECUs or controllers. This application adds an upgrade function sub-module, and the Bootloader of the MCU is upgraded through the upgrade function sub-module. Each sub-module is executed sequentially and cyclically, so when the Bootloader is upgraded, the functions of other sub-modules except the upgrade function sub-module will not be affected. Since the MCU updates the firmware Bootloader in the APP and calls the upgrade function sub-module that updates the Bootloader, the APP will still execute other sub-modules such as the network management sub-module, the power management sub-module, the cloud service sub-module, etc., to respond to related application services, such as power management, etc., without affecting the normal functions of the system.

[0060] By using the sub-module in the APP program of the first controller MCU to update its firmware, the update function can be realized without affecting the normal business functions of the system, thereby improving the user experience.

[0061] S204: The first controller obtains the firmware data information to be updated sent by the second controller when the first controller application is running.

[0062] In the embodiment of the present application, the first controller can obtain the firmware data information to be updated sent by the second controller when the first controller application is running. The first controller application can be an application on the MCU.

[0063] S205: The first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size.

[0064] In an embodiment of the present application, the first controller may write the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size. In some embodiments, the first preset framing data block size is the rate at which the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller.

[0065] In one embodiment, before writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the first controller may write the firmware data information to be updated into the data backup area of ​​the first controller, and the data backup area is located in the application backup area of ​​the first controller, wherein the firmware data information to be updated includes at least the firmware data to be updated.

[0066] In one embodiment, when the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the firmware data to be updated can be read from the data backup area after determining that the firmware data to be updated is completely written into the data backup area of ​​the first controller; and the read firmware data to be updated can be written into the firmware area of ​​the first controller according to the firmware address to be updated according to the first preset framing data block size.

[0067] In an embodiment of the present application, an OTA upgrade package is obtained through an OTA server, and the OTA upgrade package is sent to a second controller. The second controller parses the OTA upgrade package to obtain firmware data information to be updated, and sends the parsed firmware data information to be updated to the first controller. When the first controller application is running, the first controller obtains the firmware data information to be updated sent by the second controller, and writes the firmware data information to be updated into the firmware area of ​​the first controller according to a first preset framing data block size. The firmware data information to be updated can be written into the firmware area of ​​the controller safely and reliably, thereby improving the efficiency and effectiveness of firmware updates.

[0068] See also Figure 4 , Figure 4 is a flowchart of a firmware update method provided in an embodiment of the present application, wherein the firmware update method is applied to a first controller, such as Figure 4 The firmware update method in this embodiment may at least include the following steps:

[0069] S401: When the first controller application is running, firmware data information to be updated is obtained.

[0070] In one embodiment, when the first controller obtains the firmware data information to be updated, it can receive the firmware data information to be updated sent by the second controller, and the firmware data information to be updated is obtained by the second controller receiving an OTA upgrade package sent by the OTA server and parsing the OTA upgrade package.

[0071] In one embodiment, when acquiring the firmware data information to be updated, the first controller may receive an OTA upgrade package sent by an OTA server and parse the OTA upgrade package to obtain the firmware data information to be updated.

[0072] S402: Writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size.

[0073] In one embodiment, before writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the first controller may write the firmware data information to be updated into the data backup area of ​​the first controller, and the data backup area is located in the application backup area of ​​the first controller, wherein the firmware data information to be updated includes at least the firmware data to be updated.

[0074] In some embodiments, the data backup area is set in the first controller, and the first controller flash memory FLASH includes four areas: data backup area, application program APP area, secondary bootloader Bootloader area and primary bootloader LittleBootloader area, among which the data backup area is a public backup area.

[0075] Specific as Figure 5 As shown, Figure 5 is a schematic diagram of memory space distribution of a controller provided in an embodiment of the present application, such as Figure 5As shown, taking the first controller as MCU as an example, the FLASH space of MCU is divided into four parts starting from address zero, BLOCK1: used to store LittleBootloader; BLOCK2: used to store Bootloader; BLOCK3: used to store APP; BLOCK4: used as a data backup area to store update programs. Among them, LittleBootloader is used to determine the identifier of the firmware update status stored in the designated storage unit EEPROM, which is used to indicate that the firmware update is unsuccessful. When the identifier of the designated storage unit is detected, it is determined that the firmware update is unsuccessful, and the APP of the first controller is run. When the identifier of the designated storage unit is not detected, it is determined that the firmware update is successful, and the Bootloader of the first controller is run. Among them, the Bootloader is used to upgrade (i.e. update) the APP program. When the APP is running, the upgrade program of the APP is written in the data backup area (BLOCK4). After the APP program is verified, the MCU is reset to enter the Bootloader, and the APP program stored in the data backup area (BLOCK4) is read out and written into the APP area (BLOCK3). APP is the application program of MCU. When upgrading Bootloader, write the Bootloader program in the data backup area (BLOCK4). After the Bootloader verifies the completeness, read the data in the data backup area (BLOCK4) and write it to the Bootloader area (BLOCK2). The data backup area is used to store the upgraded APP program or Bootloader program.

[0076] In one embodiment, the firmware data information to be updated also includes the firmware data address to be updated. When the first controller writes the firmware data information to be updated into the data backup area of ​​the first controller, it can determine the data erase address corresponding to the firmware data address to be updated from the data backup area; delete the backup data corresponding to the data erase address in the data backup area, and after the deletion, write the firmware data to be updated into the backup area corresponding to the data erase address in the data backup area.

[0077] In one embodiment, the first preset framing data block size may be the maximum data amount for each transmission. When the first controller writes the firmware data to be updated into the backup area corresponding to the data erase address in the data backup area, it may send the maximum data amount for each transmission to the second controller, so that the second controller transmits the firmware data to be updated to the first controller according to the maximum data amount; the first controller receives the firmware data sent by the second controller according to the maximum data amount, and writes the received firmware data into the data backup area. For example, the first preset framing data block size may be 2K.

[0078] The embodiment of the present application can ensure that the firmware of the first controller does not affect the operation of the application program when updating by writing the read firmware data to be updated into the firmware area of ​​the first controller according to the firmware address to be updated according to the first preset framing data block size.

[0079] In one embodiment, when the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the firmware data to be updated can be read from the data backup area after determining that the firmware data to be updated is completely written into the data backup area of ​​the first controller; and the read firmware data to be updated can be written into the firmware area of ​​the first controller according to the firmware address to be updated according to the first preset framing data block size.

[0080] The embodiment of the present application uses a public data backup area to store updated firmware data information, reads the firmware data information to be updated from the data backup area, and stores the read firmware data information to be updated in the firmware area of ​​the first controller, so as to prevent the failure of the firmware update of the first controller from causing system paralysis. At the same time, the storage space of the first controller is reasonably allocated. Using the data backup area as a public backup area can realize batch updating of the firmware of the first controller, save device resources, and improve the efficiency of firmware update.

[0081] In one embodiment, the firmware data information to be updated also includes software coding information to be updated and firmware version information to be updated. Before receiving the firmware data information to be updated sent by the second controller, the first controller may send the software coding information and firmware version information stored locally in the first controller to the second controller, so that the second controller uses the locally stored software coding information and firmware version information to determine whether the software coding information to be updated and the firmware version information to be updated meet the update conditions; if it is confirmed that the software coding information to be updated and the firmware version information to be updated meet the update conditions, the firmware data information to be updated sent by the second controller is received. In some embodiments, the firmware version information includes but is not limited to the firmware version number.

[0082] In some embodiments, the software coding information to be updated and the firmware version information to be updated meet the update conditions, including: the comparison result of the locally stored software coding information and the software coding information to be updated is consistent, and the firmware version information to be updated is greater than the locally stored firmware version information.

[0083] In one embodiment, the first controller can read the locally stored software coding information and send the locally stored software coding information to the second controller, so that the second controller compares the locally stored software coding information with the software coding information in the firmware data information to be updated to obtain a first comparison result; when the first comparison result is consistent, the first controller can read the locally stored firmware version information and send the locally stored firmware version information to the second controller, so that the second controller compares the locally stored firmware version information with the firmware version information in the firmware data information to be updated to obtain a second comparison result; when the second comparison result is that the firmware version information in the firmware data information to be updated is greater than the locally stored firmware version information, it is determined whether the software coding information to be updated and the firmware version information to be updated meet the update conditions.

[0084] In one embodiment, before receiving the firmware data information to be updated sent by the second controller, the first controller may receive a first instruction sent by the second controller, and the first instruction is used to instruct the first controller to enter an extended session mode so that the first controller enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

[0085] In one embodiment, after determining whether the software coding information to be updated and the firmware version information to be updated meet the update conditions, the first controller can receive a first instruction sent by the second controller and control the first controller to enter an extended session mode. After entering the extended session mode, the first controller can be controlled to enter a state of prohibiting fault code setting and / or prohibiting communication message sending.

[0086] The first controller may receive a second instruction for instructing to prohibit setting of a fault code sent by the second controller after a first time interval after receiving the first instruction sent by the second controller, so as to control the first controller to enter a state of prohibiting setting of a fault code.

[0087] The first controller may receive a third instruction from the second controller for instructing prohibition of sending communication messages after a second time interval of receiving the second instruction from the second controller, so as to control the first controller to enter a state of prohibiting sending communication messages.

[0088] In one embodiment, before receiving the firmware data information to be updated sent by the second controller, the first controller may receive a security verification request sent by the second controller; respond to the security verification request, calculate a first key according to a preset security verification algorithm and a random number, and send the random number to the second controller; receive a second key sent by the second controller, the second key is calculated by the second controller according to a preset security verification algorithm and a random number; compare the first key and the second key, and if the comparison results are consistent, determine that the security verification of the first controller has passed, and control the first controller to enter the programming session mode. In some embodiments, the preset security verification algorithm may include a keyword key, and the keyword in the preset security verification algorithm used by the first controller may be the same as or different from the keyword in the preset security verification algorithm used by the first controller.

[0089] In one embodiment, after the second controller sends a third instruction to the first controller to indicate prohibition of sending communication messages after a second time interval after sending the second instruction, it can send a security verification request to the first controller; the first controller responds to the security verification request, obtains a first key according to a preset security verification algorithm and random number calculation, and sends a random number to the second controller; the second controller obtains a second key according to a preset security verification algorithm and random number calculation, and sends the second key to the first controller; the first controller compares the first key and the second key, and when the comparison results are consistent, determines that the security verification has passed, and controls the first controller to enter the programming session mode, in which the firmware data to be updated is written into the data backup area of ​​the controller.

[0090] In one embodiment, when the first controller receives the firmware data information to be updated sent by the second controller, it can receive the firmware data information to be updated sent by the second controller with a second preset framing data block size, wherein the second preset framing data block size refers to the receiving rate of the firmware data information to be updated by the first controller, that is, the sending rate of the firmware data information to be updated sent by the second controller.

[0091] In one embodiment, after the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the first controller may obtain a first check value transmitted by the second controller, the first check value being the cumulative sum of each byte data of the firmware data to be updated calculated by the second controller; obtain each byte data of the firmware data to be updated written into the firmware area of ​​the first controller, and calculate the cumulative sum of each byte data of the firmware data to be updated written into the firmware area of ​​the first controller to obtain a second check value; compare the first check value with the second check value; if the comparison results of the first check value and the second check value are consistent, determine that the firmware update is successful; if the comparison results of the first check value and the second check value are inconsistent, re-execute the step of writing the firmware data information to be updated into the data backup area of ​​the first controller for n times, where n is a positive integer; if the step of writing the firmware data information to be updated into the data backup area of ​​the first controller is re-executed for n times, and the comparison results of the first check value and the second check value are inconsistent, determine that the firmware update is unsuccessful, generate an identifier of unsuccessful firmware update, write the identifier into a designated storage unit, and send a notification message of firmware update failure to the second controller. The designated storage unit may be an electrically erasable programmable read only memory (EEPROM).

[0092] In one embodiment, after the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, when the first controller is powered on or reset and an indication of unsuccessful firmware update is detected, the first controller application can be run; when the first controller is powered on or reset and no indication of unsuccessful firmware update is detected, the new firmware on the first controller can be run.

[0093] In the embodiment of the present application, the first controller can obtain the firmware data information to be updated when the first controller application is running; write the firmware data in the firmware data information to be updated into the data backup area of ​​the first controller; after determining that the firmware data is completely written into the data backup area, read the firmware data from the data backup area, and read the firmware data in the data backup area according to the firmware address to be updated in the firmware data information to be updated, and write it into the firmware area of ​​the first controller to update the firmware in the controller. Updating the firmware of the first controller by storing the update program in the public data backup area can prevent the system from being paralyzed due to the failure of the firmware program upgrade of the first controller, and at the same time reasonably allocate the storage space of the first controller, and use the data backup area as a public backup area to save device resources.

[0094] See also Figure 6 , Figure 6 is a flowchart of another firmware update method provided in an embodiment of the present application, wherein the firmware update method is applied to a second controller, such as Figure 6 The firmware update method in this embodiment may at least include the following steps:

[0095] S601: Obtaining firmware data information to be updated.

[0096] In an embodiment of the present application, the second controller may receive an OTA upgrade package sent by the OTA server, and parse the OTA upgrade package to obtain firmware data information to be updated.

[0097] S602: Sending firmware data information to be updated to the first controller, so that the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to a first preset framing data block size when the application is running.

[0098] In one embodiment, before sending the firmware data information to be updated to the first controller, the second controller can read the software coding information and firmware version information stored locally in the first controller; and use the locally stored software coding information and firmware version information to determine whether the software coding information to be updated and the firmware version information to be updated meet the update conditions.

[0099] In some embodiments, the software coding information to be updated and the firmware version information to be updated meet the update conditions, including: the comparison result of the software coding information locally stored in the first controller and the software coding information to be updated is consistent, and the firmware version information to be updated is greater than the locally stored firmware version information.

[0100] In one embodiment, before sending the firmware data information to be updated to the first controller, the second controller may send a first instruction to the first controller, where the first instruction is used to instruct the first controller to enter an extended session mode so that the first controller enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

[0101] In one embodiment, before sending the firmware data information to be updated to the first controller, the second controller may send a security verification request to the first controller, so that the first controller responds to the security verification request, obtains a first key according to a preset security verification algorithm and random number calculation, and sends the random number to the second controller; receives the random number sent by the first controller, and obtains a second key according to the preset security verification algorithm and random number calculation; sends the second key to the first controller, so that the first controller compares the first key and the second key, and when the comparison results are consistent, determines that the security verification of the first controller has passed, and controls the first controller to enter the programming session mode.

[0102] In one embodiment, when the second controller sends the firmware data information to be updated to the first controller, the second controller may send the firmware data information to be updated to the first controller in a second preset framing data block size.

[0103] In one embodiment, after sending the firmware data information to be updated to the first controller, the second controller can calculate the cumulative sum of each byte data of the firmware data to be updated to obtain a first check value, and send the first check value to the first controller, so that the first controller compares the first check value with the second check value, and determines whether the firmware is updated successfully based on the comparison result, the second check value is the cumulative sum of each byte data of the firmware data to be updated calculated by the first controller and written into the firmware area of ​​the first controller; receive a notification message of firmware update failure sent by the first controller, the notification message is generated and sent by the first controller when confirming that the firmware update is unsuccessful.

[0104] See also Figure 7 , Figure 7 is a flowchart of another firmware update method provided in an embodiment of the present application. The firmware update method is applied to a controller, the controller includes a first controller and a second controller, the first controller is a SOC, the second controller is an MCU, and the firmware is a Bootloader, such as Figure 7 The firmware update method in this embodiment may at least include the following steps:

[0105] S701: The SOC obtains firmware data information to be updated.

[0106] The SOC receives the OTA upgrade package sent by the OTA server, and parses the OTA upgrade package to obtain the firmware data information to be updated, wherein the firmware data information to be updated includes the firmware data to be updated, the software coding information to be updated, the firmware version information to be updated and the firmware data address to be updated, wherein the firmware version information to be updated includes but is not limited to the firmware version number to be updated.

[0107] S702: The SOC verifies the software coding information.

[0108] The SOC reads the software coding information stored locally in the MCU, and then compares it with the software coding information to be updated in the firmware data information to be updated. If they are the same, S703 is executed, otherwise the firmware update process is exited.

[0109] Specific combination Figure 8 Explain the startup process of MCU. Figure 8 This is a schematic diagram of a MCU startup process provided by an embodiment of the present application, such as Figure 8As shown, after the MCU is started, it can enter LittleBootloader and read the identifier stored in the specified storage unit EEPROM, and further determine whether the firmware is updated successfully through the identifier. If the firmware is updated successfully, the Bootloader of the first controller is run. If the firmware update is unsuccessful, the APP of the first controller is run.

[0110] S703: The SOC verifies the firmware version information.

[0111] The SOC reads the Bootloader version number stored locally on the MCU (i.e., the firmware version information stored locally), and then compares it with the firmware version number to be updated (i.e., the firmware version information to be updated). S707 can only be executed when the firmware version number to be updated is greater than the Bootloader version number of the MCU, otherwise the upgrade process is exited.

[0112] S704: The SOC controls the MUC to enter the extended session mode so that the MCU enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

[0113] According to the UDS diagnostic protocol, the SOC sends the first instruction for entering the extended session mode to the MCU to control the MCU to enter the extended session mode, and then sends the second instruction for indicating the prohibition of fault code setting to the MCU to make the MCU enter the fault code setting prohibition state, and then sends the third instruction for indicating the prohibition of communication message sending to the MCU to make the MCU enter the communication message sending prohibition state.

[0114] S705: MCU performs safety verification on SOC.

[0115] The SOC sends a security verification request to the MCU and obtains the seed (i.e., random number) that the MCU replies to the security verification request. The MCU calculates the first key based on the preset security verification algorithm and the seed (i.e., random number). The SOC calculates the second key based on the seed (i.e., random number) and the preset security verification algorithm (such as the preset keyword key), and sends the second key to the MCU. After the MCU passes the verification, step S706 is executed, otherwise the firmware update program is exited.

[0116] S706: The MCU enters programming session mode.

[0117] S707: The MCU erases the data in the data backup area.

[0118] The MCU determines whether to upgrade (ie update) the Bootloader according to the data erase address corresponding to the firmware data address to be updated sent by the SOC, and erases the corresponding size from the starting address of the data backup area (BLOCK4) of the FLASH according to the size of the Bootloader.

[0119] S708: The SOC sends a data transmission request to the MCU.

[0120] The SOC sends a data transmission request to the MCU to transmit data, and the MCU replies to the SOC how much data can be transmitted at one time, that is, the maximum data amount (that is, the second preset framing data block size), for example, 2KB of data is transmitted at one time.

[0121] S709: SOC transmits data to MCU.

[0122] The SOC transmits data to the MCU according to the maximum amount of data that the SOC can transmit at one time as replied by the MCU (i.e., the firmware data to be updated). The MCU begins to receive the data sent by the SOC and packages the received data according to the UDS diagnostic protocol format.

[0123] S710: The MCU starts writing the transmission data sent by the SOC, namely the Bootloader program, from the starting address of the data backup area (BLOCK4).

[0124] Start writing the Bootloader program from the start address of the data backup area (BLOCK4), write 2KB of data each time, read it out after writing, and compare it with the written data. If they are the same, it means the writing is successful, otherwise rewrite it. The address of the written backup area plus 2048 is used as the next writing address.

[0125] S711: Determine whether writing the Bootloader program is completed. If the determination result is that the Bootloader program transmission is completed, execute step S712; if the determination result is that the Bootloader program transmission is not completed, execute step S710.

[0126] The end address is used to determine whether writing to the Bootloader is completed. If it is not completed, continue to wait for receiving data.

[0127] S712: Check whether the Bootloader is complete. If the check result is no, execute step S713; if the check result is yes, execute step S714.

[0128] Read out the Bootloader program in the backup area (BLCOK4) and calculate the cumulative sum, and then compare it with the checksum transmitted by the SOC. If the comparison result is consistent, it is confirmed that the Bootloader is complete.

[0129] S713: MCU is powered on or reset.

[0130] After the MCU is powered on or reset, when an unsuccessful firmware update flag is detected, the MCU's APP program is rerun to determine that the Bootloader upgrade fails, and the SOC restarts the upgrade process, repeating the upgrade process up to n (such as 3) times; when no unsuccessful firmware update flag is detected, it is determined that the Bootloader upgrade is successful, and the new Bootloader on the MCU is run.

[0131] S714: The MCU erases the Bootloader area (BLOCK2).

[0132] S715: The MCU reads the Bootloader program from the starting address of the backup area (BLOCK4), and writes the Bootloader program from the starting address of the Bootloader area (BLCOK2).

[0133] MCU starts reading the Bootloader program from the start address of the backup area (BLOCK4), reading 2KB of data each time, and writes 2KB of Bootloader program from the start address of the Bootloader area (BLCOK2). After writing, it is read out and compared with the written data. If they are the same, it means the writing is successful, otherwise it is rewritten. The next read address and write address are the addresses calculated in step S715.

[0134] S716: The MCU controls the data backup area (BLOCK4) address plus 2048 (ie, the bytes corresponding to the maximum data volume) as the next read address, and the Bootloader (BLOCK2) address plus 2048 as the next write address.

[0135] S717: The MCU determines whether the writing of the Bootloader program is completed. If it is determined that it is not completed, continue to execute step S715. If it is determined that the transfer of the Bootloader program is completed, execute step S718.

[0136] S718: The MCU verifies whether the Bootloader is complete. If the verification result is complete, execute step S713; if the verification result is incomplete, execute step S719.

[0137] Read the data in the Bootloader area (BLCOK2) and calculate the cumulative sum (i.e., the second check value), and then compare it with the checksum transmitted by the SOC (i.e., the first check value). If the check passes, the MCU is reset and the APP is re-run. If the check fails, execute step S715.

[0138] S719: The MCU determines whether the number of re-executions exceeds a preset number. If so, it determines that the firmware update has failed and executes step S720.

[0139] It is determined whether the number of re-executions exceeds a preset number n (eg, 3 times), that is, it is determined whether the number of re-writing the Bootloader (BLOCK2) from the data backup area (BLCOK4) exceeds 3 times.

[0140] S720: The MCU writes a firmware update failure flag in a designated storage unit, and sends a firmware update failure notification message to the SOC.

[0141] If the verification of reading from the data backup area (BLOCK4) and then writing to the Bootloader area (BLOCK2) fails n times, it is determined that the firmware upgrade has failed, and a firmware update failure flag is written to the EEPROM (i.e., the designated storage unit), and the SOC is notified that the Bootloader update has failed. The MCU is reset and restarted, and the flag stored in the EEPROM is read when entering the LittleBootloader area (BLOCK1) after restart. If it is a flag indicating the failure of the Bootloader upgrade, it directly jumps to the APP. In this way, the MCU will not fail to run when the Bootloader upgrade fails.

[0142] See also Fig. 9 , Fig. 9 is a structural diagram of a firmware update device provided in an embodiment of the present application. The firmware update device is arranged in a first controller. The firmware update device includes an acquisition unit 901 and a writing unit 902, wherein:

[0143] An acquisition unit 901 is used to acquire firmware data information to be updated when the first controller application is running;

[0144] The writing unit 902 is configured to write the firmware data information to be updated into the firmware area of ​​the first controller according to a first preset framing data block size.

[0145] Further, when the acquisition unit 901 acquires the firmware data information to be updated, it is specifically used to:

[0146] The firmware data information to be updated sent by the second controller is received, where the firmware data information to be updated is obtained by the second controller receiving an OTA upgrade package sent by an OTA server and parsing the OTA upgrade package.

[0147] Furthermore, before the writing unit 902 writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, it is further configured to:

[0148] The firmware data information to be updated is written into a data backup area of ​​the first controller, where the data backup area is located in an application backup area of ​​the first controller, wherein the firmware data information to be updated at least includes the firmware data to be updated.

[0149] Further, the firmware data information to be updated also includes the firmware data address to be updated; when the writing unit 902 writes the firmware data information to be updated into the data backup area of ​​the first controller, it is specifically used to:

[0150] Determining a data erasure address corresponding to the firmware data address to be updated from the data backup area;

[0151] The backup data corresponding to the data erasure address in the data backup area is deleted, and after the deletion, the firmware data to be updated is written into the backup area corresponding to the data erasure address in the data backup area.

[0152] Further, when the writing unit 902 writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, it is specifically used to:

[0153] After determining that the firmware data to be updated is completely written into the data backup area of ​​the first controller, reading the firmware data to be updated from the data backup area;

[0154] According to the first preset framing data block size, the read firmware data to be updated is written into the firmware area of ​​the first controller according to the firmware address to be updated.

[0155] Further, the firmware data information to be updated also includes software coding information to be updated and firmware version information to be updated; before the acquisition unit 901 receives the firmware data information to be updated sent by the second controller, it is also used to:

[0156] Sending the software coding information and the firmware version information stored locally in the first controller to the second controller, so that the second controller uses the locally stored software coding information and the firmware version information to determine whether the software coding information to be updated and the firmware version information to be updated meet an update condition;

[0157] When it is confirmed that the software coding information to be updated and the firmware version information to be updated meet the update condition, the step of receiving the firmware data information to be updated sent by the second controller is performed.

[0158] Further, the software coding information to be updated and the firmware version information to be updated meet the update conditions, including: the comparison result of the locally stored software coding information and the software coding information to be updated is consistent, and the firmware version information to be updated is greater than the locally stored firmware version information.

[0159] Furthermore, before the acquisition unit 901 receives the firmware data information to be updated sent by the second controller, it is also used to:

[0160] A first instruction sent by the second controller is received, where the first instruction is used to instruct the first controller to enter an extended session mode so that the first controller enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

[0161] Furthermore, before the acquisition unit 901 receives the firmware data information to be updated sent by the second controller, it is also used to:

[0162] receiving a security verification request sent by the second controller;

[0163] In response to the security verification request, obtain a first key according to a preset security verification algorithm and a random number calculation, and send the random number to the second controller;

[0164] receiving a second key sent by the second controller, where the second key is calculated by the second controller according to the preset security verification algorithm and the random number;

[0165] The first key and the second key are compared, and when the comparison results are consistent, it is determined that the security check of the first controller has passed, and the first controller is controlled to enter a programming session mode.

[0166] Further, when the acquisition unit 901 receives the firmware data information to be updated sent by the second controller, it is specifically used to:

[0167] The firmware data information to be updated sent by the second controller is received with a second preset frame data block size.

[0168] Further, after the writing unit 902 writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, it is further used to:

[0169] Acquire a first check value transmitted by the second controller, where the first check value is the cumulative sum of each byte data of the firmware data to be updated calculated by the second controller;

[0170] Acquire each byte data of the firmware data to be updated written in the firmware area of ​​the first controller, and calculate the cumulative sum of each byte data of the firmware data to be updated written in the firmware area of ​​the first controller to obtain a second check value;

[0171] Comparing the first verification value with the second verification value;

[0172] If the comparison result of the first verification value and the second verification value is consistent, determining that the firmware update is successful;

[0173] When the comparison result between the first check value and the second check value is inconsistent, re-performing the step of writing the firmware data information to be updated into the data backup area of ​​the first controller;

[0174] When the comparison results of the first verification value and the second verification value obtained by re-executing the step of writing the firmware data information to be updated into the data backup area of ​​the first controller are inconsistent, it is determined that the firmware update is unsuccessful, and an identifier of the unsuccessful firmware update is generated, the identifier is written into a designated storage unit, and a notification message of the firmware update failure is sent to the second controller.

[0175] Further, after the writing unit 902 writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, it is further used to:

[0176] After the first controller is powered on or reset, when an indication that the firmware update is unsuccessful is detected, running the first controller application;

[0177] After the first controller is powered on or reset, if no indication indicating that the firmware update is unsuccessful is detected, the new firmware on the first controller is run.

[0178] In an embodiment of the present application, by obtaining the firmware data information to be updated when the first controller application is running; and writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the firmware data information to be updated can be safely and reliably written into the firmware area of ​​the controller, thereby improving the efficiency and effectiveness of the firmware update.

[0179] See also Fig.10 , Fig.10 1 is a schematic diagram of the structure of another firmware update device provided in an embodiment of the present application. The firmware update device is arranged in a second controller. The firmware update device includes an acquisition unit 1001 and a sending unit 1002, wherein:

[0180] The acquisition unit 1001 is used to acquire the firmware data information to be updated;

[0181] The sending unit 1002 is used to send the firmware data information to be updated to the first controller, so that the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size when the application is running.

[0182] Further, when the acquisition unit 1001 acquires the firmware data information to be updated, it is specifically used to:

[0183] Receive the OTA upgrade package sent by the OTA server, and parse the OTA upgrade package to obtain the firmware data information to be updated.

[0184] Furthermore, before the sending unit 1002 sends the firmware data information to be updated to the first controller, it is also used to:

[0185] Reading software coding information and firmware version information stored locally in the first controller;

[0186] The locally stored software coding information and firmware version information are used to determine whether the software coding information to be updated and the firmware version information to be updated meet an update condition.

[0187] Further, the software coding information to be updated and the firmware version information to be updated meet the update conditions, including: the comparison result of the locally stored software coding information and the software coding information to be updated is consistent, and the firmware version information to be updated is greater than the locally stored firmware version information.

[0188] Furthermore, before the sending unit 1002 sends the firmware data information to be updated to the first controller, it is also used to:

[0189] A first instruction is sent to the first controller, where the first instruction is used to instruct the first controller to enter an extended session mode, so that the first controller enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

[0190] Furthermore, before the sending unit 1002 sends the firmware data information to be updated to the first controller, it is also used to:

[0191] Sending a security verification request to the first controller, so that the first controller responds to the security verification request, obtains a first key according to a preset security verification algorithm and a random number calculation, and sends the random number to the second controller;

[0192] Receive the random number sent by the first controller, and calculate a second key according to the preset security verification algorithm and the random number;

[0193] The second key is sent to the first controller so that the first controller compares the first key with the second key, and if the comparison results are consistent, it is determined that the security check of the first controller has passed, and the first controller is controlled to enter the programming session mode.

[0194] Further, when the sending unit 1002 sends the firmware data information to be updated to the first controller, it is specifically used to:

[0195] The firmware data information to be updated is sent to the first controller with a second preset framing data block size.

[0196] Further, the firmware data information to be updated includes at least the firmware data to be updated; after the sending unit 1002 sends the firmware data information to be updated to the first controller, it is also used to:

[0197] Calculating the cumulative sum of each byte data of the firmware data to be updated to obtain a first check value, and sending the first check value to the first controller, so that the first controller compares the first check value with a second check value, and determines whether the firmware is successfully updated according to the comparison result, wherein the second check value is the cumulative sum of each byte data of the firmware data to be updated calculated by the first controller and written into the firmware area of ​​the first controller;

[0198] A notification message of firmware update failure sent by the first controller is received, where the notification message is generated and sent by the first controller when confirming that the firmware update is unsuccessful.

[0199] In an embodiment of the present application, the controller can obtain firmware data information to be updated; and send the firmware data information to be updated to the first controller, so that when the application is running, the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size. The firmware data information to be updated can be safely and reliably written into the firmware area of ​​the controller, thereby improving the efficiency and effectiveness of firmware updates.

[0200] See also Fig.11 , Fig.11 It is a structural diagram of an electronic device provided by an embodiment of the present application. As shown in the figure, the electronic device in this embodiment may include: one or more processors 1101, memory 1102, bus 1103 and communication interface 1104, the processor 1101, communication interface 1104 and memory 1102 are connected through bus 1103; memory 1102 is used to store programs; processor 1101 is used to call the program stored in the above memory through bus 1103, and perform the following steps:

[0201] When the first controller application is running, obtaining firmware data information to be updated;

[0202] The firmware data information to be updated is written into the firmware area of ​​the first controller according to a first preset framing data block size.

[0203] Further, when the processor 1101 obtains the firmware data information to be updated, it is specifically used to:

[0204] The firmware data information to be updated sent by the second controller is received, where the firmware data information to be updated is obtained by the second controller receiving an OTA upgrade package sent by an OTA server and parsing the OTA upgrade package.

[0205] Further, before writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the processor 1101 is further configured to:

[0206] The firmware data information to be updated is written into a data backup area of ​​the first controller, where the data backup area is located in an application backup area of ​​the first controller, wherein the firmware data information to be updated at least includes the firmware data to be updated.

[0207] Further, the firmware data information to be updated also includes a firmware data address to be updated; when the processor 1101 writes the firmware data information to be updated into the data backup area of ​​the first controller, it is specifically used to:

[0208] Determining a data erasure address corresponding to the firmware data address to be updated from the data backup area;

[0209] The backup data corresponding to the data erasure address in the data backup area is deleted, and after the deletion, the firmware data to be updated is written into the backup area corresponding to the data erasure address in the data backup area.

[0210] Further, when the processor 1101 writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, it is specifically configured to:

[0211] After determining that the firmware data to be updated is completely written into the data backup area of ​​the first controller, reading the firmware data to be updated from the data backup area;

[0212] According to the first preset framing data block size, the read firmware data to be updated is written into the firmware area of ​​the first controller according to the firmware address to be updated.

[0213] Further, the firmware data information to be updated also includes software coding information to be updated and firmware version information to be updated; before the processor 1101 receives the firmware data information to be updated sent by the second controller, it is also used to:

[0214] Sending the software coding information and the firmware version information stored locally in the first controller to the second controller, so that the second controller uses the locally stored software coding information and the firmware version information to determine whether the software coding information to be updated and the firmware version information to be updated meet an update condition;

[0215] When it is confirmed that the software coding information to be updated and the firmware version information to be updated meet the update condition, the step of receiving the firmware data information to be updated sent by the second controller is performed.

[0216] Further, the software coding information to be updated and the firmware version information to be updated meet the update conditions, including: the comparison result of the locally stored software coding information and the software coding information to be updated is consistent, and the firmware version information to be updated is greater than the locally stored firmware version information.

[0217] Furthermore, before receiving the firmware data information to be updated sent by the second controller, the processor 1101 is further configured to:

[0218] A first instruction sent by the second controller is received, where the first instruction is used to instruct the first controller to enter an extended session mode so that the first controller enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

[0219] Furthermore, before receiving the firmware data information to be updated sent by the second controller, the processor 1101 is further configured to:

[0220] receiving a security verification request sent by the second controller;

[0221] In response to the security verification request, obtain a first key according to a preset security verification algorithm and a random number calculation, and send the random number to the second controller;

[0222] receiving a second key sent by the second controller, where the second key is calculated by the second controller according to the preset security verification algorithm and the random number;

[0223] The first key and the second key are compared, and when the comparison results are consistent, it is determined that the security check of the first controller has passed, and the first controller is controlled to enter a programming session mode.

[0224] Further, when the processor 1101 receives the firmware data information to be updated sent by the second controller, it is specifically configured to:

[0225] The firmware data information to be updated sent by the second controller is received with a second preset frame data block size.

[0226] Further, after the processor 1101 writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, it is further configured to:

[0227] Acquire a first check value transmitted by the second controller, where the first check value is the cumulative sum of each byte data of the firmware data to be updated calculated by the second controller;

[0228] Acquire each byte data of the firmware data to be updated written in the firmware area of ​​the first controller, and calculate the cumulative sum of each byte data of the firmware data to be updated written in the firmware area of ​​the first controller to obtain a second check value;

[0229] Comparing the first verification value with the second verification value;

[0230] If the comparison result of the first verification value and the second verification value is consistent, determining that the firmware update is successful;

[0231] When the comparison result between the first check value and the second check value is inconsistent, re-performing the step of writing the firmware data information to be updated into the data backup area of ​​the first controller;

[0232] When the comparison results of the first verification value and the second verification value obtained by re-executing the step of writing the firmware data information to be updated into the data backup area of ​​the first controller are inconsistent, it is determined that the firmware update is unsuccessful, and an identifier of the unsuccessful firmware update is generated, the identifier is written into a designated storage unit, and a notification message of the firmware update failure is sent to the second controller.

[0233] Further, after the processor 1101 writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, it is further configured to:

[0234] After the first controller is powered on or reset, when an indication that the firmware update is unsuccessful is detected, running the first controller application;

[0235] After the first controller is powered on or reset, if no indication indicating that the firmware update is unsuccessful is detected, the new firmware on the first controller is run.

[0236] In an embodiment of the present application, the electronic device obtains the firmware data information to be updated when the first controller application is running; and writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size. The firmware data information to be updated can be safely and reliably written into the firmware area of ​​the controller, thereby improving the efficiency and effectiveness of the firmware update.

[0237] like Fig.11 As shown, the processor 1101 of the electronic device provided in the embodiment of the present application can also be used to call the program stored in the above memory through the bus 1103 to perform the following steps:

[0238] Obtain the firmware data information to be updated;

[0239] The firmware data information to be updated is sent to the first controller, so that the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size when the application is running.

[0240] Further, when the processor 1101 obtains the firmware data information to be updated, it is specifically used to:

[0241] Receive the OTA upgrade package sent by the OTA server, and parse the OTA upgrade package to obtain the firmware data information to be updated.

[0242] Furthermore, before sending the firmware data information to be updated to the first controller, the processor 1101 is further configured to:

[0243] Reading software coding information and firmware version information stored locally in the first controller;

[0244] The locally stored software coding information and firmware version information are used to determine whether the software coding information to be updated and the firmware version information to be updated meet an update condition.

[0245] Further, the software coding information to be updated and the firmware version information to be updated meet the update conditions, including: the comparison result of the locally stored software coding information and the software coding information to be updated is consistent, and the firmware version information to be updated is greater than the locally stored firmware version information.

[0246] Furthermore, before sending the firmware data information to be updated to the first controller, the processor 1101 is further configured to:

[0247] A first instruction is sent to the first controller, where the first instruction is used to instruct the first controller to enter an extended session mode, so that the first controller enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

[0248] Furthermore, before sending the firmware data information to be updated to the first controller, the processor 1101 is further configured to:

[0249] Sending a security verification request to the first controller, so that the first controller responds to the security verification request, obtains a first key according to a preset security verification algorithm and a random number calculation, and sends the random number to the second controller;

[0250] Receive the random number sent by the first controller, and calculate a second key according to the preset security verification algorithm and the random number;

[0251] The second key is sent to the first controller so that the first controller compares the first key with the second key, and if the comparison results are consistent, it is determined that the security check of the first controller has passed, and the first controller is controlled to enter the programming session mode.

[0252] Further, when the processor 1101 sends the firmware data information to be updated to the first controller, it is specifically used to:

[0253] The firmware data information to be updated is sent to the first controller with a second preset framing data block size.

[0254] Further, the firmware data information to be updated includes at least the firmware data to be updated; after the processor 1101 sends the firmware data information to be updated to the first controller, it is also used to:

[0255] Calculating the cumulative sum of each byte data of the firmware data to be updated to obtain a first check value, and sending the first check value to the first controller, so that the first controller compares the first check value with a second check value, and determines whether the firmware is successfully updated according to the comparison result, wherein the second check value is the cumulative sum of each byte data of the firmware data to be updated calculated by the first controller and written into the firmware area of ​​the first controller;

[0256] A notification message of firmware update failure sent by the first controller is received, where the notification message is generated and sent by the first controller when confirming that the firmware update is unsuccessful.

[0257] In an embodiment of the present application, the electronic device obtains firmware data information to be updated; sends the firmware data information to be updated to the first controller, so that when the application is running, the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size. The firmware data information to be updated can be safely and reliably written into the firmware area of ​​the controller, thereby improving the efficiency and effectiveness of firmware updates.

[0258] It should be understood that in the embodiment of the present application, the processor 1101 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0259] The memory 1102 may include a read-only memory and a random access memory, and provide instructions and data to the processor 1101. A portion of the memory 1102 may also include a non-volatile random access memory. For example, the memory 1102 may also store information about the device type.

[0260] In a specific implementation, the processor 1101 described in the embodiments of the present application can execute the embodiments of the present application. Figure 2 , Figure 4 , Figure 6 , Figure 7 The implementation of any firmware update method described in the embodiment of the present application can also be performed. Fig. 9 or Fig.10 The implementation method of the described firmware update device will not be repeated here.

[0261] The embodiment of the present application provides a vehicle, which includes a vehicle body and an electronic device, wherein the electronic device includes a first controller and a second controller, wherein the first controller is used to execute Figure 2 , Figure 4 , Figure 7 The firmware of the first controller of the vehicle is updated by any method described in Figure 2 ,like Figure 6 , Figure 7 Any of the methods described above updates the firmware of the first controller of the vehicle.

[0262] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0263] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the terminals and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0264] In the several embodiments provided in the present application, it should be understood that the disclosed terminal and method can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.

[0265] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.

[0266] The units in the terminal in the embodiment of the present application can be merged, divided and deleted according to actual needs.

[0267] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0268] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0269] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0270] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A firmware update method, It is characterized in that Applied to a first controller, the method comprises: When the first controller application is running, obtaining firmware data information to be updated; The firmware data information to be updated is written into the firmware area of ​​the first controller according to a first preset framing data block size.

2. The method according to claim 1, It is characterized in that The obtaining of firmware data information to be updated includes: The firmware data information to be updated sent by the second controller is received, where the firmware data information to be updated is obtained by the second controller receiving an OTA upgrade package sent by an OTA server and parsing the OTA upgrade package.

3. The method according to claim 1, It is characterized in that Before writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the method further includes: The firmware data information to be updated is written into a data backup area of ​​the first controller, where the data backup area is located in an application backup area of ​​the first controller, wherein the firmware data information to be updated at least includes the firmware data to be updated.

4. The method according to claim 3, It is characterized in that The firmware data information to be updated also includes the firmware data address to be updated; and the step of writing the firmware data information to be updated into the data backup area of ​​the first controller includes: Determining a data erasure address corresponding to the firmware data address to be updated from the data backup area; The backup data corresponding to the data erasure address in the data backup area is deleted, and after the deletion, the firmware data to be updated is written into the backup area corresponding to the data erasure address in the data backup area.

5. The method according to claim 4, It is characterized in that The step of writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size includes: After determining that the firmware data to be updated is completely written into the data backup area of ​​the first controller, reading the firmware data to be updated from the data backup area; According to the first preset framing data block size, the read firmware data to be updated is written into the firmware area of ​​the first controller according to the firmware address to be updated.

6. The method according to claim 2, It is characterized in that The firmware data information to be updated also includes software coding information to be updated and firmware version information to be updated; before receiving the firmware data information to be updated sent by the second controller, the method further includes: Sending the software coding information and the firmware version information stored locally in the first controller to the second controller, so that the second controller uses the locally stored software coding information and the firmware version information to determine whether the software coding information to be updated and the firmware version information to be updated meet an update condition; When it is confirmed that the software coding information to be updated and the firmware version information to be updated meet the update condition, the step of receiving the firmware data information to be updated sent by the second controller is performed.

7. The method according to claim 6, It is characterized in that The software encoding information to be updated and the firmware version information to be updated meet the update conditions, including: the comparison result of the locally stored software encoding information and the software encoding information to be updated is consistent, and the firmware version information to be updated is greater than the locally stored firmware version information.

8. The method according to claim 2, It is characterized in that Before receiving the firmware data information to be updated sent by the second controller, the method further includes: A first instruction sent by the second controller is received, where the first instruction is used to instruct the first controller to enter an extended session mode so that the first controller enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

9. The method according to claim 2, It is characterized in that Before receiving the firmware data information to be updated sent by the second controller, the method further includes: receiving a security verification request sent by the second controller; In response to the security verification request, obtain a first key according to a preset security verification algorithm and a random number calculation, and send the random number to the second controller; receiving a second key sent by the second controller, where the second key is calculated by the second controller according to the preset security verification algorithm and the random number; The first key and the second key are compared, and when the comparison results are consistent, it is determined that the security check of the first controller has passed, and the first controller is controlled to enter a programming session mode.

10. The method according to claim 2, It is characterized in that The receiving firmware data information to be updated sent by the second controller, the method comprising: The firmware data information to be updated sent by the second controller is received with a second preset frame data block size.

11. The method according to claim 1, It is characterized in that After writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the method further includes: Acquire a first check value transmitted by the second controller, where the first check value is the cumulative sum of each byte data of the firmware data to be updated calculated by the second controller; Acquire each byte data of the firmware data to be updated written in the firmware area of ​​the first controller, and calculate the cumulative sum of each byte data of the firmware data to be updated written in the firmware area of ​​the first controller to obtain a second check value; Comparing the first verification value with the second verification value; If the comparison result of the first verification value and the second verification value is consistent, determining that the firmware update is successful; When the comparison result between the first check value and the second check value is inconsistent, re-performing the step of writing the firmware data information to be updated into the data backup area of ​​the first controller; When the comparison results of the first verification value and the second verification value obtained by re-executing the step of writing the firmware data information to be updated into the data backup area of ​​the first controller are inconsistent, it is determined that the firmware update is unsuccessful, and an identifier of the unsuccessful firmware update is generated, the identifier is written into a designated storage unit, and a notification message of the firmware update failure is sent to the second controller.

12. The method according to claim 11, It is characterized in that After writing the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size, the method further includes: After the first controller is powered on or reset, when an indication that the firmware update is unsuccessful is detected, running the first controller application; After the first controller is powered on or reset, if no indication indicating that the firmware update is unsuccessful is detected, the new firmware on the first controller is run.

13. A firmware update method, It is characterized in that Applied to the second controller, the method comprises: Obtain the firmware data information to be updated; The firmware data information to be updated is sent to the first controller, so that the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size when the application is running.

14. The method according to claim 13, It is characterized in that Before sending the firmware data information to be updated to the first controller, the method further includes: Receive the OTA upgrade package sent by the OTA server, and parse the OTA upgrade package to obtain the firmware data information to be updated.

15. The method according to claim 13, It is characterized in that Before sending the firmware data information to be updated to the first controller, the method further includes: Reading software coding information and firmware version information stored locally in the first controller; The locally stored software coding information and firmware version information are used to determine whether the software coding information to be updated and the firmware version information to be updated meet an update condition.

16. The method according to claim 15, It is characterized in that The software encoding information to be updated and the firmware version information to be updated meet the update conditions, including: the comparison result of the locally stored software encoding information and the software encoding information to be updated is consistent, and the firmware version information to be updated is greater than the locally stored firmware version information.

17. The method according to claim 13, It is characterized in that Before sending the firmware data information to be updated to the first controller, the method further includes: A first instruction is sent to the first controller, where the first instruction is used to instruct the first controller to enter an extended session mode, so that the first controller enters a state of prohibiting fault code setting and / or prohibiting communication message sending.

18. The method according to claim 13, It is characterized in that Before sending the firmware data information to be updated to the first controller, the method further includes: Sending a security verification request to the first controller, so that the first controller responds to the security verification request, obtains a first key according to a preset security verification algorithm and a random number calculation, and sends the random number to the second controller; Receive the random number sent by the first controller, and calculate a second key according to the preset security verification algorithm and the random number; The second key is sent to the first controller so that the first controller compares the first key with the second key, and if the comparison results are consistent, it is determined that the security check of the first controller has passed, and the first controller is controlled to enter the programming session mode.

19. The method according to claim 13, It is characterized in that The sending the firmware data information to be updated to the first controller includes: The firmware data information to be updated is sent to the first controller with a second preset framing data block size.

20. The method according to claim 13, It is characterized in that The firmware data information to be updated includes at least the firmware data to be updated; after sending the firmware data information to be updated to the first controller, the method includes: Calculating the cumulative sum of each byte data of the firmware data to be updated to obtain a first check value, and sending the first check value to the first controller, so that the first controller compares the first check value with a second check value, and determines whether the firmware is successfully updated according to the comparison result, wherein the second check value is the cumulative sum of each byte data of the firmware data to be updated calculated by the first controller and written into the firmware area of ​​the first controller; A notification message of firmware update failure sent by the first controller is received, where the notification message is generated and sent by the first controller when confirming that the firmware update is unsuccessful.

21. A firmware update device, It is characterized in that The firmware update device is arranged in the first controller, and the device comprises: An acquisition unit, configured to acquire firmware data information to be updated when the first controller application is running; The writing unit is used to write the firmware data information to be updated into the firmware area of ​​the first controller according to a first preset framing data block size.

22. A firmware update device, It is characterized in that The firmware updating device is arranged in the second controller, and the device comprises: An acquisition unit, used for acquiring firmware data information to be updated; The sending unit is used to send the firmware data information to be updated to the first controller, so that the first controller writes the firmware data information to be updated into the firmware area of ​​the first controller according to the first preset framing data block size when the application is running.

23. An electronic device, It is characterized in that The electronic device comprises a processor, a memory, a bus and a communication interface, wherein the processor, the communication interface and the memory are connected via the bus; The memory is used to store programs; The processor is used to call the program stored in the memory through the bus to execute any one of the methods of claims 1-12.

24. An electronic device, It is characterized in that The electronic device comprises a processor, a memory, a bus and a communication interface, wherein the processor, the communication interface and the memory are connected via the bus; The memory is used to store programs; The processor is used to call the program stored in the memory through the bus to execute any method described in claims 13-20.

25. A vehicle, It is characterized in that The vehicle includes a car body and an electronic device, the electronic device includes a first controller and a second controller, the first controller is used to execute the method described in any one of claims 1-12 to update the firmware of the first controller of the vehicle, and the second controller is used to execute the method described in any one of claims 13-20 to update the firmware of the first controller of the vehicle.

Citation Information

Patent Citations

  • A method for MCU online upgrading

    CN109240721A

  • Vehicle controller firmware upgrading method and system, vehicle controller and storage medium

    CN114840235A