Ota upgrade method, ota upgrade device, electronic device and electromagnetic descaling processor

CN123011279APending Publication Date: 2026-10-30RUINA INTELLIGENT EQUIP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611498796.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-24
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

相关技术中,用于电磁除垢处理器的OTA升级通常采用单存储分区直接覆盖的方式,即升级数据包直接写入业务程序所在的存储区域并覆盖原有固件代码,而不考虑升级过程中供电中断、传输丢包等异常工况所导致的业务固件损坏风险

Benefits of technology

清理模块,被配置为在将所述升级固件写入所述第二区后,对所述第三区存储的升级固件进行擦除,并在所述升级固件擦除完成后跳转至所述第二区运行电磁除垢业务代码,以实现所述OTA升级。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011279A_ABST
    Figure CN123011279A_ABST
Patent Text Reader

Abstract

The application discloses an OTA upgrading method and device, an electronic device and an electromagnetic descaling processor, and is applied to the field of intelligent heat supply, in particular to the electromagnetic descaling processor. The storage area of the electromagnetic descaling processor is divided into a first area, a second area and a third area, and the method comprises the following steps: after the electromagnetic descaling processor is started, the program of the first area is run, the embedded parameter field at the preset offset position of the third area is read to determine whether the third area stores the upgrading firmware of the OTA upgrading package. In the case that the third area does not store the upgrading firmware of the OTA upgrading package, the electromagnetic descaling business code is run in the second area. In the case that the third area stores the upgrading firmware of the OTA upgrading package, the original business firmware of the second area is erased, and the upgrading firmware is written into the second area. After the upgrading firmware is written into the second area, the upgrading firmware stored in the third area is erased, and after the upgrading firmware is erased, the electromagnetic descaling business code is run in the second area, so that the OTA upgrading is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of OTA upgrade technology, and in particular to an OTA upgrade method, OTA upgrade device, electronic device and electromagnetic descaling processor. Background Technology

[0002] In the field of smart heating, impurities easily accumulate in the water of heating pipelines. Electromagnetic descaling can remove these internal impurities. In related technologies, OTA upgrades for electromagnetic descaling processors typically employ a single storage partition direct overwrite method. This means the upgrade data packet is directly written to the storage area where the application program resides, overwriting the existing firmware code, without considering the risk of firmware corruption due to abnormal operating conditions such as power outages or packet loss during the upgrade process. Therefore, when updating the firmware of an electromagnetic descaling processor in operation, this method of directly receiving the upgrade data packet and overwriting the existing firmware in place may prevent the electromagnetic descaling processor from automatically recovering from abnormal operating conditions during the upgrade process, resulting in prolonged downtime and increased on-site maintenance costs. Summary of the Invention

[0003] This application provides an OTA upgrade method, an OTA upgrade device, an electronic device, and an electromagnetic descaling processor.

[0004] This application provides an OTA upgrade method applied to an electromagnetic descaling processor. The storage area of ​​the electromagnetic descaling processor is divided into a first area, a second area, and a third area. The first area is used to guide and verify the OTA upgrade package, the second area is used to run the electromagnetic descaling service, and the third area is used to store the upgrade firmware of the OTA upgrade package. The method includes: After the electromagnetic descaling processor is started, the program in the first area is run to read the embedded parameter field at the preset offset position of the third area to determine whether the third area stores the upgrade firmware of the OTA upgrade package, and the upgrade firmware includes the embedded parameter field. If the OTA upgrade package firmware is not available in the third zone, the system will jump to the second zone to run the electromagnetic descaling service code. If the upgrade firmware of the OTA upgrade package is stored in the third area, the original service firmware in the second area is erased, and the upgrade firmware is written to the second area. After the upgrade firmware is written to the second area, the upgrade firmware stored in the third area is erased, and after the upgrade firmware is erased, the system jumps to the second area to run the electromagnetic descaling service code to realize the OTA upgrade.

[0005] Thus, through the functional separation design of the first, second, and third zones, a stable and reliable upgrade boot system is constructed. The boot program is unaffected by business firmware upgrades. Even if the business firmware is damaged, it can be repaired and re-upgraded through the boot program, effectively preventing the electromagnetic descaling processor from malfunctioning due to upgrade failure. Furthermore, by fully caching the upgrade firmware to the third zone before writing it to the business zone, the integrity of the firmware data written to the business zone is ensured, reducing the risk of data errors during the upgrade process. In addition, the interruption of the business program during the upgrade process only occurs during the brief firmware erasure and writing phase, minimizing the duration of business interruption and reducing the impact of the upgrade on industrial production processes. It should also be noted that the upgrade firmware in the third zone is automatically cleaned after the upgrade is completed, freeing up storage resources and preventing the upgrade process from being repeatedly triggered during subsequent startups, ensuring the long-term stability of the electromagnetic descaling processor.

[0006] In some implementations, reading the embedded parameter field at a preset offset position in the third region to determine whether the third region stores the OTA upgrade firmware includes: Parse the embedded parameter fields to obtain the upgrade firmware length information and preset verification information; Calculate the actual verification information of the upgraded firmware based on the upgraded firmware length information; The actual verification information is compared with the preset verification information; If the actual verification value is consistent with the preset verification information, it is determined that the third area stores the upgrade firmware of the OTA upgrade package; If the actual verification value is inconsistent with the preset verification information, it is determined that the third zone does not contain the upgrade firmware of the OTA upgrade package.

[0007] This effectively identifies invalid data and residual fragments in the storage area, preventing incorrect upgrade processes from starting due to misjudgment. Furthermore, by combining length range definition with checksum comparison, the integrity of the upgrade firmware can be comprehensively verified, preventing corrupted firmware from being written to the operational area and reducing the risk of electromagnetic descaling processor failure due to upgrade failure. In addition, the entire verification process is completed during the bootloader phase, requiring no additional functional modules, resulting in a simple execution flow, minimal computational resource consumption, and rapid judgment during the electromagnetic descaling processor's startup process without significantly increasing the processor's startup time.

[0008] In some implementations, the embedded parameter field is 8 bytes, the first 4 bytes of the embedded parameter field are used to indicate the length information of the upgraded firmware, and the last 4 bytes of the embedded parameter field are used to indicate the preset verification information.

[0009] This simplifies the bootloader's parsing logic and reduces the amount of boot code, thereby reducing the space occupied in the first storage area. Furthermore, a unified field format improves compatibility between different upgrade packages, facilitating long-term iteration and maintenance of the electromagnetic descaling processor firmware.

[0010] In some embodiments, the method further includes: During the process of running the electromagnetic descaling service code in the second zone, based on the OTA upgrade request sent by the external device in response to the second zone, the original data stored in the third zone is erased, and the original data includes the upgrade firmware of the historical version OTA upgrade package. Receive OTA upgrade packages sent by the external device and write them to the third area one by one; Upon completion of receiving the OTA upgrade package, an integrity check is performed on the upgrade firmware within the third zone. If the integrity check passes, restart the electromagnetic descaling processor; If the integrity check fails, the electromagnetic descaling service code will continue to run.

[0011] This avoids prolonged business interruptions during the upgrade process and meets the continuous operation requirements of electromagnetic descaling processors in industrial scenarios. Furthermore, the reception and verification of the upgrade package are completed in the third zone, preventing any modification or interference with the business firmware in the second zone, thus ensuring the stability of business operations.

[0012] In some embodiments, the method further includes: If a power outage occurs during the OTA upgrade data packet reception process, the electromagnetic descaling processor will run the program in the first area after power-on and read the embedded parameter field at the preset offset position in the third area to determine whether the third area stores the upgrade firmware of the OTA upgrade package. The upgrade firmware includes the embedded parameter field. If the OTA upgrade package firmware is not available in the third zone, the system will jump to the second zone to run the electromagnetic descaling service code. If the upgrade firmware of the OTA upgrade package is stored in the third area, the original service firmware in the second area is erased, and the upgrade firmware is written to the second area. After the upgrade firmware is written to the second area, the upgrade firmware stored in the third area is erased, and after the upgrade firmware is erased, the system jumps to the second area to run the electromagnetic descaling service code to realize the OTA upgrade.

[0013] In this way, abnormal scenarios such as power outages during the receiving process can be handled automatically without manual intervention to re-initiate the upgrade, thus reducing the operation and maintenance costs of electromagnetic descaling processors in industrial sites.

[0014] In some embodiments, the method further includes: If the original business firmware of the second zone is erased during the process of the first zone program erasing the original business firmware or the upgrade firmware is written to the second zone, the electromagnetic descaling processor will restart and run the first zone program again to read the embedded parameter field at the preset offset position of the third zone, so as to erase the original business firmware of the second zone again and write the upgrade firmware to the second zone.

