BootLoader program upgrading method and device and controller
By mapping the BootLoader program to RAM and updating it with the Flash driver of the host computer, the problem of insufficient online update capability of BootLoader is solved, and a simplified update process and improved system security and maintainability are achieved.
Patent Information
- Application Number
- CN202411300455.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2024-12-24
AI Technical Summary
In the prior art, BootLoader lacks online update function, and traditional update methods are cumbersome and inconvenient, which increases the cost and complexity of system maintenance and upgrades, making it difficult to ensure the security and stability of the system.
Map the BootLoader program to RAM, use RAM to update, and update the Flash area through the Flash driver of the host computer, avoid frequent read and write directly to Flash, disable boot jumps and software reset functions, and ensure the security of the update process. and reliability.
Simplifies the update process of BootLoader, reduces the risk of memory wear and data loss, improves the maintainability and security of the system, and is suitable for electronic control systems that require frequent upgrades and high security requirements.
Smart Images

Figure CN119179508A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of program upgrade, and in particular to a BootLoader program upgrade method, device and controller. Background Art
[0002] In modern electronic control units (ECUs), BootLoader is a key underlying software component responsible for loading and executing applications (Apps) when the system starts. BootLoader usually resides in the non-volatile memory (such as Flash) of the controller, runs first when powered on, completes hardware initialization, and then hands control to the application. Once the traditional BootLoader version is fixed in the device, it is usually difficult to update online unless it is re-written by disassembling the device or using special hardware tools (such as programmers), which brings great inconvenience to maintenance and upgrades. With the rapid development of automotive electronics, power equipment, embedded systems and other fields, the complexity and functional requirements of the system are constantly increasing, and new requirements are put forward for the online update capability of BootLoader. Especially when there are bugs or security vulnerabilities in the system, manufacturers hope to be able to update BootLoader in time through remote means to ensure the security and stability of the system. However, in the prior art, BootLoader itself often lacks online update function, and traditional update methods usually involve cumbersome operation steps, such as disassembling the machine, manually replacing hardware or reprogramming using specific development tools. These operations are time-consuming and labor-intensive, and do not meet the needs of modern equipment maintenance and upgrades. In the prior art, some solutions attempt to update the BootLoader by reserving a spare storage area in the device or using an external storage medium, but these methods have obvious defects, such as requiring additional hardware support, increasing the cost and complexity of the system, or easily causing errors during the update process, resulting in the system not being able to work properly. Therefore, how to improve the maintainability and security of the BootLoader has become an urgent problem to be solved in the current technical field.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a BootLoader program upgrade method, device and controller, aiming to solve the technical problem of how to improve the maintainability and security of BootLoader.
[0005] To achieve the above object, the present invention provides a BootLoader program upgrade method, which is applied to a controller and includes:
[0006] Map the Bootloader program to the corresponding area of RAM;
[0007] After the controller is powered on, running the BootLoader program from the RAM;
[0008] When an update instruction from the host computer is received, the Flash area of the BootLoader program is updated based on the program in the corresponding area and the Flash driver of the host computer.
[0009] Optionally, when receiving an update instruction from a host computer, the step of updating the Flash area of the BootLoader program based on the program in the corresponding area and a Flash driver of the host computer includes:
[0010] When receiving an update instruction from the host computer, running the program in the corresponding area to identify the update instruction;
[0011] Calling the download function of the program in the corresponding area, and downloading the update data from the host computer to the RAM based on the Flash driver of the host computer;
[0012] Based on the Flash driver, the update data in the RAM is written into the Flash area of the BootLoader program.
[0013] Optionally, after the step of updating the Flash area of the BootLoader program based on the program in the corresponding area and the Flash driver of the host computer when receiving the update instruction of the host computer, the method further includes:
[0014] Disable the boot jump function and software reset function of the Bootloader program.
[0015] Optionally, the method further comprises:
[0016] Load a miniBoot program when the software is reset;
[0017] Based on the miniBoot program and the flag bit of the boot area, determine the Bootloader that needs to be run currently;
[0018] Based on the update instruction, the Flash area of another Bootloader is updated.
[0019] Optionally, after the step of updating the Flash area of another Bootloader based on the update instruction, the method further includes:
[0020] The flag bit of the boot area is updated to the latest state.
[0021] Optionally, the method further comprises:
[0022] After receiving the update instruction, the update data downloaded by the host computer is verified through a verification program, and a write operation is performed after the verification passes.
[0023] In addition, to achieve the above object, the present invention also proposes a BootLoader program upgrade device, the BootLoader program upgrade device comprising:
[0024] Mapping module, used to map the Bootloader program to the corresponding area of RAM;
[0025] A running module, used for running the BootLoader program from the RAM after the controller is powered on;
[0026] The update module is used to update the Flash area of the BootLoader program based on the program in the corresponding area and the Flash driver of the host computer when receiving an update instruction from the host computer.
[0027] In addition, to achieve the above object, the present invention further proposes a controller, on which the BootLoader program upgrade method described in any one of the above embodiments is run.
[0028] In addition, to achieve the above object, the present invention also provides an electronic control unit, which includes the controller as described in the above embodiment.
[0029] In addition, to achieve the above object, the present invention also provides a vehicle, which includes the electronic control unit as described in the above embodiment.
[0030] This application maps the Bootloader program to the corresponding area of RAM; then after the controller is powered on, the BootLoader program is run from RAM; when an update instruction from the host computer is received, the Flash area of the BootLoader is updated based on the program in the corresponding area and the Flash driver of the host computer. This application maps the BootLoader program to RAM, runs it from RAM after the controller is powered on, and performs update operations based on the program in RAM and the Flash driver of the host computer, thereby avoiding frequent direct reading and writing of Flash, reducing the risk of memory wear and data loss, simplifying the update process, and improving the maintainability of the system. At the same time, by strictly controlling the data transmission and update process at the software level to prevent interference from external factors, the security and reliability of the BootLoader update are improved, and it is suitable for electronic control systems that require frequent upgrades and high security requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a flowchart of the first embodiment of the BootLoader program upgrade method of the present invention;
[0032] Figure 2 It is a flowchart of the second embodiment of the BootLoader program upgrade method of the present invention;
[0033] Figure 3 This is a schematic diagram of a sub-flow in the third embodiment of the BootLoader program upgrade method of the present invention;
[0034] Figure 4 It is a schematic diagram of the module structure of the BootLoader program upgrading device of the present invention.
[0035] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0036] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0037] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0038] It should be noted that in modern electronic control units (ECUs), BootLoader is a key underlying software component responsible for loading and executing applications (Apps) when the system starts. BootLoader usually resides in the non-volatile memory (such as Flash) of the controller, runs first when powered on, and after completing hardware initialization, it hands control to the application. Once the traditional BootLoader version is solidified into the device, it is usually difficult to update it online unless it is re-flashed by disassembling the device or using special hardware tools (such as programmers), which brings great inconvenience to maintenance and upgrades. With the rapid development of automotive electronics, power equipment, embedded systems and other fields, the complexity and functional requirements of the system are constantly increasing, which puts forward new requirements for the online update capability of BootLoader. Especially when there are bugs or security vulnerabilities in the system, manufacturers hope to be able to update the BootLoader in a timely manner through remote means to ensure the security and stability of the system. However, in the prior art, the BootLoader itself often lacks the online update function, and the traditional update method usually involves cumbersome operation steps, such as disassembling the machine, manually replacing hardware, or reprogramming using specific development tools. These operations are time-consuming and labor-intensive, and do not meet the needs of modern equipment maintenance and upgrades. In the prior art, some solutions attempt to update the BootLoader by reserving a spare storage area in the device or using an external storage medium, but these methods have obvious defects, such as requiring additional hardware support, increasing the cost and complexity of the system, or being prone to errors during the update process, causing the system to fail to work properly. Therefore, how to improve the maintainability and security of the BootLoader has become an urgent problem to be solved in the current technical field.
[0039] The main solution of this application is: this application maps the Bootloader program to the corresponding area of RAM; then after the controller is powered on, run the BootLoader program from RAM; when an update instruction from the host computer is received, the Flash area of the BootLoader is updated based on the program in the corresponding area and the Flash driver of the host computer.
[0040] This application maps the BootLoader program to RAM, runs it from RAM after the controller is powered on, and performs update operations based on the program in RAM and the Flash driver of the host computer, thereby avoiding frequent reading and writing of Flash directly, reducing the risk of memory wear and data loss, simplifying the update process, and improving the maintainability of the system. At the same time, by strictly controlling the data transmission and update process at the software level to prevent interference from external factors, the security and reliability of the BootLoader update are improved, and it is suitable for electronic control systems that require frequent upgrades and high security requirements.
[0041] Reference Figure 1 , Figure 1 It is a flowchart of the first embodiment of the BootLoader program upgrade method of the present invention.
[0042] In this embodiment, the BootLoader program upgrade method includes the following steps:
[0043] S1: Map the Bootloader program to the corresponding area of RAM;
[0044] It should be noted that BootLoader is the underlying software used to start and load applications in embedded systems. It is usually stored in the non-volatile memory (such as Flash) of the controller, and is used to run first when the device is powered on or reset, initialize the hardware and load the operating system or application. RAM is a volatile memory in the controller, and its data storage is temporary. Once the power is off, the data will be lost. Compared with non-volatile memory (such as Flash), RAM has a higher read and write speed. Therefore, running a program in RAM can usually improve the execution efficiency of the program. Mapping refers to the process of loading data or programs into a specified memory. Here, "mapping to the corresponding area of RAM" means copying or loading the BootLoader program from the non-volatile memory (such as Flash) to a specific memory address range in RAM so that the program can run in RAM. This specific area is usually reserved in advance and has enough space and appropriate permissions to run the BootLoader program.
[0045] Specifically, when the device starts or restarts, the controller first executes the hardware reset logic and then starts to initialize the RAM. After the initialization is completed, the system will copy the BootLoader program from its default storage location (such as Flash) to a specific area of RAM. This process is usually completed by a low-level boot program or system firmware, which directly accesses the controller bus to read the data block from Flash and write it to the specified address of RAM. During this process, the system needs to ensure that all data is copied correctly and no data errors or losses occur.
[0046] Furthermore, after the mapping is completed, the system will set the program counter (PC) to the starting address of the BootLoader program in RAM, and then start executing the BootLoader program from RAM. At this stage, the BootLoader runs in RAM and can complete its initialization and system configuration tasks at a higher speed, such as hardware detection, environment settings, and preparation for starting application programs. This method not only speeds up the system startup process, but also provides a more efficient execution environment for subsequent software update operations.
[0047] By mapping the BootLoader program to the corresponding area of RAM, the execution speed of the program can be significantly improved, because the read and write speed of RAM is much higher than that of Flash storage. In addition, running the BootLoader in RAM can reduce the read and write operations on Flash, thereby reducing the wear of Flash and extending its service life. At the same time, this method provides a more flexible operation mode for subsequent BootLoader updates, and can perform online update operations without affecting system stability, thereby improving system reliability and maintainability.
[0048] S2: After the controller is powered on, running the BootLoader program from the RAM;
[0049] It should be noted that controller power-on refers to the process of the controller starting to be powered on. When a controller (such as a microcontroller or embedded processor) is powered on, the circuit and all hardware components begin to initialize. During this process, the controller's core and peripherals are also reset in preparation for loading and executing the initial program (usually the BootLoader). Running from RAM means executing the program (the BootLoader program in this step) from RAM (random access memory) instead of running it from non-volatile memory (such as Flash). RAM is very suitable for temporarily storing and running program code due to its fast read and write capabilities. The BootLoader program refers to the boot program stored in the non-volatile memory of the controller, which is used to initialize the system hardware and load the operating system or application. In this step, the BootLoader program is loaded into RAM to improve startup speed and responsiveness.
[0050] Specifically, after the controller is powered on, the system hardware first undergoes a reset and initialization process. At this point, the controller will start running according to the preset startup process, usually first reading the startup code from a predefined storage location (such as a specific address in the Flash memory). In the previous step, the BootLoader program has been mapped to a specific area of RAM, so after the system performs initialization, it directly sets the program counter (PC) to the starting address of the BootLoader program in RAM.
[0051] Furthermore, the controller starts executing the BootLoader program from the specified address of the RAM. Because RAM has a higher read and write speed than Flash, the BootLoader program running in RAM can complete the necessary startup operations more quickly, such as hardware self-test, system initialization, peripheral configuration, setting clock frequency and other tasks. After these operations are completed, the BootLoader will prepare to load and start the system's application or operating system, and provide further update and maintenance support.
[0052] Running the BootLoader program from RAM has multiple beneficial effects. First, the high read and write speed of RAM greatly improves the efficiency of program execution, which can significantly shorten the system startup time and improve the response speed of the device. Secondly, it reduces direct operations on Flash and avoids frequent reading and writing of Flash, thereby extending the service life of Flash and improving the reliability of the system. In addition, running the BootLoader in RAM also provides a stable operating environment, which is convenient for flexible execution of update operations after receiving instructions from the host computer, thereby enhancing the maintainability and security of the system.
[0053] S3: When an update instruction from the host computer is received, the Flash area of the BootLoader program is updated based on the program in the corresponding area and the Flash driver of the host computer.
[0054] It should be noted that the host computer refers to an external computer or device connected to the controller, which can send instructions, transfer data or update programs to the controller. In this context, the host computer is responsible for sending update instructions and providing the required Flash driver so that the controller can correctly update the BootLoader program. The update instruction is a command sent by the host computer to notify the controller that the BootLoader program needs to be updated. The instruction usually contains the necessary information for the update, such as the target address to be updated, the version of the update data, the checksum, etc., to ensure the correctness and integrity of the update operation. The Flash driver refers to the software module used by the controller to read and write its Flash memory. In this step, the Flash driver is provided by the host computer and is responsible for controlling the write and erase operations of the update data to ensure that the data can be correctly stored in a specific area of the Flash. The Flash area of the BootLoader program refers to the non-volatile storage area (such as Flash memory) in the controller where the BootLoader program is stored. This area stores the startup code and related data, which is used to start and load system applications when the controller is powered on.
[0055] Specifically, when the controller is running the BootLoader program in RAM, the host computer sends an update instruction to the controller, indicating that the BootLoader program needs to be updated. After receiving the instruction, the controller first identifies and parses the update instruction to confirm the target area and data content that need to be updated. Subsequently, the controller calls the Flash driver provided by the host computer from the BootLoader program in RAM to prepare for the update operation.
[0056] Furthermore, during the update process, the controller downloads the new BootLoader data from the host computer through the Flash driver and temporarily stores it in the RAM. Then, the Flash driver controls the operation of the Flash memory, first erasing the old data area of the BootLoader program in the Flash to ensure that there is no residual data affecting the update. Then, the controller writes the updated data in the RAM to the BootLoader area of the Flash memory block by block according to the instructions. After the update is completed, the controller will perform data verification to ensure that the newly written data is complete and correct.
[0057] The update operation based on the program in the corresponding area and the Flash driver of the host computer has many beneficial effects. First, by using the update instructions and drivers provided by the host computer, the flexibility and controllability of the update process are ensured, and the BootLoader program can be flexibly upgraded or repaired according to different needs. Secondly, the controller runs the BootLoader in the RAM and uses the driver of the host computer to perform update operations, avoiding frequent reading and writing of the Flash directly, thereby reducing the wear of the memory and extending the service life of the Flash. In addition, through precise instruction control and data verification, the safety and reliability of the update operation are ensured, effectively preventing data damage or system failure caused by erroneous operation or external interference, thereby improving the stability and maintainability of the system.
[0058] This embodiment maps the Bootloader program to the corresponding area of RAM; then after the controller is powered on, the BootLoader program is run from RAM; when an update instruction from the host computer is received, the Flash area of the BootLoader is updated based on the program in the corresponding area and the Flash driver of the host computer. This embodiment maps the BootLoader program to RAM, runs it from RAM after the controller is powered on, and performs update operations based on the program in RAM and the Flash driver of the host computer, thereby avoiding frequent direct reading and writing of Flash, reducing the risk of memory wear and data loss, simplifying the update process, and improving the maintainability of the system. At the same time, by strictly controlling the data transmission and update process at the software level to prevent interference from external factors, the security and reliability of the BootLoader update are improved, and it is suitable for electronic control systems that require frequent upgrades and high security requirements.
[0059] See also Figure 2 , Figure 2 It is a flowchart of the second embodiment of the BootLoader program upgrade method of the present invention.
[0060] Based on the above first embodiment, in this embodiment, step S3 includes:
[0061] S31: When receiving an update instruction from the host computer, running the program in the corresponding area to identify the update instruction;
[0062] S32: calling the download function of the program in the corresponding area, and downloading the update data from the host computer to the RAM based on the Flash driver of the host computer;
[0063] S33: Based on the Flash driver, write the update data in the RAM into the Flash area of the BootLoader program.
[0064] It should be noted that the program in the corresponding area refers to the BootLoader program or the auxiliary program related thereto that has been loaded into a specific area in the RAM. The program runs in the RAM and is responsible for processing the instructions received from the host computer and performing related operations, such as updating the BootLoader program. The download function is a part of the BootLoader program and is used to obtain update data from the host computer. This function usually interacts with the host computer through a communication protocol to ensure the correct download and transmission of the update data. The Flash driver is a software module provided by the host computer for controlling and managing the read and write operations of the Flash memory. The Flash driver ensures that the update data is correctly written to the specified area in the Flash memory and performs necessary erase and verification operations.
[0065] Specifically, after the controller is powered on, the BootLoader program runs from the RAM and continuously monitors the instructions from the host computer. When receiving the update instruction from the host computer, the BootLoader program immediately starts its parsing and identification functions, analyzes the content and type of the instruction, and confirms the specific update operation to be performed. This process ensures that the controller clearly understands the target area, data size, and update steps of the BootLoader program to be updated.
[0066] Further, after identifying the update instruction, the BootLoader program calls its built-in download function to obtain the update data from the host computer through the Flash driver of the host computer. The update data is transmitted to the controller through a predefined communication protocol, and the data is first stored in the RAM during the transmission process. The BootLoader program will continuously verify the received data to ensure integrity and correctness, and request the host computer to retransmit the error data block when necessary until all the update data is correctly stored in the RAM. Once all the update data is successfully downloaded and verified, the BootLoader program will perform data write operations based on the Flash driver provided by the host computer. First, the controller uses the Flash driver to erase the old data area of the BootLoader program in the Flash memory. Then, the update data in the RAM is written to the Flash area of the BootLoader program block by block according to the specified write steps. After the write is completed, the program will verify the data in the Flash again to ensure that the updated BootLoader data has been successfully written and is correct.
[0067] This step realizes efficient and secure update of BootLoader by combining the BootLoader program running in RAM with the Flash driver of the host computer. First, by identifying the update instruction and calling the download function, it ensures that the controller accurately obtains the update data and avoids erroneous operations caused by instruction misunderstanding. Secondly, the update data is downloaded to RAM, avoiding frequent direct operations on Flash and reducing the wear and aging of Flash. Finally, based on the precise control of the Flash driver, the correct writing and verification of data is ensured, avoiding data corruption or system failure that may occur during the update process, thereby improving the maintainability of BootLoader and the overall security and reliability of the system.
[0068] After step S3, the method further includes:
[0069] S3a: Disable the boot jump function and software reset function of the Bootloader program.
[0070] It should be noted that the boot jump function is a functional module in the BootLoader program, which is used to determine which memory address to jump to during the startup process to perform the next operation. It is usually used to jump to the memory address where the application is located to start execution after the BootLoader has performed the necessary initialization and configuration. The software reset function refers to the ability of the BootLoader or other software modules to control the reset of the system. Reset is usually triggered by a software command to restart the system so that it can resume executing the program from a known state. Software reset is used to quickly restore to the initial state when the system fails or needs to reload the program.
[0071] Specifically, after the controller completes the update of the BootLoader program, in order to ensure system stability, the boot jump function and software reset function in the BootLoader program are disabled. First, the BootLoader program runs in RAM, and after identifying and processing the relevant update instructions, it calls the internal configuration module or function routine to disable the boot jump function. This process usually involves setting a status flag or modifying the control logic in the program so that the BootLoader no longer executes the operation of jumping to other memory addresses and maintains the current execution state.
[0072] Furthermore, the BootLoader program disables its software reset function. This is usually achieved by adjusting the relevant software flags or configuration registers to ensure that the BootLoader will not restart the system due to an unexpected reset instruction during the update process. After disabling the reset function, the system can stably complete data verification and writing operations, avoiding interruption of the update process or data corruption due to unexpected reset.
[0073] By disabling the boot jump function and software reset function of the BootLoader program, the stability and security of the system during the update process can be improved. First, disabling the boot jump function can prevent the BootLoader from accidentally jumping to the application area during the update operation, ensuring the continuity and integrity of the update operation. Second, disabling the software reset function can avoid system interruption or data corruption caused by accidental reset during the update process, ensuring that the update operation can be completed safely and reliably. Overall, these measures can reduce unexpected situations during the update process and improve the maintainability and data security of the system.
[0074] This embodiment maps the Bootloader program to the corresponding area of RAM; then after the controller is powered on, the BootLoader program is run from RAM; when an update instruction from the host computer is received, the Flash area of the BootLoader is updated based on the program in the corresponding area and the Flash driver of the host computer. This embodiment maps the BootLoader program to RAM, runs it from RAM after the controller is powered on, and performs update operations based on the program in RAM and the Flash driver of the host computer, thereby avoiding frequent direct reading and writing of Flash, reducing the risk of memory wear and data loss, simplifying the update process, and improving the maintainability of the system. At the same time, by strictly controlling the data transmission and update process at the software level to prevent interference from external factors, the security and reliability of the BootLoader update are improved, and it is suitable for electronic control systems that require frequent upgrades and high security requirements.
[0075] See also Figure 3 , Figure 3 This is a schematic diagram of a sub-flow in the third embodiment of the BootLoader program upgrade method of the present invention;
[0076] Based on the above second embodiment, in this embodiment, the method further includes:
[0077] S4: Load a miniBoot program when the software is reset;
[0078] S5: Determine the Bootloader that needs to be run currently based on the flag bit of the miniBoot program and the boot area;
[0079] S6: Based on the update instruction, update the Flash area of another Bootloader.
[0080] It should be noted that software reset refers to the process of restarting the system through software instructions. Software reset usually does not involve power-off operation, but triggers the reset logic inside the controller to restart the system from the initialization state. Software reset is used to restore the system to a known initial state to ensure that the program can be reloaded during the update or repair process. The miniBoot program is a simplified version of the BootLoader program, which is mainly used to guide the system into the correct BootLoader version or perform other initialization operations after the software reset. The main function of the miniBoot program is to determine which BootLoader to run based on the flag bit in the boot area, or to select the appropriate version to load when the BootLoader needs to be updated. The flag bit of the boot area is a specific area stored in the controller, which is used to mark and indicate the BootLoader version that the current system should run. The flag bit of the boot area is usually modified when the BootLoader version is updated or switched, and is used to guide the miniBoot program to select the correct BootLoader to execute at the next reset or startup. The update instruction is a command sent by the host computer to notify the controller that the BootLoader program needs to be updated. The instruction contains necessary update information, such as the address of the target BootLoader, version information and update data.
[0081] Specifically, during the update operation, when the controller performs a software reset, the system first loads and runs the miniBoot program. The miniBoot program is a simplified boot program whose main task is to boot the system to the correct BootLoader version after reset. The miniBoot program will first access the boot area in the controller, read the flag information stored in the area, and determine the BootLoader version that should be loaded and run according to the status of the flag. This step ensures that the system can accurately load the expected BootLoader program after the update operation without mistakenly jumping to other program areas.
[0082] Furthermore, once the miniBoot program determines the BootLoader version to be run, if the update instruction indicates that the Flash area of another BootLoader needs to be updated, the miniBoot program will start the corresponding update operation. It will call the Flash driver provided by the internal or host computer to write the new BootLoader data from the RAM or the temporary storage area downloaded by the host computer to the Flash area of the target BootLoader. The update process includes erasing the old data in the target Flash area, writing the new data, and checking the data integrity to ensure that the BootLoader version has been successfully updated and can run normally.
[0083] By loading the miniBoot program at software reset and determining the BootLoader version that needs to be run based on the flag bit in the boot area, the reliability and correctness of the system during the switching and updating process between different BootLoader versions can be ensured. First, the miniBoot program provides a flexible mechanism to manage multiple BootLoader versions, ensuring that the system can automatically select and load the correct version after any update. Secondly, updating the Flash area of another BootLoader based on the update instruction avoids incorrect loading or system crashes caused by manual selection or incorrect operations. Through these steps, the system can maintain stability during the update operation and reduce security risks and maintenance costs caused by update failures.
[0084] After step S6, the method further includes:
[0085] S6a: Update the flag bit of the boot area to the latest state.
[0086] It should be noted that the boot area refers to a specific storage area inside the controller, which is used to store system boot information and control parameters. The boot area is usually located in a non-volatile memory (such as Flash) and stores key data required by the system when it is started or reset, such as flags, the starting address of the boot program, etc. The latest status refers to the flag value required for the current update operation. The latest status usually reflects the latest BootLoader version or location that the boot area should point to, to ensure that the system can correctly load and run the updated BootLoader during future startup or reset processes.
[0087] Specifically, after completing the update operation of the Flash area of another BootLoader, the system needs to update the flag bit of the boot area to the latest state. This process first confirms that the update of the target BootLoader has been successfully completed through the miniBoot program or the main BootLoader program running in RAM. Then, the program will calculate or determine the new value of the flag bit according to the predetermined update strategy or operation logic.
[0088] Furthermore, the program will call the Flash driver to perform a write operation on the boot area and write the new flag status to the specified location of the boot area. The writing process usually includes the following steps: first, erase the existing flag content in the boot area, then write the new flag value to the specified memory address, and finally verify the written data to ensure that the boot area flag has been correctly updated to the latest state. After completing this operation, the system will record the successful update and prepare to load the appropriate BootLoader version according to the instructions of the new flag at the next system startup or reset.
[0089] Updating the boot area flag to the latest state can ensure that the system accurately loads and runs the latest BootLoader version during future startup or reset processes. This operation helps maintain the normal startup process of the system and avoids incorrect startup or system crashes caused by flags not being updated or incorrect states after the update operation. At the same time, updating the flag to the latest state can ensure the correctness of the BootLoader version switching, allowing the system to flexibly switch between multiple BootLoader versions, providing higher security and flexibility. In addition, this step also provides guarantees for subsequent system maintenance and further update operations, reducing potential system failure risks and maintenance costs.
[0090] In this embodiment, the method further includes:
[0091] S7: After receiving the update instruction, the update data downloaded by the host computer is verified through a verification program, and a write operation is performed after the verification passes.
[0092] It should be noted that the verification program refers to an algorithm or routine used to verify the integrity and correctness of data. The verification program is usually based on a hash function (such as CRC32 or MD5) or other data verification methods to ensure that the data is not erroneous or damaged during transmission. In this step, the verification program is used to check the accuracy of the update data downloaded from the host computer to the controller. The write operation refers to the process of writing the updated BootLoader data to the specified area of the Flash memory. The write operation includes erasing the original data in the Flash, writing new data, and verifying the written data to ensure that it is correctly stored in the target area.
[0093] Specifically, after the controller receives the update command sent by the host computer, it first starts the verification program through the BootLoader program running in the RAM to verify the integrity and correctness of the update data downloaded from the host computer to the controller. The verification program will check the downloaded update data block by block, calculate its verification code (such as CRC32 or MD5) and compare it with the verification code provided by the host computer. If the two match, it means that there is no error or damage in the data transmission process, and the verification passes.
[0094] Furthermore, if the verification program confirms the integrity and correctness of the updated data, the controller will continue the data writing operation. First, the controller calls the Flash driver provided by the host computer to erase the target Flash area of the BootLoader program and clear the old program data. Then, the updated data that has passed the verification is written block by block to the designated Flash area of the BootLoader program. After the writing is completed, the program will perform data verification again to ensure that the newly written data is accurate and successfully stored in the Flash. If the data verification passes, the BootLoader update is completed, and the controller will return a successful response to the host computer, indicating that the update operation has been successfully executed.
[0095] By using a verification program to verify the update data downloaded from the host computer during the update process, the security and reliability of the update operation can be significantly improved. First, this method ensures that the update data is not tampered with or damaged during transmission, preventing system crashes or abnormal behaviors caused by data errors. Secondly, performing the write operation after the verification is passed can avoid writing erroneous data to the Flash memory, reducing the risk of memory wear and data corruption that may be caused. In short, through data verification and a safe writing process, the system can perform BootLoader update operations more effectively, reduce potential failure rates, and improve the maintainability and stability of the system.
[0096] This embodiment maps the Bootloader program to the corresponding area of RAM; then after the controller is powered on, the BootLoader program is run from RAM; when an update instruction from the host computer is received, the Flash area of the BootLoader is updated based on the program in the corresponding area and the Flash driver of the host computer. This embodiment maps the BootLoader program to RAM, runs it from RAM after the controller is powered on, and performs update operations based on the program in RAM and the Flash driver of the host computer, thereby avoiding frequent direct reading and writing of Flash, reducing the risk of memory wear and data loss, simplifying the update process, and improving the maintainability of the system. At the same time, by strictly controlling the data transmission and update process at the software level to prevent interference from external factors, the security and reliability of the BootLoader update are improved, and it is suitable for electronic control systems that require frequent upgrades and high security requirements.
[0097] The present application also provides a BootLoader program upgrade device, please refer to Figure 4 , Figure 4 The module structure diagram of the BootLoader program upgrade device of the present invention is shown in FIG. 1 , wherein the BootLoader program upgrade device comprises:
[0098] A mapping module 401 is used to map the Bootloader program to a corresponding area of the RAM;
[0099] An operation module 402 is used to run the BootLoader program from the RAM after the controller is powered on;
[0100] The update module 403 is used to update the Flash area of the BootLoader program based on the program in the corresponding area and the Flash driver of the host computer when receiving an update instruction from the host computer.
[0101] The BootLoader program upgrade device provided in the embodiment of the present application adopts the BootLoader program upgrade method in the above embodiment, which can solve the technical problem of how to improve the maintainability and security of the BootLoader. Compared with the prior art, the beneficial effects of the BootLoader program upgrade device provided in the embodiment of the present application are the same as the beneficial effects of the BootLoader program upgrade method provided in the above embodiment, and other technical features in the BootLoader program upgrade device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0102] In addition, to achieve the above object, the present invention further proposes a controller, on which the BootLoader program upgrade method described in any one of the above embodiments is run.
[0103] In addition, to achieve the above purpose, the present invention also provides an electronic control unit, which includes the controller as described in the above embodiment. Since the electronic control unit adopts all the technical solutions of all the above embodiments, it at least has all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0104] In addition, to achieve the above purpose, the present invention also provides a vehicle, the vehicle comprising the electronic control unit as described in the above embodiment. Since the vehicle adopts all the technical solutions of all the above embodiments, it at least has all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0105] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0106] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0107] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0108] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A BootLoader program upgrade method, characterized in that: The BootLoader program upgrade method is applied to a controller, and the method comprises: Map the Bootloader program to the corresponding area of RAM; After the controller is powered on, running the BootLoader program from the RAM; When an update instruction from the host computer is received, the Flash area of the BootLoader program is updated based on the program in the corresponding area and the Flash driver of the host computer.
2. The method according to claim 1, characterized in that The step of updating the Flash area of the BootLoader program based on the program in the corresponding area and the Flash driver of the host computer when receiving the update instruction of the host computer comprises: When receiving an update instruction from the host computer, running the program in the corresponding area to identify the update instruction; Calling the download function of the program in the corresponding area, and downloading the update data from the host computer to the RAM based on the Flash driver of the host computer; Based on the Flash driver, the update data in the RAM is written into the Flash area of the BootLoader program.
3. The method according to claim 1, characterized in that After the step of updating the Flash area of the BootLoader program based on the program in the corresponding area and the Flash driver of the host computer when receiving the update instruction of the host computer, the method further includes: Disable the boot jump function and software reset function of the Bootloader program.
4. The method according to claim 1, characterized in that The method further comprises: Load a miniBoot program when the software is reset; Based on the miniBoot program and the flag bit of the boot area, determine the Bootloader that needs to be run currently; Based on the update instruction, the Flash area of another Bootloader is updated.
5. The method according to claim 4, characterized in that After the step of updating the Flash area of another Bootloader based on the update instruction, the method further includes: The flag bit of the boot area is updated to the latest state.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: After receiving the update instruction, the update data downloaded by the host computer is verified through a verification program, and a write operation is performed after the verification passes.
7. A BootLoader program upgrade device, characterized in that: The BootLoader program upgrade device comprises: Mapping module, used to map the Bootloader program to the corresponding area of RAM; A running module, used for running the BootLoader program from the RAM after the controller is powered on; The update module is used to update the Flash area of the BootLoader program based on the program in the corresponding area and the Flash driver of the host computer when receiving an update instruction from the host computer.
8. A controller, characterized in that: The controller runs the BootLoader program upgrade method as described in any one of claims 1 to 6.
9. An electronic control unit, characterized in that: The electronic control unit comprises the controller as claimed in claim 8 above.
10. A vehicle, characterized in that: The vehicle comprises an electronic control unit as claimed in claim 9 above.
