Program updating method, system and device
By dividing the program update data into batches and performing batch-by-batch verification and resending requests, the problem of low efficiency in traditional program updates is solved, and a more efficient update process is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-07
AI Technical Summary
In traditional program update methods, when the large amount of data being updated causes a verification failure, the entire data needs to be resent, which is inefficient.
The program updates data into several batches, receives and verifies each batch, stores the data if the checksum matches, otherwise requests a retransmission, until the checksum matches.
It improves the efficiency of program updates, especially when data batches are abnormal, the resend efficiency is higher.
Smart Images

Figure CN121807342A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of program updates, and in particular to a program update method, system, and apparatus. Background Technology
[0002] To fix software defects, add new features, or optimize device performance, processor updates are typically required. Traditional update methods involve a host computer transmitting the entire update data to the processor, which then verifies and saves the data; if the update is successful, the update is considered complete. However, if verification fails, the entire update data is discarded, requiring the host computer to resend the data for a second update. This process can significantly reduce update efficiency, especially when the update data volume is large. Summary of the Invention
[0003] The purpose of this invention is to provide a program update method, system, and apparatus. The program update data is divided into several data batches by the host computer. During program update, only one data batch of the program update data is received at a time. If the actual checksum of the current data batch is inconsistent with the target checksum, a data retransmission request can be sent to the host computer, so that the host computer only needs to retransmit the current data batch. Since the data volume of the data batch is smaller than the data volume of the program update data, the retransmission efficiency is higher when the data batch is abnormal, thereby improving the efficiency of program update.
[0004] To solve the above-mentioned technical problems, the present invention provides a program update method, applied to a program update device, comprising:
[0005] Receive the current data batch and the target checksum of the current data batch sent by the host computer, wherein the program update data is divided into several data batches by the host computer, and the current data batch is a data batch in the program update data;
[0006] Calculate the actual checksum of the current data batch;
[0007] If the actual checksum matches the target checksum, then the current data batch is stored in the program update storage module;
[0008] If the actual checksum is inconsistent with the target checksum, a data retransmission request is sent to the host computer so that the host computer retransmits the current data batch.
[0009] Preferably, before receiving the current data batch and the target checksum of the current data batch sent by the host computer, the method further includes:
[0010] Receive update data information sent by the host computer, the update data information including the size of the program update data;
[0011] Based on the updated data information, a preset rule is generated and the preset rule is fed back to the host computer so that the host computer divides the program update data into several data batches according to the preset rule.
[0012] Preferably, before receiving the current data batch and the target checksum of the current data batch sent by the host computer, the method further includes:
[0013] A data batch retrieval request is sent to the host computer, so that the host computer sends the current data batch corresponding to the data batch retrieval request.
[0014] Preferably, before calculating the actual checksum of the current data batch, the method further includes:
[0015] Determine whether the batch index of the current data batch and the batch index of the data batch retrieval request are consistent; the batch index is used to identify the order of each data batch;
[0016] If they match, proceed to the step of calculating the actual checksum of the current data batch;
[0017] If there is a discrepancy, a data resend request is sent to the host computer so that the host computer can resend the current data batch.
[0018] Preferably, after sending a data batch acquisition request to the host computer, the method further includes:
[0019] If the current data batch is not received after the first preset interval, a data batch acquisition request is sent to the host computer again.
[0020] Preferably, before receiving the update data information sent by the host computer, the method further includes:
[0021] If a program update instruction is received from the host computer, the download program flag is set to indicate that data download is in progress and the computer is restarted.
[0022] After reading that the download program flag indicates that data download is in progress, the download program flag is restored to its initial state, and a program update request is sent to the host computer, so that the host computer sends the updated data information based on the program update request.
[0023] Preferably, after sending a program update request to the host computer, the method further includes:
[0024] If the updated data is not received after the second preset interval, the program update request is sent to the host computer every third preset interval until the updated data is received.
[0025] Preferably, after storing the current data batch to the program update storage module, the method further includes:
[0026] If the current data batch is the last data batch in the program update data, then calculate the total actual checksum of each data batch in the program update storage module;
[0027] If the total actual checksum is consistent with the total target checksum sent by the host computer, then the program update is determined to be complete.
[0028] The total target checksum is the checksum of the program update data sent by the host computer.
[0029] To solve the above-mentioned technical problems, the present invention provides a program update method, applied to a host computer, comprising:
[0030] The program update data is divided into several data batches, and each data batch and its checksum are sent to the program update device.
[0031] Upon receiving a data retransmission request, the data batch corresponding to the data retransmission request is retransmitted.
[0032] Preferably, before dividing the program update data into several data batches, the method further includes:
[0033] Send update data information to the program update device, the update data information including the size of the program update data, so as to receive the preset rules generated by the program update device based on the program update data, and divide the program update data into several data batches according to the preset rules.
[0034] Preferably, sending each data batch and the checksum of each data batch to the program update device respectively includes:
[0035] Upon receiving a data batch retrieval request from the program update device, the current data batch and target checksum corresponding to the data batch retrieval request are sent to the program update device.
[0036] Preferably, it also includes,
[0037] Upon receiving a data resend request, resend the data batch corresponding to the data resend request.
[0038] To solve the above-mentioned technical problems, the present invention provides a program update system, comprising:
[0039] The first receiving unit is used to receive the current data batch and the target checksum of the current data batch sent by the host computer, wherein the program update data is divided into several data batches by the host computer, and the current data batch is a data batch in the program update data;
[0040] The first calculation unit is used to calculate the actual checksum of the current data batch;
[0041] The storage execution unit is configured to store the current data batch to the program update storage module when the actual checksum matches the target checksum;
[0042] The first feedback unit is used to send a data retransmission request to the host computer when the actual checksum is inconsistent with the target checksum, so that the host computer retransmits the current data batch.
[0043] Preferably, it further includes:
[0044] The second receiving unit is used to receive update data information sent by the host computer, the update data information including the size of the program update data;
[0045] The generation unit is used to generate preset rules based on the updated data information and feed the preset rules back to the host computer so that the host computer divides the program update data into several data batches according to the preset rules.
[0046] Preferably, it further includes:
[0047] The sending unit is used to send a data batch acquisition request to the host computer, so that the host computer sends the current data batch and the target checksum corresponding to the data batch acquisition request.
[0048] Preferably, it further includes:
[0049] The first determining unit is used to determine whether the batch index of the current data batch and the batch index of the data batch acquisition request are consistent; the batch index is used to identify the order of each data batch; if they are consistent, the calculation unit is triggered; if they are inconsistent, the second feedback unit is triggered.
[0050] The second feedback unit is used to send a data resend request to the host computer so that the host computer can resend the current data batch.
[0051] Preferably, it further includes:
[0052] The second calculation unit is used to calculate the total actual checksum of each data batch in the program update storage module when the current data batch is the last data batch in the program update data;
[0053] The second determining unit is used to determine that the program update is complete when the total actual checksum is consistent with the total target checksum sent by the host computer.
[0054] The total target checksum is the checksum of the program update data sent by the host computer.
[0055] To solve the above-mentioned technical problems, the present invention provides a program update device, comprising:
[0056] Memory, used to store computer programs;
[0057] A processor, configured to implement the steps of the program update method as described above when executing a computer program.
[0058] Preferably, it further includes a protective housing disposed outside the memory and the processor.
[0059] Preferably, it further includes an external interface component, which is disposed on the protective housing and is used to provide a data transmission channel for the processor and the host computer.
[0060] Preferably, the protective shell includes several detachable cover plates, which are connected by connecting components to form a sealed structure. This application provides a program update method, system, and apparatus. It receives a current data batch and a target checksum of the current data batch sent by a host computer. The actual checksum of the current data batch is compared with the target checksum. If the comparison results match, the current data batch is stored in the program update storage module; if the comparison results do not match, the host computer resends the current data batch. The program update data is divided into several data batches by the host computer. During program updates, only one data batch is received at a time. If the actual checksum of the current data batch does not match the target checksum, a data retransmission request can be sent to the host computer, allowing the host computer to retransmit only the current data batch. Since the data volume of a data batch is smaller than the data volume of the program update data, the retransmission efficiency is higher when a data batch is abnormal, thereby improving the efficiency of program updates. Attached Figure Description
[0061] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0062] Figure 1 A flowchart illustrating a program update method provided in this application;
[0063] Figure 2 A schematic diagram of the structure of a program update system provided in this application;
[0064] Figure 3 A schematic diagram of a program update device provided in this application;
[0065] Figure 4 This is a schematic diagram of the structure of a computer-readable storage medium provided in this application. Detailed Implementation
[0066] The core of this invention is to provide a program update method, system, and apparatus. The program update data is divided into several data batches by the host computer. During program update, only one data batch of the program update data is received at a time. If the actual checksum of the current data batch is inconsistent with the target checksum, a data retransmission request can be sent to the host computer, so that the host computer only needs to retransmit the current data batch. Since the data volume of the data batch is smaller than the data volume of the program update data, the retransmission efficiency is higher when the data batch is abnormal, thereby improving the efficiency of program update.
[0067] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0068] Please refer to Figure 1 , Figure 1 A flowchart illustrating a program update method provided in this application, the method being applied to a program update apparatus, comprising:
[0069] S11: Receive the current data batch and the target checksum of the current data batch sent by the host computer. The program update data is divided into several data batches by the host computer, and the current data batch is the data batch in the program update data.
[0070] When updating a processor's program, the traditional method is for the host computer to directly transmit the entire program update data to the processor, and the processor updates the program based on the entire program update file. However, if the processor detects an anomaly in the program update data after the entire program update data has been transmitted to the processor, the host computer needs to resend the entire program update data, which undoubtedly leads to a decrease in program update efficiency.
[0071] In this application, when updating the program, the entire program update data sent by the host computer is not received all at once. Instead, the host computer divides the program update data into several data batches, and then sends only one data batch and its target checksum at a time. For example, in the current control cycle, the host computer sends the current data batch and its target checksum. The processor receives the current data batch and its target checksum, where the target checksum is the checksum of the current data batch calculated by the host computer and is the accurate checksum of the current data batch.
[0072] S12: Calculate the actual checksum of the current data batch;
[0073] After receiving the current data batch and the target checksum of the current data batch, calculate the actual checksum of the current data batch, that is, calculate its actual checksum based on the received current data batch.
[0074] S13: If the actual checksum matches the target checksum, then store the current data batch to the program update storage module;
[0075] The actual checksum of the current data batch is compared with the target checksum. If the actual checksum matches the target checksum, the received current data batch can be determined to be a normal data batch and can be stored in the program update storage module for program update based on the current data batch.
[0076] S14: If the actual checksum is inconsistent with the target checksum, a data retransmission request is sent to the host computer so that the host computer retransmits the current data batch.
[0077] If the actual checksum does not match the target checksum, the current data batch is considered abnormal. For example, the current data batch may have been affected by interference or other factors during transmission and an error occurred. In this case, the current data batch should not be stored in the program update request. Instead, a data retransmission request should be sent to the host computer, that is, the host computer should be requested to resend the current data batch. After receiving the resent current data batch from the host computer, the actual checksum of the current data batch should be calculated again and compared with the target checksum until a normal current data batch is determined and stored in the program update storage module.
[0078] It should be noted that the current data batch can be a data batch actively sent by the host computer, that is, the host computer actively sends each data batch in the program update data to the processor in sequence so that the processor can update the program, or the processor actively requests the host computer to obtain each data batch in sequence. This application does not limit this.
[0079] Furthermore, the processor used for program updates in this application can be an MCU (Microcontroller Unit). After the MCU is packaged, a program download cable can be pre-installed on the casing. One end of the program download cable is connected to the MCU, and the other end is led out from the casing. When a program update is required for the MCU, the host computer can be connected to the other end of the program download cable to establish a data transmission channel between the host computer and the processor without having to unpack the MCU. This saves manpower and resources during the unpacking process, avoids damage to the casing and the MCU, and improves the efficiency of MCU program updates.
[0080] In summary, the program update data is divided into several data batches by the host computer. During program updates, only one data batch is received at a time. If the actual checksum of the current data batch is inconsistent with the target checksum, a data retransmission request can be sent to the host computer, so that the host computer only needs to retransmit the current data batch. Since the data volume of the data batch is smaller than the data volume of the program update data, the retransmission efficiency is higher when the data batch is abnormal, thereby improving the efficiency of program updates.
[0081] Based on the above embodiments:
[0082] As a preferred embodiment, before receiving the current data batch and the target checksum of the current data batch sent by the host computer, the method further includes:
[0083] Receive update data information sent by the host computer, including the size of the program update data;
[0084] Preset rules are generated based on the updated data information, and the preset rules are fed back to the host computer so that the host computer can divide the program update data into several data batches according to the preset rules.
[0085] In this embodiment, before updating the program, the update data information sent by the host computer is received. The update data information includes the size of the program update data. A preset rule is generated based on the update data information. The preset rule can be to divide the program update data into several data batches. Each data batch includes N frames of data, and each frame of data includes M bytes, where N and M are both positive integers.
[0086] After generating the preset rules, the preset rules are fed back to the host computer, which then divides the program update data into batches according to the preset rules.
[0087] As a preferred embodiment, before receiving the current data batch and the target checksum of the current data batch sent by the host computer, the method further includes:
[0088] Send a data batch retrieval request to the host computer so that the host computer sends the current data batch corresponding to the data batch retrieval request.
[0089] In this embodiment, a data batch retrieval request is proactively sent to the host computer so that the host computer can determine that the processor is ready for program updates after receiving the data batch retrieval request, and then send the current data batch corresponding to the data batch retrieval request.
[0090] For example, a data batch retrieval request for the first data batch is first sent to the host computer. The host computer sends the first data batch as the current data batch to the processor. After the processor determines that the actual checksum of the current data batch is consistent with the target checksum and stores the current data batch in the program update storage module, it sends a data batch retrieval request for the second data batch to the host computer, and so on, until all data batches are retrieved and stored in the program update storage module, thus completing the program update.
[0091] As a preferred embodiment, before calculating the actual checksum of the current data batch, the method further includes:
[0092] Determine if the batch index of the current data batch is consistent with the batch index of the data batch retrieval request; the batch index is used to identify the order of each data batch.
[0093] If they match, proceed to the step of calculating the actual checksum of the current data batch;
[0094] If there is a discrepancy, a data resend request is sent to the host computer so that the host computer can resend the current data batch.
[0095] In this embodiment, the batch index of each data batch retrieval request sent to the host computer is different. For example, if the first data batch retrieval request sent to the host computer requests the first data batch, then the batch index of the first data batch retrieval request is "first". If the second data batch retrieval request sent to the host computer requests the second data batch, then the batch index of the second data batch retrieval request is "second". Based on this, the current data batch also has its own batch index. The batch index of each data batch identifies the order of each data batch. For example, after the host computer divides the program update data into several data batches based on preset rules, the batch index of the first data batch is "first", and the batch index of the second data batch is "second". This ensures that after the processor receives and stores each data batch, the order of each data batch in the program update storage module is also the order of each data batch of the program update data, avoiding the processor program update failure due to the disorder of the data batch order.
[0096] After receiving the current data batch, the batch index of the current data batch is compared with the batch index of the data batch retrieval request for the current data batch. If they match, the received current data batch is the expected data batch, and the actual checksum of the current data batch can be calculated. If they do not match, the received current data batch is not the expected data batch, and a data resend request needs to be sent to the host computer to request the host computer to resend the current data batch.
[0097] In a preferred embodiment, after sending a data batch retrieval request to the host computer, the method further includes:
[0098] If the current data batch is not received after the first preset interval, a data batch retrieval request will be sent to the host computer again.
[0099] If a data batch retrieval request is sent to the host computer but the current data batch is not received after the first preset time interval, it may be that the host computer has not received the data batch retrieval request or that the data has been lost. In this case, send another data batch retrieval request to the host computer to request the host computer to send the current data batch corresponding to the data batch retrieval request.
[0100] If the current data batch is not received after the first preset time, continue to send a data batch acquisition request to the host computer until the current data batch and the target checksum of the current data batch are received from the host computer.
[0101] As a preferred embodiment, before receiving the update data information sent by the host computer, the method further includes:
[0102] If a program update command is received from the host computer, the download program flag is set to indicate that data download is in progress and the computer is restarted.
[0103] After reading that the download program flag indicates that data download is in progress, the download program flag is restored to its initial state, and a program update request is sent to the host computer so that the host computer can send updated data information based on the program update request.
[0104] In this embodiment, during normal operation, if a program update command is received from the host computer, the download program flag is first set to indicate a data download state, such as setting the download program flag to 1. Considering that before the program update, during normal operation, the program code before the update is loaded from Flash into RAM before it can be executed by the CPU, directly performing a program update at this time might cause system crashes. Therefore, after setting the download program flag to indicate a data download state, the system restarts. After restarting, the download program flag is read. Upon finding that the download program flag indicates a data download state, it is restored to its initial state to avoid repeatedly entering the program update state during the next restart. A program update request is then sent to the host computer, enabling the host computer to send update data information based on the program update request. This allows the host computer to determine that the processor is ready for a program update and that a normal data transmission channel has been established between the two computers.
[0105] In a preferred embodiment, after sending a program update request to the host computer, the process further includes:
[0106] If no updated data is received after the second preset interval, a program update request will be sent to the host computer every third preset interval until updated data is received.
[0107] If no update data is received after the second preset interval, it may be due to a communication interruption with the host computer, or the host computer being unable to send update data due to other programs being occupied. Based on this, a program update request is sent to the host computer every third preset interval so that the host computer can send update data when it is idle or after the communication connection is re-established, ensuring that update data can be received in a timely manner and improving program update efficiency.
[0108] As a preferred embodiment, after storing the current data batch to the program update storage module, the method further includes:
[0109] If the current data batch is the last data batch in the program update data, then calculate the total actual checksum of all data batches in the program update storage module;
[0110] If the total actual checksum matches the total target checksum sent by the host computer, then the program update is considered complete.
[0111] The overall target checksum is the checksum of the program update data sent by the host computer.
[0112] After confirming that the current data batch is normal and storing it in the program update storage module, if the current data batch is the last data batch, then the storage of the entire program update data can be determined to be complete. At this point, in order to further ensure the accuracy of the entire program update data stored in the program update storage module, the total actual checksum of each data batch in the program update storage module, that is, the total actual checksum of the entire program update data, is calculated. If the total actual checksum is consistent with the total target checksum, then the entire program update data can be determined to be normal, the program update has been completed, and the storage of the new program code has been completed.
[0113] The following is a complete embodiment:
[0114] Taking MCU program updates as an example. After the MCU starts up, the BootLoader in the MCU first reads the download program flag. If the download program flag is in the initial state, it enters the normal operation state, that is, the application runs normally. During the operation, after receiving the program update command sent by the host computer, it sets the download program flag to indicate the state of data download and restarts. After restarting, the MCU's BootLoader reads the download program flag, confirms that the download program flag is in the state of indicating data download, restores the download program flag to the initial state, and starts timing. After a fourth preset interval, if no program update request is received from the host computer after 2 seconds, it enters the normal operation state, that is, the application runs normally. If a program update request is received from the host computer within 2 seconds, the internal program update flag is set to indicate the state of entering the program update process, and a program update request is sent to the host computer. This means that the host computer confirms that the MCU has completed the program update preparation and sends the update data information. At this time, the update data information includes the size of the program update data and the total target checksum of the program update data. After sending a program update request to the host computer, a timer is started. If the timer reaches the second preset interval, and no update data is received within 2 seconds, a program update request is sent to the host computer every third preset time interval, such as every 500ms, until the update data is received.
[0115] After receiving the update data information, a preset rule is generated based on the size of the program update data in the update data information. The preset rule is to divide the program update data into multiple data batches, each data batch includes N frames of data, and each frame of data includes M bytes. For example, the program update data is divided into 8 data batches, each data batch includes 16 frames of data, and each frame of data contains 7 bytes. Of course, this application does not limit this, and the specific size is determined according to the actual size of the program update data.
[0116] The generated preset rules are fed back to the host computer so that the host computer can divide the program update data into data batches according to the preset rules. After division, the program update data includes the first data batch, the second data batch, and so on, up to the last data batch. Then, a data batch retrieval request is sent to the host computer. At this time, a request to retrieve the first data batch can be sent to the host computer first, and the status of the request data is set to indicate that a data batch retrieval request has been sent, and a timer is started. If the current data batch corresponding to the data batch retrieval request is not received after the first preset time interval (e.g., 1 second), then the data batch retrieval request is sent to the host computer again until the current data batch is received. It should be noted that the host computer sends the target checksum of the current data batch only after it has sent the current data batch corresponding to the data batch retrieval request. If the current data batch is received within the first preset time interval, first determine whether the batch index of the current data batch is consistent with the batch index of the data batch retrieval request. If the data batch retrieval request corresponds to the first data batch, then the batch index of the data batch retrieval request is first. If the batch index of the current data batch is also first, that is, the current data batch is the first data batch in the program update data, then it can be determined that the current data batch is the expected data batch. However, if the batch index of the current data batch is not first, then the current data batch is not the expected data batch. At this time, a data retransmission request is sent to the host computer so that the host computer retransmits the current data batch until it is determined that the batch index of the received current data batch is consistent with the batch index of the data batch retrieval request.
[0117] After confirming that the batch index of the current data batch matches the batch index of the data batch retrieval instruction, to ensure the accuracy of the current data batch, the actual checksum of the current data batch needs to be further calculated. If the actual checksum of the current data batch matches the target checksum, the current data batch can be stored in the program update storage module, and a data batch retrieval request for the next data batch is sent to the host computer. It should be noted that the MCU will not send a data batch retrieval request before storing the current data batch in the program update storage module. If the actual checksum of the current data batch does not match the target checksum, a data retransmission request is sent to the host computer so that the host computer retransmits the current data batch. Since the host computer has not yet received the data batch retrieval request for the next data batch, it will retransmit the current data batch according to the data retransmission request. This is the first data batch. This process continues until the MCU confirms that the actual checksum of the current data batch matches the target checksum, stores the current data batch in the program update storage module, and then sends a data batch retrieval request for the next data batch to the host computer.
[0118] Similarly, after storing the current data batch to the program update storage module each time, it is necessary to determine whether the current data batch is the last data batch in the program update data. If the current data batch is not the last data batch, then each data batch sent by the host computer is received in the order of each data batch in the program update data, and the batch index and actual checksum are verified each time the current data batch is received. If the current data batch is stored in the program update storage module and it is determined that the current data batch is the last data batch, the total actual checksum of all data batches stored in the program update storage module can be calculated. That is, the total actual checksum of the entire received program update data can be calculated. The total actual checksum is compared with the total target checksum. If the total actual checksum is consistent with the total target checksum, the entire program update data is complete and accurate. At this time, it can be determined that the program update is complete, and the program update completion information is fed back to the host computer so that the host computer can indicate the program update completion based on the program update completion information. For example, the host computer can indicate the upgrade completion through an external indicator light or display screen, and send a program update completion command based on the program update completion information. After receiving the program update completion command, the MCU restarts and runs the updated program. If the total actual checksum does not match the total target checksum, the entire program update data is inaccurate. In this case, the program update can be determined to have failed, and the program update failure information will be fed back to the host computer. The host computer will then issue a program update failure indication based on the program update failure information, such as through an external indicator light or display screen. The host computer will also send a program update failure command based on the program update failure information. After receiving the program update failure command, the MCU will return to the step of feeding back the preset rules to the host computer, thereby re-acquiring each batch of data in the program update data until the program update is determined to be complete. Of course, it is also possible to wait for manual confirmation after the host computer issues the program update failure indication based on the program update failure information to feed back the preset rules to the host computer. This application does not limit this step.
[0119] It should also be noted that, after determining that the batch index of the current data batch and the batch index of the data batch retrieval request are inconsistent, the data reception status can be set to indicate that the current data batch has not been received, and the number of lost batches can be set to a non-zero value to trigger the step of sending a data resend request to the host computer so that the host computer can resend the current data batch. Alternatively, after determining that the batch index of the current data batch and the batch index of the data batch retrieval request are consistent, the data reception status can be set to indicate that the current data batch has been received, and the number of lost batches can be set to 0 to trigger the step of determining that the current data batch is the last data batch in the program's update data.
[0120] When determining whether the current data batch is the last data batch in the program's update data, it can be determined based on the batch index of the current data batch. If the number of data batches is determined in the preset rules, and the batch index of the current data batch is the index of the last batch, then the current data batch can be determined to be the last data batch. Alternatively, it can be determined based on the current frame length of the current data batch. Typically, the frame length of the last data batch is not the frame length set in the preset rules. For example, if the preset rules specify that each data batch includes 16 frames, but the frame length of the program's update data is not a multiple of 16, the frame length of the last data batch may be less than 16, possibly 15 or less. In this case, the current frame length of the current data batch can be calculated. If the current frame length matches the frame length of each data batch specified in the preset rules, then the current data batch is not the last data batch. Conversely, if the current frame length is less than the frame length of each data batch specified in the preset rules, then the current data batch is the last data batch.
[0121] To solve the above-mentioned technical problems, the present invention provides a program update method, applied to a host computer, comprising:
[0122] The program update data is divided into several data batches, and each data batch and its checksum are sent to the program update device.
[0123] Upon receiving a data retransmission request, retransmit the data batch corresponding to the data retransmission request.
[0124] As a preferred embodiment, before dividing the program update data into several data batches, the method further includes:
[0125] Send update data information to the program update device. The update data information includes the size of the program update data. Receive the preset rules generated by the program update device based on the program update data and divide the program update data into several data batches according to the preset rules.
[0126] In a preferred embodiment, sending each data batch and the checksum of each data batch to the program update device respectively includes:
[0127] Upon receiving a data batch retrieval request from the program update device, the current data batch and target checksum corresponding to the data batch retrieval request are sent to the program update device.
[0128] As a preferred embodiment, it also includes,
[0129] Upon receiving a data resend request, resend the data batch corresponding to the data resend request.
[0130] For a description of the program update method provided by this invention, please refer to the above embodiments; the invention will not be described again here.
[0131] Please refer to Figure 2 , Figure 2 This application provides a schematic diagram of the structure of a program update system, which includes:
[0132] The first receiving unit 21 is used to receive the current data batch and the target checksum of the current data batch sent by the host computer. The program update data is divided into several data batches by the host computer, and the current data batch is a data batch in the program update data.
[0133] The first calculation unit 22 is used to calculate the actual checksum of the current data batch;
[0134] The storage execution unit 23 is used to store the current data batch to the program update storage module when the actual checksum matches the target checksum;
[0135] The first feedback unit 24 is used to send a data retransmission request to the host computer when the actual checksum is inconsistent with the target checksum, so that the host computer can resend the current data batch.
[0136] As a preferred embodiment, it also includes:
[0137] The second receiving unit is used to receive update data information sent by the host computer, including the size of the program update data;
[0138] The generation unit is used to generate preset rules based on the updated data information and feed the preset rules back to the host computer so that the host computer can divide the program update data into several data batches according to the preset rules.
[0139] As a preferred embodiment, it also includes:
[0140] The sending unit is used to send a data batch acquisition request to the host computer, so that the host computer sends the current data batch and the target checksum corresponding to the data batch acquisition request.
[0141] As a preferred embodiment, it also includes:
[0142] The first determining unit is used to determine whether the batch index of the current data batch is consistent with the batch index of the data batch retrieval request; the batch index is used to identify the order of each data batch; if they are consistent, the calculation unit is triggered; if they are inconsistent, the second feedback unit is triggered.
[0143] The second feedback unit is used to send a data resend request to the host computer so that the host computer can resend the current data batch.
[0144] As a preferred embodiment, it also includes:
[0145] The second calculation unit is used to calculate the total actual checksum of each data batch in the program update storage module when the current data batch is the last data batch in the program update data;
[0146] The second determining unit is used to determine that the program update is complete when the total actual checksum is consistent with the total target checksum sent by the host computer.
[0147] The overall target checksum is the checksum of the program update data sent by the host computer.
[0148] For a description of the program update system provided by this invention, please refer to the above embodiments; further details of this invention will not be repeated here.
[0149] Please refer to Figure 3 , Figure 3 A schematic diagram of a program update device provided in this application is provided. The device includes:
[0150] Memory 31 is used to store computer programs;
[0151] The processor 32 is configured to implement the steps of the program update method described above when executing a computer program.
[0152] As a preferred embodiment, a protective housing is also included, which is disposed outside the memory 31 and the processor 32.
[0153] In a preferred embodiment, an external interface component is also included, which is disposed on the protective housing and is used to provide a data transmission channel between the processor 32 and the host computer.
[0154] In a preferred embodiment, the protective housing includes several removable covers, which are connected by connecting components to form a sealed structure.
[0155] For a description of the program update device provided by the present invention, please refer to the above embodiments; the present invention will not be described again here.
[0156] Please refer to Figure 4 , Figure 4 This is a schematic diagram of the structure of a computer-readable storage medium provided in this application. The computer-readable storage medium 41 stores a computer program 42. When the computer program 42 is executed by the processor 32, it implements the steps of the program update method described above.
[0157] For a description of the computer-readable storage medium provided by the present invention, please refer to the above method embodiments; the present invention will not be described again here.
[0158] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0159] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A program update method, characterized in that, Applied to a program update device, including: Receive the current data batch and the target checksum of the current data batch sent by the host computer, wherein the program update data is divided into several data batches by the host computer, and the current data batch is a data batch in the program update data; Calculate the actual checksum of the current data batch; If the actual checksum matches the target checksum, then the current data batch is stored in the program update storage module; If the actual checksum is inconsistent with the target checksum, a data retransmission request is sent to the host computer so that the host computer retransmits the current data batch.
2. The program update method as described in claim 1, characterized in that, Before receiving the current data batch and the target checksum of the current data batch sent by the host computer, the process also includes: Receive update data information sent by the host computer, the update data information including the size of the program update data; Based on the updated data information, a preset rule is generated and the preset rule is fed back to the host computer so that the host computer divides the program update data into several data batches according to the preset rule.
3. The program update method as described in claim 2, characterized in that, Before receiving the current data batch and the target checksum of the current data batch sent by the host computer, the process also includes: A data batch acquisition request is sent to the host computer, so that the host computer sends the current data batch and the target checksum corresponding to the data batch acquisition request.
4. The program update method as described in claim 3, characterized in that, Before calculating the actual checksum of the current data batch, the following steps are also included: Determine whether the batch index of the current data batch and the batch index of the data batch retrieval request are consistent; the batch index is used to identify the order of each data batch; If they match, proceed to the step of calculating the actual checksum of the current data batch; If there is a discrepancy, a data resend request is sent to the host computer so that the host computer can resend the current data batch.
5. The program update method as described in claim 4, characterized in that, After sending a data batch acquisition request to the host computer, the process also includes: If the current data batch is not received after the first preset interval, a data batch acquisition request is sent to the host computer again.
6. The program update method as described in claim 2, characterized in that, Before receiving the update data information sent by the host computer, the process also includes: If a program update instruction is received from the host computer, the download program flag is set to indicate that data download is in progress and the computer is restarted. After reading that the download program flag indicates that data download is in progress, the download program flag is restored to its initial state, and a program update request is sent to the host computer, so that the host computer sends the updated data information based on the program update request.
7. The program update method as described in claim 6, characterized in that, After sending the program update request to the host computer, the process also includes: If the updated data is not received after the second preset interval, the program update request is sent to the host computer every third preset interval until the updated data is received.
8. The program update method according to any one of claims 1-7, characterized in that, After storing the current data batch to the program update storage module, the method further includes: If the current data batch is the last data batch in the program update data, then calculate the total actual checksum of each data batch in the program update storage module; If the total actual checksum is consistent with the total target checksum sent by the host computer, then the program update is determined to be complete. The total target checksum is the checksum of the program update data sent by the host computer.
9. A program update method, characterized in that, Applications in host computers include: The program update data is divided into several data batches, and each data batch and its checksum are sent to the program update device. Upon receiving a data retransmission request, the data batch corresponding to the data retransmission request is retransmitted.
10. The program update method as described in claim 9, characterized in that, Before dividing the program update data into several data batches, it also includes: Send update data information to the program update device, the update data information including the size of the program update data, so as to receive the preset rules generated by the program update device based on the program update data, and divide the program update data into several data batches according to the preset rules.
11. The program update method as described in claim 9, characterized in that, Sending each of the data batches and the checksums of each of the data batches to the program update device, including: Upon receiving a data batch retrieval request from the program update device, the current data batch and target checksum corresponding to the data batch retrieval request are sent to the program update device.
12. The program update method as described in claim 9, characterized in that, It also includes, Upon receiving a data resend request, resend the data batch corresponding to the data resend request.
13. A program update system, characterized in that, include: The first receiving unit is used to receive the current data batch and the target checksum of the current data batch sent by the host computer, wherein the program update data is divided into several data batches by the host computer, and the current data batch is a data batch in the program update data; The first calculation unit is used to calculate the actual checksum of the current data batch; The storage execution unit is configured to store the current data batch to the program update storage module when the actual checksum matches the target checksum; The first feedback unit is used to send a data retransmission request to the host computer when the actual checksum is inconsistent with the target checksum, so that the host computer retransmits the current data batch.
14. The program update system as described in claim 13, characterized in that, Also includes: The second receiving unit is used to receive update data information sent by the host computer, the update data information including the size of the program update data; The generation unit is used to generate preset rules based on the updated data information and feed the preset rules back to the host computer so that the host computer divides the program update data into several data batches according to the preset rules.
15. The program update system as described in claim 13, characterized in that, Also includes: The sending unit is used to send a data batch acquisition request to the host computer, so that the host computer sends the current data batch and the target checksum corresponding to the data batch acquisition request.
16. The program update system as described in claim 15, characterized in that, Also includes: The first determining unit is used to determine whether the batch index of the current data batch and the batch index of the data batch acquisition request are consistent; The batch index is used to identify the order of the various data batches; If they match, the calculation unit is triggered; if they do not match, the second feedback unit is triggered. The second feedback unit is used to send a data resend request to the host computer so that the host computer can resend the current data batch.
17. The program update system as described in claim 13, characterized in that, Also includes: The second calculation unit is used to calculate the total actual checksum of each data batch in the program update storage module when the current data batch is the last data batch in the program update data; The second determining unit is used to determine that the program update is complete when the total actual checksum is consistent with the total target checksum sent by the host computer. The total target checksum is the checksum of the program update data sent by the host computer.
18. A program update device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the program update method as described in any one of claims 1-8 when executing a computer program.
19. The program update apparatus as described in claim 18, characterized in that, It also includes a protective casing disposed outside the memory and the processor.
20. The program update apparatus as described in claim 19, characterized in that, It also includes an external interface component, which is disposed on the protective shell and is used to provide a data transmission channel for the processor and the host computer.
21. The program update apparatus as described in claim 19, characterized in that, The protective shell includes several removable cover plates, which are connected by connecting components to form a sealed structure.