[0015] In this way, the entire upgrade process can be covered by power outage scenarios. Whether the power outage occurs in the receiving or writing stage, the electromagnetic descaling processor can automatically recover and complete the upgrade, avoiding the failure of the electromagnetic descaling processor to start due to power outage during the upgrade process.

[0016] In some embodiments, the method further includes: Upon receiving the OTA upgrade package sent by the external device, if it is determined that the OTA upgrade package has been received and verified without error and successfully written to the third area, the upgrade package feedback information is sent back to the external device. The upgrade package feedback information is used to indicate that the current OTA upgrade package has been correctly received and processed by the electromagnetic descaling processor. If the external device does not receive the upgrade package feedback information within a preset time, the OTA upgrade package will be resent. If the upgrade package feedback information is not received after the number of resends reaches the preset threshold, the OTA upgrade will be terminated.

[0017] This effectively addresses packet loss and error issues in complex industrial communication environments, improving the success rate of OTA upgrade packet transmission. Furthermore, through confirmation feedback from the electromagnetic descaling processor, external devices can accurately monitor the transmission status of each data packet, promptly detect transmission anomalies, and execute retransmissions, preventing the entire upgrade from failing due to the loss of a single packet.

[0018] In some implementations, the OTA upgrade package includes the embedded parameter field, the electromagnetic descaling processor address field, the command word field, the software version field, the current package sequence number field, the maximum package length field, the current package actual length field, the upgrade package entity field, and the checksum field; The command field contains a preset numerical identifier for the upgrade control instruction; The first preset byte of the software version field is the electromagnetic descaling processor type, and the second preset byte of the software version field is the software version number, which is used for version matching and to avoid repeated upgrades. The preset verification information in the embedded parameter field is obtained by performing verification calculations after setting the byte data at the preset offset position to zero.

[0019] In this way, through multi-dimensional field design, multiple functions such as electromagnetic descaling processor addressing, instruction recognition, version matching, package management and multi-level verification can be realized, thereby effectively avoiding various problems such as electromagnetic descaling processor mismatch, repeated upgrades, transmission packet loss and data errors, and improving the success rate and stability of OTA upgrades.

[0020] This application also provides an OTA upgrade device, which is applied to an electromagnetic descaling processor to implement the above-described OTA upgrade method. The storage area of ​​the electromagnetic descaling processor is divided into a first area, a second area, and a third area. The first area is used to guide and verify the OTA upgrade package, the second area is used to run the electromagnetic descaling service, and the third area is used to store the upgrade firmware of the OTA upgrade package. The device includes: The verification module is configured to run the program in the first area after the electromagnetic descaling processor is started, and read the embedded parameter field at the preset offset position of the third area to determine whether the third area stores the upgrade firmware of the OTA upgrade package, wherein the upgrade firmware includes the embedded parameter field. The jump execution module is configured to, if the upgrade firmware of the OTA upgrade package is not present in the third zone, jump to the second zone to run the electromagnetic descaling service code; and if the upgrade firmware of the OTA upgrade package is stored in the third zone, erase the original service firmware in the second zone and write the upgrade firmware into the second zone. The cleaning module is configured to erase the upgrade firmware stored in the third area after the upgrade firmware is written to the second area, and then jump to the second area to run the electromagnetic descaling service code after the upgrade firmware is erased, so as to realize the OTA upgrade.

[0021] Thus, relying on the collaborative cooperation between various modules, the OTA upgrade device provided in this application constructs a stable and reliable upgrade boot system through the functional separation design of the first, second, and third zones. The boot program is never affected by the business firmware upgrade. Even if the firmware in the business zone is damaged, it can be repaired and re-upgraded through the boot program, effectively avoiding the situation where the electromagnetic descaling processor cannot operate due to upgrade failure. Furthermore, by fully caching the upgrade firmware to the third zone before writing it to the business zone, the integrity of the firmware data written to the business zone can be ensured, reducing the risk of data errors during the upgrade process. In addition, the interruption of the business program during the upgrade process only occurs during the brief firmware erasure and writing phase, which can minimize the business interruption time and reduce the impact of the upgrade on the industrial production process. It should also be noted that the upgrade firmware in the third zone is automatically cleaned after the upgrade is completed, which not only releases storage resources but also avoids repeated triggering of the upgrade process during subsequent startups, ensuring the long-term stability of the electromagnetic descaling processor.

[0022] This application also provides an electronic device that stores a computer program, which, when executed by a processor, implements the steps of the above-described method.

[0023] This application also provides an electromagnetic descaling processor, which includes the above-described electronic device.

[0024] Additional aspects and advantages of embodiments of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of embodiments of this application. Attached Figure Description

[0025] The above and additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is one of the flowcharts illustrating the OTA upgrade method according to certain embodiments of this application; Figure 2 This is a second flowchart illustrating an OTA upgrade method according to certain embodiments of this application; Figure 3 This is the third flowchart illustrating the OTA upgrade method according to certain embodiments of this application; Figure 4 This is the fourth flowchart illustrating an OTA upgrade method according to certain embodiments of this application; Figure 5 This is the fifth flowchart illustrating an OTA upgrade method according to certain embodiments of this application; Figure 6 This is a flowchart of one of the OTA upgrade methods according to certain embodiments of this application; Figure 7 This is the seventh flowchart illustrating an OTA upgrade method according to certain embodiments of this application; Figure 8 This is a schematic diagram of the OTA upgrade device according to certain embodiments of this application. Detailed Implementation

[0026] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of this application, and should not be construed as limiting the embodiments of this application.

[0027] In scenarios such as industrial circulating water, municipal water supply and drainage, and heat exchange systems, electromagnetic descaling processors typically need to operate continuously online for extended periods. Remote firmware upgrades for these processors are crucial for ensuring functional iteration and defect repair. In related technologies, OTA upgrades for electromagnetic descaling processors usually employ a single storage partition direct overwrite method. This means the electromagnetic descaling processor only has a single business program storage partition. During the upgrade, the currently running business firmware directly receives the upgrade data packet, without a separate upgrade cache or pre-verification boot process. The upgrade data is directly written to the storage area where the business program resides, overwriting the original firmware code. The entire upgrade process does not consider the risk of firmware corruption due to abnormal operating conditions such as power outages, packet loss, or data distortion.

[0028] Thus, if a power outage occurs during the upgrade process, the firmware will be damaged to varying degrees depending on the stage at which the power outage occurs: if the power outage occurs during the erasure of the original firmware, the original code in the application program storage area will be partially erased, and the remaining code will be incomplete; if the power outage occurs during the writing of the new firmware, the original firmware will be erased, and only a portion of the data will be written to the new firmware. In either case, the electromagnetic descaling processor will be unable to load a complete and valid application program after restarting, becoming unusable and bricked. Maintenance personnel must arrive on-site and re-flash the complete firmware using a dedicated programmer interface to restore operation.

[0029] Furthermore, the deployment sites of electromagnetic descaling processors are typically in complex environments, often using multiple communication interfaces such as 4G, Bluetooth, RS485, and serial ports for upgrade transmission. Electromagnetic interference, link fluctuations, and signal attenuation at these sites can easily cause upgrade data packet loss, data bit distortion, or verification errors. In direct overwrite mode, erroneous upgrade data will be directly written to the business program storage area, compromising the executability of the original firmware. This can lead to minor issues like partial malfunctions and reduced descaling efficiency in the electromagnetic descaling processor, or even serious issues like startup failure or complete shutdown.

[0030] In summary, when updating the firmware of an electromagnetic descaling processor in operation, the current method of directly receiving the upgrade data packet and overwriting the existing firmware in place not only requires interrupting normal water treatment operations throughout the upgrade process, making parallel operation of operations and upgrade impossible, but also risks the electromagnetic descaling processor failing to automatically resume operation in case of abnormal conditions during the upgrade, resulting in prolonged downtime. Furthermore, since electromagnetic descaling processors are often deployed at various pipeline nodes and heat exchange sites, the long distances for on-site maintenance and high dispatch costs mean that bricked processors require dedicated personnel for repair, significantly increasing on-site maintenance costs and management difficulty. It may even lead to secondary problems such as pipe scaling and decreased heat exchange efficiency due to the interruption of descaling function, affecting the stable operation of the overall system.

