Firmware upgrade method and its device, server, terminal device and storage medium
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2026-04-07
AI Technical Summary
Existing firmware upgrade methods for IoT devices with limited computing power and storage resources are insecure, as traditional security management solutions like firewalls and application stores cannot effectively prevent security risks during the upgrade process.
A method involving a server-side process that divides firmware upgrade packets into sub-upgrade packets based on unique identification codes of target devices, reorders them if necessary, and transmits these packets securely to ensure each device receives a customized upgrade process, enhancing security by preventing leaks and tampering.
This approach significantly enhances the security of firmware upgrades by making it difficult for attackers to intercept or alter the upgrade process, protecting multiple devices from security breaches even if one is compromised.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
[Technical Field]
[0001] This application claims priority to a Chinese patent application filed on October 21, 2022, bearing application number 202211295975.2, the entire contents of which are incorporated herein by reference.
[0002] The present invention relates to the technical field of firmware upgrade, and more particularly to a firmware upgrade method and its device, server, terminal device and storage medium. [Background technology]
[0003] Unlike traditional network security, Internet of Things (IoT) security is the product of integrating network security with other engineering disciplines. Compared with simple data, server, network infrastructure, and information security, the meaning of IoT security is richer. Furthermore, IoT security must also include direct or distributed monitoring and control of the status of networked physical systems.
[0004] The Internet of Things (IoT) system has a large number of terminal devices, most of which are single-chip microcomputer devices with limited computing power and storage resources. In this resource-constrained device environment, traditional operating system-based security management solutions such as firewalls and application stores cannot guarantee device security during upgrade operations.
[0005] Therefore, there is an urgent need in this field for a secure firmware upgrade method to effectively avoid security risks during the firmware upgrade process of terminal equipment. Summary of the Invention
[0006] The present invention provides a firmware upgrade method and a device, server, terminal device and storage medium thereof, which can effectively avoid security risks in the firmware upgrade process.
[0007] According to an embodiment of the present disclosure, a firmware upgrade method applied to a server side is provided, including the steps of: acquiring a target firmware upgrade packet; acquiring the target firmware upgrade packet; receiving an identification code of the target terminal device; dividing the target firmware upgrade packet into sub-upgrade packets based on the identification code of the target terminal device; and storing the sub-upgrade packets and / or sending the sub-upgrade packets to the target terminal device.
[0008] According to an embodiment of the present disclosure, the firmware upgrade method applied to the server side further includes a step of obtaining the size of the sub-upgrade packet through the identification code of the target terminal device and determining the number of sub-upgrade packets to be divided based on the size of the sub-upgrade packet.
[0009] According to an embodiment of the present disclosure, the firmware upgrade method applied to the server side further includes a step of determining a download address for the target terminal device to download the sub-upgrade packet based on the identification code of the sub-upgrade packet and the default changeable address.
[0010] According to an embodiment of the present disclosure, the firmware upgrade method applied to the server side further includes the steps of: obtaining a sub-upgrade packet order identifier through an identification code of a target terminal device; determining whether the order of the sub-upgrade packets has been changed based on the sub-upgrade packet order identifier; and, if it is determined that the order of the sub-upgrade packets has not been changed, numbering the sub-upgrade packets according to their initial order; and, if it is determined that the order of the sub-upgrade packets has been changed, changing the order of the sub-upgrade packets and numbering the sub-upgrade packets according to the changed order of the sub-upgrade packets.
[0011] In the firmware upgrade method applied to the server side according to the embodiment of the present disclosure, each of the sub-upgrade packets includes a sub-upgrade packet header including a sub-upgrade packet number.
[0012] In a firmware upgrade method applied to a server side according to an embodiment of the present disclosure, the header of the sub-upgrade packet further includes an identification code of the target terminal device and at least one of the number of sub-upgrade packets divided from the target firmware upgrade packet.
[0013] According to an embodiment of the present disclosure, in a firmware upgrade method applied to a server side, the step of determining whether the order of the sub-upgrade packets has been changed based on the order identifier of the sub-upgrade packets includes the steps of identifying a value indicated by the order identifier and determining whether the order of the sub-upgrade packets has been changed based on the value indicated by the order identifier.
[0014] According to an embodiment of the present disclosure, in a firmware upgrade method applied to a server side, the step of determining whether the order of the sub-upgrade packets has been changed based on the value indicated by the order identifier includes the step of determining whether the order of the sub-upgrade packets has been changed based on whether the value indicated by the order identifier is a first predetermined value.
[0015] According to an embodiment of the present disclosure, in a firmware upgrade method applied to a server side, the step of determining whether the order of the sub-upgrade packets has been changed based on the value indicated by the order identifier includes the step of obtaining a remainder of the value indicated by the order identifier by a second predetermined value that is a natural number greater than or equal to 2, and determining whether the order of the sub-upgrade packets has been changed based on the remainder.
[0016] According to an embodiment of the present disclosure, in a firmware upgrade method applied to a server side, the second predetermined value is 2, and the step of determining whether the order of the sub-upgrade packets has been changed based on the value indicated by the order identifier includes the step of determining whether the order of the sub-upgrade packets has been changed based on the parity of the value indicated by the order identifier.
[0017] According to an embodiment of the present disclosure, in a firmware upgrade method applied to a server side, the step of changing the order of the sub-upgrade packets based on the order identifier includes identifying a value indicated by the order identifier and changing the order of the sub-upgrade packets based on the value indicated by the order identifier.
[0018] In a firmware upgrade method applied to a server side according to an embodiment of the present disclosure, the order identifier includes data of a predetermined number of bits, and the step of identifying a value indicated by the order identifier includes a step of identifying a value indicated by the data, and the step of changing the order of the sub-upgrade packets includes a step of dividing the sub-upgrade packets into sub-upgrade packet groups, each sub-upgrade packet group including a specific number of sub-upgrade packets whose initial order is adjacent, the specific number being one plus the maximum value that can be indicated by the data of the predetermined number of bits, and a step of changing the order of two sub-upgrade packets in each sub-upgrade packet group, whose difference in initial order is the value indicated by the data.
[0019] According to an embodiment of the firmware upgrade method applied to the server side of the present disclosure, the step of changing the order of the sub-upgrade packets includes: dividing the sub-upgrade packets into sub-upgrade packet groups, each sub-upgrade packet group including a specific number of sub-upgrade packets whose initial order is adjacent, the specific number being predetermined by the server; and changing the order of two sub-upgrade packets in each sub-upgrade packet group whose difference in initial order is less than the value of the specific number.
[0020] According to an embodiment of the present disclosure, a firmware upgrade method applied to a server side includes generating a matrix according to the number of sub-upgrade packets and arranging the sub-upgrade packets in the matrix, and changing the order of the sub-upgrade packets includes translating the sub-upgrade packets in the matrix according to an order identifier.
[0021] According to an embodiment of the present disclosure, in a firmware upgrade method applied to a server side, the step of generating a matrix according to the number of sub-upgrade packets includes a step of determining whether to generate an odd-dimensional matrix or an even-dimensional matrix according to the number of sub-upgrade packets.
[0022] According to an embodiment of the present disclosure, the firmware upgrade method applied on the server side further includes filling a matrix with one or more of garbled packets, empty packets, and duplicated sub-upgrade packets.
[0023] In a firmware upgrade method applied to a server side according to an embodiment of the present disclosure, the order identifier indicates one or more of the number of translations of the sub-upgrade packet in the matrix, the shift-out direction of the sub-upgrade packet, and the clockwise or counterclockwise rotation of the sub-upgrade packet in the matrix.
[0024] According to an embodiment of the present disclosure, the firmware upgrade method applied to the server side further includes determining a translation method for the sub-upgrade packet according to the serial number in the matrix of the sub-upgrade packet and the dimension of the matrix.
[0025] According to an embodiment of the present disclosure, the firmware upgrade method applied to the server side further includes a step of storing and / or sending a header of a target firmware upgrade packet to the target terminal device, where the header of the target firmware upgrade packet includes one or more of an identification code of the target terminal device, the number and number of sub-upgrade packets, a firmware upgrade key, and integrity verification information.
[0026] According to an embodiment of the present disclosure, a firmware upgrade method applied to a terminal device is provided, including the steps of obtaining a firmware upgrade command, transmitting an identification code of the target terminal device, downloading sub-upgrade packets from a server, and integrating the sub-upgrade packets into a target firmware upgrade packet based on the identification code of the target terminal device.
[0027] A firmware upgrade method applied to a server side according to an embodiment of the present disclosure further includes the steps of downloading a firmware upgrade packet header from the server and performing the following processes through a secure boot program: determining whether to change the order of the downloaded sub-upgrade packets based on an order identifier in the identification code of the terminal device in response to downloading all sub-upgrade packets and the firmware upgrade packet header to the terminal device; performing security or integrity verification on the downloaded sub-upgrade packets; and operating the target firmware integrated with the sub-upgrade packets in response to the security or integrity verification of the downloaded sub-upgrade packets being successful.
[0028] According to a firmware upgrade method applied to a server side according to an embodiment of the present disclosure, the step of obtaining a firmware upgrade command includes a step of disconnecting from a wide area network and obtaining a firmware upgrade command and a security verification key, the step of downloading a sub-upgrade packet from the server includes a step of obtaining a firmware upgrade packet and a security key for the firmware upgrade packet via the wide area network, and security verification for the downloaded sub-upgrade packet includes a step of determining whether the security verification key matches the security key of the firmware upgrade packet.
[0029] According to an embodiment of the present disclosure, there is provided a firmware upgrade device applied to a server, which includes a firmware upgrade packet acquisition device for acquiring a target firmware upgrade packet, a receiving device for receiving an identification code of the target terminal device, a dividing device for dividing the target firmware upgrade packet into sub-upgrade packets based on the identification code of the target terminal device, and a storage and transmission device for storing and / or transmitting the sub-upgrade packets to the target terminal device.
[0030] According to an embodiment of the present disclosure, a firmware upgrade device applicable to a terminal device is provided, which includes: a firmware upgrade command acquisition device for acquiring a firmware upgrade command; a transmission device for transmitting an identification code of a target terminal device; a download and reception device for downloading and receiving sub-upgrade packets; and an integration device for integrating the sub-upgrade packets into a target firmware upgrade packet based on the identification code of the target terminal device.
[0031] According to an embodiment of the present disclosure, a server including a memory and one or more processors is provided, wherein a computer program is stored in the memory, and when the computer program is executed by the one or more processors, a firmware upgrade method applied to the server is performed.
[0032] According to an embodiment of the present disclosure, a terminal device is provided that includes a memory and one or more processors, wherein a computer program is stored in the memory, and when the computer program is executed by the one or more processors, a firmware upgrade method applicable to the above terminal device is performed.
[0033] According to an embodiment of the present disclosure, a secure boot method applied to a terminal device is provided, which includes the steps of: determining whether to change the order of the downloaded sub-upgrade packets based on an order identifier in an identification code of the terminal device in response to downloading all sub-upgrade packets and a firmware upgrade packet header to the terminal device; performing security or integrity verification on the downloaded sub-upgrade packets; and activating the target firmware integrated in the sub-upgrade packets in response to the downloaded sub-upgrade packets successfully passing the security or integrity verification.
[0034] According to an embodiment of the present disclosure, a security verification method applied to a target terminal device is provided, which includes the steps of disconnecting from a wide area network and obtaining a firmware upgrade command and a security verification key, obtaining a firmware upgrade packet and a security key for the firmware upgrade packet via the wide area network, and determining whether the security verification key matches the security key for the firmware upgrade packet.
[0035] According to the security verification method of an embodiment of the present disclosure, the step of obtaining a firmware upgrade packet via a wide area network includes a step of downloading a sub-upgrade packet from a server, and the method further includes a step of sending an identification code of the target terminal device, and aggregating the sub-upgrade packet into a target firmware upgrade packet based on the identification code of the target terminal device.
[0036] The security verification method according to an embodiment of the present disclosure further includes downloading a firmware upgrade packet header from a server and performing the following processes through a secure boot program: determining whether to change the order of the downloaded sub-upgrade packets based on an order identifier in the identification code of the target terminal device in response to downloading all sub-upgrade packets and the firmware upgrade packet header to the target terminal device; performing security or integrity verification on the downloaded sub-upgrade packets; and operating the target firmware integrated with the sub-upgrade packets in response to the security or integrity verification of the downloaded sub-upgrade packets being successful.
[0037] These and other aspects, features, and advantages of particular embodiments of the present disclosure will become more apparent from the following description taken in conjunction with the accompanying drawings. [Brief explanation of the drawings]
[0038] [Figure 1] 1 is a flowchart of a firmware upgrade method applied to a server according to an embodiment of the present disclosure. [Figure 2] 1 is a flowchart of a firmware upgrade method applied to a terminal device according to an embodiment of the present disclosure; [Figure 3] 1 is a flowchart of a firmware upgrade method applied to a server according to an embodiment of the present disclosure. [Figure 4] 1 is a flowchart of a firmware upgrade method applied to a terminal device according to an embodiment of the present disclosure; [Figure 5A] FIG. 10 is a schematic diagram illustrating a server reordering sub-upgrade packets in an odd-dimensional matrix clockwise with a shift-out direction to the left, according to an embodiment of the present disclosure. [Figure 5B]FIG. 10 is a schematic diagram illustrating a server reordering sub-upgrade packets in an odd-dimensional matrix clockwise with a shift-out direction to the left, according to an embodiment of the present disclosure. [Figure 5C] FIG. 10 is a schematic diagram illustrating a server reordering sub-upgrade packets in an odd-dimensional matrix clockwise with a shift-out direction to the left, according to an embodiment of the present disclosure. [Figure 5D] FIG. 10 is a schematic diagram of a reverse process of a data packet translation process according to an embodiment of the present disclosure. [Figure 6] 10 is a flowchart for determining a method for translating data packets in an odd matrix according to an embodiment of the present disclosure. [Figure 7] 10 is a flowchart of a reverse process of translating a data packet according to an embodiment of the present disclosure. [Figure 8] 10 is a flowchart illustrating a process for determining the number of translations that must be performed by the server to restore the order of the sub-upgrade packets, according to an embodiment of the present disclosure. [Figure 9A] FIG. 10 is a schematic diagram of a method for a server to translate data packets into an odd-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure. [Figure 9B] FIG. 10 is a schematic diagram of a method for a server to translate data packets into an odd-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure. [Figure 9C] FIG. 10 is a schematic diagram of a method for a server to translate data packets into an odd-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure. [Figure 9D] FIG. 10 is a schematic diagram of a method for a server to translate data packets into an odd-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure. [Figure 10] FIG. 10 is a schematic diagram illustrating a server reordering sub-upgrade packets based on an order identifier indicating a shift-out direction is left, counterclockwise, according to an embodiment of the present disclosure. [Figure 11]FIG. 11 is a schematic diagram illustrating a server reordering sub-upgrade packets in an even-dimensional matrix clockwise with a shift-out direction to the left, according to an embodiment of the present disclosure. [Figure 12] FIG. 12 is a flowchart for determining a method for translating data packets in a matrix with even dimensions according to an embodiment of the present disclosure. [Figure 13A] FIG. 10 is a schematic diagram illustrating how a server translates data packets into an even-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure. [Figure 13B] FIG. 10 is a schematic diagram illustrating how a server translates data packets into an even-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure. [Figure 13C] FIG. 10 is a schematic diagram illustrating how a server translates data packets into an even-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure. [Figure 13D] FIG. 10 is a schematic diagram illustrating how a server translates data packets into an even-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure. [Figure 14] FIG. 14 is a diagram illustrating a firmware upgrade device applied to a server according to an embodiment of the present disclosure. [Figure 15] FIG. 15 is a diagram illustrating a firmware upgrade device applied to a terminal device according to an embodiment of the present disclosure. [Figure 16] FIG. 16 is a flowchart of a secure boot applied to a target terminal device according to an embodiment of the present disclosure. [Figure 17] FIG. 17 is a flowchart of combining offline and online security verification applied to a target terminal device according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE INVENTION
[0039] Before proceeding with the detailed description below, it may be helpful to explain the definitions of certain words and phrases used throughout this patent document. The terms "comprise" and "contain," along with their derivatives, mean including but not limited to. The term "controller" or "control unit" refers to any device, system, or portion thereof that controls at least one operation. Such a controller may be implemented in hardware or a combination of hardware, software, and / or firmware. The functionality associated with a particular controller may be centralized or distributed, whether local or remote. The phrase "at least one," when used in connection with a list of items, means that various combinations of one or more of the listed items may be used, and that only one item from the list may be required. For example, "at least one of A, B, and C" includes any combination of A, B, C, A and B, A and C, B and C, or A, B, and C.
[0040] Definitions of other specific words and phrases are provided throughout this patent document, and those skilled in the art will understand that in many, if not most, cases, the definitions apply to previous and future uses of the words and phrases so defined.
[0041] Various embodiments of the principles of the present disclosure of this patent document are described below in conjunction with the accompanying drawings, which are merely illustrative and should not be construed as limiting the scope of the present disclosure in any way. Those skilled in the art will understand that the principles of the present disclosure may be implemented in any suitably arranged system or device. In some cases, the operations described in the specification may be performed in a different order and still achieve desirable results. Moreover, the processes depicted in the accompanying drawings do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In certain embodiments, multitasking and parallel processing may be advantageous.
[0042] The Internet of Things (IoT) uses various devices and technologies, such as information sensors, radio frequency identification technology, global positioning systems, infrared sensors, and laser scanners, to collect real-time information on any object or process that needs to be monitored, connected, or interacted with. This information, including sound, light, heat, electricity, mechanics, chemistry, biology, and location, is then transmitted through various network access options to achieve ubiquitous connections between objects and people, enabling intelligent recognition, identification, and management of objects and processes. The IoT is an information carrier based on the Internet, traditional telecommunications networks, and other technologies, enabling all independently addressable, ordinary physical objects to form an interconnected network. Unlike traditional network security, IoT security is a product of integrating network security with other engineering disciplines. Compared with simple data, server, network infrastructure, and information security, the implications of IoT security are richer. Furthermore, IoT security must also include direct and distributed monitoring and control of the status of networked physical systems. The Internet of Things system has a large number of terminal devices, most of which are single-chip microcontroller devices with limited computing power and storage resources. In this resource-constrained device environment, traditional operating system-based security management solutions such as firewalls and application stores cannot guarantee the security of devices during upgrades.
[0043] Taking Android-based terminal devices as an example, in some cases, firmware upgrades can be performed through the App Store. The source of the upgrade data packets is legitimate and encrypted during transmission, but the upgrade process is performed in the entire form for both the complete packet and the divided packets. When upgrading the same firmware on each terminal device, the firmware upgrade packet and the upgrade process are the same, which makes it difficult to effectively avoid security risks during the upgrade process. In other cases, firmware upgrades can be performed by downloading an APK-format firmware upgrade packet from a webpage, but this involves the user's subjective judgment and choice regarding risks, making it difficult to effectively avoid security risks during the firmware upgrade process.
[0044] Embodiments of the present invention provide a firmware upgrade method, device, server, terminal device, and storage medium that can effectively avoid security risks in the firmware upgrade process. Because different devices may have different identification codes, the sub-upgrade packets and firmware upgrade processes of different devices may be different. If a single device is hacked, information about other devices will not be leaked, and it is difficult to find patterns in the network and widely disrupt the firmware upgrade of terminal devices. The difficulty of cracking the system is proportional to the number of terminal devices, which is particularly suitable for large-scale sensor and controller networks, and is suitable for military and factory scenarios.
[0045] FIG. 1 is a flowchart of a firmware upgrade method applied to a server according to an embodiment of the present disclosure.
[0046] In step S101, the server obtains a target firmware upgrade packet. For example, a firmware upgrade packet created by a developer can be obtained. When a developer develops upgrade firmware, the upgrade firmware is added to or overwrites the existing firmware on the device, allowing the device to operate at peak efficiency and security again. For example, if there is a defect that needs to be addressed or a new security patch is created, the currently installed firmware becomes obsolete. For devices that frequently access the Internet or whose security features need to be constantly updated, firmware upgrades may occur very frequently. During actual use, the firmware upgrade packet can be considered an entire file, which is debugged and tested by the developer when creating the firmware upgrade packet.
[0047] In step S102, the server receives an identification code of the target terminal device, for example, the server receives the identification code from the target terminal device.
[0048] The target terminal device may refer to the terminal device to be upgraded, which may be any terminal device in the Internet of Things, such as various information sensors, radio frequency identification devices, global positioning systems, infrared sensors, laser scanners, computers, etc.
[0049] In some embodiments, the identification code may refer to the SN (Serial Number) code of the terminal device that has been pre-configured. The firmware upgrade packets in the related art are all created in a unified upgrade packet file. Therefore, when upgrading the firmware of a batch of terminal devices, if each terminal device upgrades the same firmware, the firmware upgrade packet and the upgrade process are all the same. Therefore, if the firmware upgrade packet is monitored during transmission (downloading), the entire firmware upgrade packet may easily be leaked or even tampered with, making it impossible to effectively guarantee the security of terminal devices with the same firmware upgrade requirements when upgrading firmware.
[0050] In the firmware upgrade security mechanism adopted in this embodiment, each terminal device is provided with a specific customized identification code, and upgrade information is provided in at least some fields of the identification code. The identification code is customized for each terminal device, and the identification codes of terminal devices with the same firmware upgrade requirements are configured differently or are not completely identical, so the specific formats for splitting and transmitting (downloading) are not all unified. Therefore, even if information from one terminal device is leaked, it will not cause security problems for all terminal devices in the entire system.
[0051] In some embodiments, the upgrade information includes at least one of a sub-upgrade packet size, a sub-upgrade packet sequence identifier, and a sub-upgrade packet download address offset. The sub-upgrade packet size is the size of each sub-upgrade packet divided from the sub-upgrade packet. For example, the sub-upgrade packet size can be transmitted using 7 bits. The sub-upgrade packet sequence identifier is used to determine whether and how to change the sequence of each sub-upgrade packet. This changes the order in which the divided sub-upgrade packets are transmitted, which increases the complexity of the transmission process and prevents the entire firmware upgrade packet from being leaked or even tampered with if listening. In practice, the sub-upgrade packet sequence identifier can be set for different terminal devices, and can be set randomly or according to a specific rule, but this embodiment is not limited thereto.
[0052] An example of the identification code is shown in Table 1. [Table 1]
[0053] The identification code in Table 1 includes a header field, a sub-upgrade packet sequence identifier, a sub-upgrade packet size, a sub-upgrade packet download address offset, and a tail field. The positions of the sub-upgrade packet sequence identifier, the sub-upgrade packet size, and the sub-upgrade packet download address offset in the identification code are merely exemplary, and they may be arranged in a different order within the identification code. The total number of bits in the identification code and the number of bytes (or bits) of various upgrade information, header fields, tail fields, etc. can be determined according to the configuration rules of the actual identification code. The header field and tail field can be arranged with reference to the header field and tail field of an SN in the related art to identify basic information of the corresponding terminal device. The header field and tail field can also be customized and set. In some cases, the header field and tail field can be omitted, i.e., the identification code consists only of upgrade information.
[0054] In step S103, the server divides the target firmware upgrade packet into sub-upgrade packets based on the identification code of the target terminal device. The server divides the packets for storage or transmission during firmware upgrade. When dividing the packets, the identification number of the terminal device to be upgraded needs to be entered, or the server may automatically divide the firmware upgrade packet based on the identification number of the terminal device. In one embodiment, the server can divide the target firmware upgrade packet into several sub-upgrade packets based on the size of the target firmware upgrade packet and the size of the sub-upgrade packets in the identification code of the target terminal device. Alternatively, the server can divide the target firmware upgrade packet into several sub-upgrade packets based on the size of the target firmware upgrade packet and the size of the predetermined sub-upgrade packets, or other mechanisms. In one embodiment, the server can determine whether and how to change the order of each sub-upgrade packet based on the order identifier of the sub-upgrade packets in the identification code of the target terminal device.
[0055] In step S104, the server stores and / or transmits the sub-upgrade packets to the target terminal device. The server stores each sub-upgrade packet file on the server and transmits it when upgrading the firmware of the target terminal device. Alternatively or additionally, the sub-upgrade packet file is transmitted to the target terminal device while the current target terminal device is undergoing a firmware upgrade. During actual use, the server first stores several divided sub-upgrade packets and then begins transmitting the sub-upgrade packets to the target terminal device upon request from the terminal device. Alternatively or additionally, the server can automatically transmit the sub-upgrade packets to the target terminal device. In one embodiment, to achieve backup, several divided sub-upgrade packets can be stored and transmitted to the target terminal device. In one embodiment, the server can determine the address where the sub-upgrade packets are stored based on the identification code of the target terminal device, and the terminal device can then download the sub-upgrade packets from that address. For example, the server can receive the identification code sn001 of the terminal device from the terminal device. The server stores the sub-upgrade packet in PROTOCOL: / / HOSTNAME / PATH / sn001 based on the default changeable address PROTOCOL: / / HOSTNAME / PATH / SN and the target terminal device's identification code sn001. The target terminal device can download the sub-upgrade packet from the address PROTOCOL: / / HOSTNAME / PATH / sn001. The specific format of the address above is exemplary and not limiting. Alternatively, the server can store the sub-upgrade packet in a predetermined address so that the terminal device can download the sub-upgrade packet from the predetermined address.
[0056] 2 is a flowchart of a firmware upgrade method applied to a terminal device according to an embodiment of the present disclosure. The terminal device may be various Internet of Things terminal devices, such as smart sensors (e.g., sensors that collect ambient environmental data such as temperature, humidity, vibration, pressure, and liquid level), smart home devices (e.g., smart sockets, smart lights, smart speakers, smart washing machines, smart refrigerators, smart air purifiers, etc.), smart wearable devices (e.g., smart watches, sports bracelets, smart glasses, etc.), smart transportation devices (e.g., smart street lights, smart cars, smart parking lots, etc.), smart healthcare devices (e.g., smart blood pressure monitors, smart health bracelets, smart dialing machines, etc.), and smart industrial devices (e.g., computer numerically controlled machine tools, industrial robots). The above terminal devices may be implemented using embedded technology or other technologies.
[0057] In step S201, the terminal device obtains a firmware upgrade command. In some implementations, the firmware upgrade command is transmitted by a broadcast device disconnected from the wide area network or triggered by a preset button on the terminal device. The broadcast device disconnected from the wide area network may be, for example, a handheld broadcast device. A broadcast device disconnected from the wide area network can be realized using short-range wireless communication technologies such as Bluetooth, Bluetooth LE, ZigBee, Radio Frequency Identification (RFID), Ultra Wide Band (UWB), 60 GHz, Wi-Fi, or WiMAX, or a wired communication method such as USB. Because the broadcast device is disconnected from the wide area network, not using the wide area network can fully avoid security risks associated with transmission over the wide area network. The terminal device can also preset physical buttons, such as a toggle button, a slide button, or a button, and a specific area displayed on a touchscreen, to trigger the firmware upgrade command and realize an upgrade strategy that combines both offline and online methods. In one embodiment, the firmware upgrade command may be transmitted to the terminal device by a server via the wide area network. During actual use, according to the needs of firmware upgrade, one or more of the following can be selected: sending a firmware upgrade instruction by broadcast equipment, triggering a firmware upgrade instruction by a preset button on a terminal equipment, and sending a firmware upgrade instruction by a server via a wide area network.
[0058] In step S202, the terminal device transmits the identification code of the target terminal device. For example, the terminal device can obtain the identification code of the target terminal device from the memory area of the flash chip of the terminal device. The identification code of the target terminal device has been described in step S102 of FIG. 1, so the description will not be repeated here.
[0059] In step S203, the terminal device receives (downloads) the sub-upgrade packet. In one embodiment, the terminal device can download the sub-upgrade packet from a server.
[0060] In one embodiment, the identification code may further include a storage address offset, but this is not required. For example, the terminal device stores the sub-upgrade packet at a storage address in the terminal device's flash memory (flash) determined based on the changeable storage address and the storage address offset. This realizes area-specific storage of the sub-upgrade packet in the terminal device. The storage address offset of the sub-upgrade packet is used to determine the storage address of the sub-upgrade packet in the terminal device, thereby realizing area-specific storage of the sub-upgrade packet in the terminal device. During actual use, the sub-upgrade packet is stored in the flash chip of the terminal device, and the flash chip can be partitioned into different storage areas so that the sub-upgrade packet can be stored area-specific in the terminal device.
[0061] Table 2 shows an example of the partitioning of memory area on a terminal device's flash chip. [Table 2]
[0062] It can be seen that by partitioning the flash chip into different storage areas, the sub-upgrade packets can be stored in different areas in the terminal device.
[0063] In one embodiment, the terminal device can determine the address to download the sub-upgrade packet from the server based on the terminal device's identification code and the default changeable download address read from the terminal device's flash chip according to the download address offset. For example, in the example of Table 2, the terminal device can obtain the target terminal device's download address offset, address_offset001, based on the identification code read from address 00000000 of the flash chip. The terminal device can read the changeable address, PROTOCOL: / / HOSTNAME / PATH / SN, from address 0000000F of the flash chip based on address_offset001, and download the sub-upgrade packet stored in the server from PROTOCOL: / / HOSTNAME / PATH / sn001 based on the terminal device's identification code, sn001, and the changeable address, PROTOCOL: / / HOSTNAME / PATH / SN. The specific format of the above address is illustrative and not limiting. Alternatively, the terminal device can download the sub-upgrade packet from a predetermined address.
[0064] In step S204, the sub-upgrade packets are merged into a target firmware upgrade packet based on the identification code of the target terminal device. For example, the terminal device determines whether and how to reorder the received sub-upgrade packets based on the sub-upgrade packet order identifiers in the identification code of the target terminal device, and then merges the sub-upgrade packets into a target firmware upgrade packet. In one embodiment, merging may refer to sequentially reading the sub-upgrade packets from the memory area of the target terminal device. In some embodiments, after the sub-upgrade packets are merged into the target firmware upgrade packet, a soft reboot is further performed.
[0065] FIG. 3 is a flowchart of a firmware upgrade method applied to a server according to an embodiment of the present disclosure.
[0066] In step S301, the server obtains a target firmware upgrade packet. The similar parts between step S301 in Figure 3 and step S101 in Figure 1 will not be described again here.
[0067] In step S302, the server receives the identification code of the target terminal device. The similar parts of step S302 in Figure 3 and step S102 in Figure 1 will not be described again here.
[0068] In step S303, the server determines whether to reorder the sub-upgrade packets based on the identification code of the target terminal device. If it is determined that the sub-upgrade packets should be reordered, the process proceeds to S304. In S304, the server divides the target firmware upgrade packet into sub-upgrade packets, reorders them, and numbers the sub-upgrade packets. If it is determined that the sub-upgrade packets should not be reordered, the process proceeds to S305. In S305, the server divides the target firmware upgrade packet into sub-upgrade packets, does not reorder them, and numbers the sub-upgrade packets. In one embodiment, the numbers of the sub-upgrade packets in the server are 0001, 0002, 0003, 0004, and 0005. Regardless of whether the order of the sub-upgrade packets is changed, the numbers indicating the transmission order of the sub-upgrade packets are written in order. In one embodiment, the header of each sub-upgrade packet may include the sub-upgrade packet number. In one embodiment, the header of each sub-upgrade packet may include an identification code of the target terminal device and a number of the sub-upgrade packet.
[0069] In one embodiment, the sequence identifier may be binary data, however, binary data is merely an example and in other embodiments, the sequence identifier may be another type of identifier.
[0070] In some implementations, step S303 divides the target firmware upgrade packet into multiple sub-upgrade packets and determines whether to change the order of the sub-upgrade packets according to whether a value corresponding to the predetermined number of bits of binary data is a predetermined value (e.g., 0). The order of the sub-upgrade packets can be adjusted based on the order identifier during division, thereby improving the security of the transmission (download) of the firmware upgrade packet.
[0071] For example, a specific reordering rule is to divide some sub-upgrade packets into several pairs of adjacent sub-upgrade packets in S304, and change the order of the two sub-upgrade packets in each pair of adjacent sub-upgrade packets. After the order of the sub-upgrade packets is changed according to this rule, when the firmware upgrade packets are transmitted (downloaded), it becomes significantly more difficult for them to be leaked or tampered with by eavesdropping, thereby improving the security of the firmware upgrade.
[0072] For example, if the preset bit number is 1, the binary data contains 0 or 1, and the corresponding value is also 0 or 1. Furthermore, in step S303, if the corresponding value of the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 0, the target firmware upgrade packet is divided into several sub-upgrade packets, and the order of each sub-upgrade packet is not changed. If the corresponding value of the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 1, the target firmware upgrade packet is divided into several sub-upgrade packets, and the order of each sub-upgrade packet needs to be changed. Alternatively, the opposite setting to the above may be used.
[0073] In some implementations where the preset number of bits is 1, S304 can change the order of adjacent sub-upgrade packets by swapping the order of the sub-upgrade packets. Therefore, changing the order of each sub-upgrade packet according to the value corresponding to the binary data of the predetermined number of bits includes dividing some sub-upgrade packets into several pairs of adjacent sub-upgrade packets and swapping the order of two of the adjacent sub-upgrade packets in each pair. Continuing from the previous example, when the preset number of bits is 1, the binary data contains 0 or 1. If the corresponding value of the binary data corresponding to the order identifier in the identification code of the current terminal device is 1, it is determined to change the order of each sub-upgrade packet. In this case, the several sub-upgrade packets obtained by dividing the target firmware upgrade packet are divided into several pairs of adjacent sub-upgrade packets, and the order of the two sub-upgrade packets in each pair is swapped. If the corresponding value of the binary data corresponding to the order identifier in the identification code of the current terminal device is 0, this order swapping operation does not need to be performed and the original order can be maintained.
[0074] In another example, when the preset bit number is 2, the binary data includes 00, 01, 10, and 111, and the corresponding values are 0, 1, 2, and 3. Furthermore, in step S303, if the corresponding value of the binary data 00 corresponding to the sequence identifier in the identification code of the current terminal device is 0, the target firmware upgrade packet is divided into several sub-upgrade packets, and the order of each sub-upgrade packet is not changed. If the corresponding value of the binary data 01, 10, or 11 corresponding to the sequence identifier in the identification code of the current terminal device is 1, 2, or 3, the target firmware upgrade packet is divided into several sub-upgrade packets, and the order of each sub-upgrade packet needs to be changed. Alternatively, settings different from the above may be used.
[0075] In some implementations, step S303 may further determine whether to reorder the sub-upgrade packets based on the parity of the value corresponding to the predetermined number of bits of binary data. Thus, the step of determining whether to reorder the sub-upgrade packets while dividing the target firmware upgrade packet into several sub-upgrade packets according to the value corresponding to the predetermined number of bits of binary data comprises: if the value corresponding to the predetermined number of bits of binary data is an even number, dividing the target firmware upgrade packet into several sub-upgrade packets without changing the order of the sub-upgrade packets; if the value corresponding to the predetermined number of bits of binary data is an odd number, dividing the target firmware upgrade packet into several sub-upgrade packets without changing the order of the sub-upgrade packets; alternatively, if the value corresponding to the predetermined number of bits of binary data is an odd number, dividing the target firmware upgrade packet into several sub-upgrade packets without changing the order of the sub-upgrade packets; and if the value corresponding to the predetermined number of bits of binary data is an even number, dividing the target firmware upgrade packet into several sub-upgrade packets without changing the order of the sub-upgrade packets. If the preset number of bits is 1, the process of determining whether to reorder the sub-upgrade packets based on the parity is similar to the process of determining whether to reorder the sub-upgrade packets based on whether the order identifier is 0 or 1.
[0076] In some implementations, step S303 may further determine whether to reorder the sub-upgrade packets by dividing a predetermined value by a remainder of a value corresponding to the predetermined number of bits of binary data. Thus, the step of determining whether to reorder the sub-upgrade packets while dividing the target firmware upgrade packet into several sub-upgrade packets based on the remainder of the value corresponding to the predetermined number of bits of binary data by the predetermined value includes the steps of: deciding to divide the target firmware upgrade packet into several sub-upgrade packets and not reorder the sub-upgrade packets if the remainder of the value corresponding to the predetermined number of bits of binary data by the predetermined value is one of one or more specific values; and deciding to divide the target firmware upgrade packet into several sub-upgrade packets and reorder the sub-upgrade packets if the remainder of the value corresponding to the predetermined number of bits of binary data by the predetermined value is not one of one or more specific values. Alternatively, if the remainder of the value corresponding to the predetermined number of bits of binary data modulo the predetermined value is one or more specific values, it is determined to divide the target firmware upgrade packet into multiple sub-upgrade packets and change the order of the sub-upgrade packets; if the remainder of the value corresponding to the predetermined number of bits of binary data modulo the predetermined value is not one of the one or more specific values, it is determined to divide the target firmware upgrade packet into multiple sub-upgrade packets and not change the order of the sub-upgrade packets. For example, if the predetermined value is 3, if the remainder of the value corresponding to the predetermined number of bits of binary data modulo the predetermined value is a specific value (e.g., 0), it is possible to divide the target firmware upgrade packet into multiple sub-upgrade packets and decide whether to change the order of the sub-upgrade packets.When the preset number of bits is 2, the process of determining whether to change the order of the sub-upgrade packets based on the remainder of the value corresponding to the binary data of the predetermined number of bits by a predetermined value is similar to the process of determining whether to change the order of the sub-upgrade packets based on parity.
[0077] In some implementations, the reordering rule can be determined based on a value corresponding to the predetermined number of bits of binary data. Thus, in step S304, the step of reordering each sub-upgrade packet according to a value corresponding to the predetermined number of bits of binary data includes dividing the sub-upgrade packets into several sub-upgrade packet groups, each sub-upgrade packet group including a specific number of sub-upgrade packets, the specific number being a value corresponding to the maximum number of bits of binary data plus one, and swapping the orders of two sub-upgrade packets in each sub-upgrade packet group, the difference in order being a value corresponding to the predetermined number of bits of binary data.
[0078] Continuing with the previous example, if the preset number of bits is 2, the binary data includes 00, 01, 10, and 11, and the value corresponding to the largest 2-bit binary data is 3. Furthermore, if the value corresponding to the binary data 00 corresponding to the sequence identifier in the current terminal device identification code is 0, the target firmware upgrade packet is divided into multiple sub-upgrade packets, and the sequence of each sub-upgrade packet does not need to be changed or swapped. However, if the value corresponding to the binary data 01, 10, or 11 corresponding to the sequence identifier in the current terminal device identification code is 1, 2, or 3, the target firmware upgrade packet is divided into multiple sub-upgrade packets, and the sequence of each sub-upgrade packet needs to be swapped. For example, if the binary data corresponding to the sequence identifier is 10, the corresponding value is 2. In this case, the specific method for swapping the sequence is as follows: The sub-upgrade packets are divided into multiple groups of sub-upgrade packets, each group containing four sub-upgrade packets (i.e., the value corresponding to the maximum binary data is 3 + 1). The first group contains the 0th packet, the 1st packet, the 2nd packet, and the 3rd packet. Two sub-upgrade packets with an order difference of 2 are swapped, i.e., the 0th packet is swapped with the 2nd packet, and the 1st packet is swapped with the 3rd packet. If the preset number of bits is 1, 1 is added to the value corresponding to the maximum binary data of the predetermined number of bits. The process of grouping the sub-upgrade packets and reordering the sub-upgrade packets according to the value corresponding to the maximum binary data of the predetermined number of bits is similar to the process of dividing the sub-upgrade packets into several pairs of adjacent sub-upgrade packets and swapping the order of the two sub-upgrade packets in each pair of adjacent sub-upgrade packets to reorder the sub-upgrade packets.Based on a similar principle, when the number of preset bits is 3 bits, 4 bits, ... N bits, this embodiment does not give examples one by one, but the more the number of preset bits is and / or the more complicated the order exchange rule is, the more difficult the transmission (download) becomes in the firmware upgrade process.
[0079] In some of the above embodiments, the determination of whether to change and the change method are associated with the preset number of bits of the sequence identifier. The embodiments of the present disclosure are not limited thereto. For example, in an embodiment in which the preset number of bits is 1, the binary data includes 0 or 1, and the corresponding value is also 0 or 1. Furthermore, in step S303, if the corresponding value of the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 0, the target firmware upgrade packet is divided into several sub-upgrade packets, and the order of each sub-upgrade packet is not changed. If the corresponding value of the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 1, the target firmware upgrade packet is divided into several sub-upgrade packets, and the order of each sub-upgrade packet needs to be changed. However, the reordering method includes dividing the sub-upgrade packets into several sub-upgrade packet groups, each containing a specific number of sub-upgrade packets, the number of which is a number (2 or more) preset by the server and the target terminal device, and reordering two sub-upgrade packets in each group whose order difference is the specified number minus 1 (or another value smaller than this number, e.g., the order difference is smaller than this number minus 2). For example, in an embodiment in which whether to reorder the sub-upgrade packets is determined based on the remainder of a value corresponding to a predetermined number of bits of binary data by a predetermined value, the server and the target terminal device can respectively set a method for reordering the sub-upgrade packets of target terminal devices with different remainders. For example, if the remainder is 0, the order of the sub-upgrade packets does not need to be reordered. If the remainder is 1, the sub-upgrade packets can be divided into several pairs of adjacent sub-upgrade packets, and the order of the two sub-upgrade packets in each pair of adjacent sub-upgrade packets can be swapped.If the remainder is 2, some sub-upgrade packets can be divided into multiple sub-upgrade packet groups, each group containing 3 (i.e., the remainder plus 1) sub-upgrade packets, and the order of two sub-upgrade packets whose order difference is 2 (i.e., the remainder) can be swapped. The present disclosure is not limited in this respect.
[0080] In step S306, the server generates a header for a target firmware upgrade packet. The header for the target firmware upgrade packet may include one or more of an identification code of the target terminal device, the number and number of sub-upgrade packets, a firmware upgrade key, and integrity verification information. The firmware upgrade key and / or the integrity verification information may be used by the terminal device for security verification during the secure boot process.
[0081] In step S307, the server stores and / or sends the sub-upgrade packet and the info packet to the target terminal device. The info packet corresponds to a data packet that provides the header of the target firmware upgrade packet. Similar parts of S307 in Figure 3 and S104 in Figure 1 will not be described again.
[0082] FIG. 4 is a flowchart of a firmware upgrade method applied to a terminal device according to an embodiment of the present disclosure.
[0083] In step S401, the terminal device obtains a firmware upgrade command. The similar parts between step S401 in Figure 4 and step S201 in Figure 2 will not be described again.
[0084] In step S402, the terminal device transmits the identification code of the target terminal device. The similar parts between step S402 in Figure 4 and step S202 in Figure 2 will not be described again.
[0085] In step S403, the terminal device downloads the info packet. Through the downloaded info packet, the terminal device obtains one or more of the target terminal device's identification code, the number of sub-upgrade packets, the firmware upgrade key, and integrity verification information. For example, the terminal device can verify whether the target terminal device's identification code in the info packet matches the identification code of the current terminal device. If the terminal device's identification code matches the identification code in the info packet sent from the server, the sub-upgrade packets divided based on the upgrade information sent from the server are downloaded. If the obtained terminal device's identification code does not match the identification code in the header sent from the server, the current firmware upgrade command may be invalid, and the download operation is not performed.
[0086] The server can send GET information (an info packet including header information) to the terminal device. The GET information may include the terminal device's identification code SN, the number of divided sub-upgrade packets (quantity), and may also include the numbers of the divided sub-upgrade packets, an integrity check value such as an MD5 value, and security verification information such as a firmware upgrade key. During actual use, a greater number and types of security verification information can be configured according to security requirements to achieve security verification of the terminal device and improve the security of the firmware upgrade.
[0087] In some cases, the header may further include a firmware upgrade key and / or integrity verification information that verifies with the firmware upgrade key and / or integrity verification information included in the firmware upgrade instruction for added security.
[0088] The info packet sent by the server is downloaded and stored in the terminal device's pre-configured tmp partition, so that the information can be called during the upgrade process.
[0089] In the process of downloading the sub-upgrade packets divided based on the upgrade information sent from the server, a method of sending and downloading each packet according to a request for each packet is used, and each time a sub-upgrade packet is downloaded, it is determined based on the information provided in the packet header whether the last sub-upgrade packet has been downloaded. Accordingly, in some implementations, the method further includes a step of determining whether the last sub-upgrade packet has been downloaded according to the number of sub-upgrade packets in the header.
[0090] Since the number and numbers of the sub-upgrade packets are fixed, when each sub-upgrade packet is downloaded in order, it can be determined whether all the sub-upgrade packets have been transmitted based on the sub-upgrade packet number.
[0091] In S404, the terminal device determines whether the order of the sub-upgrade packets has been changed based on the identification code.
[0092] If it is determined to change the order of the sub-upgrade packets, the process proceeds to S405. In S405, the terminal device downloads the sub-upgrade packets. In S406, the terminal device checks whether the currently downloaded sub-upgrade packet is the last upgrade packet. If the currently downloaded sub-upgrade packet is not the last upgrade packet, the process proceeds to S405. If the currently downloaded sub-upgrade packet is the last upgrade packet, the process proceeds to S407. In S407, the terminal device changes the order of the sub-upgrade packets.
[0093] If it is determined that the order of the sub-upgrade packets has not been changed, the process proceeds to S408. In S408, the terminal device downloads the sub-upgrade packets. In S409, the terminal device checks whether the currently downloaded sub-upgrade packet is the last upgrade packet. If the currently downloaded sub-upgrade packet is not the last upgrade packet, the process proceeds to S408. If the currently downloaded sub-upgrade packet is the last upgrade packet, the process proceeds to S410. In S410, the terminal device does not change the order of the sub-upgrade packets.
[0094] Therefore, when the terminal device downloads the sub-upgrade packets, it first determines whether the order of the sub-upgrade packets has been changed based on the order identifier. If the order of the sub-upgrade packets needs to be changed, it changes the order of the sub-upgrade packets to their original order and integrates each sub-upgrade packet into the original firmware upgrade packet. If the order of the sub-upgrade packets does not need to be changed, it simply integrates each sub-upgrade packet directly into the original firmware upgrade packet.
[0095] In step S411, the terminal device combines the sub-upgrade packets into an upgrade packet for the target firmware.
[0096] In S404, the terminal device determines whether the order of the sub-upgrade packets has been changed based on the identification code, and in S406, the process in which the terminal device changes the order of the sub-upgrade packets and integrates the changed order into the initial order is similar to steps 303 and 304 in Figure 3, so it will not be described again here.
[0097] 5A-5C are schematic diagrams illustrating a server reordering sub-upgrade packets in an odd-dimensional matrix with a clockwise shift-out direction to the left, according to an embodiment of the present disclosure.
[0098] The process in FIGS. 5A to 5C in which the server divides the sub-upgrade packet based on the identification code of the target terminal device is similar to the process described in FIG. 3, and therefore will not be described again.
[0099] In one embodiment, the order identifier in the identification code may include a predetermined number of bits of data indicating at least one of the translation number, the shift-out direction, and the rotation direction. When the order identifier includes a predetermined number of bits of data indicating one or two of the translation number, the shift-out direction, and the rotation direction, the remaining translation number, the shift-out direction, and the rotation direction can be determined in advance between the terminal device and the server. If necessary, the translation number may be one, two, three, or more. The shift-out direction refers to the translation direction of the sub-upgrade packet or data packet that is shifted out of the matrix when the sub-upgrade packet or other data packet is translated. If necessary, the shift-out direction may be up, down, left, right, or other direction. If necessary, the rotation direction may be clockwise or counterclockwise. For example, if the translation number is two, the shift-out direction is left, and the rotation direction is clockwise, all data packets in the matrix are translated twice, the data shifted out of the matrix each time is shifted left, and the data packets are rotated clockwise within the matrix. If the translation number indicated by the order identifier in the identification code is not 0, it can be determined to change the order of the sub-upgrade packets.
[0100] The server generates a matrix based on the number N of sub-upgrade packets that are split from the target upgrade packet. In one embodiment, the server determines the dimension of the generated matrix based on the number N of sub-upgrade packets that are split from the target upgrade packet. T is calculated according to the following formula:
number
[0101] roundup() means rounding up.
[0102] If the remainder of T modulo 2 is 0, then a matrix of even dimension is used. If the remainder is 1, then a matrix of odd dimension is used.
[0103] Next, referring to FIG. 5A, a method for changing the order of sub-upgrade packets using an odd-dimensional matrix will be described.
[0104] Assume there are a total of N=17 sub-upgrade packets. According to equation (1), T=5, and the remainder of T modulo 2 is 1, so it can be determined to generate an odd-dimensional matrix. When generating an odd-dimensional matrix, the matrix dimensions are determined by the following equation:
number
[0105] According to Equation (2), when n = 2, the dimension of the odd matrix is 2n + 1 = 5. That is, for N = 17 sub-upgrade packets, a five-dimensional matrix is generated as shown in FIG. 5A. As shown in FIG. 5A, 17 sub-upgrade packets, whose initial sub-upgrade packet numbers S range from 1 to 17, are arranged from left to right in the matrix with automatic line breaks. The above arrangement is merely exemplary, and other arrangements can be used. Each position in the matrix, from left to right and from top to bottom, contains an original serial number P_original. As shown in FIG. 5A, the 17 sub-upgrade packets cannot exactly fill the five-dimensional matrix, so interference packets (garbled packets, empty packets, or one or more of the 17 repeated sub-upgrade packets) can be used to fill the matrix until it is completely filled.
[0106] Assume that the order identifier includes a predetermined number of bits of data indicating that the translation count K is 1, the shift-out direction is left, and the rotation direction is clockwise. As shown in FIG. 5A, the data packet (P_original=21) with coordinates (1,5) is shifted out of the matrix to the left, and the data packet is rotated clockwise within the matrix. After the data packet with coordinates (1,5) is shifted out of the matrix to the left, the matrix becomes as shown in FIG. 5B. Next, the data packet shifted out of the matrix is filled into the empty position in the center of FIG. 5B, and the translated matrix is shown in FIG. 5C. The matrix in FIG. 5C is after the matrix in FIG. 5A has been translated to the left and clockwise once.
[0107] FIG. 6 is a flowchart for determining a translation method for data packets in an odd matrix according to an embodiment of the present disclosure.
[0108] The process of determining how to translate each data packet within the matrix will now be described with reference to Figures 5A and 6. For data packets within the matrix, the following operations are performed:
[0109] In S601, it is determined whether the number of translations K is 0. If the number of translations K=1, the process proceeds to S602.
[0110] In S602, the number of layers in the matrix of the data packet having the original serial number P_original (the data packet is a sub-upgrade packet) can be determined based on the original serial number P_original. Take the original serial number P_original=13 of the data packet in the center of FIG. 5A as an example.
number
[0111] (Y-1) is the quotient and X is the remainder. Equation (3) shows that the coordinates of the sub-upgrade packet in the matrix (X, Y) = (3, 3) are determined based on the original serial number of the sub-upgrade packet P_original = 13.
number
[0112] max(|Xn-1|,|Yn-1|) represents the maximum value of |Xn-1| and |Yn-1|. According to equation (4), the layer number located in the matrix of the data packet with original serial number P_original=13 can be calculated as Layer=0. At the same time, subtract 1 from the K value, that is, K'=K-1, K'=0, K=K'.
[0113] When translating to the left, the translation method of the data packet in the matrix is determined according to the number of layers in the matrix of the data packet and the coordinates in the matrix of the data packet, by the following condition:
[0114] Condition 1: The coordinate of the data packet is Y=(n+1)+Layer.
[0115] In S603, if condition 1 is met, the process proceeds to S604, where the coordinates of the data packet are changed so that 1 is subtracted from the X value and the Y value remains unchanged; if condition 1 is not met, the process proceeds to S605.
[0116] In FIG. 5A, the data packet that satisfies condition 1 corresponds to the data packet that has been translated to the left, that is, the data packet included in dotted line region 1.
[0117] Condition 2: The coordinate of the data packet is X=n+1-Layer, and <Y<n+1+Layerである。
[0118] In S605, if condition 2 is met, the process proceeds to S606, where the coordinates of the data packet are changed so that the X value remains unchanged and 1 is subtracted from the Y value; if condition 2 is not met, the process proceeds to S607.
[0119] In FIG. 5A, the data packets that satisfy condition 2 correspond to the data packets that have been translated upward, that is, the data packets included in dotted line region 2.
[0120] Condition 3: The coordinate of the data packet is Y=n+1-Layer, and n+1-Layer<=X <n+1+Layerである。
[0121] In S607, if condition 3 is met, the process proceeds to S608, where the coordinates of the data packet are changed so that 1 is added to the X value and the Y value remains unchanged; if condition 3 is not met, the process proceeds to S609.
[0122] In FIG. 5A, the data packets that satisfy condition 3 correspond to the data packets that have been translated to the right, that is, the data packets included in dotted line region 3.
[0123] Condition 4: The coordinate of the data packet is Y=n+1-Layer, and n+1-Layer<=X <n+1+Layerである。
[0124] If condition 4 is met in S609, the process proceeds to S610, where the coordinates of the data packet are changed so that the X value remains unchanged and 1 is added to the Y value.
[0125] In FIG. 5A, the data packets that satisfy condition 4 correspond to the data packets that have been translated downward, that is, the data packets included in the dotted line region 4.
[0126] Those skilled in the art should understand that in this embodiment, in addition to moving within the matrix, the data packet is translated in four ways within the matrix: up, down, left, and right, and when three of the above four conditions are met, the translation method of the data packet can be determined by elimination. In Figure 6, the selection and execution order of conditions 1 to 4 are merely examples.
[0127] Condition 5: The coordinate of the data packet after it has been moved is X=0.
[0128] In S611, if condition 5 is met, the process proceeds to S612, where the coordinates of the data packet are changed so that X=n+1 and Y=n+1, and the process proceeds from S612 to S613. If condition 5 is not met, the process proceeds directly to S613.
[0129] As shown in FIG. 5A, the data packet with original serial number P_original=13 satisfies condition 1 and is located in dotted area 1 in the matrix, and the translation method for the data packet with original serial number P_original=13 is to translate left. As shown in FIG. 5C, the new serial number for the data packet with original serial number P_original=13 after translation is P_new=X+(Y-1)(2n+1)=12. The data packet with original serial number P_original=21 satisfies condition 1 and is located in dotted area 1 in the matrix, and the translation method for the data packet with original serial number P_original=21 is to translate left. The coordinates of the data packet with the original serial number P_original=21 after the translation are (0,5), which satisfies condition 5, and the coordinates of the data packet with the original serial number P_original=21 are changed to (3,3). Therefore, as shown in FIG. 5C , the new serial number of the data packet with the original serial number P_original=21 after the translation is P_new=X+(Y-1)(2n+1)=13.
[0130] The process proceeds to S601, where K=0 at present, and the process ends.
[0131] By repeating the process of FIG. 6 above for each data packet in the matrix, the translation method for all data packets in the matrix can be obtained.
[0132] The above is a method for translating data packets in a matrix by a server when the number of translations is 1. Those skilled in the art can understand the process of translating data packets in a matrix with more numbers of translations based on FIGS. 5A to 5C and 6.
[0133] The server performs K parallel shifts on all data packets in the matrix, then uses P_new in the matrix after the parallel shift as the number S of the data packet in the matrix and sends it to the target terminal device. During transmission, the sub-upgrade packets are out of order and mixed with interference packets, greatly increasing the difficulty of cracking.
[0134] The target terminal device can determine the manner (e.g., shift-out direction, clockwise, counterclockwise) and number of times the received data packets are translated by the server based on the sequence identifier in the identification code read from the flash. The target terminal device can obtain the total number of data packets (e.g., including sub-upgrade packets and interference packets) transmitted by the server and included in the matrix generated by the server, and the dimension of the matrix generated by the target terminal device, based on the number of sub-upgrade packets included in the info packet. Alternatively or additionally, the info packet may include the total number of data packets (e.g., including sub-upgrade packets and interference packets) included in the matrix generated by the server, and the target terminal device can generate the dimension of the matrix (i.e., the root mean square of the total number) based on the total number. The target terminal device determines the dimension of the generated matrix based on the number of sub-upgrade packets in the same manner as described with reference to FIGS. 5A to 5C, and the description will not be repeated here.
[0135] In one embodiment, the target terminal device can restore the order of the sub-upgrade packets based on the reverse process of the server's translation process of the data packets in the queue.
[0136] FIG. 5D is a schematic diagram of the reverse process of the data packet translation process according to an embodiment of the present disclosure.
[0137] FIG. 7 is a flowchart of a reverse process of translating a data packet according to an embodiment of the present disclosure.
[0138] The reverse process of the translation process of each packet in the matrix will be described with reference to FIGS. 5A to 5D and FIG. 7. For the data packets in the matrix, the following processing is performed.
[0139] In S701, it is determined whether the translation count K is 0. The translation count K = 1, and the process proceeds to S702.
[0140] In S702, based on the new serial number P_new, the number of layers in the matrix of the sub-upgraded packet of the original serial number P_new can be determined. Since the calculation method of the number of layers is the same as the description in step S602 of FIG. 6, it will not be repeatedly described here. As an example, take the new serial number P_new = 12 of the data packet in the center of FIG. 7A. The new serial number P_new = 12 determines the coordinates (X, Y) = (2, 3) of the sub-upgraded packet in the matrix. The number of layers of the data packet with P_new = 12 in the matrix is Layer = 1. At the same time, subtract 1 from the K value, and the K value after subtracting 1 is 0.
[0141] When translating to the left, according to the number of layers of the data packet in the matrix and the coordinates of the data packet in the matrix, the translation method of the data packet in the matrix is determined by the following conditions.
[0142] Preprocessing condition: The coordinates of the data packet are X = n + 1 and Y = n + 1.
[0143] In S703, if the preprocessing condition is satisfied, the process proceeds to S704, the coordinates of the data packet are changed to X = 0 and Y = 2n + 1, and the process proceeds to S705. If the preprocessing condition 1 is not satisfied, the process directly proceeds to S705.
[0144] Condition 1: The coordinates of the data packet are Y = Layer + n + 1, X < n + 1 + Layer, or X = n + 1 - Layer, Y = n + 1 + Layer - 1.
[0145] In S705, if condition 1 is met, the process proceeds to S706, where the coordinates of the data packet are changed so that 1 is added to the X value and the Y value remains unchanged; if condition 1 is not met, the process proceeds to S707.
[0146] In FIG. 5D, the data packets that satisfy condition 1 correspond to the data packets that have been translated to the right, that is, the data packets included in dotted line region 1.
[0147] Condition 2: The coordinates of the data packet are X=n+1+Layer and Y <n+1-Layerである。
[0148] In S707, if condition 2 is met, the process proceeds to S708, where the coordinates of the data packet are changed so that the X value remains unchanged and 1 is subtracted from the Y value; if condition 2 is not met, the process proceeds to S709.
[0149] In FIG. 5D, the data packets that satisfy condition 2 correspond to the data packets that have been translated upward, that is, the data packets included in the dotted line region 4.
[0150] Condition 3: The coordinates of the data packet are Y=n+1-Layer, n+1-Layer <X<n+1+Layerである。
[0151] In S709, if condition 3 is met, the process proceeds to S710, where the coordinates of the data packet are changed so that 1 is subtracted from the X value and the Y value remains unchanged; if condition 3 is not met, the process proceeds to S711.
[0152] In FIG. 5D, the data packets that satisfy condition 3 correspond to the data packets that have been translated to the left, that is, the data packets included in dotted region 3.
[0153] Condition 4: The coordinates of the data packet are X=n+1-Layer and Y>n+1+Layer-1.
[0154] If condition 4 is met in S711, the process proceeds to S712, where the coordinates of the data packet are changed so that the X value remains unchanged and 1 is added to the Y value.
[0155] In FIG. 5D, the data packets that satisfy condition 4 correspond to the data packets that have been translated downward, that is, the data packets included in the dotted line region 2.
[0156] Those skilled in the art should understand that in this embodiment, in addition to being shifted out of the matrix, the data packets are translated in four ways within the matrix: up, down, left, and right, and if three of the above four conditions are met, the translation method for the data packets can be determined by elimination. For simplicity, only three of the four conditions are shown in Figure 7, excluding the pre-processing condition. In Figure 7, the selection and execution order of conditions 1 to 3 are for illustrative purposes only.
[0157] 5D, the data packet with new serial number P_new=12 satisfies condition 1, the parallel movement method of the data packet with new serial number P_new=12 is to move to the right, and the coordinates are changed to (3, 3). The process proceeds to S713, where P=13.
[0158] The process continues to S701, where K=0 and the process ends.
[0159] By repeating the process of FIG. 7 for each data packet in the matrix, the matrix can be restored from FIG. 5C to FIG. 5A. In FIG. 5A, the serial numbers of the sub-upgrade packets in the matrix are the same as the original order of the sub-upgrade packets. According to the serial numbers of the sub-upgrade packets and the number of sub-upgrade packets in the restored matrix, the restored order of the sub-upgrade packets can be obtained.
[0160] The above is the method by which the target terminal device moves the data packet in the matrix when the number of translations is 1. Those skilled in the art can understand the process of restoring more number of translations based on Figures 5D and 7.
[0161] In one embodiment, the target terminal device can restore the order of the sub-upgrade packets by continuing the server's translation process of the data packets in the queue.
[0162] The process of translating data packets within a queue by the server has been described above with reference to Figures 5A-5C and 6, and will not be repeated here.
[0163] FIG. 8 is a flowchart illustrating a process for determining the number of translations that must be performed by the server to restore the order of the sub-upgrade packets, according to an embodiment of the present disclosure.
[0164] Assume that the data packet with the initial serial number P_original is translated as shown in Figure 6, and then the new serial number becomes P_new. The process in Figure 8 can calculate the number of times the server needs to continue translating, and restore the order of the sub-upgrade packets.
[0165] In S801, it is determined whether P_original is equal to P_new. If not, the process proceeds to S802.
[0166] In S802, the number of layers in the matrix of the sub-upgrade packet having the original serial number P_original can be determined based on the original serial number P_original. The determination method is similar to the above process described with reference to Figure 6, so it will not be described again. At the same time, 1 is added to the R value, and the R value after adding 1 is 1.
[0167] S802 to S813 are similar to S602 to S613 in FIG. 6 and will not be described again.
[0168] The process proceeds to S801, where P_new = P_original, and continues until the process terminates, where R represents the number of parallel moves that the server must continue to make to restore the order of the sub-upgrade packets.
[0169] 9A-9D are schematic diagrams of a method for a server to translate data packets in an odd-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure.
[0170] In one embodiment, the layer number (Layer) in which the data packet is located can be determined based on the serial number P of each data packet. Referring to the first and second layers in Figure 5A, when the shift-out direction is left and the rotation is clockwise, the movement method of the data packet in any layer in the matrix is as shown in Figure 9A.
[0171] In region 1, the movement method of the data packet is to move it to the left, and the coordinates of the data packet are changed to subtract 1 from the X value and leave the Y value as it is.
[0172] In region 2, the data packet is moved up, and the coordinates of the data packet are changed so that the X value remains the same and 1 is subtracted from the Y value.
[0173] In region 3, the movement method of the data packet is to move it to the right, and the coordinates of the data packet are changed to add 1 to the X value and leave the Y value unchanged.
[0174] In region 4, the data packet is moved downwards, and the coordinates of the data packet are changed so that the X value remains the same and 1 is added to the Y value.
[0175] In the layer of FIG. 9A, conditions 1 to 5 for determining the movement direction of a data packet, which have been described with reference to FIG. 6, can be obtained based on dividing the regions of different movement directions.
[0176] Referring to FIG. 9B, we will explain how data packets move in any layer of the matrix when the shift-out direction is right and rotated clockwise.
[0177] In regions 1 to 4, the data packet movement method is the same as that described with reference to FIG. 9A, so it will not be described again here. Based on dividing the regions with different movement directions in the layer of FIG. 9B, we can obtain the conditions under which the server determines the movement direction of the data packet in the matrix when the shift-out direction is right and rotated clockwise. For the sake of brevity, the specific conditions will not be described.
[0178] Referring to FIG. 9C, we will now explain how data packets move in any layer of the matrix when the shift-out direction is up and rotated clockwise.
[0179] In regions 1 to 4, the movement of data packets is the same as that described with reference to FIG. 9A, and therefore will not be described again here. Based on dividing the regions with different movement directions in the layer of FIG. 9C, the conditions under which the server determines the movement direction of data packets in the queue can be obtained when the movement direction is up and rotated clockwise. For the sake of brevity, the specific conditions will not be described.
[0180] Referring to FIG. 9D, we will now explain how data packets move at any layer in the matrix when the shift-out direction is down and rotates clockwise.
[0181] In regions 1 to 4, the data packet movement method is the same as that described with reference to FIG. 9A, so it will not be described again here. Based on dividing the regions with different movement directions in the layer of FIG. 9D, we can obtain the conditions under which the server determines the movement direction of the data packet in the matrix when the shift-out direction is downward and rotates clockwise. For the sake of brevity, the specific conditions will not be described.
[0182] FIG. 10 is a schematic diagram illustrating a server reordering sub-upgrade packets based on an order identifier indicating a shift-out direction is left and counterclockwise, according to an embodiment of the present disclosure.
[0183] In Figure 10, the process of determining the layer in which the data packet is located is the same as the process in Figure 5A. It will not be repeated. The process of the server reordering the sub-upgrade packets based on the order identifier indicating that the shift-out direction is left and counterclockwise is similar to the process of the server reordering the sub-upgrade packets based on the order identifier indicating that the shift-out direction is left and clockwise, as shown in Figure 6. By adjusting conditions 1 to 5, a method of translating data packets within a matrix can be obtained.
[0184] When moving a data packet within an odd-dimensional matrix, the data packet shifted out of the matrix is always placed back at the center (n+1, n+1) of the odd-dimensional matrix.
[0185] 9A to 10, the server can change the order of the sub-upgrade packets by shifting the data packets in the matrix in a shift-out direction such as left, right, up, or down, or in a clockwise or counterclockwise rotation direction, based on the order identifier in the identification code. Similarly, the target terminal can restore the order of the sub-upgrade packets through a process reverse to the server's process of translating the data packets in the matrix, according to the order identifier in the identification code.
[0186] FIG. 11 illustrates a schematic diagram of a server reordering sub-upgrade packets in an even-dimensional matrix clockwise with a shift-out direction to the left, according to an embodiment of the present disclosure.
[0187] Assume there are a total of N=14 sub-upgrade packets. According to equation (1), T=4, and the remainder of T modulo 2 is 0, so it can be determined to generate a matrix with even dimensions. When generating a matrix with even dimensions, the dimensions of the matrix are determined by the following equation:
number
[0188] According to Equation (5), when n = 2, the dimension of the even matrix is 2n = 4. That is, when there are N = 14 sub-upgrade packets, a four-dimensional matrix is generated as shown in FIG. 11. As shown in FIG. 11, the 14 sub-upgrade packets, whose initial sub-upgrade packet numbers S range from 1 to 14, are arranged from left to right in the matrix with automatic line breaks. Each position in the matrix from left to right and from top to bottom has its own original serial number P_original. As shown in FIG. 11, the 14 sub-upgrade packets cannot exactly fill the four-dimensional matrix, so interference packets (garbled packets, empty packets, or one or more of the 14 repeated sub-upgrade packets) can be used to fill the matrix until it is completely filled.
[0189] Assume that the order identifier contains a predetermined number of bits of data indicating that the translation count K is 1, the shift-out direction is left, and the rotation direction is clockwise. As shown in Figure 11, the data packet with coordinates (1,4) is shifted out of the matrix to the left, and the data packet is rotated clockwise within the matrix. After the data packet with coordinates (1,4) is shifted out of the matrix to the left, the data packet shifted out of the matrix is translated to an empty position (n,n) in the center of Figure 11.
[0190] FIG. 12 is a flowchart for determining a method for translating data packets in a matrix with even dimensions according to an embodiment of the present disclosure.
[0191] The process of determining how to translate a data packet within a matrix is described with reference to FIGS.
[0192] In S1201, it is determined whether the number of translations K is 0. The number of translations K=1, and the process proceeds to S1202.
[0193] In S1202, the number of layers in the matrix of the sub-upgrade packet having the original serial number P_original can be determined based on the original serial number P_original. Take the original serial number P_original=13 of the data packet in FIG. 11 as an example.
number
[0194] (Y-1) is the quotient and X is the remainder. Equation (3) shows that the coordinates (X, Y) = (2, 2) of the sub-upgrade packet in the matrix are determined based on the original serial number of the sub-upgrade packet P_original = 6.
number
[0195] max( , ) represents the maximum value. According to equation (6), the number of layers in the matrix of the data packet with original serial number P_original=6 can be calculated as Layer=0. At the same time, 1 is subtracted from the K value, and the K value after subtracting 1 is 0.
[0196] When translating to the left, the translation method of the data packet in the matrix is determined according to the number of layers in the matrix of the data packet and the coordinates in the matrix of the data packet, by the following condition:
[0197] Condition 1: The coordinates of the data packet are Y=n+Layer.
[0198] In S1203, if condition 1 is met, the process proceeds to S1204, where the coordinates of the data packet are changed so that 1 is subtracted from the X value and the Y value remains unchanged; if condition 1 is not met, the process proceeds to S1205.
[0199] In FIG. 11, the data packet that satisfies condition 1 corresponds to the data packet that has been translated to the left, that is, the data packet included in dotted line area 1.
[0200] Condition 2: The coordinates of the data packet are X=n-Layer and Y <n-Layerである。
[0201] In S1205, if condition 2 is met, the process proceeds to S1206, where the coordinates of the data packet are changed so that the X value remains unchanged and 1 is subtracted from the Y value; if condition 2 is not met, the process proceeds to S1207.
[0202] In FIG. 11, the data packets that satisfy condition 2 correspond to the data packets that have been translated upward, that is, the data packets included in the dotted line area 2.
[0203] Condition 3: The coordinates of the data packet are Y=n+1-Layer and X <n+Layerである。
[0204] In S1207, if condition 3 is met, the process proceeds to S1208, where the coordinates of the data packet are changed so that 1 is added to the X value and the Y value remains unchanged; if condition 3 is not met, the process proceeds to S1209.
[0205] In FIG. 5A, the data packets that satisfy condition 3 correspond to the data packets that have been translated to the right, that is, the data packets included in dotted line region 3.
[0206] Condition 4: The coordinates of the data packet are X = n + Layer and Y <n+Layerである。
[0207] If condition 4 is met in S1209, the process proceeds to S1210, where the coordinates of the data packet are changed so that the X value remains unchanged and 1 is added to the Y value.
[0208] In FIG. 11, the data packets that satisfy condition 4 correspond to the data packets that have been translated downward, that is, the data packets included in the dotted line area 4.
[0209] Those skilled in the art should understand that in this embodiment, in addition to moving within the matrix, the data packet is translated in four ways within the matrix: up, down, left, and right, and when three of the above four conditions are met, the translation method of the data packet can be determined by elimination. In Figure 12, the selection and execution order of conditions 1 to 4 are merely examples.
[0210] Condition 5: The coordinate of the data packet after it has been moved is X=0.
[0211] In S1211, if condition 5 is met, the process proceeds to S1212, where the coordinates of the data packet are changed to X=n, Y=n, and the process proceeds from S1212 to S1213. If condition 5 is not met, the process proceeds directly to S1213.
[0212] As shown in FIG. 11, the data packet with original serial number P_original=6 satisfies condition 3 and is located in dotted area 3 in the matrix. The translation method for the data packet with original serial number P_original=6 is to translate to the right. As shown in FIG. 5C, the new serial number of the data packet with original serial number P_original=6 after translation is P_new=X+2n(Y-1)=7. The data packet with original serial number P_original=13 satisfies condition 1 and is located in dotted area 1 in the matrix. The translation method for the data packet with original serial number P_original=13 is to translate to the left. The coordinates of the data packet with original serial number P_original=13 after translation are (0,4), which satisfies condition 5. The coordinates of the data packet with original serial number P_original=13 are changed to (2,2). Therefore, the new serial number of the data packet with original serial number P_original=13 after translation is P_new=X+2n(Y-1)=6.
[0213] The process then proceeds to S1201, where K=0 at present, and the process ends.
[0214] By repeating the process of FIG. 12 above for each data packet in the matrix, the translation method for all data packets in the matrix can be obtained.
[0215] The above is the method by which the server translates data packets in the matrix when the translation number is 1. Those skilled in the art can understand the translation process for more translation numbers based on Figures 11 and 12.
[0216] The server performs K parallel shifts on all data packets in the matrix, then uses P_new in the matrix after the parallel shift as the number of the data packet in the matrix and sends it to the target terminal device. During transmission, the sub-upgrade packets are out of order and mixed with interference packets, greatly increasing the difficulty of cracking.
[0217] 13A-13D are schematic diagrams illustrating how a server translates data packets into an even-dimensional matrix according to different shift-out directions, according to an embodiment of the present disclosure.
[0218] In one embodiment, the layer number in which the data packet is located can be determined based on the serial number P of each data packet. Referring to the first and second layers in Figure 11, when the shift-out direction is left and rotated clockwise, the movement method of the data packet in any layer in the matrix is as shown in Figure 13A.
[0219] In region 1, the movement method of the data packet is to move it to the left, and the coordinates of the data packet are changed to subtract 1 from the X value and leave the Y value as it is.
[0220] In region 2, the data packet is moved up, and the coordinates of the data packet are changed so that the X value remains the same and 1 is subtracted from the Y value.
[0221] In region 3, the movement method of the data packet is to move it to the right, and the coordinates of the data packet are changed to add 1 to the X value and leave the Y value unchanged.
[0222] In region 4, the data packet is moved downwards, and the coordinates of the data packet are changed so that the X value remains the same and 1 is added to the Y value.
[0223] In the layer of FIG. 13A, conditions 1 to 5 for determining the movement direction of a data packet, which have been described with reference to FIG. 12, can be obtained based on dividing the regions of different movement directions.
[0224] In FIG. 13A, the data packet shifted out of the matrix is returned to coordinates (n,n).
[0225] Referring to FIG. 13B, we will now explain how data packets move at any layer in the matrix when the shift-out direction is right and rotated clockwise.
[0226] In regions 1 to 4, the data packet movement method is the same as that described with reference to FIG. 13A, and therefore will not be described again here. In the layer of FIG. 13B, based on dividing the regions with different movement directions, the conditions for the server to determine the movement direction of the data packet in the matrix can be obtained when the movement direction is right and rotated clockwise. For the sake of brevity, the specific conditions will not be described.
[0227] In FIG. 13B, the data packet shifted out of the matrix is returned to coordinates (n+1, n+1).
[0228] Referring to FIG. 13C, we will now explain how data packets move in any layer of the matrix when the shift-out direction is up and rotated clockwise.
[0229] In regions 1 to 4, the data packet movement method is the same as that described with reference to FIG. 13A, and therefore will not be described again here. In the layer of FIG. 13C, based on dividing the regions with different movement directions, the conditions for the server to determine the movement direction of the data packet in the matrix can be obtained when the movement direction is up and rotated clockwise. For the sake of brevity, the specific conditions will not be described.
[0230] In FIG. 13C, the data packet shifted out of the matrix is returned to coordinates (n+1,n).
[0231] Referring to FIG. 13D, we will now explain how data packets move at any layer in the matrix when the shift-out direction is down and rotates clockwise.
[0232] In regions 1 to 4, the data packet movement method is the same as that described with reference to FIG. 13A, so it will not be described again here. Based on dividing the regions with different movement directions in the layer of FIG. 13D, we can obtain the conditions under which the server determines the movement direction of the data packet in the matrix when the shift-out direction is down and rotated clockwise. For the sake of brevity, the specific conditions will not be described.
[0233] In FIG. 13D, the data packet shifted out of the matrix is returned to coordinates (n, n+1).
[0234] Meanwhile, the order of the sub-upgrade packets can be changed within an even-dimensional matrix by translating the matrix and rotating it counterclockwise. For the sake of brevity, the detailed process will not be described.
[0235] In one embodiment, the target terminal device can restore the order of the sub-upgrade packets based on the reverse process of the server's translation process of the data packets in the matrix. In one embodiment, the target terminal device can restore the order of the sub-upgrade packets by continuing the server's translation process of the data packets in the matrix.
[0236] The above describes an example in which the order of sub-upgrade packets is changed in the form of a rotation by translating data packets within a matrix. In addition to the above-described left, right, up, and down shift-out directions and clockwise and counterclockwise rotations, the order of sub-upgrade packets can be changed / restored by translating data packets within an odd- or even-dimensional matrix with different translation counts. Those skilled in the art can move data packets within a matrix using a translation method without rotation or other translation methods to change / restore the order of sub-upgrade packets. All of these are within the contemplation of the present disclosure.
[0237] FIG. 14 is a diagram illustrating a firmware upgrade device applied to a server according to an embodiment of the present disclosure.
[0238] As shown in FIG. 14, 1400 is a firmware upgrade device for a server.
[0239] The firmware upgrade device 1400 may include a firmware upgrade packet acquirer 1410 for acquiring a target firmware upgrade packet.
[0240] The firmware upgrade device 1400 may include a receiving device 1420 for receiving an identification code of the target terminal device.
[0241] The firmware upgrade device 1400 may include a dividing device 1430 that divides the target firmware upgrade packet into sub-upgrade packets based on the identification code of the target terminal device.
[0242] The firmware upgrade device 1400 may include a storage and transmission device 1440 for storing and / or transmitting the sub-upgrade packets to the target terminal device.
[0243] FIG. 15 is a diagram illustrating a firmware upgrade device applied to a terminal device according to an embodiment of the present disclosure.
[0244] As shown in FIG. 15, 1500 is a firmware upgrade device applied to a target terminal device.
[0245] The firmware upgrade device 1500 may include a firmware upgrade instruction obtainer 1510 for obtaining firmware upgrade instructions.
[0246] The firmware upgrade device 1500 may include a receiving device 1520 for receiving an identification code of the target terminal device.
[0247] The firmware upgrade device 1500 may include a download and receive unit 1530 for downloading and receiving sub-upgrade packets.
[0248] The firmware upgrade device 1500 may include a merging device 1540 for merging the sub-upgrade packets into a target firmware upgrade packet based on the identification code of the target terminal device.
[0249] FIG. 16 is a flowchart of a secure boot applied to a target terminal device according to an embodiment of the present disclosure.
[0250] After the terminal device is soft rebooted, the terminal device executes the secure boot program.
[0251] In S1601, it is determined whether the firmware upgrade information has been upgraded. If so, the process proceeds to S1602, where the target firmware is started.
[0252] If not, the process proceeds to S1603, where information in the terminal device's preset tmp partition is obtained and analyzed to determine whether to change the order of the sub-upgrade packets. In S1603 to S1605, the process of determining whether to change the order of the sub-upgrade packets and how to change the order of the sub-upgrade packets is similar to the description in the corresponding part above, and therefore will not be repeated.
[0253] In S1606, it is determined whether security verification of the target firmware is successful. Security verification can be performed on the target firmware based on the firmware upgrade key and / or integrity verification information included in the firmware upgrade command. In some implementations, the integrity verification information may be, for example, an MD5 value or other integrity verification information, and is not limited to unique information in this embodiment. The info packet sent to the target terminal device may further include the firmware upgrade key and / or integrity verification information. Security verification of the target firmware is performed based on the firmware upgrade key and / or integrity verification information. If the firmware upgrade key carried by the info packet and sent to the terminal device matches the firmware upgrade key in the firmware upgrade command and / or the integrity verification information of the terminal device matches the integrity verification information in the firmware upgrade command, the security verification is successful. If the security verification fails, the process ends. If the security verification is successful, the process proceeds to S1607.
[0254] In S1607, the firmware upgrade packet can be executed. In one embodiment, the firmware upgrade packet can be copied to an execution address and jumped to the execution address to run the upgraded target firmware. In one embodiment, the firmware upgrade packet can be executed directly from the corresponding partition in flash.
[0255] In S1607, the boot information of the target firmware can be changed to indicate that it has been upgraded.
[0256] Through the above-mentioned secure boot process, the sub-upgrade packets are divided and the order of the sub-upgrade packets is changed for transmission and download, which further improves the security of the firmware upgrade, realizes firmware integrity verification and secure boot configuration operation, and ensures the legitimacy of the firmware.
[0257] FIG. 17 is a flowchart of combining offline and online security verification applied to a target terminal device according to an embodiment of the present disclosure.
[0258] In step S1701, the target terminal device may disconnect from the wide area network and obtain a firmware upgrade command and a security verification key. The target terminal device may obtain the firmware upgrade command and the security verification key through a broadcast device disconnected from the wide area network via broadcast or point-to-point communication. The broadcast device disconnected from the wide area network may be, for example, a handheld broadcast device. In one embodiment, the target terminal device may obtain a download base address from the broadcast device disconnected from the wide area network. The target terminal device may obtain the download address of the firmware upgrade packet based on the default changeable address, the download base address, and the identification code. The broadcast device disconnected from the wide area network may be realized using short-range wireless communication such as Bluetooth, Bluetooth LE, ZigBee, Radio Frequency Identification (RFID), Ultra Wide Band (UWB), 60 GHz, Wi-Fi, or WiMAX, or a wired communication method such as USB. Since the broadcasting device is disconnected from the wide area network, not using the wide area network can effectively avoid the security risks involved in transmitting over the wide area network.
[0259] In step S1702, the target terminal device can obtain the firmware upgrade packet and the security key of the firmware upgrade packet through the wide area network.
[0260] In step S1703, the target terminal device can determine whether the security verification key matches the security key of the firmware upgrade packet. For example, the target terminal device can determine whether the security verification key obtained by disconnecting from the wide area network matches the security key of the firmware upgrade packet obtained through the wide area network. If they match, the firmware upgrade packet is confirmed to be safe; if they do not match, risk information is reported.
[0261] The process of obtaining the firmware upgrade packet by the target terminal device is similar to the above-mentioned firmware upgrade process of the terminal device based on the identification code and the secure boot process applied to the target terminal device, and will not be repeated here.
[0262] The present specification and the accompanying drawings are provided only as examples to aid in the understanding of the present disclosure. They should not be construed as limiting the scope of the present disclosure in any way. Although specific embodiments and examples have been provided, it will be apparent to those skilled in the art based on the content disclosed herein that modifications can be made to the illustrated embodiments and examples without departing from the scope of the present disclosure.
[0263] Although the present disclosure has been described with illustrative examples, various changes and modifications may be suggested to those skilled in the art, and the present disclosure is intended to cover such changes and modifications that fall within the scope of the appended claims.
[0264] No description of the present invention should be construed as implying that any particular element, step, or function is essential for inclusion within the scope of the claims. The scope of patented subject matter is limited only by the claims.
Claims
1. A method for upgrading the firmware applied to the server side, Steps to obtain the target firmware upgrade packet, The steps include receiving the identification code of the target terminal device, The steps include dividing the target firmware upgrade packet into sub-upgrade packets based on the identification code of the target terminal device, A firmware upgrade method characterized by comprising the steps of storing the sub-upgrade packet and / or transmitting the sub-upgrade packet to a target terminal device.
2. The steps include obtaining the size of the sub-upgrade packet based on the identification code of the target terminal device, The firmware upgrade method according to claim 1, further comprising the step of determining the number of divided sub-upgrade packets based on the size of the sub-upgrade packets.
3. The firmware upgrade method according to claim 1, further comprising the step of determining a download address on which a target terminal device will download the sub-upgrade packet, based on the identification code of the sub-upgrade packet and the default changeable address.
4. The steps include obtaining the sequence identifier of the sub-upgrade packet based on the identification code of the target terminal device, A step of determining whether the order of the sub-upgrade packets has been changed based on the order identifier of the sub-upgrade packets, The steps include: determining that the order of the sub-upgrade packets has not been changed, and assigning numbers to the sub-upgrade packets according to their initial order; A firmware upgrade method according to claim 1, further comprising the steps of: changing the order of sub-upgrade packets in response to the determination that the order of sub-upgrade packets has been changed, and numbering the sub-upgrade packets according to the changed order of sub-upgrade packets.
5. The firmware upgrade method according to claim 4, characterized in that each of the sub-upgrade packets includes a sub-upgrade packet header that includes a sub-upgrade packet number.
6. The firmware upgrade method according to claim 5, wherein the header of the sub-upgrade packet further includes an identification code for a target terminal device and at least one of the number of sub-upgrade packets separated from the target firmware upgrade packet.
7. The step of determining whether the order of the sub-upgrade packets has been changed based on the order identifier of the sub-upgrade packets is: The steps include identifying the value indicated by the sequence identifier, A firmware upgrade method according to claim 4, comprising the step of determining whether the order of sub-upgrade packets has been changed based on the value indicated by the sequence identifier.
8. The firmware upgrade method according to claim 7, characterized in that the step of determining whether the order of sub-upgrade packets has been changed based on the value indicated by the sequence identifier includes the step of determining whether the order of sub-upgrade packets has been changed based on whether the value indicated by the sequence identifier is a first predetermined value.
9. The step of determining whether the order of sub-upgrade packets has been changed based on the value indicated by the sequence identifier is: The steps include obtaining the remainder of the value indicated by the sequence identifier by a second predetermined value of two or more natural numbers, A firmware upgrade method according to claim 7, comprising the step of determining whether the order of sub-upgrade packets has been changed based on the remainder.
10. The firmware upgrade method according to claim 9, characterized in that the second predetermined value is 2, and the step of determining whether the order of sub-upgrade packets has been changed based on the value indicated by the sequence identifier includes the step of determining whether the order of sub-upgrade packets has been changed based on the parity of the value indicated by the sequence identifier.
11. The step of changing the order of sub-upgrade packets based on the aforementioned order identifier is: The steps include identifying the value indicated by the sequence identifier, A firmware upgrade method according to claim 4, comprising the step of changing the order of sub-upgrade packets based on the value indicated by the sequence identifier.
12. The sequence identifier includes data of a predetermined number of bits, and the step of identifying the value indicated by the sequence identifier includes the step of identifying the value indicated by the data. The step of changing the order of sub-upgrade packets is: A step of dividing a sub-upgrade packet into sub-upgrade packet groups, wherein each sub-upgrade packet group includes a specific number of sub-upgrade packets whose initial order is adjacent, and the specific number is the maximum value that a predetermined number of bits of data can represent plus one. A firmware upgrade method according to claim 11, comprising the step of swapping the order of two sub-upgrade packets in each sub-upgrade packet group whose difference in initial order is equal to the value shown in the data.
13. The step of changing the order of the sub-upgrade packets is: A step of dividing a sub-upgrade packet into sub-upgrade packet groups, wherein each sub-upgrade packet group contains a specific number of sub-upgrade packets whose initial order is adjacent, and the specific number is predetermined by the server. A firmware upgrade method according to claim 4, comprising the step of swapping the order of two sub-upgrade packets such that the difference in their initial order within each sub-upgrade packet group is less than a specific value.
14. A step of generating a matrix according to the number of sub-upgrade packets, The steps include arranging the sub-upgrade packets in a matrix, The firmware upgrade method according to claim 4, characterized in that the step of changing the order of sub-upgrade packets includes the step of translating the sub-upgrade packets into a matrix according to an order identifier.
15. The firmware upgrade method according to claim 14, wherein the step of generating a matrix according to the number of sub-upgrade packets includes a step of determining whether to generate an odd-dimensional matrix or an even-dimensional matrix according to the number of sub-upgrade packets.
16. The firmware upgrade method according to claim 15, further comprising the step of filling a matrix with one or more of garbled packets, empty packets, and duplicate sub-upgrade packets.
17. The firmware upgrade method according to claim 14, characterized in that the sequence identifier indicates one or more of the following: the number of translations of the sub-upgrade packets in the matrix, the shift-out direction of the sub-upgrade packets, and the clockwise or counterclockwise rotation of the sub-upgrade packets in the matrix.
18. The firmware upgrade method according to claim 17, further comprising the step of determining a method for translating sub-upgrade packets according to the serial number in the matrix of sub-upgrade packets and the dimensions of the matrix.
19. The process further includes the step of storing the header of the target firmware upgrade packet and / or sending it to the target terminal device, The firmware upgrade method according to claim 1, characterized in that the header of the target firmware upgrade packet includes one or more of the following: an identification code for the target terminal device, the number and number of sub-upgrade packets, a firmware upgrade key, and integrity verification information.
20. A method for upgrading the firmware applied to terminal equipment, Steps to obtain firmware upgrade instructions, The steps include transmitting the identification code of the target terminal device, The steps to download the sub-upgrade packet from the server, A firmware upgrade method characterized by comprising the step of integrating sub-upgrade packets based on the identification code of a target terminal device to form an upgrade packet for the target firmware.
21. Download the firmware upgrade packet header from the server and, through the secure boot program, The steps include determining whether to change the order of downloaded sub-upgrade packets based on the order identifier in the terminal device's identification code, in accordance with the download of all sub-upgrade packets and firmware upgrade packet headers to the terminal device, A step to perform security or integrity verification on the downloaded sub-upgrade packets, The firmware upgrade method according to claim 20, further comprising the step of activating the target firmware integrated in the sub-upgrade packet in response to the successful security or integrity verification of the downloaded sub-upgrade packet.
22. The step of obtaining the firmware upgrade command includes the step of disconnecting from the wide area network and obtaining the firmware upgrade command and security verification key. The step of downloading the sub-upgrade packet from the server includes the step of obtaining the firmware upgrade packet and the security key for the firmware upgrade packet via a wide area network. The firmware upgrade method according to claim 21, characterized in that security verification of the downloaded sub-upgrade packet includes the step of determining whether the security verification key matches the security key of the firmware upgrade packet.
23. A firmware upgrade device applied to a server, A firmware upgrade packet acquisition device that acquires upgrade packets for the target firmware, A receiving device that receives the identification code of the target terminal device, A splitting device that splits the target firmware upgrade packet into sub-upgrade packets based on the identification code of the target terminal device, A firmware upgrade device comprising a storage and transmission device for storing the sub-upgrade packets and / or for transmitting the sub-upgrade packets to a target terminal device.
24. A firmware upgrade device applicable to terminal devices, A firmware upgrade command acquisition device that acquires firmware upgrade commands, A transmitting device that transmits an identification code for a target terminal device, A download and receive device that downloads and receives sub-upgrade packets from the server, A firmware upgrade device comprising: an integrating device that integrates the sub-upgrade packets into a target firmware upgrade packet based on the identification code of the target terminal device.
25. Includes memory and one or more processors, A server characterized in that a computer program is stored in the memory, and when the computer program is executed by the one or more processors, the method according to any one of claims 1 to 19 is executed.
26. Includes memory and one or more processors, A terminal device characterized in that a computer program is stored in the memory, and when the computer program is executed by the one or more processors, the method according to any one of claims 20 to 22 is performed.
27. A secure boot method applicable to terminal devices, The steps include determining whether to change the order of downloaded sub-upgrade packets based on the order identifier in the terminal device's identification code, in accordance with the download of all sub-upgrade packets and firmware upgrade packet headers to the terminal device, A step to perform security or integrity verification on the downloaded sub-upgrade packets, A secure boot method characterized by comprising the step of activating the target firmware integrated in the sub-upgrade packet, depending on whether the downloaded sub-upgrade packet has successfully undergone security or integrity verification.
28. A security verification method applicable to target terminal devices, The steps include disconnecting from the wide area network and obtaining the firmware upgrade command and security verification key, The steps include obtaining a firmware upgrade packet and the security key for the firmware upgrade packet via a wide-area network, A security verification method characterized by comprising the step of determining whether the security verification key matches the security key of the firmware upgrade packet.
29. The step of obtaining firmware upgrade packets via a wide area network includes the step of downloading sub-upgrade packets from a server via a wide area network. The aforementioned security verification method is The steps include transmitting the identification code of the target terminal device, The security verification method according to claim 28, further comprising the step of integrating the sub-upgrade packets based on the identification code of the target terminal device to form an upgrade packet for the target firmware.
30. The aforementioned security verification method downloads the firmware upgrade packet header from the server and, through the secure boot program, The steps include: determining whether to change the order of downloaded sub-upgrade packets based on the order identifier in the identification code of the target terminal device, in accordance with the download of all sub-upgrade packets and firmware upgrade packet headers to the target terminal device; A step to perform security or integrity verification on the downloaded sub-upgrade packets, The security verification method according to claim 29, further comprising the step of activating the target firmware integrated in the sub-upgrade packet in response to the successful security or integrity verification of the downloaded sub-upgrade packet.