Two-stage Bootloader updating method and system based on double partitions
By adopting dual-partition switching technology in the vehicle ECU, we ensure that the SBL update is successful and the APP is kept unchanged, and the recovery problems caused by power failure or disconnection in software updates and APP version changes are solved, and flexible debugging and production requirements are achieved. satisfy.
Patent Information
- Application Number
- CN202410952173.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-11-01
AI Technical Summary
In the process of vehicle ECU software update, the program is prone to failing to resume normal operation due to power failure or disconnection, and the SBL update does not pay attention to the APP version, which cannot meet the flash write rollback mechanism.
Using a two-level Bootloader update method based on dual partitions, by switching states between the first and second partitions, ensuring that after the SBL update is successful, the new version of SBL software covers the valid area, and keeps the APP unchanged during the update process, satisfying the satisfaction of Flash write rollback mechanism.
Regardless of whether the SBL update is successful or not, it can ensure that the current SBL is a complete old version or new version, avoiding the inability to recover by itself due to other reasons and affecting normal work, and ensuring that the APP remains unchanged during the update process, meeting the needs of internal flexible debugging and flexible production. .
Smart Images

Figure CN118885201A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of software update, and in particular to a two-level Bootloader update method and system based on dual partitions. Background Art
[0002] Vehicle OTA (Over-the-Air Technology) technology is becoming increasingly popular, and the frequency of vehicle ECU (Electronic Control Unit) software updates is increasing. Traditional ECU software update solutions require users to wait for upgrades, and if the update process is interrupted, the update needs to be restarted.
[0003] MCUs based on AB partitions came into being. MCUs that support AB partitions divide CFlash (Code Flash, i.e. instruction-accessible flash memory, also known as Program Flash or PFlash) into two equal parts, called Partition A and Partition B. MCUs can only run programs in one of the partitions (the partition being executed is hereinafter referred to as the valid area, and the other is called the invalid area). Running programs in Partition A or B can be controlled by the instruction set. When the MCU runs a program in one of the partitions, the partition is usually not erasable, but the other partition can be erased.
[0004] This solution brings a benefit: after the software upgrade is interrupted, it will not affect the user's use of application functions, and the valid area program can still run, which satisfies the software rollback mechanism.
[0005] The so-called two-level bootloader (i.e. boot loader) includes PBL (primary bootloader), SBL (secondary bootloader) and APP in CFlash. PBL is a private bootloader, SBL is a bootloader that meets OEM requirements, PBL supports updating SBL, and SBL supports updating APP. PBL is burned by the burner through the JTAG port, SBL and APP can be burned through the JTAG interface, and can also be burned through the CAN line through the UDS protocol. The MCU first runs PBL, then jumps from PBL to SBL, and SBL jumps to APP.
[0006] In order to avoid upgrade failure caused by abnormalities, power failures, etc., the existing SBL update can be self-repaired and restored to normal operation through the combination of the boot module, the bootloader dual module and the bootloader configuration module to ensure that the program startup and upgrade process are safe and reliable. However, this method is prone to the following two problems:
[0007] First, when power outages or disconnections occur, the original program cannot run after recovery, and normal operation can only be restored after subsequent self-repair. If other failures occur, such as problems with the upgrade program itself, normal operation may not be restored;
[0008] Secondly, when updating SBL, it does not pay attention to the version of the APP in the partition, which may cause changes to the APP in the original partition and fail to meet the flash rollback mechanism. Summary of the invention
[0009] The embodiment of the present invention provides a two-level Bootloader update method and system based on dual partitions, which can ensure that whether the SBL update is successful or not, the current SBL can be guaranteed to be a complete old version or a new version. The SBL update is flexible and can meet the needs of internal flexible debugging and flexible production.
[0010] A first aspect of an embodiment of the present invention provides a two-level Bootloader update method based on dual partitions, wherein the dual partition includes a first partition and a second partition, and the two-level Bootloader includes a first Bootloader, a second Bootloader and an APP, wherein the first partition and the second partition store the first Bootloader, the second Bootloader and the APP respectively, and the first Bootloader, the second Bootloader and the APP stored in the first partition are respectively recorded as PBL_x, SBL_x and APP_x, and the first Bootloader, the second Bootloader and the APP stored in the second partition are respectively recorded as PBL_y, SBL_y and APP_y, and the method includes updating the second Bootloader, specifically including:
[0011] Set the first partition as a valid area, and set the second partition as an invalid area;
[0012] Use the new version of SBL software to update SBL_y in the second partition, and check whether the first Bootloader of the first partition and the second partition are the same. If they are different, copy PBL_x stored in the first partition to the second partition to overwrite PBL_y in the second partition;
[0013] Switching the states of the first partition and the second partition, switching the first partition to an invalid area, and switching the second partition to a valid area;
[0014] Copying the new version of SBL software to the first partition to overwrite SBL_x in the first partition;
[0015] Switch the states of the first partition and the second partition again, switching the first partition to a valid area and switching the second partition to an invalid area;
[0016] Run the first partition to complete the update of the second Bootloader.
[0017] As an optional implementation manner, in the first aspect of the embodiment of the present invention, after switching the states of the first partition and the second partition and before running the first partition, if a power-off restart occurs, it is checked whether the second Bootloaders of the first partition and the second partition are the same, and if they are different, the new version of the SBL software in the second partition is copied to the first partition to overwrite the second Bootloader in the first partition;
[0018] The states of the first partition and the second partition are switched again, the first partition is switched to a valid area, and the second partition is switched to an invalid area.
[0019] As an optional implementation manner, in the first aspect of the embodiment of the present invention, SBL_y is updated using a new version of SBL software, and then the method further includes:
[0020] Verify the integrity and legality of the new version of the SBL software in the second partition.
[0021] As an optional implementation manner, in the first aspect of the embodiment of the present invention, the method further includes updating the APP, specifically including:
[0022] Set the first partition as a valid area, and set the second partition as an invalid area;
[0023] Use the new version of APP software to update APP_y in the second partition;
[0024] Copying PBL_x and SBL_x in the first partition to the second partition to cover PBL_y and SBL_y in the second partition respectively;
[0025] Switch the states of the first partition and the second partition, switch the second partition to a valid area, and switch the first partition to an invalid area;
[0026] Run the second partition to complete the update of the APP.
[0027] As an optional implementation manner, in the first aspect of the embodiment of the present invention, the method further includes:
[0028] Verify the integrity and legitimacy of the new version of the APP software in the second partition.
[0029] As an optional implementation, in the first aspect of the embodiment of the present invention, the first Bootloader supports updating of the second Bootloader, and the second Bootloader supports updating of the APP.
[0030] As an optional implementation, in the first aspect of the embodiment of the present invention, the update of the second Bootloader is realized by burning through the JTAG interface, or by burning through the CAN bus through the UDS protocol.
[0031] In a second aspect of an embodiment of the present invention, a two-level Bootloader update system based on dual partitions is provided, wherein the dual partition includes a first partition and a second partition, and the two-level Bootloader includes a first Bootloader, a second Bootloader and an APP, wherein the first partition and the second partition store the first Bootloader, the second Bootloader and the APP respectively, and the first Bootloader, the second Bootloader and the APP stored in the first partition are respectively recorded as PBL_x, SBL_x and APP_x, and the first Bootloader, the second Bootloader and the APP stored in the second partition are respectively recorded as PBL_y, SBL_y and APP_y, and the system includes:
[0032] A first updating unit is used to update the second Bootloader, wherein the first updating unit includes:
[0033] A setting subunit, configured to set the first partition as a valid area and the second partition as an invalid area;
[0034] The update subunit uses the new version of the SBL software to update the SBL_y in the second partition, and checks whether the first Bootloaders of the first partition and the second partition are the same. If they are different, the PBL_x stored in the first partition is copied to the second partition to cover the PBL_y in the second partition.
[0035] A first switching subunit is used to switch the states of the first partition and the second partition, switching the first partition to an invalid area and switching the second partition to a valid area;
[0036] The overwriting subunit is used to copy the new version of the SBL software to the first partition to overwrite the SBL_x in the first partition;
[0037] A second switching subunit is used to switch the states of the first partition and the second partition again, switching the first partition to a valid area and switching the second partition to an invalid area;
[0038] The running subunit is used to run the first partition to complete the update of the second Bootloader.
[0039] A third aspect of an embodiment of the present invention discloses an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, the steps of the two-level Bootloader update method based on dual partitions disclosed in the first aspect of the embodiment of the present invention are implemented.
[0040] A fourth aspect of an embodiment of the present invention discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the steps of the two-level Bootloader update method based on dual partitions disclosed in the first aspect of the embodiment of the present invention.
[0041] A fifth aspect of an embodiment of the present invention discloses a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the steps of the two-level Bootloader update method based on dual partitions disclosed in the first aspect of the embodiment of the present invention.
[0042] A sixth aspect of an embodiment of the present invention discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer executes the steps of the two-level Bootloader update method based on dual partitions disclosed in the first aspect of the embodiment of the present invention.
[0043] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0044] 1. In the embodiment of the present invention, the new version of SBL software is written into the SBL storage area in the invalid area, that is, SBL_y is updated to the new version of SBL software, and the PBL_x software in the valid area is moved to the PBL storage area in the invalid area, that is, PBL_x is used to cover PBL_y. Regardless of whether the SBL update is successful, it can be ensured that the current SBL is a complete old version or a new version. The SBL update is flexible, which can meet the needs of internal flexible debugging and flexible production, and avoid the original version being unable to continue to run due to failure to recover by itself due to other reasons, thereby affecting normal work.
[0045] 2. The APP software in the valid area and the invalid area remains unchanged during the entire SBL update process, avoiding the failure to meet the APP software flash rollback mechanism due to the APP being updated during the SBL software upgrade. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1It is a flow chart of a method for updating SBL software in a two-level Bootloader based on dual partitions provided by an embodiment of the present invention;
[0047] Figure 2 It is a flowchart of an APP software update method in a two-level Bootloader based on dual partitions provided by an embodiment of the present invention;
[0048] Figure 3 It is a structural schematic diagram of an SBL software update system in a two-level Bootloader based on dual partitions provided by an embodiment of the present invention;
[0049] Figure 4 It is a structural diagram of an APP software update system in a two-level Bootloader based on dual partitions provided by an embodiment of the present invention;
[0050] Figure 5 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical scheme and advantages of the present invention clearer, the specific embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. It should be noted that, under the premise of no conflict, the various embodiments described below or the various technical features can be arbitrarily combined to form a new embodiment. Except for special instructions, the materials and equipment used in this embodiment can be purchased from the market. Examples of embodiments are shown in the accompanying drawings, in which the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and the limitations of the present application cannot be understood.
[0052] In the description of the present application, it should be understood that the terms "upper", "lower", "front", "back", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific position, be constructed and operated in a specific position, and therefore cannot be understood as a limitation on the present application. In the description of the present application, "plurality" means two or more, unless otherwise precisely and specifically specified.
[0053] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "connected", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, or it can be connected through an intermediary medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0054] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0055] Embodiment 1
[0056] The execution subject of the two-level Bootloader update method based on dual partitions in the embodiment of the present invention is ECU, which includes hardware and software parts, wherein the hardware part mainly includes MCU and memory, and the memory preferably uses CFlash, and the MCU supports AB partitions. The MCU that supports AB partitions divides CFlash into two equal parts, respectively called A partition and B partition. The MCU can only run the program of one of the partitions (the partition being executed is hereinafter referred to as the valid area, and the invalid area is called the invalid area). The program running A or B partition can be controlled by the instruction set. When the MCU runs the program of one of the partitions, the partition is usually not erasable, and the other partition must be erasable.
[0057] The so-called two-level bootloader means that the memory stores PBL (i.e. PBL software program, the same below), SBL (i.e. SBL software program, the same below) and APP (i.e. APP software program, the same below). APP can be set to multiple types as needed. When updating (also called flashing or upgrading) APP, any target APP in APP can be updated.
[0058] It should be noted that PBL can support updating SBL, and SBL can support updating APP. During the flashing process, PBL can be burned by the burner through the JTAG port, SBL and APP can be burned through the JTAG interface, or burned through the CAN line through the UDS protocol. During operation, the MCU first runs PBL, then jumps from PBL to SBL, and SBL jumps to APP.
[0059] To distinguish them, the first Bootloader, the second Bootloader and the APP stored in the first partition (BANK_x) are respectively recorded as PBL_x, SBL_x and APP_x, and the first Bootloader, the second Bootloader and the APP stored in the second partition (BANK_y) are respectively recorded as PBL_y, SBL_y and APP_y.
[0060] The first partition and the second partition are just relative concepts. When x=A and y=B, the first partition is the A partition and the second partition is the B partition. If x=B and y=A, the second partition is the A partition and the first partition is the B partition.
[0061] The dual-partition based two-level Bootloader update method mainly includes the update of SBL software and the update of APP software.
[0062] SBL software is the Bootloader software that meets the OEM's needs and does not need to meet the flash rollback mechanism. APP software updates need to meet the flash rollback mechanism. Therefore, when updating the SBL software, the existing APP software in any current partition cannot be destroyed.
[0063] Assume that the partition currently mapped to the valid area is BANK_x, and the partition mapped to the invalid area is BANK_y, then PBL_x, SBL_x, and APP_x are stored in BANK_x, and PBL_y, SBL_y, and APP_y are stored in BANK_y. PBL_x needs to be used to update the SBL_x software to the new version of SBL software (denoted as SBL_new). After the update is completed, the program needs to run PBL_x+SBL_new+APP_x, and the APP in the invalid area is still APP_y.
[0064] The partitions mapped to the valid area and the invalid area can be exchanged with each other. Therefore, if the partition mapped to the current valid area is BANK_y, you need to use PBL_y to update the SBL_y software to SBL_new. After the update is completed, the program needs to run PBL_y+SBL_new+APP_y, and the APP in the invalid area is still APP_x.
[0065] Here, we only take the first partition BANK_x as the valid area to explain and illustrate the SBL update process. Figure 1 As shown, the method for updating SBL software based on dual partitions includes the following steps:
[0066] S110. Set the first partition as a valid area, and set the second partition as an invalid area.
[0067] The first partition is set as the valid area, that is, the partition mapped to the valid area is the first partition. At this time, the partition mapped to the invalid area is the second partition. In other embodiments, the second partition can also be initially set as the valid area.
[0068] When the SBL needs to be flashed, the operations of steps S120-160 are performed. If there is no flash operation, the valid area program can be directly run.
[0069] S120, use the new version of SBL software to update SBL_y in the second partition, and check whether the first Bootloaders of the first partition and the second partition are the same. If they are different, move PBL_x stored in the first partition to the second partition, overwriting PBL_y in the second partition.
[0070] In order to prevent the original program from being unable to run due to a direct update failure of the SBL in the valid area (power failure, disconnection, etc.), in a preferred embodiment of the present invention, the new version of the SBL software is first written into the SBL storage area in the invalid area, that is, SBL_new is used to overwrite the original SBL_y of the second partition. In this case, even if the update in this step fails, the original program can continue to run.
[0071] After the original SBL_y of the second partition is updated, the integrity and legality of SBL_new need to be verified. The verification process is implemented using existing conventional technology and will not be repeated here. If the integrity and / or legality verification of SBL_new fails, the valid area program continues to run.
[0072] If the verification is successful, check whether the first bootloader of the first partition and the second partition are the same. The reason for checking whether the first bootloader of the first partition and the second partition are the same is to avoid the program from being unable to run when power failure or network disconnection occurs in any of the following steps S140-S150, and the status of PBL_y is unknown. Therefore, PBL_x stored in the first partition is moved to the second partition, overwriting PBL_y in the second partition.
[0073] S130 , switching the states of the first partition and the second partition, switching the first partition to an invalid area, and switching the second partition to a valid area.
[0074] The partitions mapped to the valid area and the invalid area are switched so that the first partition becomes the invalid area and the second partition becomes the valid area. At this time, the software combination of the valid area is PBL_x+SBL_new+APP_y.
[0075] S140 , copy the new version of the SBL software to the first partition to overwrite SBL_x in the first partition.
[0076] Since the ultimate goal is to update the software combination of PBL_x+SBL_new+APP_x that the program needs to run after the SBL is completed, which is different from the software combination in the valid area at this time, and since it is necessary to ensure that the APP version running in each partition does not change during the SBL update process, the new version of SBL_new needs to be copied to the invalid area (i.e., the first partition) to overwrite SBL_x in the first partition. At this time, the software combination in the invalid area becomes PBL_x+SBL_new+APP_x, which meets the ultimate update goal.
[0077] S150 , switching the states of the first partition and the second partition again, switching the first partition to a valid area, and switching the second partition to an invalid area.
[0078] The partitions mapped to the valid area and the invalid area are exchanged again, so that the first partition becomes the valid area, the second partition becomes the invalid area, and the software combination of the valid area is PBL_x+SBL_new+APP_x.
[0079] S160: Run the first partition to complete the update of the second Bootloader.
[0080] When the first partition is running, the software combination of PBL_x+SBL_new+APP_x can be run to complete the update of SBL.
[0081] If power failure and restart occur in any step between S140-S150, the MCU will maintain the state of the first partition as an invalid area and the second partition as a valid area in step S130. At this time, since the software combination of the second partition is PBL_x+SBL_new+APP_y, PBL_x can be run and check whether the second Bootloaders of the first partition and the second partition are the same. If they are the same, it means that the combination in the first partition is PBL_x+SBL_new+APP_x, and the states of the first partition and the second partition are directly switched, and the first partition is switched to the valid area and the second partition is switched to the invalid area. If they are different, it means that the second Bootloader in the first partition is unknown (it may be the original SBL_x or the updated SBL_new). At this time, it is necessary to copy the new version of the SBL software to the first partition to cover the second Bootloader in the first partition, and then switch the states of the first partition and the second partition, and switch the first partition to the valid area and the second partition to the invalid area.
[0082] During the SBL update process, the APP is not updated or copied from beginning to end. Therefore, the APP software does not undergo any changes during the SBL update process, so the APP software still meets the flash rollback mechanism during the SBL update.
[0083] When updating the APP software, the flash rollback mechanism must be met, that is, after the update of the new version of the APP fails, the old version of the APP should be able to continue running.
[0084] Based on this, assuming that the partition currently mapped to the valid area is the first partition, and the partition mapped to the invalid area is the second partition, PBL_x, SBL_x, and APP_x are stored in BANK_x, and PBL_y, SBL_y, and APP_y are stored in BANK_y. SBL_x needs to be used to update the APP_x software to APP_new. After the update is completed, the program needs to run PBL_x+SBL_x+APP_new.
[0085] Please refer to Figure 2 As shown, the update of the APP software may include the following steps:
[0086] S210: Set the first partition as a valid area and the second partition as an invalid area.
[0087] The first partition is set as the valid area, that is, the partition mapped to the valid area is the first partition. At this time, the partition mapped to the invalid area is the second partition. In other embodiments, the second partition can also be initially set as the valid area.
[0088] When the APP software needs to be flashed, the operation of steps S220-250 is performed. If there is no flash operation of the APP software, the valid area program can be directly run.
[0089] S220. Use the new version of APP software to update APP_y in the second partition.
[0090] In order to prevent the original program from being unable to run due to a direct update failure of the APP software in the valid area (power failure, disconnection, etc.), in a preferred embodiment of the present invention, the new version of the APP software is first written into the APP storage area in the invalid area, that is, APP_new is used to overwrite the original APP_y in the second partition. In this case, even if the update in this step fails, the original program can continue to run.
[0091] After updating the original APP_y in the second partition, it is necessary to verify the integrity and legitimacy of APP_new. The verification process is implemented using existing conventional technology and will not be repeated here. If the integrity and / or legitimacy verification of APP_new fails, the valid area program continues to run.
[0092] If the verification is successful, the operation of step S230 is executed.
[0093] S230 , copy PBL_x and SBL_x in the first partition to the second partition to cover PBL_y and SBL_y in the second partition respectively.
[0094] Since the APP software update needs to meet the flash rollback mechanism, the software combination of the valid area needs to remain unchanged, and the software combination of the invalid area is PBL_x+SBL_x+APP_new. Even if the APP software update in the invalid area fails, the valid area can still run the original program.
[0095] Based on the above principle, PBL_x and SBL_x in the first partition can be copied to the second partition respectively to cover PBL_y and SBL_y in the second partition respectively. At this time, the software combination of the invalid area becomes PBL_x+SBL_x+APP_new.
[0096] During this process, if a power outage and restart occur, the original valid area program can continue to run. If the APP software needs to be updated, it can be checked whether the first Bootloader and the second Bootloader of the first partition and the second partition are respectively the same. If they are the same, execute step S240. If they are different, copy the different Bootloader (first Bootloader and / or Bootloader) from the first partition to the second partition, so that the first Bootloader and the second Bootloader of the first partition and the second partition are respectively the same.
[0097] S240 , switching the states of the first partition and the second partition, switching the second partition to a valid area, and switching the first partition to an invalid area.
[0098] The partitions mapped to the valid area and the invalid area are switched so that the first partition becomes the invalid area and the second partition becomes the invalid area. At this time, the software combination of the valid area is PBL_x+SBL_x+APP_new.
[0099] S250: Run the second partition to complete the update of the APP.
[0100] When the second partition is running, the software combination of PBL_x+SBL_new+APP_x can be run to complete the update of the APP software, and the software combination of the first partition is: PBL_x+SBL_x+APP_x, which meets the flash rollback mechanism.
[0101] Embodiment 2
[0102] See also Figure 3 , Figure 3It is a structural diagram of a two-level Bootloader update system based on dual partitions disclosed in an embodiment of the present invention. The dual partition includes a first partition and a second partition, the two-level Bootloader includes a first Bootloader, a second Bootloader and an APP, the first partition and the second partition store the first Bootloader, the second Bootloader and the APP respectively, the first Bootloader, the second Bootloader and the APP stored in the first partition are respectively recorded as PBL_x, SBL_x and APP_x, and the first Bootloader, the second Bootloader and the APP stored in the second partition are respectively recorded as PBL_y, SBL_y and APP_y.
[0103] like Figure 3 and 4 As shown, the dual-partition based two-level Bootloader update system includes: a first update unit 310 and a second update unit 320, wherein the first update unit is used to update the second Bootloader, and the second update unit is used to update the APP.
[0104] Please refer to Figure 3 As shown, the first updating unit 310 may include:
[0105] A first setting subunit 311, configured to set the first partition as a valid area and the second partition as an invalid area;
[0106] The first updating subunit 312 is used to update the SBL_y in the second partition using the new version of the SBL software, and check whether the first Bootloaders of the first partition and the second partition are the same. If they are different, copy the PBL_x stored in the first partition to the second partition to cover the PBL_y in the second partition;
[0107] A first switching subunit 313, used to switch the states of the first partition and the second partition, switching the first partition to an invalid area and switching the second partition to a valid area;
[0108] The first overwriting subunit 314 is used to copy the new version of the SBL software to the first partition to overwrite the SBL_x in the first partition;
[0109] The second switching subunit 315 is used to switch the states of the first partition and the second partition again, switching the first partition to a valid area and switching the second partition to an invalid area;
[0110] The first running subunit 316 is used to run the first partition to complete the update of the second Bootloader.
[0111] Please refer to Figure 4 As shown, the second updating unit 320 may include:
[0112] The second setting subunit 321 is used to set the first partition as a valid area and the second partition as an invalid area;
[0113] The second updating subunit 322 is used to update APP_y in the second partition using the new version of APP software;
[0114] A second covering subunit 323, configured to copy PBL_x and SBL_x in the first partition to the second partition to cover PBL_y and SBL_y in the second partition respectively;
[0115] The third switching subunit 324 is used to switch the states of the first partition and the second partition, switching the second partition to a valid area and switching the first partition to an invalid area;
[0116] The second running subunit 325 is used to run the second partition to complete the update of the APP.
[0117] Embodiment 3
[0118] See also Figure 5 , Figure 5 The schematic diagram of the structure of the electronic device that can be used to implement the embodiment of the present invention is shown. In the preferred embodiment of the present invention, the electronic device mainly refers to the ECU (Electronic Control Unit), of course, in other embodiments, it can also be other devices with processing and storage functions, such as a single-chip microcomputer.
[0119] like Figure 5 As shown, the electronic device includes at least one processor 410, and a memory connected to the at least one processor 410, such as a ROM (read-only memory) 420, a RAM (random access memory) 430, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 410 can perform various appropriate actions and processes according to the computer program stored in the ROM 420 or the computer program loaded from the storage unit 480 to the random access memory RAM 430. In the RAM 430, various programs and data required for the operation of the electronic device can also be stored. The processor 410, the ROM 420, and the RAM 430 are connected to each other via a bus 440. An I / O (input / output) interface 450 is also connected to the bus 440.
[0120] A number of components in the electronic device are connected to the I / O interface 450, including: an input unit 460, such as a keyboard, a mouse, etc.; an output unit 470, such as various types of displays, speakers, etc.; a storage unit 480, such as a disk, an optical disk, etc.; and a communication unit 490, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 490 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet or / and various telecommunication networks.
[0121] The processor 410 may be a variety of general or / and special processing components with processing and computing capabilities. Some examples of the processor 410 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 410 executes one or more steps of a two-stage bootloader update method based on dual partitions described in the first embodiment above.
[0122] In some embodiments, a two-stage bootloader update method based on dual partitions may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 480. In some embodiments, part or all of the computer program may be loaded or / and installed on an electronic device via ROM 420 and / or communication unit 490. When the computer program is loaded into RAM 430 and executed by processor 410, one or more steps of a two-stage bootloader update method based on dual partitions described in the first embodiment above may be performed. Alternatively, in other embodiments, processor 410 may be configured to execute a two-stage bootloader update method based on dual partitions in any other appropriate manner (e.g., by means of firmware).
[0123] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, or / and combinations thereof. These various embodiments may include: being implemented in one or more computer programs that can be executed or / and interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0124] The computer programs for implementing the methods of the embodiments of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart or / and the block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0125] In the context of an embodiment of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0126] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0127] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0128] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0129] The above is a detailed introduction to a two-level Bootloader update method and system based on dual partitions disclosed in the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A two-level Bootloader update method based on dual partitions, wherein the dual partitions include a first partition and a second partition, the two-level Bootloaders include a first Bootloader, a second Bootloader and an APP, the first partition and the second partition store the first Bootloader, the second Bootloader and the APP respectively, the first Bootloader, the second Bootloader and the APP stored in the first partition are respectively recorded as PBL_x, SBL_x and APP_x, and the first Bootloader, the second Bootloader and the APP stored in the second partition are respectively recorded as PBL_y, SBL_y and APP_y, characterized in that: The method includes updating the second Bootloader, specifically including: Set the first partition as a valid area, and set the second partition as an invalid area; Use the new version of SBL software to update SBL_y in the second partition, and check whether the first Bootloader of the first partition and the second partition are the same. If they are different, copy PBL_x stored in the first partition to the second partition to overwrite PBL_y in the second partition; Switching the states of the first partition and the second partition, switching the first partition to an invalid area, and switching the second partition to a valid area; Copying the new version of SBL software to the first partition to overwrite SBL_x in the first partition; Switch the states of the first partition and the second partition again, switching the first partition to a valid area and switching the second partition to an invalid area; Run the first partition to complete the update of the second Bootloader.
2. The dual-partition based two-stage Bootloader update method according to claim 1, characterized in that: After switching the states of the first partition and the second partition and before running the first partition, if a power-off restart occurs, check whether the second Bootloaders of the first partition and the second partition are the same. If they are different, copy the new version of the SBL software in the second partition to the first partition to overwrite the second Bootloader in the first partition; The states of the first partition and the second partition are switched again, the first partition is switched to a valid area, and the second partition is switched to an invalid area.
3. The dual-partition based two-stage Bootloader update method according to claim 1, characterized in that: Update SBL_y with the new version of SBL software, and then: Verify the integrity and legality of the new version of the SBL software in the second partition.
4. The dual-partition based two-stage Bootloader update method according to claim 1, characterized in that: The method further includes updating the APP, specifically including: Set the first partition as a valid area, and set the second partition as an invalid area; Use the new version of APP software to update APP_y in the second partition; Copying PBL_x and SBL_x in the first partition to the second partition to cover PBL_y and SBL_y in the second partition respectively; Switch the states of the first partition and the second partition, switch the second partition to a valid area, and switch the first partition to an invalid area; Run the second partition to complete the update of the APP.
5. The dual-partition based two-stage Bootloader update method according to claim 4, characterized in that: The method further comprises: Verify the integrity and legitimacy of the new version of the APP software in the second partition.
6. The dual-partition based two-stage Bootloader update method according to any one of claims 1 to 5, characterized in that: The first Bootloader supports updating of the second Bootloader, and the second Bootloader supports updating of the APP.
7. The dual-partition based two-stage Bootloader update method according to any one of claims 1 to 5, characterized in that: The update of the second Bootloader is realized by burning through the JTAG interface, or by burning through the CAN bus through the UDS protocol.
8. A two-level Bootloader update system based on dual partitions, the dual partitions comprising a first partition and a second partition, the two-level Bootloader comprising a first Bootloader, a second Bootloader and an APP, the first partition and the second partition respectively store the first Bootloader, the second Bootloader and the APP, the first Bootloader, the second Bootloader and the APP stored in the first partition are respectively recorded as PBL_x, SBL_x and APP_x, the first Bootloader, the second Bootloader and the APP stored in the second partition are respectively recorded as PBL_y, SBL_y and APP_y, characterized in that: The system comprises: A first updating unit is used to update the second Bootloader, wherein the first updating unit includes: A setting subunit, configured to set the first partition as a valid area and the second partition as an invalid area; The update subunit uses the new version of the SBL software to update the SBL_y in the second partition, and checks whether the first Bootloaders of the first partition and the second partition are the same. If they are different, the PBL_x stored in the first partition is copied to the second partition to cover the PBL_y in the second partition. A first switching subunit is used to switch the states of the first partition and the second partition, switching the first partition to an invalid area and switching the second partition to a valid area; The overwriting subunit is used to copy the new version of the SBL software to the first partition to overwrite the SBL_x in the first partition; A second switching subunit is used to switch the states of the first partition and the second partition again, switching the first partition to a valid area and switching the second partition to an invalid area; The running subunit is used to run the first partition to complete the update of the second Bootloader.
9. An electronic device, characterized in that: It comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein when the processor executes the computer program, the two-level Bootloader update method based on dual partitions as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: It stores a computer program, wherein the computer program enables a computer to execute the dual-partition-based two-stage Bootloader update method according to any one of claims 1 to 7.