[0031] Based on the above issues, please refer to Figure 1 This application provides an OTA upgrade method applied to an electromagnetic descaling processor. The storage area of ​​the electromagnetic descaling processor is divided into a first area, a second area, and a third area. The first area is used to guide and verify the OTA upgrade package, the second area is used to run the electromagnetic descaling service, and the third area is used to store the upgrade firmware of the OTA upgrade package. The method includes: 011: After the electromagnetic descaling processor is started, the program in the first zone is run to read the embedded parameter field at the preset offset position in the third zone to determine whether the third zone stores the upgrade firmware of the OTA upgrade package. The upgrade firmware includes the embedded parameter field. 012: If there is no OTA upgrade package firmware in Zone 3, jump to Zone 2 to run the electromagnetic descaling service code; 013: If the upgrade firmware of the OTA upgrade package is stored in the third zone, erase the original service firmware in the second zone and write the upgrade firmware into the second zone. 014: After writing the upgrade firmware to the second zone, the upgrade firmware stored in the third zone is erased. After the upgrade firmware is erased, the system jumps to the second zone to run the electromagnetic descaling business code to achieve OTA upgrade.

[0032] This application also provides an electronic device, including a memory and a processor. The OTA upgrade method of this application can be implemented by the electronic device of this application. Specifically, the memory stores a computer program, and the processor executes the computer program to implement the following method steps: After the electromagnetic descaling processor is started, the program in the first zone is run to read the embedded parameter field at the preset offset position in the third zone to determine whether the third zone stores the upgrade firmware of the OTA upgrade package. The upgrade firmware includes the embedded parameter field. If there is no OTA upgrade package for the firmware in the third zone, jump to the second zone to run the electromagnetic descaling service code; If the upgrade firmware of the OTA upgrade package is stored in the third zone, the original service firmware in the second zone is erased and the upgrade firmware is written to the second zone. After the upgrade firmware is written to the second zone, the upgrade firmware stored in the third zone is erased. After the upgrade firmware is erased, the system jumps to the second zone to run the electromagnetic descaling business code to achieve OTA upgrade.

[0033] This application also provides an OTA upgrade device 1000. The OTA upgrade method of this application can be implemented by the OTA upgrade device 1000 of this application. Specifically, the OTA upgrade device 1000 includes a verification module 100, a jump execution module 200, and a cleaning module 300. The verification module 100 is used to run the program in the first zone after the electromagnetic descaling processor starts, and read the embedded parameter field at a preset offset position in the third zone to determine whether the third zone stores the upgrade firmware of the OTA upgrade package, the upgrade firmware including the embedded parameter field. The jump execution module 200 is used to jump to the second zone to run the electromagnetic descaling service code if the upgrade firmware of the OTA upgrade package is not present in the third zone. And if the upgrade firmware of the OTA upgrade package is stored in the third zone, it erases the original service firmware in the second zone and writes the upgrade firmware into the second zone. The cleaning module 300 is used to erase the upgrade firmware stored in the third zone after writing the upgrade firmware into the second zone, and jumps to the second zone to run the electromagnetic descaling service code after the upgrade firmware erasure is completed, so as to realize the OTA upgrade.

[0034] Specifically, the storage area of ​​the electromagnetic descaling processor is first logically divided into three zones: Zone 1, Zone 2, and Zone 3. Zone 1 is the boot program storage area, storing the boot code that executes first upon power-up of the electromagnetic descaling processor. It possesses basic hardware driver and storage read / write capabilities. The program in this zone is separate from the business firmware and will not be modified during business firmware upgrades, forming the security foundation of the entire upgrade process. Zone 2 is the business program storage area, used to store and run the complete firmware code for the electromagnetic descaling business. When the electromagnetic descaling processor is working normally, all logic related to electromagnetic descaling, such as function control, parameter adjustment, and status monitoring, is executed under the program scheduling of this zone. Zone 3 is the upgrade firmware cache area, specifically used to receive and temporarily store the upgrade firmware in OTA upgrade packages. This zone does not participate in daily business operations; the reception, temporary storage, and verification of upgrade packages are all completed within this zone, without interfering with the business operations in Zone 2. Furthermore, the physical storage addresses of these three zones (Zone 1, Zone 2, and Zone 3) do not overlap, and each zone performs its own function, collectively forming a storage architecture that separates upgrades from business operations.

[0035] After the electromagnetic descaling processor powers on, the program counter first points to the starting address of the first zone, and the boot program within the first zone runs. After the boot program completes the initialization of basic hardware such as the clock and storage interface, it directly addresses the preset offset position in the third zone and reads the embedded parameter field at that preset offset position. This embedded parameter field is part of the upgrade firmware and is preset at a fixed offset position in the upgrade firmware to identify its existence and integrity. The boot program parses the content at this preset offset position to determine whether the third zone stores a complete and valid OTA upgrade package of upgrade firmware.

[0036] If it is determined that there is no OTA upgrade firmware in Zone 3, the bootloader will directly execute a program jump operation, transferring program control to the business program entry address in Zone 2. Zone 2 loads and runs the electromagnetic descaling business code, and the electromagnetic descaling processor enters normal working state, continuously executing various business functions of electromagnetic descaling.

[0037] If the third zone is determined to contain the OTA upgrade firmware, the bootloader first performs a second zone erase operation, clearing all existing firmware stored in the second zone to reserve ample storage space for the new firmware. After the erase operation is complete, the bootloader reads the upgrade firmware data from the third zone and writes it segment by segment to the corresponding storage address in the second zone. After the firmware writing operation is complete, the bootloader then performs a third zone erase operation, clearing all upgrade firmware data stored in the third zone. After the third zone erase is complete, the bootloader performs a program jump operation again, transferring control to the second zone and running the updated electromagnetic descaling business code. The electromagnetic descaling processor then enters normal working condition with the new firmware, thus completing the full OTA upgrade process.

[0038] In summary, the OTA upgrade method provided in this application constructs a stable and reliable upgrade boot system through the functional separation design of the first, second, and third zones. The boot program is always unaffected by the business firmware upgrade. Even if the business firmware is damaged, it can be repaired and re-upgraded through the boot program, effectively avoiding the situation where the electromagnetic descaling processor cannot operate due to upgrade failure. Furthermore, by fully caching the upgrade firmware to the third zone before writing it to the business zone, the integrity of the firmware data written to the business zone can be ensured, reducing the risk of data errors during the upgrade process. In addition, the interruption of the business program during the upgrade process only occurs during the brief firmware erasure and writing phase, which can minimize the business interruption time and reduce the impact of the upgrade on the industrial production process. It should also be noted that the upgrade firmware in the third zone is automatically cleaned after the upgrade is completed, which not only releases storage resources but also avoids repeated triggering of the upgrade process during subsequent startups, ensuring the long-term stability of the electromagnetic descaling processor.

[0039] Please see Figure 2 In some implementations, step 011 includes: 0111: Parse the embedded parameter fields to obtain the upgrade firmware length information and preset verification information; 0112: Calculate the actual verification information of the upgraded firmware based on the firmware length information; 0113: Compare the actual verification information with the preset verification information; 0114: If the actual verification value is consistent with the preset verification information, it is determined that the third zone stores the upgrade firmware of the OTA upgrade package; 0115: If the actual verification value is inconsistent with the preset verification information, it is determined that there is no OTA upgrade firmware in the third zone.

[0040] In some implementations, the verification module 100 is used to parse the embedded parameter fields to obtain the upgrade firmware length information and preset verification information. It also calculates the actual verification information of the upgrade firmware based on the upgrade firmware length information and compares the actual verification information with the preset verification information. The verification module 100 is further used to determine that the third area stores the upgrade firmware with an OTA upgrade package if the actual verification value matches the preset verification information, and to determine that the third area does not contain the upgrade firmware with an OTA upgrade package if the actual verification value does not match the preset verification information.

[0041] In some implementations, the processor is further configured to parse the embedded parameter field to obtain the upgrade firmware length information and preset verification information. It also calculates the actual verification information of the upgrade firmware based on the upgrade firmware length information and compares the actual verification information with the preset verification information. The processor is further configured to determine that the third area stores the upgrade firmware with an OTA upgrade package if the actual verification value matches the preset verification information, and to determine that the third area does not contain the upgrade firmware with an OTA upgrade package if the actual verification value does not match the preset verification information.

[0042] Specifically, in the upgrade determination phase after the electromagnetic descaling processor starts up, relying solely on a single identifier or fixed marker to determine the existence of upgrade firmware can easily lead to errors. Residual historical data fragments in the storage area, or incomplete firmware due to transmission interruptions, can trigger incorrect upgrade processes, resulting in corrupted firmware data being written to the service area, ultimately causing the electromagnetic descaling processor to malfunction and fail to perform its business functions.

[0043] To address the aforementioned issues, this application's implementation method parses the length information and preset verification information in the embedded parameter fields, compares them with the actual verification information calculated based on the firmware length, and determines the existence and validity of the upgrade firmware based on the comparison results. This achieves integrity verification of the content stored in the third area and avoids erroneous triggering of the upgrade process.

