Controller chip firmware upgrade method and system
By obtaining and verifying the firmware upgrade data of the controller chip to ensure its integrity and accuracy, the problem of inoperability due to abnormal conditions during the firmware upgrade process in the existing technology is solved, and a more efficient and reliable firmware upgrade process is achieved.
Patent Information
- Application Number
- CN202410586222.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-13
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-05-13
AI Technical Summary
Existing firmware upgrade methods can easily cause the controller chip to fail to operate normally due to abnormal conditions such as power outages in field applications. In serious cases, the controller chip needs to be returned to the factory for repair, which harms the interests of customers.
By obtaining the bootloader information of the controller chip, the corresponding firmware upgrade data is issued, and when receiving the completion information, data integrity verification and burning verification are performed to ensure data accuracy and completeness, and finally a restart command is sent to complete the firmware upgrade. .
It improves the accuracy and efficiency of firmware upgrades, avoids errors during data transmission, ensures that the controller chip can operate normally after the upgrade, and reduces the possibility of returning to the factory for repairs.
Smart Images

Figure CN118151977B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of firmware upgrade, and in particular to a firmware upgrade method and system for a controller chip. Background Art
[0002] The so-called online firmware upgrade is usually an online upgrade of the main program of the controller chip in the device. By running the bootloader (Bootloader / upgrader), the main program in the controller chip is updated to the new version of the firmware to implement new functions or fix design defects.
[0003] However, in the field application of the equipment, abnormal situations such as power outages and errors may occur during the firmware upgrade process. If the firmware upgrade is not handled properly, it is easy to cause the controller to be unable to be re-upgraded, and in serious cases, it may not operate normally and can only be returned to the factory for repair, which seriously damages the interests of customers.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of the present application is to provide a controller chip firmware upgrade method and system, aiming to solve the technical problem that the existing firmware upgrade method may fail to run if not handled properly.
[0006] To achieve the above object, the present application proposes a controller chip firmware upgrade method, the controller chip firmware upgrade method comprising:
[0007] Acquire boot loader information of the controller chip, and send corresponding firmware upgrade data to the controller chip according to the boot loader information;
[0008] Upon receiving the data receiving completion information returned by the controller chip, performing data integrity verification on the firmware upgrade data stored in the storage area of the controller chip;
[0009] Determine block information of consecutive blocks in the storage area, and send the block information to the controller chip for burning verification;
[0010] When the data integrity verification and the burning verification are passed, a restart instruction is sent to the controller chip to complete the firmware upgrade of the controller chip.
[0011] Optionally, the step of determining block information of consecutive blocks in the storage area and sending the block information to the controller chip for burning verification includes:
[0012] Performing block identification in the storage area according to the address sequence from low to high to determine continuous blocks in the storage area;
[0013] Reading block data of the continuous blocks and determining a checksum based on the block data;
[0014] The block parameters of the block are obtained, and the block parameters and the checksum are sent as the block information of the continuous block to the controller chip for burning verification.
[0015] Optionally, the step of performing data integrity verification on the firmware upgrade data stored in the storage area of the controller chip includes:
[0016] Determining a chip type of the controller chip, and determining a verification position of the firmware upgrade data according to the chip type;
[0017] Determining the data to be verified at the verification position in the firmware upgrade data stored in the storage area of the controller chip;
[0018] If the data to be verified is preset data, the data integrity of the firmware upgrade data passes;
[0019] If the data to be verified is not the preset data, the data integrity of the firmware upgrade data fails.
[0020] Optionally, before the step of obtaining the boot loader information of the controller chip and sending corresponding firmware upgrade data to the controller chip according to the boot loader information, the method further includes:
[0021] Sending a switching instruction to the communication link through the firmware upgrade interface; the switching instruction carries a controller chip identification mark;
[0022] When there is a controller chip responding to the controller chip, sending a handshake instruction to the controller chip so that the controller chip performs a handshake based on the handshake instruction;
[0023] When the handshake is passed, a connection relationship with the controller chip is established.
[0024] Optionally, the step of sending corresponding firmware upgrade data to the controller chip according to the boot loader information includes:
[0025] Determining corresponding firmware upgrade data according to the boot loader information;
[0026] Sending a key update instruction to the controller chip; the key update instruction includes an updated key;
[0027] Sending the firmware upgrade data to the controller chip, and encrypting the firmware upgrade data by using the updated key when sending the firmware upgrade data, so that the firmware upgrade data is sent in the form of an encrypted data packet;
[0028] When the number of the encrypted data packets sent reaches a preset number, if the firmware upgrade data has not been sent completely, return to the step of sending a key update instruction to the controller chip to replace the key.
[0029] In addition, to achieve the above purpose, the present application also proposes another controller chip firmware upgrade method, the method is applied to the controller chip, the controller chip is connected to the host computer, the method includes:
[0030] In the online upgrade mode, in response to the boot loader information acquisition instruction of the host computer, the boot loader information is sent to the host computer;
[0031] Receiving firmware upgrade data sent by the host computer based on the boot loader information, and writing the firmware upgrade data into a storage area;
[0032] Obtaining block information generated by the host computer based on the storage area after writing the firmware upgrade data, and performing burning verification on the block information;
[0033] In response to a restart instruction sent by the host computer when the burning verification and integrity verification are passed, restart is performed to complete the firmware upgrade.
[0034] Optionally, before the step of sending the boot loader information to the host computer in response to the boot loader information acquisition instruction of the host computer, the step further includes:
[0035] Check the integrity of the firmware main program;
[0036] If the integrity check fails, initialization is performed and the online upgrade mode is entered.
[0037] Optionally, after the step of determining the integrity of the firmware main program, the method further includes:
[0038] If the integrity judgment is passed, the firmware main program is run;
[0039] When the firmware main program is running, if a switching instruction is received, obtaining a controller chip identification mark in the switching instruction;
[0040] The controller chip identification mark is verified, and when the verification is passed, a response is made to the host computer that sends the switching instruction and the firmware main program is stopped to switch to the online upgrade mode.
[0041] Optionally, after the step of verifying the controller chip identification, the method further includes:
[0042] If the verification fails, the switching instruction is forwarded to other controller chips.
[0043] In addition, to achieve the above-mentioned purpose, the present application also proposes a firmware upgrade device for a controller chip, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the firmware upgrade method for the controller chip as described above.
[0044] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the firmware upgrade method of the controller chip as described above are implemented.
[0045] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the controller chip firmware upgrade method as described above.
[0046] One or more technical solutions proposed in this application have at least the following technical effects:
[0047] The embodiment of the present application obtains the boot loader information of the controller chip, and sends the corresponding firmware upgrade data to the controller chip according to the boot loader information; upon receiving the data reception completion information returned by the controller chip, the firmware upgrade data stored in the storage area of the controller chip is verified for data integrity; the block information of the continuous blocks in the storage area is determined, and the block information is sent to the controller chip for burning verification; when the data integrity verification and burning verification pass, a restart instruction is sent to the controller chip to complete the firmware upgrade of the controller chip. By performing data integrity verification on the firmware upgrade data received in the storage area of the controller chip, the integrity of the firmware upgrade data is guaranteed and the accuracy of the data is improved; by determining the block information of the continuous blocks in the storage area, the controller chip can perform burning verification according to the block information, avoiding errors caused during data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0050] Figure 1 A flowchart of a first embodiment of a method for upgrading the firmware of a controller chip of the present application;
[0051] Figure 2 A flowchart of the second embodiment of the firmware upgrade method for the controller chip of the present application is provided;
[0052] Figure 3 A schematic diagram of a multi-device upgrade mechanism for a firmware upgrade method for a controller chip of the present application;
[0053] Figure 4 A schematic diagram of a workflow in one implementation scenario of the firmware upgrade method for the control chip of this application;
[0054] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the firmware upgrade method of the controller chip in the embodiment of the present application.
[0055] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0056] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0057] 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.
[0058] The method of the present application mainly includes two aspects: one is applied to the host computer, and the other is applied to the control chip.
[0059] On the host computer, the main solution of the embodiment of the present application is: obtain the boot loader information of the controller chip, and send the corresponding firmware upgrade data to the controller chip according to the boot loader information; when receiving the data reception completion information returned by the controller chip, perform data integrity verification on the firmware upgrade data stored in the storage area of the controller chip; determine the block information of the continuous blocks in the storage area, and send the block information to the controller chip for burning verification; when the data integrity verification and burning verification are passed, send a restart command to the controller chip to complete the firmware upgrade of the controller chip.
[0060] In the control chip, the main solution of the embodiment of the present application is: in the online upgrade mode, in response to the boot loader information acquisition instruction of the host computer, the boot loader information is sent to the host computer; the firmware upgrade data sent by the host computer based on the boot loader information is received, and the firmware upgrade data is written to the storage area; the block information generated by the host computer based on the storage area after the firmware upgrade data is written is obtained, and the block information is burned and verified; in response to the restart instruction sent by the host computer when the burning verification and integrity verification are passed, restart is performed to complete the firmware upgrade.
[0061] At present, when upgrading the firmware, the existing technology needs to first erase part or all of the original firmware data stored in the storage area, and then write the firmware upgrade data to the storage area to complete the firmware upgrade of the controller chip. However, when this method is implemented on site, it is easy to cause the firmware data to be incomplete and the main program cannot be run due to unexpected situations such as power failure, and the device can only be returned to the factory for repair.
[0062] In the present application, the host computer performs block integrity verification on the firmware upgrade data in the storage area of the controller chip and determines the block information of the continuous blocks in the storage area to make the controller chip perform burning verification when the firmware upgrade data is burned. In this way, the firmware upgrade data sent is determined to be accurate, complete and correct, thereby improving the efficiency of the firmware upgrade. At the same time, the present application distinguishes the controller chip on the communication link through the controller chip identification mark, so that multiple controller chips in the device can be burned at the same time. In addition, when the controller chip is started, the preset data at the verification position is first verified to determine the integrity of the main program. When the main program is incomplete, it directly enters the online upgrade mode to avoid starting the incomplete main program and causing damage to the device.
[0063] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a cloud server, etc. The following takes the host computer as an example to illustrate this embodiment and the following embodiments.
[0064] Based on this, the present application embodiment provides a controller chip firmware upgrade method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the firmware upgrade method of the controller chip of the present application.
[0065] In this embodiment, the firmware upgrade method of the controller chip is applied to a host computer, including steps S10 to S40:
[0066] Step S10, obtaining the boot loader information of the controller chip, and sending corresponding firmware upgrade data to the controller chip according to the boot loader information.
[0067] It is understandable that in the controller chip of an embedded product, its firmware usually includes two parts: one is the main program, which is the program that implements the functions defined by the product specifications. Generally speaking, this part of the code can be burned into the storage area inside the chip, such as Flash, random access memory (RAM), read-only memory (ROM), etc. The other is the boot loader, which is the program that checks the integrity of the program when the controller chip is started, performs main program upgrade operations, and other functions.
[0068] It should be understood that the boot loader information is information generated by the boot loader during operation. By analyzing the boot loader information, functions such as system maintenance and troubleshooting can be achieved.
[0069] It should be noted that for different versions of boot loaders, the corresponding firmware upgrade data that can be processed may be different. Therefore, the present application can determine different versions of boot loaders according to the boot loader information, and then send the corresponding firmware upgrade data to the controller chip, thereby increasing the application scope of the present application.
[0070] In a specific implementation, the host computer can obtain the boot loader information of the controller chip, and send corresponding firmware upgrade data to the controller chip according to the boot loader information, thereby performing a firmware upgrade.
[0071] Step S20: upon receiving the data receiving completion information returned by the controller chip, performing data integrity verification on the firmware upgrade data stored in the storage area of the controller chip.
[0072] It should be noted that when the controller chip has received all the firmware upgrade data, it can send the corresponding data reception completion information to the host computer. When the host computer receives the data reception completion information returned by the controller chip, it can send a check storage command to the controller chip to read the storage area. The controller chip can respond to the check storage command so that the host computer can perform data integrity verification and burning verification on the firmware upgrade data in the controller chip.
[0073] It should be understood that data integrity verification is to perform integrity verification on the firmware upgrade data stored in the storage area of the controller chip. In practical applications, when sending firmware upgrade data, the host computer can write specific preset data to a specific location in the storage area, such as a checksum or other fixed data, which can be selected according to the actual application, and the embodiments of the present application are not limited to this.
[0074] It should be noted that, since different controller chips have different ways of reading data, it is necessary to determine the write location of the preset data according to different controller chip types. For example, for a chip, its DSP program entry is fixed at the end of the storage area, and the storage area of different DSPs extends to the lower address, and the high address is fixed. For this type of chip, the preset data should be written at the last position of the storage area. For another chip, the preset data can be written at the initial position of the storage area, because its program entry is fixed at the beginning of the storage area, and the storage area is extended to the higher address.
[0075] It is understandable that the writing location of the data to be verified can be determined based on different controller chip types, so that when the main program is started, the controller chip can check whether the firmware data is complete according to the preset data.
[0076] It should be understood that the host computer detects the data to be verified at the verification position. If it is the preset data, it means that the firmware upgrade data received by the controller chip is complete; if not, it means that the received firmware upgrade data is incomplete.
[0077] Specifically, the step of performing data integrity verification on the firmware upgrade data stored in the storage area of the controller chip includes:
[0078] Determining a chip type of the controller chip, and determining a verification position of the firmware upgrade data according to the chip type;
[0079] Determining the data to be verified at the verification position in the firmware upgrade data stored in the storage area of the controller chip;
[0080] If the data to be verified is preset data, the data integrity of the firmware upgrade data passes;
[0081] If the data to be verified is not the preset data, the data integrity of the firmware upgrade data fails.
[0082] In one implementation of the embodiment of the present application, the preset data of the present application is not sent together with the firmware upgrade data. Specifically, the host computer can first burn the firmware upgrade data into the storage area of the controller chip, and if the storage area supports read verification, send a check storage command to the controller chip, and when the controller chip responds, perform a data integrity check on the firmware upgrade data in the storage area.
[0083] It is understandable that, in this implementation, the preset data can only be burned after the storage area is read and verified, and the burning data of the block where it is located cannot be sent during this period.
[0084] In a specific implementation, the host computer can send a check storage command to the controller chip when receiving the data reception completion information returned by the controller chip. When the controller chip responds to the check storage command, the integrity check is performed on the firmware upgrade data stored in the storage area of the controller chip, which can ensure that the firmware upgrade data has not been modified or damaged during the transmission process, thereby improving the efficiency of the firmware upgrade.
[0085] Step S30, determining block information of continuous blocks in the storage area, and sending the block information to the controller chip for burning verification;
[0086] Step S40, when the data integrity verification and the burning verification are passed, sending a restart instruction to the controller chip to complete the firmware upgrade of the controller chip.
[0087] It should be noted that the storage area of the controller chip can be divided into multiple units, namely blocks. During the firmware upgrade process, the firmware upgrade data can be stored in each block in sequence according to the address. Through multiple blocks, the firmware upgrade data can be managed more flexibly, and incremental updates can be performed during the firmware upgrade process to improve the update efficiency.
[0088] It should be understood that by performing burn verification on the firmware upgrade process, it can be ensured that there are no errors in the firmware upgrade data during burn, thereby improving the accuracy of data burn. When both the data integrity verification and the burn verification are passed, it can be determined that the burn is correct, and a restart / reset is performed to complete the firmware upgrade.
[0089] In an implementation of the embodiment of the present application, the step of determining block information of consecutive blocks in the storage area and sending the block information to the controller chip for burning verification includes:
[0090] Performing block identification in the storage area according to the address sequence from low to high to determine continuous blocks in the storage area;
[0091] reading block data of the continuous blocks, and determining a checksum based on the block data;
[0092] The block parameters of the block are obtained, and the block parameters and the checksum are sent as the block information of the continuous block to the controller chip for burning verification.
[0093] It should be noted that, in the upgrade process of the embodiment of the present invention, a burning verification mechanism can be added as needed. Specifically, during the burning verification, the host computer can read the data of the continuous blocks from the storage area of the controller chip in order from low to high and calculate the checksum. The calculation method of the checksum can be calculated based on the minimum addressing unit, that is, the S2 format is added with 16-bit data, and the S3 format is added with 8-bit data. If the data in a block is all 0xFFFF (or 0xFF), it can be considered that the block is discontinuous and the checksum of the block is not calculated. By sending the multiple block information (including block parameters (block parameters include the starting address of the block, length (the number of minimum addressing units, which must be an integer multiple of the block size)) and checksum) that need to be verified in the continuous block to the boot loader of the controller chip for verification; recalculate the checksum after the next block.
[0094] In addition, it should be noted that the size of the block can be based on the information position read from the register (assuming the value is 64, then for the S2 format, the block size is 64, for the S3 format, the block size is 128), and pay attention to the data edge alignment. Among them, data edge alignment means that the starting position of the data can be divided by the block size.
[0095] In one implementation of the embodiment of the present application, each time the firmware upgrade data is sent, it is for a continuous block group (ie, multiple blocks with continuous addresses). If there are multiple block groups, the block information is sent multiple times.
[0096] In a specific implementation, the host computer can identify blocks in the storage area according to the address sequence from low to high to determine the continuous blocks in the storage area; read the block data of the continuous blocks and determine the checksum according to the block data; obtain the block parameters of the blocks, and send the block parameters and checksum as the block information of the continuous blocks to the controller chip for burning verification. By burning and verifying the firmware upgrade data in the storage area of the controller chip, errors can be avoided during the firmware burning process, which may lead to abnormal firmware burning.
[0097] The embodiment of the present application obtains the boot loader information of the controller chip, and sends the corresponding firmware upgrade data to the controller chip according to the boot loader information; upon receiving the data reception completion information returned by the controller chip, the firmware upgrade data stored in the storage area of the controller chip is verified for data integrity; the block information of the continuous blocks in the storage area is determined, and the block information is sent to the controller chip for burning verification; when the data integrity verification and burning verification pass, a restart instruction is sent to the controller chip to complete the firmware upgrade of the controller chip. By performing data integrity verification on the firmware upgrade data received in the storage area of the controller chip, the integrity of the firmware upgrade data is guaranteed and the accuracy of the data is improved; by determining the block information of the continuous blocks in the storage area, the controller chip can perform burning verification according to the block information, avoiding errors caused during data transmission.
[0098] Based on the first embodiment of the firmware upgrade method of the controller chip of the present invention, a second embodiment of the firmware upgrade method of the controller chip of the present invention is proposed.
[0099] Reference Figure 2 , Figure 2 This is a flow chart of the second embodiment of the firmware upgrade method of the controller chip of the present application.
[0100] In this embodiment, before the step of obtaining the boot loader information of the controller chip and sending corresponding firmware upgrade data to the controller chip according to the boot loader information, the method further includes:
[0101] Step S100, sending a switching instruction to the communication link through the firmware upgrade interface; the switching instruction carries a controller chip identification mark;
[0102] Step S200, when there is a controller chip responding to the controller chip, sending a handshake instruction to the controller chip, so that the controller chip performs handshake based on the handshake instruction;
[0103] Step S300, when the handshake is passed, establishing a connection relationship with the controller chip.
[0104] It should be noted that in some practical applications, multiple devices are directly or indirectly connected to the communication link (or multiple controller chips are set on one device), and these controller chips are upgraded through the same communication port. In this case, if only one of the devices needs to be upgraded, it is necessary to distinguish them through the controller chip identification mark.
[0105] Specifically, please refer to Figure 3 As shown, Figure 3 Schematic diagram of multi-device upgrade mechanism.
[0106] It should be understood that, for these controller chips, a unique controller chip identification mark can be allocated in advance, and the identification mark can be used for the boot loader. Generally speaking, the controller chip identification mark can be directly fixed in the boot loader.
[0107] In one implementation of the embodiment of the present application, the length of the chip identification identifier can be set to 8 bits or other. The embodiment of the present application does not limit this. It only needs to ensure that all controller chips in the current communication link are assigned different controller chip identification identifiers. 0 and 1 are temporarily reserved, where 0 is the broadcast ID and all devices need to respond. When there is only one controller chip in the communication link, there is no need to verify the controller chip identification code, and the connection and upgrade can be performed directly.
[0108] It should be noted that the host computer can connect to the communication link through the firmware upgrade interface and send the corresponding switching instruction to the communication link. When the controller chip receives the switching instruction, it verifies the controller chip identification code. If the verification fails, the switching instruction is forwarded to the downstream through the communication link; if the verification passes, a response is made and the switching instruction is forwarded to the downstream through the communication link.
[0109] It can be understood that each controller chip in the communication link forwards and connects the switching instructions, so that the host computer can establish a communication connection with multiple controller chips to achieve batch firmware upgrades.
[0110] It should be noted that, in a communication link, if the controller chip receives data sent by a downstream device (ie, a downstream controller chip), the data is directly forwarded to the previous device of the controller chip without any processing.
[0111] In one implementation of the embodiment of the present application, all controller chips need to respond to the switching instruction with the controller chip identification mark of 0. For this command, it can generally be a reset command. For this command, the controller chip can determine whether to forward it according to the actual situation. If the downstream controller chip has been reset, it may not be forwarded. Similarly, when performing batch upgrades, if the downstream controller chip to be upgraded has entered the online upgrade mode, the upstream controller chip to be upgraded can enter the online upgrade mode, so that all controller chips to be upgraded can enter the online upgrade mode.
[0112] It should be noted that for firmware upgrade data, the file type can be .up, and the file format can adopt the XML specification. The XML header is unified as<?xml version="1.0" encoding="gb2312"?> The root element is Database, which does not contain any attributes and includes the following child elements:
[0113] 1.Info: This element is optional and can be used to define some relevant information of the boot loader, such as version information, framework version number information, etc.
[0114] 2. PreCmd, this element is an optional element. PreCmd defines the command that needs to be sent before entering the online upgrade mode. It can include multiple PreCmd elements. This element can include attributes such as sending order, communication type, baud rate, data bits during serial communication, verification mode during serial communication, stop bits during serial communication, number of bytes of data, data sent, CAN frame format, whether it is a remote frame, CAN ID, etc.
[0115] 3. PostCmd, this element is an optional element. PostCmd defines the command that needs to be sent after the upgrade is completed. It will be sent regardless of whether the upgrade succeeds or fails. The attributes that this element can include are the same as those of the above PreCmd.
[0116] 4.Firmware, this element is a required element. This element defines the location information of the software version information in the program file. The attribute start indicates the storage area address of the firmware upgrade data, and len indicates the size of the occupied space. If there are multiple Srecords, each Srecord corresponds to a firmware node. The first Srecord corresponds to Firmware, the second Srecord corresponds to Firmware1, the third Srecord corresponds to Firmware2, and so on.
[0117] 5. Srecord, this element is required. This element defines the detailed information of a program file. An upgrade file can have multiple elements, that is, a firmware upgrade data file can replace multiple program files. This element can include one or more of the following attributes: the start address of the main program, the end address of the main program, the controller chip identification, the device name, the write location, the file format (the default is S2 / S3), and the data alignment method.
[0118] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the firmware upgrade method of the controller chip of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0119] In an implementation of the embodiment of the present application, the step of sending corresponding firmware upgrade data to the controller chip according to the boot loader information includes:
[0120] Determining corresponding firmware upgrade data according to the boot loader information;
[0121] Sending a key update instruction to the controller chip; the key update instruction includes an updated key;
[0122] Sending the firmware upgrade data to the controller chip, and encrypting the firmware upgrade data by using the updated key when sending the firmware upgrade data, so that the firmware upgrade data is sent in the form of an encrypted data packet;
[0123] When the number of the encrypted data packets sent reaches a preset number, if the firmware upgrade data has not been sent completely, return to the step of sending a key update instruction to the controller chip to replace the key.
[0124] It should be noted that in order to improve the security of transmission, the firmware upgrade data can be encrypted for transmission, and the encryption is only for the data that needs to be burned into the storage area. Specifically, the host computer can send a key update command to the controller chip to notify the boot loader to update the key. The host computer can obtain the updated key and verify the integrity of the key. When the verification passes, the firmware upgrade data is encrypted so that the firmware upgrade data can be sent in the form of an encrypted data packet.
[0125] Among them, the encryption rules can be as follows:
[0126] data[i]= (data[i] ^ (key + i));
[0127] Among them, key is the key, and data[i] is the i-th firmware upgrade data.
[0128] It should be noted that when the number of encrypted data packets sent reaches the preset number N, if the firmware upgrade data has not been sent, it returns to the key update to change the key. The value of N can be determined randomly or in advance, and the embodiment of the present application does not limit this.
[0129] Before sending the firmware upgrade data, the host computer can also send a command to modify the baud rate, a data erase command, etc. to the controller chip to implement pre-operation of the data upgrade.
[0130] The embodiment of the present application sends a switching instruction to the communication link through the firmware upgrade interface; the switching instruction carries a controller chip identification mark; when there is a controller chip responding to the controller chip, a handshake instruction is sent to the controller chip, so that the controller chip performs a handshake based on the handshake instruction; when the handshake is passed, a connection relationship with the controller chip is established. Since the switching instruction carrying the controller chip identification mark is sent in the communication link, it is possible to connect with the controller chip that can respond to the switching instruction. Compared with the prior art, the present application performs connection identification through the controller chip identification mark, and can communicate with multiple controller chips at the same time.
[0131] In addition, the present application also proposes an embodiment of the controller chip firmware upgrade method. In this embodiment, the controller chip firmware upgrade method is applied to the controller chip, and the controller chip can be connected to the host computer. Specifically, the method includes:
[0132] In the online upgrade mode, in response to the boot loader information acquisition instruction of the host computer, the boot loader information is sent to the host computer;
[0133] Receiving firmware upgrade data sent by the host computer based on the boot loader information, and writing the firmware upgrade data into a storage area;
[0134] Obtaining block information generated by the host computer based on the storage area after writing the firmware upgrade data, and performing burning verification on the block information;
[0135] In response to a restart instruction sent by the host computer when the burning verification and integrity verification are passed, restart is performed to complete the firmware upgrade.
[0136] It should be noted that the controller chip can respond to the boot loader information acquisition instruction of the host computer in the online upgrade mode, and send the corresponding boot loader information to the host computer. The host computer can issue firmware upgrade data based on the boot loader information, and the controller chip can write the firmware upgrade data to the storage area, and send corresponding feedback information to the host computer when all firmware upgrade data are fully written. When the host computer receives the feedback information, the integrity of the firmware upgrade data written in the controller chip can be verified. When the integrity verification passes, the corresponding preset data is sent to the write position of the controller chip, so that the controller chip can judge whether the main program is complete (that is, the integrity judgment of the firmware main program) according to the preset data each time it is started. If it is incomplete, it is initialized and enters the online upgrade mode to avoid the problem of the controller chip directly starting and causing a malfunction due to an unexpected interruption during the upgrade process. Specifically, before the step of sending the boot loader information to the host computer in response to the boot loader information acquisition instruction of the host computer, it also includes:
[0137] Check the integrity of the firmware main program;
[0138] If the integrity check fails, initialization is performed and the online upgrade mode is entered.
[0139] After the step of determining the integrity of the firmware main program, the method further includes:
[0140] If the integrity judgment is passed, the firmware main program is run;
[0141] When the firmware main program is running, if a switching instruction is received, obtaining a controller chip identification mark in the switching instruction;
[0142] The controller chip identification mark is verified, and when the verification is passed, a response is made to the host computer that sends the switching instruction and the firmware main program is stopped to switch to the online upgrade mode.
[0143] It is understandable that when the controller chip passes the integrity judgment of the firmware main program, the firmware main program can be started. When the firmware main program is running, if a switching instruction sent by the host computer is received, the identification mark of the controller chip in the switching can be obtained for verification. If the verification passes, it switches to the online upgrade mode and responds to the host computer; if the verification fails, the switching instruction is forwarded to the downstream controller chip of the communication link.
[0144] It should be noted that the controller chip can enter the online upgrade mode (also known as the burning mode) after power-on reset, or it can enter the online upgrade mode through the switching command of the host computer when the main program is running normally. When entering the online upgrade mode, it is necessary to ensure that the product is in a safe and stable state, such as shutting down, disabling interrupts, etc., before entering the online upgrade mode.
[0145] It is understandable that in the online upgrade mode, the boot loader of the controller chip can perform corresponding actions according to the instructions sent by the host computer, such as erasing the storage area, burning data, etc. When the upgrade is completed, the controller chip can receive a reset instruction or a restart instruction sent by the host computer to exit the online upgrade mode.
[0146] It should be noted that when the controller chip receives the block information sent by the host computer, it can compare the block information such as the checksum value and address of the corresponding block in the firmware upgrade data. If the comparison passes, it means that the burning verification is passed.
[0147] In the embodiment of the present application, in the online upgrade mode, in response to the boot loader information acquisition instruction of the host computer, the boot loader information is sent to the host computer; the firmware upgrade data sent by the host computer based on the boot loader information is received, and the firmware upgrade data is written into the storage area; the block information generated by the host computer based on the storage area after the firmware upgrade data is written is obtained, and the block information is burned and verified; in response to the restart instruction sent by the host computer when the burning verification and integrity verification are passed, the firmware upgrade is completed by restarting. The block information sent by the host computer and the block information obtained from the firmware upgrade data are compared to achieve burning verification, thereby improving the accuracy of burning.
[0148] Furthermore, if Figure 4 As shown, Figure 4 This is a schematic diagram of the workflow in one implementation scenario of the firmware upgrade method for the control chip of this application.
[0149] Reference Figure 4 When the host computer and the controller chip establish a communication connection, the host computer can send a switching instruction to the controller chip, and the controller chip can switch to the online upgrade mode according to the switching instruction. The boot loader information is sent to the host computer, and the host computer can then send an erase instruction to the controller chip so that the controller chip can erase part or all of the initial firmware information in the storage area. When the erasure is completed, the host computer can send the firmware upgrade data to the controller chip, and the controller chip can save the firmware upgrade data to the storage area. When all the firmware upgrade data is saved in the storage area, the controller chip can provide feedback to the host computer.
[0150] Furthermore, the host computer can check the storage area in the controller chip based on the feedback to implement integrity verification of the firmware upgrade data. When the integrity verification passes, the preset data can be written to the preset write location of the controller chip. Thus, when the controller chip starts to verify the main program, it can determine whether the main program is complete based on the write location, and then determine whether to start normally or directly enter the online upgrade mode.
[0151] Furthermore, when the above preset data is written completely, the burning verification can be performed. The host computer can calculate the checksum based on the data of each block, and generate block information based on the block reference, and send the block information to the controller chip for burning verification. When the burning verification passes, the host computer can send a reset / restart instruction to the controller chip, and the controller chip resets or restarts to achieve firmware upgrade.
[0152] The present application also proposes a controller chip firmware upgrade system, in which the system may include a host computer and a device to be upgraded as described above. The device to be upgraded may include at least one controller chip as described above.
[0153] In an implementation of the embodiment of the present application, the system may further include a communication link. The communication link may include at least one device to be upgraded.
[0154] The present application provides a firmware upgrade device for a controller chip that can serve as the above-mentioned host computer, and the firmware upgrade device for the controller chip includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the firmware upgrade method for the controller chip in the above-mentioned embodiment one.
[0155] Reference below Figure 5 , which shows a schematic diagram of the structure of a firmware upgrade device for a controller chip suitable for implementing an embodiment of the present application. The firmware upgrade device for the controller chip in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5The firmware upgrade device of the controller chip shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0156] like Figure 5 As shown, the firmware upgrade device of the controller chip may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the firmware upgrade device of the controller chip are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the firmware upgrade device of the controller chip to communicate wirelessly or wired with other devices to exchange data. Although the figure shows the firmware upgrade device of the controller chip with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0157] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0158] The controller chip firmware upgrade device provided by the present application adopts the controller chip firmware upgrade method in the above embodiment, which can solve the technical problem that the existing firmware upgrade method is not properly handled and easily leads to inoperability. Compared with the prior art, the beneficial effects of the controller chip firmware upgrade device provided by the present application are the same as the beneficial effects of the controller chip firmware upgrade method provided by the above embodiment, and the other technical features of the controller chip firmware upgrade device are the same as the features disclosed in the previous embodiment method, which will not be repeated here.
[0159] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0160] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0161] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, the computer-readable program instructions being used to execute the firmware upgrade method for the controller chip in the above-mentioned embodiment.
[0162] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0163] The computer-readable storage medium may be included in the firmware upgrade device of the controller chip; or may exist independently without being assembled into the firmware upgrade device of the controller chip.
[0164] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the firmware upgrade device of the controller chip, the firmware upgrade device of the controller chip:
[0165] Acquire boot loader information of the controller chip, and send corresponding firmware upgrade data to the controller chip according to the boot loader information;
[0166] Upon receiving the data receiving completion information returned by the controller chip, performing data integrity verification on the firmware upgrade data stored in the storage area of the controller chip;
[0167] Determine block information of consecutive blocks in the storage area, and send the block information to the controller chip for burning verification;
[0168] When the data integrity verification and the burning verification are passed, a restart instruction is sent to the controller chip to complete the firmware upgrade of the controller chip.
[0169] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0170] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0171] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0172] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the firmware upgrade method of the above-mentioned controller chip, and can solve the technical problem that the existing firmware upgrade method is easily unable to run when it is not handled properly. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the firmware upgrade method of the control chip provided by the above-mentioned embodiment, and will not be repeated here.
[0173] The present application also provides a computer program product, including a computer program, which implements the steps of the firmware upgrade method of the controller chip as described above when the computer program is executed by a processor.
[0174] The computer program product provided by the present application can solve the technical problem that the existing firmware upgrade method is easily unable to run when it is not handled properly. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the firmware upgrade method of the controller chip provided by the above embodiment, and will not be repeated here.
[0175] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A controller chip firmware upgrade method, characterized in that: The method is applied to a host computer, the host computer is connected to at least one controller chip, and the method includes: Obtaining boot loader information of the controller chip, and issuing corresponding firmware upgrade data to the controller chip according to the boot loader information; when issuing the firmware upgrade data, writing preset data to a verification position of the controller chip; the verification position is related to a storage area expansion type of the controller chip; When receiving the data receiving completion information returned by the controller chip, sending a check storage command to the controller chip to perform data integrity verification on the firmware upgrade data stored in the storage area of the controller chip; Determine block information of consecutive blocks in the storage area, and send the block information to the controller chip for burning verification; When the data integrity verification and the burning verification are passed, sending a restart instruction to the controller chip to complete the firmware upgrade of the controller chip; The step of determining the block information of the continuous blocks in the storage area and sending the block information to the controller chip for burning verification includes: Performing block identification in the storage area according to the address sequence from low to high to determine continuous blocks in the storage area; Reading block data of the continuous blocks and determining a checksum based on the block data; Obtaining block parameters of the block, and sending the block parameters and the checksum as block information of the continuous block to the controller chip for burning verification; The step of performing data integrity verification on the firmware upgrade data stored in the storage area of the controller chip includes: Determine the chip type of the controller chip, and determine the verification position of the firmware upgrade data according to the data writing position corresponding to the chip type; Determining the data to be verified at the verification position in the firmware upgrade data stored in the storage area of the controller chip; If the data to be verified is preset data, the data integrity of the firmware upgrade data passes; If the data to be verified is not the preset data, the data integrity of the firmware upgrade data fails; Before the step of obtaining the boot loader information of the controller chip and sending corresponding firmware upgrade data to the controller chip according to the boot loader information, the method further includes: Send a switching instruction to the communication link through the firmware upgrade interface; The switching instruction carries a controller chip identification mark; When there is a controller chip responding to the controller chip, sending a handshake instruction to the controller chip so that the controller chip performs a handshake based on the handshake instruction; When the handshake is passed, establishing a connection relationship with the controller chip; The step of sending corresponding firmware upgrade data to the controller chip according to the boot loader information includes: Determining corresponding firmware upgrade data according to the boot loader information; Sending a key update instruction to the controller chip; The key update instruction includes the updated key; Sending the firmware upgrade data to the controller chip, and encrypting the firmware upgrade data by using the updated key when sending the firmware upgrade data, so that the firmware upgrade data is sent in the form of an encrypted data packet; When the number of the encrypted data packets sent reaches a preset number, if the firmware upgrade data has not been sent completely, return to the step of sending a key update instruction to the controller chip to replace the key.
2. A controller chip firmware upgrade method, characterized in that: The method is applied to a controller chip, the controller chip is connected to a host computer via a communication link, and the host computer is used to implement the steps of the controller chip firmware upgrade method according to claim 1, the method comprising: In the online upgrade mode, in response to the boot loader information acquisition instruction of the host computer, the boot loader information is sent to the host computer; Receiving firmware upgrade data sent by the host computer based on the boot loader information, and writing the firmware upgrade data into a storage area; Obtaining block information generated by the host computer based on the storage area after writing the firmware upgrade data, and performing burning verification on the block information; In response to a restart instruction sent by the host computer when the burning verification and integrity verification pass, restart to complete the firmware upgrade; Before the step of sending the boot loader information to the host computer in response to the boot loader information acquisition instruction of the host computer, the step further includes: Check the integrity of the firmware main program; If the integrity check fails, initialization is performed and online upgrade mode is entered; After the step of determining the integrity of the firmware main program, the method further includes: If the integrity judgment is passed, the firmware main program is run; When the firmware main program is running, if a switching instruction is received, obtaining a controller chip identification mark in the switching instruction; Verifying the controller chip identification mark, and when the verification is passed, responding to the host computer that sends the switching instruction and stopping the running of the firmware main program; When the downstream controller chip to be upgraded has entered the online upgrade mode, switch to the online upgrade mode; After the step of verifying the controller chip identification mark, the method further includes: If the verification fails, the switching instruction is forwarded to other controller chips.
3. A firmware upgrade system for a controller chip, characterized in that: The system includes a host computer and a device to be upgraded; The device to be upgraded includes at least one controller chip; The host computer is used to implement the steps of the controller chip firmware upgrade method according to claim 1; The controller chip is used to implement the steps of the controller chip firmware upgrade method as claimed in claim 2.
