On-chip limited space one-way transmission equipment firmware updating method
By storing the encrypted firmware to the USB flash drive and using the optical module on the HOST side for firmware update, the problem of complex operation and insufficient storage space in the firmware update process of optical signal unidirectional transmission equipment is solved, and an efficient and simplified firmware update process is achieved.
Patent Information
- Application Number
- CN202411875274.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-19
AI Technical Summary
The optical signal one-way transmission device has problems such as complex operation during the firmware update process, which may cause the device to lose power and cannot continue to use during the update process. Moreover, due to limited on-chip storage space, it is impossible to complete the update of the original firmware and the new firmware.
By encrypting the new version of firmware and storing it to the USB flash drive, and using the optical module on the HOST side to send initialization commands, the USB flash drive file system is completed, the firmware is read and decrypted, the new firmware base address is judged and written to complete the firmware update. At the same time, firmware update is achieved through optical module transmission at the HOST and SLAVE terminals.
Without the need to use PC update tools, the operation process is simplified, the security and reliability of the equipment are improved, the problem of insufficient on-chip storage space is solved, and batch firmware update is realized, which is suitable for optical signal one-way transmission equipment.
Smart Images

Figure CN119781795A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of optical signal unidirectional transmission equipment, and in particular to a firmware update method for unidirectional transmission equipment with limited space within a chip. Background Art
[0002] The optical signal unidirectional transmission device consists of two security chips and optical fiber modules that realize the functions of the transmitter (HOST) and the receiver (SLAVE). Figure 1 Among them, the HOST end realizes the U disk mounting and the file system analysis in the disk, and sends the data of the files in the disk to the SLAVE end through a single-channel path; the SLAVE end transfers the received files to the PC host through the host USB port.
[0003] During the use of the one-way transmission device, if there are firmware defects or function improvements, the new firmware program needs to be burned into the device to replace the original firmware program. Because the one-way transmission device is a dual-chip solution, the firmware update is more complicated than that of a single-chip device. During the development stage of the one-way transmission device, a downloader can be used to download or update the program. However, after being launched on the market, the product has been encapsulated with a shell, and no download interface is reserved in the shell. The HOST and SLAVE chips need to be removed from the shell, and the firmware can be updated with the help of a PC update tool after entering the BOOT mode through short-circuiting and other methods. This method is not only cumbersome to operate, but also may cause a sudden power failure during the update process, and the device cannot continue to be used. When a large number of device firmware needs to be updated, it will also consume a lot of manpower and financial resources.
[0004] In addition, when writing new firmware, the device needs to be powered on again to verify the new firmware before the original firmware can be updated to prevent firmware loss. The on-chip NORFLASH storage space is limited. Because the HOST end loads the USB file system, it involves Chinese character encoding conversion. The data volume of this encoding conversion table is more than 100KB, which will occupy a very large on-chip storage space. In this way, the sum of the size of the original firmware and the new firmware exceeds the on-chip storage space. When the on-chip storage space is smaller than the sum of the size of the original firmware and the new firmware, the firmware update cannot be completed. Summary of the invention
[0005] In order to overcome the deficiencies of the above technologies, the present invention provides a method for updating firmware of a unidirectional transmission device in a limited space within a chip, which has short execution time, high efficiency, wide adaptability and realizes batch firmware updates.
[0006] The technical solution adopted by the present invention to overcome the technical problems is: A method for updating firmware of a unidirectional transmission device in a limited space on a chip, comprising: S1. Encrypt the new version of the firmware and store the encrypted firmware in a USB flash drive; S2. The optical module at the HOST end of the unidirectional transmission device sends an initialization command, and the xchi interface completes initialization; S3. Insert the USB flash drive into the HOST end of the one-way transmission device. The HOST end of the one-way transmission device determines whether a USB flash drive is inserted. If yes, the USB flash drive file system is built. S4. The HOST end of the one-way transmission device reads the firmware in the USB disk and decrypts it; S5. Determine whether the decrypted firmware is upgraded for the HOST end, if so, execute step S6, if not, send it to the SLAVE end of the one-way transmission device; S6. The HOST end of the one-way transmission device starts the initialization and sets the new firmware base address, writes the decrypted firmware to the new firmware base address, and completes the firmware update; S7. After the firmware is updated, the HOST end of the one-way transmission device is powered on again; S8. The optical module at the SLAVE end of the unidirectional transmission device sends an initialization command and starts the cycle; S9. Determine whether the optical module at the SLAVE end receives the firmware information sent by the HOST end, if yes, execute step S10, if not, return to step S8; S10. Determine whether the message type sent by the HOST end is an update start instruction. If so, the SLAVE end of the one-way transmission device starts the initialization setting and sets the new firmware base address to write the decrypted firmware to the new firmware base address to complete the firmware update. If not, execute step S11; S11 determines whether the message type sent by the HOST end is a write data command. If so, the decrypted firmware is read cyclically and updated to the FLASH in the SLAVE end of the one-way transmission device. If not, step S12 is executed; S12. Determine whether the message type sent by the HOST end is an update end instruction. If so, the SLAVE end of the one-way transmission device is powered on again after the firmware is updated. If not, execute other instructions sent by the HOST end.
[0007] Further, step S1 includes the following steps: S11. Generate SM2 private key pair, which consists of signature private key and signature public key; S12. Record the signature private key in the signature tool database; S13. Store the signature public key in the FLASH of the one-way transmission device HOST end chip; S14. Generate a hash value h for the bin file of the new version of the firmware, and perform SM4 encryption on the hash value h using the signature private key to obtain the encrypted firmware.
[0008] Furthermore, the encrypted firmware and signature public key are placed in the H_FW folder on the HOST side.
[0009] Furthermore, the encrypted firmware is placed in the S_FW folder on the SLAVE side.
[0010] Furthermore, the HOST end of the one-way transmission device completes the construction of the USB file system by mounting the file system of the USB disk.
[0011] Further, step S4 includes the following steps: S41. The HOST end of the one-way transmission device reads the encrypted firmware and signature public key in the U disk; S42 performs DM4 decryption operation on the encrypted firmware to obtain the decrypted firmware; S43. Use the signature public key to perform public key verification on the decrypted firmware to determine whether the convention verification has passed. If yes, execute step S5, if not, exit the upgrade.
[0012] Furthermore, in step S5, if the decrypted firmware is not upgraded for the HOST end, an update start instruction is sent, the decrypted firmware is read cyclically and sent to the SLAVE end of the unidirectional transmission device, and an update end instruction is sent after the decrypted firmware is sent to the SLAVE end of the unidirectional transmission device.
[0013] Furthermore, when the HOST and SLAVE ends of the unidirectional transmission device are powered on again, it is detected whether a firmware upgrade is required. If an upgrade is required, a CRC check is performed on the decrypted firmware. After the check passes, reading starts from the decrypted firmware base address and overwrites the original firmware base address. If the check fails, the firmware is returned to the original firmware. If an upgrade is not required, the BOOT program jumps to the original firmware base address and runs the original firmware.
[0014] The beneficial effects of the present invention are: without the need for PC-side update tools, the vulnerabilities and defects of the device during use can be repaired to improve the security and reliability of the device; the device can obtain the latest functions to improve the practicality of the device. The method simplifies the operation process, saves manpower and financial resources, and has good application prospects in some government departments and application scenarios with high confidentiality requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a structural diagram of a one-way optical signal transmission device; Figure 2 is a firmware update flow chart of the present invention; Figure 3 This is a comparison diagram before and after the firmware optimization of the present invention. DETAILED DESCRIPTION
[0016] The following is combined with Figure 1 , Attachment Figure 2 , Attachment Figure 3 The present invention is further described.
[0017] As attached Figure 2 As shown, a method for updating firmware of a unidirectional transmission device in a limited space on a chip includes: S1. Encrypt the new version of the firmware and store the encrypted firmware in a USB flash drive.
[0018] S2. The optical module at the HOST end of the unidirectional transmission device sends an initialization command, and the xchi interface completes initialization.
[0019] S3. Insert the USB flash drive into the HOST end of the one-way transmission device. The HOST end of the one-way transmission device determines whether a USB flash drive is inserted. If yes, the USB flash drive file system is built.
[0020] S4. The HOST end of the one-way transmission device reads the firmware in the USB flash drive and decrypts it.
[0021] S5. Determine whether the decrypted firmware is upgraded by the HOST end. If yes, execute step S6. If not, send it to the SLAVE end of the one-way transmission device.
[0022] S6. The HOST end of the one-way transmission device starts the setting initialization and sets the new firmware base address, writes the decrypted firmware to the new firmware base address, and completes the firmware update.
[0023] S7. After the firmware is updated, the HOST end of the one-way transmission device is powered on again.
[0024] S8. The optical module at the SLAVE end of the unidirectional transmission device sends an initialization command and starts the cycle.
[0025] S9. Determine whether the optical module at the SLAVE end has received the firmware information sent by the HOST end. If yes, execute step S10; if not, return to execute step S8.
[0026] S10. Determine whether the message type sent by the HOST end is an update start instruction. If so, the SLAVE end of the one-way transmission device starts the setting initialization and sets the new firmware base address to write the decrypted firmware to the new firmware base address to complete the firmware update. If not, execute step S11.
[0027] S11. Determine whether the message type sent by the HOST end is a write data command. If yes, read the decrypted firmware in a loop and update it to the FLASH in the SLAVE end chip of the unidirectional transmission device. If not, execute step S12.
[0028] S12. Determine whether the message type sent by the HOST end is an update end instruction. If so, the SLAVE end of the one-way transmission device is powered on again after the firmware is updated. If not, execute other instructions sent by the HOST end.
[0029] Without the help of PC-side update tools, the USB disk containing the firmware file is inserted into the USB port of the HOST end. The HOST end reads the firmware file after mounting the U disk file system to update the firmware of the HOST and SLAVE end chips; in addition, a method for reducing the firmware size of the HOST end firmware is proposed to solve the problem of insufficient on-chip storage space. This method is time-saving, efficient, and widely adaptable, and can realize batch firmware updates. It is suitable for the firmware update scenario of optical signal unidirectional transmission equipment. The security mechanism is mainly reflected in identity authentication, encrypted transmission, integrity verification, firmware rollback, firmware reduction, etc.
[0030] In one embodiment of the present invention, step S1 comprises the following steps: S11. Generate SM2 private key pair, the private key pair consists of a signature private key and a signature public key.
[0031] S12. Record the signature private key in the signature tool database.
[0032] S13. Store the signature public key in the FLASH in the HOST chip of the one-way transmission device.
[0033] S14. Generate a hash value h for the bin file of the new version of the firmware, and perform SM4 encryption on the hash value h using the signature private key to obtain the encrypted firmware.
[0034] In one embodiment of the present invention, the encrypted firmware and the signature public key are placed in the H_FW folder of the HOST end.
[0035] In one embodiment of the present invention, the encrypted firmware is placed in the S_FW folder of the SLAVE end.
[0036] In one embodiment of the present invention, the HOST end of the one-way transmission device completes the construction of the USB file system by mounting the file system of the USB disk.
[0037] In one embodiment of the present invention, step S4 includes the following steps: S41. The HOST end of the one-way transmission device reads the encrypted firmware and signature public key in the USB flash drive.
[0038] S42. Perform DM4 decryption operation on the encrypted firmware to obtain the decrypted firmware.
[0039] S43. Use the signature public key to perform public key verification on the decrypted firmware to determine whether the convention verification has passed. If yes, execute step S5, if not, exit the upgrade.
[0040] In one embodiment of the present invention, if the decrypted firmware is not upgraded for the HOST end in step S5, an update start instruction is sent, the decrypted firmware is read in a loop and sent to the SLAVE end of the unidirectional transmission device, and an update end instruction is sent after the decrypted firmware is sent to the SLAVE end of the unidirectional transmission device.
[0041] When the USB flash drive is identified on the HOST side, the USB3.0 OTG controller of the security chip of the one-way transmission device can act as the host (HOST) and device (DEVICE), supporting USB2.0 / USB3.0 and eXtensible Host Controller Interface (XHCI) protocols. The HOST side uses the host mode, and the controller sends a transfer request to the USB device according to the data structure prepared by the system software. The SLAVE side uses the SLAVE mode to respond to the host transfer request. The HOST side is responsible for controlling and managing the connected slave devices to realize data transmission. It includes operations such as USB flash drive enumeration and bulk transfer.
[0042] When the HOST mounts the U disk file system, the FatFs, EXT (2 / 3 / 4), and NTFS file systems are built inside the U disk to perform file read and write operations on the inserted U disk. Among them, FatFs provides a file system compatible with Windows and Linux, supports FAT12, FAT16, FAT32, exFAT, supports multiple volumes, and has good hardware platform independence. When in use, the storage medium initialization function disk_initialize, the status detection function disk_status, the sector reading function disk read, and the storage medium control function disk_ioctl are logically written.
[0043] The HOST and SLAVE ends of the unidirectional transmission device are transmitted through optical modules. The optical modules use the unidirectionality of light to establish a data path between the HOST and SLAVE ends, and send the firmware used by the SLAVE end from the HOST end to the SLAVE end for SLAVE end firmware update. The HOST end implements interfaces such as sending initialization and sending data; the SLAVE end implements interfaces such as receiving initialization, judging whether there is data to be received, and receiving data of a specified length.
[0044] The HOST side can reduce the firmware. Specifically: remove the constant large array data such as the character code conversion table in the program from the firmware, and use the conversion tool to convert the large array into a Bin data file so that it is no longer part of the firmware file, thereby reducing the firmware size. When the firmware is updated, the on-chip space changes from the previous "original firmware + new firmware + remaining space" to "original firmware + new firmware + remaining space + large array data". The comparison of the on-chip space before and after is shown in the attached figure. Figure 3 When using the firmware download tool to download the original firmware, use the script file to download the large array Bin file to the specified area in the chip. When using the array data, read the data from the specified area in sequence according to the offset.
[0045] In one embodiment of the present invention, when the HOST and SLAVE ends of the unidirectional transmission device are powered on again, it is detected whether a firmware upgrade is required. If an upgrade is required, a CRC check is performed on the decrypted firmware to ensure that it has not been tampered with or damaged. After the check passes, the firmware is read from the decrypted firmware base address and the original firmware base address is overwritten. If the check fails, the firmware is returned to the original firmware to ensure that the firmware is not lost to ensure normal use of the device. If an upgrade is not required, the BOOT program jumps to the original firmware base address and runs the original firmware.
[0046] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for updating firmware of a unidirectional transmission device in a limited space on a chip, characterized in that: include: S1. Encrypt the new version of the firmware and store the encrypted firmware in a USB flash drive; S2. The optical module at the HOST end of the unidirectional transmission device sends an initialization command, and the xchi interface completes initialization; S3. Insert the USB flash drive into the HOST end of the one-way transmission device. The HOST end of the one-way transmission device determines whether a USB flash drive is inserted. If yes, the USB flash drive file system is built. S4. The HOST end of the one-way transmission device reads the firmware in the USB disk and decrypts it; S5. Determine whether the decrypted firmware is upgraded for the HOST end, if so, execute step S6, if not, send it to the SLAVE end of the one-way transmission device; S6. The HOST end of the one-way transmission device starts the initialization and sets the new firmware base address, writes the decrypted firmware to the new firmware base address, and completes the firmware update; S7. After the firmware is updated, the HOST end of the one-way transmission device is powered on again; S8. The optical module at the SLAVE end of the unidirectional transmission device sends an initialization command and starts the cycle; S9. Determine whether the optical module at the SLAVE end receives the firmware information sent by the HOST end, if yes, execute step S10, if not, return to step S8; S10. Determine whether the message type sent by the HOST end is an update start instruction. If so, the SLAVE end of the one-way transmission device starts the initialization setting and sets the new firmware base address to write the decrypted firmware to the new firmware base address to complete the firmware update. If not, execute step S11; S11 determines whether the message type sent by the HOST end is a write data command. If so, the decrypted firmware is read cyclically and updated to the FLASH in the SLAVE end of the one-way transmission device. If not, step S12 is executed; S12. Determine whether the message type sent by the HOST end is an update end instruction. If so, the SLAVE end of the one-way transmission device is powered on again after the firmware is updated. If not, execute other instructions sent by the HOST end.
2. The method for updating firmware of a unidirectional transmission device in a limited space on a chip according to claim 1, characterized in that: Step S1 includes the following steps: S11. Generate SM2 private key pair, which consists of signature private key and signature public key; S12. Record the signature private key in the signature tool database; S13. Store the signature public key in the FLASH of the one-way transmission device HOST end chip; S14. Generate a hash value h for the bin file of the new version of the firmware, and perform SM4 encryption on the hash value h using the signature private key to obtain the encrypted firmware.
3. The method for updating firmware of a unidirectional transmission device in a limited space on a chip according to claim 2, characterized in that: Place the encrypted firmware and signature public key in the H_FW folder on the HOST side.
4. The method for updating firmware of a unidirectional transmission device in a limited space on a chip according to claim 2, characterized in that: Place the encrypted firmware in the S_FW folder on the SLAVE side.
5. The method for updating firmware of a unidirectional transmission device in a limited space on a chip according to claim 1, characterized in that: The HOST end of the one-way transmission device completes the construction of the USB file system by mounting the file system of the USB disk.
6. The method for updating firmware of a unidirectional transmission device in a limited space on a chip according to claim 3, characterized in that: Step S4 includes the following steps: S41. The HOST end of the one-way transmission device reads the encrypted firmware and signature public key in the U disk; S42 performs DM4 decryption operation on the encrypted firmware to obtain the decrypted firmware; S43. Use the signature public key to perform public key verification on the decrypted firmware to determine whether the convention verification has passed. If yes, execute step S5, if not, exit the upgrade.
7. The method for updating firmware of a unidirectional transmission device in a limited space on a chip according to claim 1, characterized in that: In step S5, if the decrypted firmware is not upgraded for the HOST end, an update start instruction is sent, the decrypted firmware is read cyclically and sent to the SLAVE end of the unidirectional transmission device, and an update end instruction is sent after the decrypted firmware is sent to the SLAVE end of the unidirectional transmission device.
8. The method for updating firmware of a unidirectional transmission device in a limited space on a chip according to claim 1, characterized in that: When the HOST and SLAVE ends of the unidirectional transmission device are powered on again, it is detected whether a firmware upgrade is required. If an upgrade is required, a CRC check is performed on the decrypted firmware. After the check passes, the firmware is read from the decrypted firmware base address and the original firmware base address is overwritten. If the check fails, the firmware is returned to the original firmware. If an upgrade is not required, the BOOT program jumps to the original firmware base address and runs the original firmware.
Citation Information
Patent Citations
Method for firmware upgrading, and host side device and system
CN105094877A
Method and apparatus for upgrading optical module firmware
CN108958765A
In-application upgrade method for optical module firmware not breaking service
US20150154017A1
System and method for providing assured database updates via a one-way data link
US20150370826A1
Program upgrade method and apparatus, computer device, storage medium, and program product
WO2024036577A1