[0044] The embedded parameter field is a structured data segment set at a fixed offset position in the upgrade firmware, used to carry the attribute information and verification information of the upgrade firmware.

[0045] The upgrade firmware length information is the total byte length of the complete upgrade firmware recorded in the embedded parameter field, which is used to define the data range of the upgrade firmware in the third zone.

[0046] The preset verification information is a verification value calculated in advance when the upgrade firmware is completed. This value is packaged together with the upgrade firmware and serves as the benchmark data for integrity verification.

[0047] The actual verification information is a verification value calculated based on the actual firmware data stored in the third zone, which is used to reflect the integrity status of the currently stored data.

[0048] During execution, the bootloader reads the embedded parameter field at the preset offset position in the third zone. It first parses the data in this field to extract the upgrade firmware length information and preset verification information. Then, based on the upgrade firmware length information, the bootloader determines the start and end addresses of the corresponding upgrade firmware within the third zone, defining the data range to be verified. Within this defined data range, the bootloader uses the corresponding verification algorithm to calculate all bytes of data, obtaining the actual verification information for the upgrade firmware.

[0049] After calculating the actual verification information, the bootloader compares the actual verification information with the preset verification information one by one. If the actual verification value matches the preset verification information, it indicates that the firmware data stored in the third zone is complete and there is no data loss, tampering, or damage. It is determined that the third zone stores the upgrade firmware with the OTA upgrade package, and subsequent firmware erasure and write operations can continue. If the actual verification value does not match the preset verification information, it indicates that the data in the third zone is incomplete, possibly historical residual data or incomplete firmware from failed transmission. It is determined that the third zone does not contain the upgrade firmware with the OTA upgrade package, and the bootloader directly jumps to the second zone to run the electromagnetic descaling service code.

[0050] This effectively identifies invalid data and residual fragments in the storage area, preventing incorrect upgrade processes from starting due to misjudgment. Furthermore, by combining length range definition with checksum comparison, the integrity of the upgrade firmware can be comprehensively verified, preventing corrupted firmware from being written to the operational area and reducing the risk of electromagnetic descaling processor failure due to upgrade failure. In addition, the entire verification process is completed during the bootloader phase, requiring no additional functional modules, resulting in a simple execution flow, minimal computational resource consumption, and rapid judgment during the electromagnetic descaling processor's startup process without significantly increasing the processor's startup time.

[0051] In some implementations, the embedded parameter field is 8 bytes. The first 4 bytes of the embedded parameter field are used to indicate the length information of the upgraded firmware, and the last 4 bytes of the embedded parameter field are used to indicate the preset verification information.

[0052] Specifically, in OTA upgrade scenarios, if the length of embedded parameter fields is not fixed, or if the byte division of internal information lacks a unified standard, the parsing logic of the bootloader will become more complex. The bootloader needs to first identify the total length of the fields, and then locate the starting position of different information, increasing the development difficulty and storage consumption of the boot code. At the same time, the arbitrariness of field length and internal division can easily cause format incompatibility between different version upgrade packages. Subsequent iterations of firmware upgrade packages cannot be correctly recognized by the old version of the bootloader, affecting the long-term maintainability of the electromagnetic descaling processor.

[0053] To address the aforementioned issues, this application's implementation sets the embedded parameter field to a fixed length of 8 bytes and divides the byte space equally, with the first 4 bytes used to carry the upgrade firmware length information and the last 4 bytes used to carry preset verification information.

[0054] The fixed total length of 8 bytes allows the bootloader to directly perform a single fixed-length read operation after locating the preset offset position, without the need for additional identification of field boundaries and length markers, thus simplifying the reading and parsing process.

[0055] The first 4 bytes of space correspond to the value range of a 32-bit unsigned integer, which can cover the capacity range of conventional firmware for embedded electromagnetic descaling processors such as electromagnetic descaling processors, and meet the firmware size representation requirements in most application scenarios.

[0056] The last 4 bytes of space match the standard output length of mainstream verification algorithms, which is consistent with the bit width of the calculation results of commonly used algorithms such as cyclic redundancy check. Therefore, it can be used directly for comparison without additional format conversion.

[0057] During execution, after the bootloader addresses the preset offset address of the third region, it continuously reads 8 bytes of binary data. After reading, according to the preset byte order rules, the first 4 bytes are converted to decimal values ​​to obtain the firmware upgrade length information. This information is used to determine the start and end addresses for subsequent verification calculations, defining the complete verification data range. Simultaneously, the last 4 bytes are converted to decimal values ​​to obtain preset verification information, which is directly used as the benchmark value for subsequent integrity comparisons.

[0058] This simplifies the bootloader's parsing logic and reduces the amount of boot code, thereby reducing the space occupied in the first storage area. Furthermore, a unified field format improves compatibility between different upgrade packages, facilitating long-term iteration and maintenance of the electromagnetic descaling processor firmware.

[0059] Please refer to the following: Figure 3 In some implementations, the method further includes: 015: During the operation of the electromagnetic descaling business code in the second zone, based on the OTA upgrade request sent by the external device in response to the second zone, the original data stored in the third zone is erased. The original data includes the upgrade firmware of the historical version OTA upgrade package. 016: Receive OTA upgrade packages sent by external devices and write them to the third area one by one; 017: After the OTA upgrade package is received, perform an integrity check on the upgrade firmware in the third zone; 018: If the integrity verification passes, restart the electromagnetic descaling processor; 019: Continue running the electromagnetic descaling service code if the integrity check fails.

[0060] In some implementations, the processor is further configured to, during the execution of the electromagnetic descaling service code in the second zone, erase the original data stored in the third zone, including upgrade firmware of historical OTA upgrade packages, based on OTA upgrade requests sent by external devices in response to the second zone. It is also configured to receive OTA upgrade packages sent by external devices and write them to the third zone package by package. Furthermore, upon completion of OTA upgrade package reception, it is configured to perform integrity verification on the upgrade firmware in the third zone. The processor is further configured to restart the electromagnetic descaling processor if the integrity verification passes, and continue running the electromagnetic descaling service code if the integrity verification fails.

[0061] Specifically, in the relevant embedded electromagnetic descaling processor OTA upgrade solutions, receiving and writing upgrade packages usually requires the electromagnetic descaling processor to pause its business operation and enter a dedicated upgrade mode. The business interruption time is relatively long, which is difficult to adapt to industrial scenarios where the electromagnetic descaling processor needs to run continuously online.

[0062] In the implementation of this application, under the normal operation of the electromagnetic descaling processor, the service program in the second zone responds to the upgrade request sent by the external device. First, the original data in the third zone is erased, and then the upgrade package is received and written to the third zone one by one. After the reception is completed, an integrity check is performed. If the check passes, the electromagnetic descaling processor is restarted to enter the upgrade process. If the check fails, the original service continues to run, so as to realize the online reception and preprocessing of upgrade packages without interrupting the service.

[0063] An OTA upgrade request is a firmware upgrade trigger command sent by an external control electromagnetic descaling processor to the electromagnetic descaling processor, used to notify the electromagnetic descaling processor to start the upgrade package receiving process.

[0064] The original data consists of historical version upgrade firmware and residual invalid data stored in the third zone, including firmware fragments and verification information left over from past upgrades.

[0065] Packet-by-packet writing follows the order of packet transmission of the upgrade package, writing each data packet sequentially to the corresponding storage address in the third area to ensure the order and integrity of the firmware data.

[0066] Integrity verification is the process of verifying the integrity and correctness of the upgraded firmware data received in the third zone.

[0067] During actual execution, the electromagnetic descaling processor operates normally, and the electromagnetic descaling business code in the second zone continues to run, maintaining the normal output of the descaling function. When an external device initiates a firmware upgrade and sends an OTA upgrade request to the processor, the business program in the second zone responds to the request. First, it calls the storage driver to perform an erase operation on the third zone, clearing all existing data stored in the third zone to reserve continuous and complete storage space for the new upgrade package. After erasure, the business program establishes a data transmission link with the external device, begins receiving OTA upgrade packages sent by the external device, and writes each data packet to the corresponding storage address in the third zone according to the sequence number of the data packets. During the receiving process, the basic descaling control logic of the business program is unaffected, and the electromagnetic descaling processor can still normally execute all functions of electromagnetic descaling.

[0068] After all data packets are received, the business program performs an integrity check on all upgrade firmware data stored in the third zone. It calculates the checksum and compares it with the built-in checksum information in the firmware to determine if the upgrade firmware is complete and correct. If the integrity check passes, the business program saves the current operating state and controls the electromagnetic descaling processor to perform a restart operation. After restarting, the electromagnetic descaling processor enters the boot program in the first zone, which completes the subsequent firmware update operation. If the integrity check fails, it indicates that data loss or errors occurred during the transmission of the upgrade package. The business program retains the original business firmware in the second zone unchanged and continues to run the electromagnetic descaling business code. The electromagnetic descaling processor maintains normal operating status and awaits the next upgrade request.

[0069] This avoids prolonged business interruptions during the upgrade process and meets the continuous operation requirements of electromagnetic descaling processors in industrial scenarios. Furthermore, the reception and verification of the upgrade package are completed in the third zone, preventing any modification or interference with the business firmware in the second zone, thus ensuring the stability of business operations.

[0070] Please see Figure 4 In some implementations, the method further includes: 020: If power is lost during OTA upgrade data packet reception, the electromagnetic descaling processor will run the program in the first zone after power-on, and read the embedded parameter field at the preset offset position in the third zone to determine whether the third zone stores the upgrade firmware of the OTA upgrade package. The upgrade firmware includes the embedded parameter field. 021: If there is no OTA upgrade firmware available in Zone 3, jump to Zone 2 to run the electromagnetic descaling service code; 022: If the upgrade firmware of the OTA upgrade package is stored in the third zone, erase the original service firmware in the second zone and write the upgrade firmware into the second zone. 023: After writing the upgrade firmware to the second zone, the upgrade firmware stored in the third zone is erased. After the upgrade firmware is erased, the system jumps to the second zone to run the electromagnetic descaling business code to achieve OTA upgrade.

[0071] In some embodiments, the processor is further configured to, if a power outage occurs during OTA upgrade data packet reception, and upon power-up, run the program in the first zone, read the embedded parameter field at a preset offset position in the third zone to determine whether the third zone stores the upgrade firmware for the OTA upgrade package, the upgrade firmware including the embedded parameter field. If the third zone does not contain the upgrade firmware for the OTA upgrade package, the processor jumps to the second zone to run the electromagnetic descaling service code. If the third zone stores the upgrade firmware for the OTA upgrade package, the processor erases the existing service firmware in the second zone and writes the upgrade firmware to the second zone. The processor is also configured to, after writing the upgrade firmware to the second zone, erase the upgrade firmware stored in the third zone, and after the upgrade firmware erasure is complete, jump to the second zone to run the electromagnetic descaling service code to achieve the OTA upgrade.

[0072] Specifically, in industrial operating environments, power fluctuations and unexpected power outages are common. If a power outage occurs during the reception of OTA upgrade data packets, only a portion of the upgrade data packet is written to the third zone, resulting in incomplete data. Related upgrade solutions typically directly enter the operational mode after power is restored to the electromagnetic descaling processor, without processing the residual data in the cache. This residual incomplete data may mistakenly trigger the upgrade process during subsequent startup, leading to firmware corruption. Some solutions directly clear the cache data during startup, but this requires maintenance personnel to re-initiate the upgrade request, preventing automatic upgrade recovery and increasing on-site maintenance costs while extending the overall upgrade cycle. Furthermore, if the embedded parameter fields are written during a power outage but the firmware body is not fully written, a simple existence check may misjudge it as valid firmware, leading to incomplete firmware writing in the operational zone and preventing the electromagnetic descaling processor from functioning properly.

[0073] The OTA upgrade data packet reception process refers to the process by which the electromagnetic descaling processor, under normal operating conditions, receives OTA upgrade data packets sent by external devices and writes them one by one to the third area. Power failure refers to a situation where the electromagnetic descaling processor's power supply is interrupted, program execution terminates, and the data in the non-volatile storage area remains in the state it was in at the time of writing. Power-on of the electromagnetic descaling processor refers to the process where, after power is restored, the electromagnetic descaling processor restarts, and the system program loads and executes from the starting address of the storage.

[0074] During execution, if a power outage occurs while receiving OTA upgrade data packets, only a portion of the data packets may be written to the third zone. Embedded parameter fields may or may not be written, resulting in an incomplete firmware data state. Upon power restoration, the electromagnetic descaling processor powers on and starts. The program counter initially points to the starting address of the first zone, running the boot program. After initializing basic hardware such as the clock and storage interface, the boot program addresses the preset offset position in the third zone and reads the embedded parameter field at that position. The boot program parses the length and verification information in the embedded parameter field, defines the corresponding data range, calculates the actual verification value, and compares the actual verification value with the preset verification information to determine whether the third zone stores a complete and valid OTA upgrade firmware package. The upgrade firmware itself contains embedded parameter fields at a fixed offset position, serving as an identifier for integrity verification.

[0075] If the third zone is found to lack a complete OTA upgrade firmware package, it indicates that the power outage occurred in the early or middle stages of the receiving process, and the firmware data was not completely written. The bootloader directly executes a program jump operation, transferring control to the second zone, running the electromagnetic descaling service code, and the electromagnetic descaling processor resumes normal operation, awaiting the next upgrade request. At this point, the incomplete data remaining in the third zone will not trigger the upgrade process because the integrity check fails, thus avoiding the risk of firmware corruption due to erroneous upgrades.

[0076] If the third zone contains the complete OTA upgrade package firmware, it indicates that the power outage occurred after reception was complete but before the electromagnetic descaling processor restarted, meaning the firmware data had been fully written to the third zone and verified. The bootloader first erases the existing business firmware in the second zone, clearing the business storage area to reserve continuous space for the new firmware. After erasing, the bootloader reads the upgrade firmware data from the third zone and writes it segment by segment to the corresponding storage address in the second zone. After the firmware is written, the bootloader erases the upgrade firmware stored in the third zone, clearing the cached upgrade data and releasing the storage space in the third zone. After erasing, the bootloader jumps to the second zone, runs the updated electromagnetic descaling business code, and the electromagnetic descaling processor enters normal working condition with the new firmware version, completing the full OTA upgrade process.

[0077] In this way, abnormal scenarios such as power outages during the receiving process can be handled automatically without manual intervention to re-initiate the upgrade, thus reducing the operation and maintenance costs of electromagnetic descaling processors in industrial sites.

[0078] Please see Figure 5 In some implementations, the method further includes: 024: If the power is interrupted during the process of erasing the original business firmware of the second zone in the first zone program or during the process of writing the upgrade firmware to the second zone, after the electromagnetic descaling processor restarts, the first zone program will be run again to read the embedded parameter field at the preset offset position of the third zone, so as to erase the original business firmware of the second zone again and write the upgrade firmware to the second zone.

[0079] In some implementations, the processor is also configured to, if the power is lost during the process of erasing the original business firmware of the second zone in the first zone program or during the process of writing the upgrade firmware to the second zone, after the electromagnetic descaling processor restarts, run the program in the first zone again, read the embedded parameter field at the preset offset position in the third zone, so as to erase the original business firmware of the second zone again and write the upgrade firmware to the second zone.

[0080] Specifically, during the firmware execution phase of an OTA upgrade, the erase operation of the original service firmware in the second zone and the write operation of the upgrade firmware to the second zone both require a certain execution time. If an unexpected power outage occurs during this phase, the firmware in the second zone will be in an incomplete state, with partial erasure or partial writing. At this time, the second zone has neither complete old service firmware nor complete new upgrade firmware, and the electromagnetic descaling processor cannot directly enter the service operation state after restarting.

[0081] In response to power failure scenarios during the firmware writing phase, this embodiment automatically re-runs the boot program of the first zone after the electromagnetic descaling processor restarts, reads the embedded parameter field at the preset offset position of the third zone again, and re-executes the original firmware erasure and upgrade firmware writing operations of the second zone based on the upgrade firmware already fully stored in the third zone, until the complete firmware update process is completed.

[0082] The first partition program is the boot verification program stored in the first partition, which is responsible for hardware initialization, upgrade status determination and firmware writing operations after the electromagnetic descaling processor is powered on.

[0083] The original firmware in the second partition was the program code used to run the electromagnetic descaling function, which was stored in the second partition before the upgrade.

[0084] The process of writing the upgrade firmware to the second partition is the operation of the bootloader copying the upgrade firmware data cached in the third partition segment by segment to the corresponding storage address of the second partition.

[0085] Electromagnetic descaling processor restart refers to the process where, after the electromagnetic descaling processor is powered off and then powered on again, the system reloads the program and starts running.

[0086] During execution, if a power outage occurs while the bootloader in Zone 1 is erasing the existing firmware in Zone 2 or writing the upgrade firmware from Zone 3 to Zone 2, the data stored in Zone 2 will be in an incomplete intermediate state. Meanwhile, the upgrade firmware data in Zone 3 has already been written and verified, remaining intact and valid despite the power outage. Upon power restoration, the electromagnetic descaling processor restarts, the program counter returns to the starting address of Zone 1, and the bootloader in Zone 1 re-runs. After initializing basic hardware such as the clock and storage interface, the bootloader addresses the preset offset position in Zone 3 again, reads the embedded parameter field at that position, and confirms that Zone 3 stores a complete and valid upgrade firmware by parsing the length and verification information in the field.

[0087] After confirming the firmware upgrade is valid, the bootloader performs a complete erase operation on the second zone again, thoroughly removing any remaining incomplete firmware data and reserving continuous, clean storage space for the new firmware. After erasing, the bootloader reads the upgraded firmware data from the third zone again and writes it completely to the corresponding storage address in the second zone. The entire writing process is executed again without being affected by the writing progress during the previous power outage, ensuring the final firmware data written to the second zone is complete and error-free. After the firmware writing is complete, the bootloader continues with the subsequent erasure of the third zone and program jump operations, ultimately entering the second zone to run the updated electromagnetic descaling service code, completing the entire upgrade process.

[0088] In this way, the entire upgrade process can be covered by power outage scenarios. Whether the power outage occurs in the receiving or writing stage, the electromagnetic descaling processor can automatically recover and complete the upgrade, avoiding the failure of the electromagnetic descaling processor to start due to power outage during the upgrade process.

[0089] Please see Figure 6 In some implementations, the method further includes: 025: Upon receiving an OTA upgrade package from an external device, if it is confirmed that the OTA upgrade package has been received and verified without error and successfully written to the third area, the upgrade package feedback information is sent back to the external device.

[0090] In some implementations, the processor is also configured to, upon receiving an OTA upgrade package from an external device, if it is determined that the OTA upgrade package has been received and verified without error and has been successfully written to the third region, send upgrade package feedback information back to the external device.

[0091] Specifically, in industrial communication environments, electromagnetic interference, line fluctuations, and network congestion are common, and the transmission of OTA upgrade packages is prone to packet loss, packet errors, or delays.

[0092] To address the issue of insufficient reliability in upgrade package transmission, this application implements a transmission guarantee mechanism that combines feedback from the electromagnetic descaling processor and retransmission from the external device. After the electromagnetic descaling processor confirms that the upgrade package has been received and verified without error and successfully written to the corresponding storage area, it sends upgrade package feedback information to the external device. After the external device sends the data packet, it starts a timeout countdown. If no feedback is received, the upgrade package is retransmitted. If the number of retransmissions reaches a preset threshold and still fails, the upgrade process is terminated. This ensures the transmission success rate while avoiding the ineffective occupation of resources.

[0093] The upgrade package feedback information is an acknowledgment message returned by the electromagnetic descaling processor to external devices, used to indicate that the current upgrade package has been correctly received, verified, and successfully written to the storage area.

[0094] The preset time is the maximum time that the external device waits for feedback after sending the upgrade package.

[0095] The retransmission count is the number of times an external device repeatedly sends the same upgrade package.

[0096] The preset threshold is a pre-defined maximum number of retransmissions, used to control the upper limit of retransmissions.

[0097] Exiting OTA upgrade means terminating the transmission process of the upgrade package and no longer attempting to continue transmission; the electromagnetic descaling processor will maintain its original operational status.

[0098] During execution, the electromagnetic descaling processor operates in a business state, receiving OTA upgrade packages from external devices and writing them one by one to the corresponding storage area. After a single upgrade package is received, the processor verifies the received data. Once it confirms the data is complete and successfully written to the corresponding storage address, it sends upgrade package feedback information back to the external device via the communication link, informing the external device that the data packet has been correctly received and processed. Each time an external device sends an OTA upgrade package, an internal timer starts. If the corresponding upgrade package feedback information is received within a preset time, the transmission of the package is considered successful, and the next upgrade package is sent; or the transmission process ends after all packages have been sent.

[0099] If the external device does not receive the corresponding upgrade package feedback information within the preset time, the transmission is deemed to have failed, possibly due to packet loss, data errors, or an abnormal write operation by the electromagnetic descaling processor. In this case, the external device resends the corresponding OTA upgrade package and resets the timer to wait for feedback again. Each resend executes the same verification and feedback logic. If feedback is still not received within the preset time after resend, it is resent again. When the number of resends reaches a preset threshold and no upgrade package feedback information is received, it indicates a persistent fault in the current communication link, or an anomaly on the electromagnetic descaling processor side that cannot be resolved by resending. Continuing to resend will not achieve the expected results. At this point, the external device stops resending, exits the OTA upgrade process, and no longer attempts to transmit. The electromagnetic descaling processor side continues to run the electromagnetic descaling business code, maintaining normal operation and awaiting subsequent upgrade attempts.

[0100] Please see Figure 7 , Figure 7 This is a flowchart illustrating the OTA upgrade process. After power-on, the entire process begins. The processor runs the bootloader in the first region and performs verification in the third region: determining whether the 8 bytes after offset n bytes in the first region contain valid verification and length information.

[0101] When valid verification and length information is obtained, the second area is erased, the first area is copied to the second area, the first area is erased again, the firmware update is completed, and then the process jumps to the second area to run the electromagnetic descaling business code.

[0102] If no valid verification or length information is found, the process jumps to the second zone and runs the electromagnetic descaling business code.

[0103] During the operation of the electromagnetic descaling service code in Zone 2, the processor will determine whether Zone 2 needs to be upgraded via 4G, wired, or Bluetooth communication links.

[0104] If it is determined that upgrading the second zone is not necessary, the electromagnetic descaling service code will be run directly to continuously provide water treatment descaling functions.

[0105] If it is determined that the second region needs to be upgraded, the first region is erased, and data is written to the first region packet by packet, while receiving upgrade data packets sent from the outside. When the last packet of data is received, the processor calculates a checksum and performs a verification comparison with all the upgrade firmware data stored in the first region.

[0106] If the verification in the first zone fails, the electromagnetic descaling service code will be executed directly without performing a firmware update.

[0107] If the verification in the first area is successful, the process jumps to the second area to execute the business code. Then the process returns to the beginning and the power-on boot process is executed again.

[0108] This embodiment, through the three partitions of the memory and the above process, can ensure that the device can autonomously resume business operation in the event of power outages, transmission abnormalities, or other situations during the upgrade, thereby reducing the workload of on-site maintenance.

[0109] This effectively addresses packet loss and error issues in complex industrial communication environments, improving the success rate of OTA upgrade packet transmission. Furthermore, through confirmation feedback from the electromagnetic descaling processor, external devices can accurately monitor the transmission status of each data packet, promptly detect transmission anomalies, and execute retransmissions, preventing the entire upgrade from failing due to the loss of a single packet.

[0110] In some implementations, the OTA upgrade package includes embedded parameter fields, electromagnetic descaling processor address fields, command words fields, software version fields, current package sequence number fields, maximum package length fields, current package actual length fields, upgrade package entity fields, and checksum fields. The command field contains a preset value that identifies the upgrade control instruction. The first preset byte of the software version field is the electromagnetic descaling processor type, and the second preset byte of the software version field is the software version number, which is used for version matching and to avoid duplicate upgrades. The preset verification information in the embedded parameter field is obtained by setting the byte data at the preset offset position to zero and then performing verification calculation.

[0111] Specifically, in related technologies, the format of upgrade data packages often lacks a unified standard, and the field definitions and arrangement order are quite arbitrary, which leads to complex parsing logic on the electromagnetic descaling processor side. Upgrade packages of different versions or different electromagnetic descaling processors are prone to being mixed up or misidentified.

[0112] To address the aforementioned issues, this application provides a standardized definition of the structure of the OTA upgrade package, dividing it into multiple ordered fields based on function. Each field is responsible for functions such as address identification, instruction recognition, version matching, sub-package management, firmware carrying, and integrity verification. At the same time, it clarifies the calculation rules for the preset verification information. By setting the byte data at the preset offset position to zero before performing the verification calculation, the problem of loop calculation is avoided, thereby improving the accuracy of verification and the standardization of the upgrade package format.

[0113] The embedded parameter field is a structured data segment set at a fixed offset position in the upgrade firmware, used to carry the length information and preset verification information of the upgrade firmware.

[0114] The electromagnetic descaling processor address field is a field in the data packet used to identify the address of the target electromagnetic descaling processor. It is used for electromagnetic descaling processor addressing during communication to ensure that the upgrade package is sent to the specified target electromagnetic descaling processor.

[0115] The command word field carries the encoding of operation instructions. The preset value in this field corresponds to the upgrade control instruction. After parsing this field, the electromagnetic descaling processor can identify the function type of the data packet and execute the corresponding upgrade processing logic. The command word field uniformly identifies the upgrade control instruction through preset values. After parsing the command word, the electromagnetic descaling processor can enter the corresponding upgrade processing flow without requiring additional instruction recognition logic.

[0116] The software version field records information related to the software version. The first preset byte identifies the electromagnetic descaling processor type, and the second preset byte identifies the software version number. These two bytes work together to perform version matching verification and avoid duplicate upgrades. The two-byte division of the software version field enables dual verification of both the electromagnetic descaling processor type and the software version. After receiving an upgrade package, the electromagnetic descaling processor first compares its type; if the type does not match, the upgrade is rejected, preventing program anomalies caused by mixing upgrade packages from different electromagnetic descaling processors. Then, it compares the software version number; if the current running version is equal to or higher than the upgrade package version, the upgrade operation is not performed, avoiding duplicate upgrades and version rollbacks.

[0117] The current packet sequence number field is a field that identifies the sequential number of the current data packet in the complete upgrade packet, and is used for data sorting and packet loss identification in packet transmission mode.

[0118] The maximum packet length field is a field that identifies the maximum allowed data length of a single packet. It is used by both parties to agree on the upper limit of data in a single packet and to standardize the transmission format.

[0119] The current packet actual length field identifies the actual data length of the current data packet and is used by the receiving end to verify the integrity of a single packet and determine whether there is truncation or packet loss. In some implementations, the current packet sequence number, maximum packet length, and current packet actual length fields work together to support packet transmission of large firmware files. The electromagnetic descaling processor can sort the received data packets according to the packet sequence number and verify the integrity of a single packet by combining the maximum packet length and the actual length, thus promptly detecting packet loss and error issues.

[0120] The upgrade package entity fields are the fields that carry the actual firmware program data and are the main component of the upgrade package. The embedded parameter fields are located at a preset offset position in the upgrade package entity and are transmitted and stored along with the firmware data. The upgrade package entity fields carry the main firmware program data, and the embedded parameter fields are embedded in fixed positions within them and written to the storage area along with the firmware data, serving as the identification basis for the electromagnetic descaling processor's startup verification.

[0121] The checksum field is calculated by verifying all data in a single packet and is used for integrity verification during single packet transmission. The checksum field provides single-packet-level transmission integrity verification, forming a two-level verification system with the firmware integrity verification at the whole packet level provided by the embedded parameter field, ensuring the correctness of the transmission process and the final stored firmware, respectively.

[0122] For the preset verification information in the embedded parameter fields, when calculating the preset verification information, first set all the byte data at the preset offset position to zero, so that the position is in a blank initial state. Then, perform the verification calculation on the complete upgrade firmware data, and fill the corresponding position of the embedded parameter field with the calculation result to form the final preset verification information. In this way, the loop logic problem caused by the verification value itself participating in the calculation can be avoided, ensuring the logical consistency of the verification calculation. It also makes it easy for the electromagnetic descaling processor to use the same method to calculate the actual verification information, improving the accuracy and comparability of the verification results.

[0123] In this way, through multi-dimensional field design, multiple functions such as electromagnetic descaling processor addressing, instruction recognition, version matching, package management and multi-level verification can be realized, thereby effectively avoiding various problems such as electromagnetic descaling processor mismatch, repeated upgrades, transmission packet loss and data errors, and improving the success rate and stability of OTA upgrades.

[0124] Please see Figure 8 In some embodiments, this application also provides an OTA upgrade device 1000, which is applied to an electromagnetic descaling processor to implement the above-mentioned OTA upgrade method. The storage area of ​​the electromagnetic descaling processor is divided into a first area, a second area, and a third area. The first area is used to guide and verify the OTA upgrade package, the second area is used to run the electromagnetic descaling service, and the third area is used to store the upgrade firmware of the OTA upgrade package. The device includes: The verification module 100 is configured to run the program in the first zone after the electromagnetic descaling processor is started, and read the embedded parameter field at the preset offset position in the third zone to determine whether the third zone stores the upgrade firmware of the OTA upgrade package, the upgrade firmware including the embedded parameter field. The jump execution module 200 is configured to jump to the second zone to run the electromagnetic descaling business code if there is no OTA upgrade package upgrade firmware in the third zone; and to erase the original business firmware in the second zone and write the upgrade firmware into the second zone if there is an OTA upgrade package upgrade firmware stored in the third zone. The cleaning module 300 is configured to erase the upgrade firmware stored in the third zone after writing the upgrade firmware to the second zone, and then jump to the second zone to run the electromagnetic descaling business code after the upgrade firmware is erased, so as to realize OTA upgrade.

[0125] Specifically, the OTA upgrade device 1000 is a functional entity integrated inside the electromagnetic descaling processor, used to carry out and execute the complete OTA upgrade logic. Its program code is stored in different storage partitions and runs sequentially according to the preset execution order.

[0126] Among them, the verification module 100 is a functional module responsible for guiding and verifying the electromagnetic descaling processor during the startup phase. Its program is stored in the first area. After the electromagnetic descaling processor is powered on, it is the first to obtain running permission and has the ability to perform basic hardware initialization, read stored data, and perform integrity verification calculations.

[0127] The jump execution module 200 is a functional module responsible for process branch selection and firmware writing. It can execute different operation branches according to the verification results to complete business program jump or firmware update writing.

[0128] The cleaning module 300 is a functional module responsible for cleaning up the cache after the upgrade and the final business jump. It is used to clear cache data after the upgrade is completed, release storage resources and guide the electromagnetic descaling processor into normal business operation.

[0129] After the electromagnetic descaling processor is powered on, the verification module 100 runs first, completing the initialization configuration of basic hardware such as the clock and storage interface. Then, the verification module 100 locates the preset offset address of the third zone, reads the embedded parameter field at that location, parses the length information and preset verification information in the field, defines the firmware data range based on the length information, and calculates the actual verification information. By comparing the actual verification information with the preset verification information, it determines whether the third zone stores a complete and valid OTA upgrade package firmware. The judgment result output by the verification module 100 serves as the basis for subsequent process branch selection and is passed to the jump execution module 200.

[0130] After receiving the judgment result, the jump execution module 200 executes the corresponding operation according to the preset branch logic. If it is determined that there is no upgrade firmware in the third zone, the jump execution module 200 directly modifies the program counter address, jumps to the business program entry point in the second zone, transfers system control to the business firmware, and the electromagnetic descaling processor enters the electromagnetic descaling business operation state. If it is determined that the third zone stores upgrade firmware, the jump execution module 200 first calls the storage driver to perform a full erase operation on the original business firmware in the second zone, completely clearing the original firmware data and reserving continuous and complete storage space for writing the new firmware. After the erase operation is completed, the jump execution module 200 reads the upgrade firmware data in the third zone and writes it segment by segment to the corresponding storage location in the second zone according to the address mapping relationship, completing the firmware update write operation.

[0131] After the firmware writing operation is completed, the cleanup module 300 takes over process control. It first calls the storage driver to erase all upgrade firmware data stored in the third zone, clearing cached upgrade data and freeing up storage space in the third zone. This also prevents residual firmware data from accidentally triggering the upgrade process when the electromagnetic descaling processor starts up. After erasing the third zone, the cleanup module 300 performs another program address jump, transferring system control to the second zone and running the updated electromagnetic descaling business code. The electromagnetic descaling processor then enters normal working condition with the new firmware version, thus completing the full OTA upgrade process.

[0132] Thus, relying on the collaborative cooperation between various modules, the OTA upgrade device provided in this application constructs a stable and reliable upgrade boot system through the functional separation design of the first, second, and third zones. The boot program is never affected by the business firmware upgrade. Even if the firmware in the business zone is damaged, it can be repaired and re-upgraded through the boot program, effectively avoiding the situation where the electromagnetic descaling processor cannot operate due to upgrade failure. Furthermore, by fully caching the upgrade firmware to the third zone before writing it to the business zone, the integrity of the firmware data written to the business zone can be ensured, reducing the risk of data errors during the upgrade process. In addition, the interruption of the business program during the upgrade process only occurs during the brief firmware erasure and writing phase, which can minimize the business interruption time and reduce the impact of the upgrade on the industrial production process. It should also be noted that the upgrade firmware in the third zone is automatically cleaned after the upgrade is completed, which not only releases storage resources but also avoids repeated triggering of the upgrade process during subsequent startups, ensuring the long-term stability of the electromagnetic descaling processor.

[0133] This application also provides an electronic device having a computer program stored thereon. The steps of the above method are implemented when the processor executes the computer program.

[0134] It is understood that a computer program includes computer program code. Computer program code can be in the form of source code, object code, executable files, or some intermediate form. Electronic devices can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), and software distribution media, etc.

[0135] This application also provides an electromagnetic descaling processor, which includes the aforementioned electronic device.

[0136] Specifically, an electromagnetic descaling processor is an industrial functional electromagnetic descaling processor applied to water treatment systems. It acts on flowing water by outputting an alternating electromagnetic field with specific parameters, changing the physical properties and crystal morphology of scale-forming ions in the water to achieve scale prevention and removal functions. It typically includes a control unit, a power drive unit, an electromagnetic coil, a status detection unit, and a protective housing. The electronic device, as the control unit of the electromagnetic descaling processor, is built into the processor's housing and establishes electrical connections with peripheral circuits such as the power drive unit, status detection unit, and external communication interfaces. It is responsible for outputting control signals, collecting operating status data, executing external communication interactions, and handling the entire firmware upgrade process. The electronic device's memory stores complete electromagnetic descaling operation programs and OTA upgrade programs. The processor manages the entire processor's functions and upgrades by running the corresponding program instructions.

[0137] Thus, the electromagnetic descaling processor provided in this application constructs a stable and reliable upgrade boot system through the functional separation design of the first, second, and third zones. The boot program is always unaffected by the business firmware upgrade. Even if the business area firmware is damaged, it can be repaired and re-upgraded through the boot program, effectively avoiding the situation where the electromagnetic descaling processor cannot operate due to upgrade failure. Furthermore, by fully caching the upgrade firmware to the third zone before writing it to the business area, the integrity of the firmware data written to the business area can be ensured, reducing the risk of data errors during the upgrade process. In addition, the interruption of the business program during the upgrade process only occurs during the brief firmware erasure and writing phase, which can minimize the business interruption time and reduce the impact of the upgrade on the industrial production process. It should also be noted that the upgrade firmware in the third zone is automatically cleaned after the upgrade is completed, which not only releases storage resources but also avoids repeated triggering of the upgrade process during subsequent startups, ensuring the long-term stability of the electromagnetic descaling processor.

[0138] This application also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the above-described method.

[0139] In this specification, the terms "specifically," "furthermore," "particularly," "understandably," etc., refer to specific features, structures, materials, or characteristics described in connection with embodiments or examples that are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0140] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of executable request code comprising one or more steps for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order according to the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0141] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.

Claims

1. An OTA upgrade method applied to an electromagnetic descaling processor, characterized in that, The storage area of ​​the electromagnetic descaling processor is divided into a first area, a second area, and a third area. The first area is used to boot and verify the OTA upgrade package, the second area is used to run the electromagnetic descaling service, and the third area is used to store the upgrade firmware of the OTA upgrade package. The method includes: After the electromagnetic descaling processor is started, the program in the first area is run to read the embedded parameter field at the preset offset position of the third area to determine whether the third area stores the upgrade firmware of the OTA upgrade package, and the upgrade firmware includes the embedded parameter field. If the OTA upgrade package firmware is not available in the third zone, the system will jump to the second zone to run the electromagnetic descaling service code. If the upgrade firmware of the OTA upgrade package is stored in the third area, the original service firmware in the second area is erased, and the upgrade firmware is written to the second area. After the upgrade firmware is written to the second area, the upgrade firmware stored in the third area is erased, and after the upgrade firmware is erased, the system jumps to the second area to run the electromagnetic descaling service code to realize the OTA upgrade.

2. The method according to claim 1, characterized in that, The step of reading the embedded parameter field at the preset offset position of the third zone to determine whether the third zone stores the upgrade firmware of the OTA upgrade package includes: Parse the embedded parameter fields to obtain the upgrade firmware length information and preset verification information; Calculate the actual verification information of the upgraded firmware based on the upgraded firmware length information; The actual verification information is compared with the preset verification information; If the actual verification value is consistent with the preset verification information, it is determined that the third area stores the upgrade firmware of the OTA upgrade package; If the actual verification value is inconsistent with the preset verification information, it is determined that the third zone does not contain the upgrade firmware of the OTA upgrade package.

3. The method according to claim 2, characterized in that, The embedded parameter field is 8 bytes long. The first 4 bytes of the embedded parameter field are used to indicate the length information of the upgraded firmware, and the last 4 bytes of the embedded parameter field are used to indicate the preset verification information.

4. The method according to claim 1, characterized in that, The method further includes: During the process of running the electromagnetic descaling service code in the second zone, based on the OTA upgrade request sent by the external device in response to the second zone, the original data stored in the third zone is erased, and the original data includes the upgrade firmware of the historical version OTA upgrade package. Receive OTA upgrade packages sent by the external device and write them to the third area one by one; Upon completion of receiving the OTA upgrade package, an integrity check is performed on the upgrade firmware within the third zone. If the integrity check passes, restart the electromagnetic descaling processor; If the integrity check fails, the electromagnetic descaling service code will continue to run.

5. The method according to claim 4, characterized in that, The method further includes: If a power outage occurs during the OTA upgrade data packet reception process, the electromagnetic descaling processor will run the program in the first area after power-on and read the embedded parameter field at the preset offset position in the third area to determine whether the third area stores the upgrade firmware of the OTA upgrade package. The upgrade firmware includes the embedded parameter field. If the OTA upgrade package firmware is not available in the third zone, the system will jump to the second zone to run the electromagnetic descaling service code. If the upgrade firmware of the OTA upgrade package is stored in the third area, the original service firmware in the second area is erased, and the upgrade firmware is written to the second area. After the upgrade firmware is written to the second area, the upgrade firmware stored in the third area is erased, and after the upgrade firmware is erased, the system jumps to the second area to run the electromagnetic descaling service code to realize the OTA upgrade.

6. The method according to claim 5, characterized in that, The method further includes: If the original business firmware of the second zone is erased during the process of the first zone program erasing the original business firmware or the upgrade firmware is written to the second zone, the electromagnetic descaling processor will restart and run the first zone program again to read the embedded parameter field at the preset offset position of the third zone, so as to erase the original business firmware of the second zone again and write the upgrade firmware to the second zone.

7. The method according to claim 4, characterized in that, The method further includes: Upon receiving the OTA upgrade package sent by the external device, if it is determined that the OTA upgrade package has been received and verified without error and successfully written to the third area, the upgrade package feedback information is sent back to the external device. The upgrade package feedback information is used to indicate that the current OTA upgrade package has been correctly received and processed by the electromagnetic descaling processor. If the external device does not receive the upgrade package feedback information within a preset time, the OTA upgrade package will be resent. If the upgrade package feedback information is not received after the number of resends reaches the preset threshold, the OTA upgrade will be terminated.

8. The method according to claim 1, characterized in that, The OTA upgrade package includes the embedded parameter field, electromagnetic descaling processor address field, command word field, software version field, current package sequence number field, package maximum length field, current package actual length field, upgrade package entity field, and checksum field; The command field contains a preset numerical identifier for the upgrade control instruction; The first preset byte of the software version field is the electromagnetic descaling processor type, and the second preset byte of the software version field is the software version number, which is used for version matching and to avoid repeated upgrades. The preset verification information in the embedded parameter field is obtained by performing verification calculations after setting the byte data at the preset offset position to zero.

9. An OTA upgrade device, characterized in that, The OTA upgrade device is applied to the electromagnetic descaling processor to implement the OTA upgrade method as described in any one of claims 1-8. The storage area of ​​the electromagnetic descaling processor is divided into a first area, a second area, and a third area. The first area is used to guide and verify the OTA upgrade package, the second area is used to run the electromagnetic descaling service, and the third area is used to store the upgrade firmware of the OTA upgrade package. The device includes: The verification module is configured to run the program in the first area after the electromagnetic descaling processor is started, and read the embedded parameter field at the preset offset position of the third area to determine whether the third area stores the upgrade firmware of the OTA upgrade package, wherein the upgrade firmware includes the embedded parameter field. The jump execution module is configured to, if the upgrade firmware of the OTA upgrade package is not present in the third zone, jump to the second zone to run the electromagnetic descaling service code; and if the upgrade firmware of the OTA upgrade package is stored in the third zone, erase the original service firmware in the second zone and write the upgrade firmware into the second zone. The cleaning module is configured to erase the upgrade firmware stored in the third area after the upgrade firmware is written to the second area, and then jump to the second area to run the electromagnetic descaling service code after the upgrade firmware is erased, so as to realize the OTA upgrade.

10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, which, when executed by the processor, implements the OTA upgrade method as described in any one of claims 1-8.

11. An electromagnetic descaling processor, characterized in that, The electromagnetic descaling processor includes the electronic device as described in claim 10.