FPGA-based dual-mirror software online upgrading anti-bricking method and system
By dividing the FPGA memory into Header sector, G image sector, and U image sector, and adopting a strategy of upgrading non-currently running images first and a dual timer design, the problem of FPGA devices becoming bricked during online upgrades is solved. Online safe upgrades and fallbacks of G and U images are realized, improving the fault tolerance and reliability of the system.
Patent Information
- Application Number
- CN202611234030.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-14
- Publication Date
- 2026-11-20
AI Technical Summary
In the existing dual-image architecture of FPGAs, the G image cannot be upgraded online. Forced upgrades can easily lead to abnormal power outages or bus interference, causing the device to be unable to load any image, resulting in the device becoming bricked and unable to start normally. Furthermore, when MultiBoot fails to load multiple images, the fallback mechanism cannot be effectively triggered, leading to a system loop crash.
The FPGA's memory is divided into a Header sector, a G-image sector, and a U-image sector. The Header sector stores boot information and is always write-protected. The G-image sector and the U-image sector are both functional images that can be upgraded online. During the upgrade, the non-currently running image is upgraded first, and the other functional image is upgraded only after the integrity verification is passed. The fallback function is determined by the ICAP primitive, and a dual timer design is adopted to limit the loading time limit to ensure that the fallback can be triggered in abnormal scenarios.
It enables online secure upgrades for G and U images, preventing boot information corruption, resolving device bricking issues, improving system fault tolerance and reliability, and ensuring that devices can still load the original, intact version through the fallback mechanism under abnormal circumstances.
Smart Images

Figure CN123137697A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of FPGA software upgrade technology, and in particular to a dual-mirror online software upgrade method and system based on FPGA to prevent bricking. Background Technology
[0002] In aerospace, high-end assembly, and other fields, FPGAs serve as core control units, and the reliability of their program upgrades and the flexibility of their operation and maintenance directly affect the success or failure of missions and the effectiveness of equipment. The traditional open-coverage upgrade mode, which relies on FPGA emulators, requires physical contact with the download port and the burning of the MCS file to the FLASH memory. In scenarios where the equipment has already been assembled, delivered to the user, or deployed in harsh environments, this not only faces the dilemma of time-consuming and labor-intensive physical operations, but also poses a severe challenge to reliability indicators such as equipment sealing, becoming a technical bottleneck restricting the intelligent operation and maintenance of high-end equipment.
[0003] While MultiBoot multi-image technology provides K7 series FPGAs with basic online upgrade and fault tolerance capabilities, the existing dual-image architecture of G image (Golden image) + U image (Update image) has inherent limitations. The G image is stored at the starting address of FLASH and serves as the system's backup version, while the U image is the upgradeable version. Under this architecture, only online updates of the U image are supported, and the G image remains fixed and cannot be upgraded according to system needs. If the G image is forcibly upgraded, abnormal power outages or bus interference during the upgrade process may cause boot information corruption, directly preventing the FPGA from loading any image, resulting in the device becoming unusable, unable to load normally, and failing to boot. When MultiBoot multi-image loading fails, the fallback mechanism cannot be effectively triggered, leading to a system loop of crashes. Summary of the Invention
[0004] Based on the above analysis, the present invention aims to provide a dual-image software online upgrade method and system based on FPGA to prevent bricking, in order to solve the existing problems that can only upgrade the U image and cannot upgrade the G image, and that forcibly upgrading the G image is prone to bricking.
[0005] On one hand, embodiments of the present invention provide a dual-mirror software online upgrade method for preventing bricking based on FPGA, comprising the following steps: The FPGA's memory is divided into multiple partitions; these partitions include a Header sector, a G-image sector, and a U-image sector; the Header sector is used to store boot information and is always write-protected; the G-image sector and the U-image sector are both functional images that can be upgraded online. After the FPGA is powered on, the boot information of the Header sector is read, and the functional image is loaded according to the boot information. During the upgrade process, the non-current running image is upgraded first. After the integrity verification is passed, the other functional image is then upgraded, and so on, until both functional images are upgraded.
[0006] Based on the above method, the current running image is determined in the following way: The ICAP primitive is called to read the FPGA register value. The register value is used to determine whether the fallback function has been triggered. If the fallback function is triggered, the current running image is the G image; otherwise, the current running image is the U image.
[0007] Further improvements to the above method include upgrading non-currently running images, including: S301. After the FPGA receives the upgrade command for a non-current running image sent by the host computer, it removes the write protection of the non-current running image area. S302: Erase non-currently running mirror areas by sector, and send a confirmation signal to the host computer after the erasure is completed; S303: The host computer sends upgrade versions of .bin files from non-currently running image areas frame by frame; S304. The FPGA verifies the received file. If the verification is successful, the received file is written to a non-current running image area. If there is an error, the upgrade fails and the process proceeds to step S306. S305. Perform integrity verification for upgrading non-current running image areas. If the verification passes, report successful upgrade to the host computer and complete the upgrade of non-current running image. Otherwise, report upgrade failure. S306. After receiving the upgrade failure feedback, the host computer powers off and restarts the FPGA; then returns to step S301.
[0008] Based on a further improvement of the above method, the Header sector is located in sector 0 of the FPGA; after the FPGA powers on, it reads the boot information of the Header sector and loads the functional image according to the boot information, including: After the FPGA is powered on, the Header image is read from sector 0 of the memory; The boot header information in the Header image is loaded, and the jump instruction in the boot header information is used to jump to the starting address of the U image to load and run the U image; if the U image fails to load, the fallback function is triggered, and the jump is used to jump to the starting address of the G image to load and run the G image.
[0009] Based on the further improvement of the above method, the FPGA memory also includes a first timer mirror area and a second timer mirror area; the first timer is used to limit the maximum lookup time of the U mirror synchronization header; the second timer is used to limit the maximum loading time of the U mirror.
[0010] On the other hand, embodiments of the present invention provide an FPGA-based dual-mirror software online upgrade anti-bricking system, comprising: Host computer, FLASH memory, and FPGA chip; The FLASH memory's storage space is divided into multiple partitions; each partition includes a Header sector, a G-image sector, and a U-image sector; the Header sector is used to store boot information and is always write-protected; the G-image sector and the U-image sector are both functional images that can be upgraded online; The FPGA chip is connected to the FLASH memory via an SPI interface; after the FPGA is powered on, it reads the boot information of the Header sector and loads the function image according to the boot information. The host computer is communicatively connected to the FPGA chip and is used to issue upgrade commands and upgrade files; When upgrading the FPGA, the non-current running image is upgraded first. After the integrity verification is passed, the other functional image is upgraded, and so on, until both functional images are upgraded.
[0011] Based on further improvements to the above system, the current running image is determined using the following method: The ICAP primitive is called to read the FPGA register value. The register value is used to determine whether the fallback function has been triggered. If the fallback function is triggered, the current running image is the G image; otherwise, the current running image is the U image.
[0012] Based on further improvements to the above system, upgrades are made to non-currently running images, including: S301. After the FPGA receives the upgrade command for a non-current running image sent by the host computer, it removes the write protection of the non-current running image area. S302: Erase non-currently running mirror areas by sector, and send a confirmation signal to the host computer after the erasure is completed; S303: The host computer sends upgrade versions of .bin files from non-currently running image areas frame by frame; S304. The FPGA verifies the received file. If the verification is successful, the received file is written to a non-current running image area. If there is an error, the upgrade fails and the process proceeds to step S306. S305. Perform integrity verification for upgrading non-current running image areas. If the verification passes, report successful upgrade to the host computer and complete the upgrade of non-current running image. Otherwise, report upgrade failure. S306. After receiving the upgrade failure feedback, the host computer powers off and restarts the FPGA; then returns to step S301.
[0013] Based on a further improvement to the above system, the Header sector is located in sector 0 of the FPGA; after the FPGA powers on, it reads the boot information of the Header sector and loads the functional image according to the boot information, including: After the FPGA is powered on, the Header image is read from sector 0 of the memory; The boot header information in the Header image is loaded, and the jump instruction in the boot header information is used to jump to the starting address of the U image to load and run the U image; if the U image fails to load, the fallback function is triggered, and the jump is used to jump to the starting address of the G image to load and run the G image.
[0014] Based on further improvements to the above system, the FPGA memory also includes a first timer mirror area and a second timer mirror area; the first timer is used to limit the maximum lookup time of the U-image synchronization header; the second timer is used to limit the maximum loading time of the U-image.
[0015] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects: 1. Breaking through the limitation of traditional solutions that can only upgrade the U image, it supports online secure software upgrades of both G and U images in the FLASH memory, meeting the needs of FPGA device system function iteration and vulnerability repair; 2. The header sector is independently designed and has a write protection mechanism to prevent boot information from being corrupted at the source, thus completely solving the "bricked" problem; 3. The dual timer design solves the problem of loading failure loops, ensuring that fallback can be triggered in abnormal scenarios, thus improving system fault tolerance.
[0016] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description
[0017] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. Figure 1 This is a flowchart of an embodiment of the FPGA-based dual-mirror software online upgrade method for preventing bricking. Figure 2 This is a schematic diagram of memory partitioning according to an embodiment of the present invention; Figure 3 This is an upgrade flowchart of an embodiment of the present invention; Figure 4 This is a diagram showing the normal operating register state of an embodiment of the present invention; Figure 5 This is a diagram showing the error register state in an embodiment of the present invention. Figure 6 This is a block diagram of an FPGA-based dual-mirror software online upgrade system for preventing bricking, as described in an embodiment of the present invention. Detailed Implementation
[0018] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0019] A specific embodiment of the present invention discloses a dual-mirror software online upgrade method based on FPGA to prevent bricking, such as... Figure 1 As shown, it includes the following steps: S1. The FPGA's memory is divided into multiple partitions; the partitions include a Header sector, a G-image sector, and a U-image sector; the Header sector is used to store boot information and is always write-protected; the G-image sector and the U-image sector are both functional images that can be upgraded online; S2. After the FPGA is powered on, it reads the boot information of the Header sector and loads the function image according to the boot information. S3. During the upgrade, first upgrade the non-current running image. After the integrity verification is passed, upgrade the other functional image, until both functional images are upgraded.
[0020] Compared to existing technologies, the FPGA-based dual-image software online upgrade method for preventing bricking provided in this embodiment divides the memory into multiple partitions, including a Header sector, a G-image sector, and a U-image sector. The Header sector partition stores boot information and is write-protected, thus preventing information corruption at its source. When the FPGA powers on, it loads the functional image based on the boot information in the Header sector. During an upgrade, the non-currently running functional image sector is upgraded first, followed by the other functional image. This overcomes the limitation of traditional solutions that can only upgrade the U-image. Throughout the upgrade process, a successfully loaded, intact version is always retained. Even if an anomaly such as power failure or bus interference occurs during the upgrade of another version, the original intact version can still be loaded via a fallback mechanism after the device restarts, completely avoiding bricking. Furthermore, both the G-image sector and the U-image sector store the upgrade version, thus achieving a truly complete upgrade.
[0021] During implementation, the FPGA's FLASH memory is first partitioned. The Header sector exclusively occupies sector 0 of the FLASH (address 0x00000000), storing the synchronization header (e.g., 0xAA995566 for a 7-series FPGA), device ID, jump instructions (pointing to the U-image's starting address), image address table, and checksum. The Header sector independently stores boot information, physically isolated from the G and U images, and is always write-protected. During upgrades, only the sector containing the functional image is erased or written; the boot information remains unaffected, ensuring that the boot parameters required for the MultiBoot jump mechanism are always valid, thus preventing bricking.
[0022] The G image region is located after the Header sector, with addresses ranging from 0x00010000 to 0x007FEFFF. It stores a functional image with basic remote upgrade capabilities, supports online erasure and write upgrades, and serves as a backup for the U image region. Configure the XDC constraint corresponding to the G image to enable Fallback.
[0023] The U-image area, located after the G-image area, stores feature images with basic remote upgrade capabilities. It supports online erasure and rewrite upgrades, serves as the default loaded image, and also acts as a backup for the G-image area. The XDC constraint of the U-image is configured to enable fallback.
[0024] When the FPGA device leaves the factory, the .bit files corresponding to each partition are assembled into a single .mcs file according to the address order. The .mcs file synthesized by the initial function software is written into the SPI FLASH memory by connecting the JTAG interface of the FPGA device through the JTAG emulator.
[0025] After programming is complete, the write-protect pin (WP) of the Header sector is pulled high by default via the FPGA's GPIO and permanently locked.
[0026] After the FPGA powers on, it reads the boot information from the Header sector and loads the functional image based on the boot information. Specifically, this includes: After the FPGA is powered on, the Header image is read from sector 0 of the memory; The boot header information in the Header image is loaded, and the jump instruction in the boot header information is used to jump to the starting address of the U image to load and run the U image; if the U image fails to load, the fallback function is triggered, and the jump is used to jump to the starting address of the G image to load and run the G image.
[0027] During implementation, since the Header sector is permanently protected after the initial write, there will be no issues with errors due to subsequent writes. Loading is performed based on the boot header information in the Header sector, defaulting to loading and running the U image. If the U image loading fails (e.g., due to device ID verification or CRC check failure), the fallback function is triggered, jumping to the G image's starting address to load and run the G image. After the functional image loading is complete, a "DONE" signal is sent to the host computer to lock the configuration data and start the full business functionality.
[0028] In practice, to further improve the operational reliability of the FPGA, a timer mirror area is partitioned in the FPGA's memory, including a first timer mirror area and a second timer mirror area. The first timer is used to limit the maximum lookup time of the U-mirror synchronization header; the second timer is used to limit the maximum loading time of the U-mirror.
[0029] In practice, the first timer mirror area is set after the G mirror area and before the U mirror area. For example, the address ranges from 0x007FF000 to 0x007FFFFF.
[0030] The second timer mirror area is set after the U mirror area. For example, if the U mirror area address is 0x00800000~0x00FFEFFF, the second timer mirror area is 0x00FFF000~0x00FFFFF.
[0031] The XDC constraint configuration corresponding to the G image also includes the jump address pointing to the starting address of the first timer image area, and the time limit of the first timer.
[0032] The XDC constraint configuration corresponding to the U image also includes the time limit of the second timer.
[0033] In implementation, the first and second timer images have built-in delay logic. The first timer's timeout is set to, for example, 100ms, and the second timer's timeout is set to, for example, 200ms. If a valid synchronization header is not found within the timeout period, a fallback is triggered, and the G image is loaded. The partitioning diagram of this invention is shown below. Figure 2 As shown.
[0034] During implementation, the logic for the first and second timers can be written using TCL scripts. Running the scripts generates .bit files for both the first and second timer images. When the FPGA device leaves the factory, the .bit files corresponding to each partition are assembled into a single .mcs firmware file according to address order. A JTAG emulator is then connected to the FPGA device's JTAG interface to write the .mcs file synthesized by the initial functional software into the SPI FLASH memory. After programming, the write-protect pin (WP) of the first timer image area is permanently locked by default through the FPGA's GPIO.
[0035] After the FPGA powers on, it reads the Header image from sector 0 of the memory. Based on the jump instruction in the boot header information of the Header image, it jumps to the starting address of the U-image, and the first timer starts. If the U-image synchronization header is not found within the longest search time limit, the fallback function is triggered. If the U-image synchronization header is found, the U-image data is loaded, and the second timer starts. If the U-image loading is not completed within the longest loading time limit, the fallback function is triggered.
[0036] The problem of loading failure loops is solved by using a dual timer design, ensuring that fallback can be triggered in abnormal scenarios, thereby improving the system's fault tolerance.
[0037] To avoid both images failing due to abnormal upgrade processes, this invention adopts a priority strategy of first upgrading the non-currently running image, and then upgrading the other functional image only after successful verification.
[0038] Specifically, the current running image is determined using the following method: The ICAP primitive is called to read the FPGA register value. The register value is used to determine whether the fallback function has been triggered. If the fallback function is triggered, the current running image is the G image; otherwise, the current running image is the U image.
[0039] During implementation, the ICAP source code is called to read the status values of each status bit in the Boot_Status register and report them to the host computer. The current FPGA device loading image is determined by judging the status bits of the register.
[0040] If the Fallback flag in the register is 1, the fallback function is triggered when loading the U image; therefore, the currently running image is the G image. If the Fallback flag in the register is 0, the image is loaded normally without triggering the fallback function; therefore, the currently running image is the U image.
[0041] During implementation, priority is given to upgrading images that are not currently running. After integrity verification, the other functional image is then upgraded. Throughout the upgrade process, a successfully loaded, intact version is always retained. Even if an anomaly such as power failure or bus interference occurs while upgrading another version, the original intact version can still be loaded through the fallback mechanism after the device restarts, completely avoiding the device becoming unusable.
[0042] During implementation, upgrades are performed on non-current running images, including: S301. After the FPGA receives the upgrade command for a non-current running image sent by the host computer, it removes the write protection of the non-current running image area. S302: Erase non-currently running mirror areas by sector, and send a confirmation signal to the host computer after the erasure is completed; S303: The host computer sends upgrade versions of .bin files from non-currently running image areas frame by frame; S304. The FPGA verifies the received file. If the verification is successful, the received file is written to a non-current running image area. If there is an error, the upgrade fails and the process proceeds to step S306. S305. Perform integrity verification for upgrading non-current running image areas. If the verification passes, report successful upgrade to the host computer and complete the upgrade of non-current running image. Otherwise, report upgrade failure. S306. After receiving the upgrade failure feedback, the host computer powers off and restarts the FPGA; then returns to step S301.
[0043] When implementing, such as Figure 3 As shown, if the currently running image is the U image, the host computer sends a G image upgrade command. After receiving the command, the FPGA removes the write protection of the G image area through the GPIO pin, while retaining the write protection status of the Header sector, timer1 area, and timer2 area. Then, it erases the data in the G image area sector by sector, and sends a confirmation signal to the host computer after the erasure is complete. After receiving the signal, the host computer sends the .bin bitstream file generated by the software with the latest functions frame by frame. The FPGA verifies the received file, verifying the sequence number and CRC value frame by frame to ensure that there is no data loss or error code. Then, it writes the received file page by page to the G image area. If the verification fails, it reports an upgrade failure and proceeds to step S306. After receiving the upgrade failure feedback, the host computer powers off and restarts the FPGA.
[0044] After the write operation is complete, the FPGA reads the synchronization header, ID identifier, and CRC checksum of the G image area and performs integrity verification: if the verification passes, it reports "G image upgrade successful"; if the verification fails, it reports "G image upgrade failed".
[0045] If the host computer receives a "G image upgrade failed" feedback, it will power off and then power on the FPGA device to restart it, repeating the above operation for a second upgrade until the FPGA device reports "G image upgrade successful". After the G image upgrade verification is successful, the host computer will then issue a U image upgrade command. The FPGA device will erase and write the U image area according to the same process as above. After completion, it will perform an integrity verification. If the verification is successful, it will report "U image upgrade successful".
[0046] If the currently running image is the G image, the host computer sends a U image upgrade command. After receiving the command, the FPGA removes the write protection of the U image area through GPIO pins, while retaining the write protection status of the Header sector, timer1 area, and timer2 area. Then, it erases the data in the U image area sector by sector, and sends a confirmation signal to the host computer after the erasure is complete. After receiving the signal, the host computer sends the latest software-generated .bin bitstream file frame by frame. The FPGA verifies the received file, checking the sequence number and CRC value frame by frame to ensure that there is no data loss or error code. Then, it writes the received file page by page to the U image area. If the verification fails, it reports an upgrade failure and proceeds to step S306. After receiving the upgrade failure feedback, the host computer powers off and restarts the FPGA to perform the update again.
[0047] After the write operation is complete, the FPGA reads the synchronization header, ID identifier, and CRC checksum of the G image area and performs integrity verification: if the verification passes, it reports "U image upgrade successful"; if the verification fails, it reports "U image upgrade failed".
[0048] If the host computer receives a "U image upgrade failed" feedback, it will power off and then power on the FPGA device (the currently running image is the G image), and repeat the above operation to perform a second upgrade until the FPGA device reports "U image upgrade successful".
[0049] After both images have been upgraded and verified, the FPGA device is powered on and restarted, and the U image is loaded first according to the Header sector boot information.
[0050] By burning the Header, dual images, and dual timer partitions at the factory, the device is safely guided by the Header to load the U image first during runtime. If the dual timers detect that the U image has failed to load, the device will automatically roll back to the G image. During upgrades, the device always follows the two-way backup logic of repairing the backup first and then the primary one, ensuring that the device can still start and has remote repair capabilities after any single point of upgrade failure, thus achieving permanent protection against bricking.
[0051] After completing the primary and backup dual-image software upgrade according to the above secure online upgrade process, in order to verify the correctness of the upgraded G image area function code stream, a U image stream that triggers the fallback mechanism can be artificially generated, including CRC error, device ID error, first timer timeout, and second timer timeout.
[0052] During implementation, the status of each status bit in the Boot_Status register of the Vivado 18.3 system in the development environment is read by calling the ICAP source code to determine whether the status is normal. For normal operating status, see [link to relevant documentation]. Figure 4 The status bits ending with "error" are all 0, and the values of status_valid (this flag indicates whether the power-on / refactoring process is complete, 1 indicates that the complete power-on / refactoring process is completed) and internal_prog (internal refactoring configuration flag) are 1, indicating that the jump to the U image is successful and the configuration is correct.
[0053] If an error occurs, the status bit corresponding to the error type ending in "error" is pulled high, triggering the rollback mechanism. The following simulates a device ID error to test and verify the rollback mechanism. See [link to Boot_Status register for details] for the status after a configuration error occurs. Figure 5 As shown. With Figure 4 Comparative analysis: FAllBACK being 1 indicates that the U image has encountered an error, triggering the rollback mechanism; ID_ERROE being 1 indicates that the error is due to a timeout error in the first timer; STATUS_VALID and INTERNAL_PROG being 1 indicate that the rollback mechanism has been successfully started and the Golden security image has been configured. The configuration file rollback is successful, and the FPGA device loads the G image region stream and continues to run with the latest system software version.
[0054] A specific embodiment of the present invention discloses an FPGA-based dual-mirror software online upgrade system to prevent bricking, such as... Figure 6 As shown, it includes: a host computer, a FLASH memory, and an FPGA chip; The FLASH memory's storage space is divided into multiple partitions; each partition includes a Header sector, a G-image sector, and a U-image sector; the Header sector is used to store boot information and is always write-protected; the G-image sector and the U-image sector are both functional images that can be upgraded online; The FPGA chip is connected to the FLASH memory via an SPI interface; after the FPGA is powered on, it reads the boot information of the Header sector and loads the function image according to the boot information. The host computer is communicatively connected to the FPGA chip and is used to issue upgrade commands and upgrade files; When upgrading the FPGA, the currently running image is upgraded first. After the integrity verification is passed, the other functional image is upgraded, and so on, until both functional images are upgraded.
[0055] During implementation, the Fudan Microelectronics XC7K325T FPGA chip (comparable to Xilinx Kintex-7) and the JFM29GL256 SPI FLASH chip (256MB capacity, SPI interface) can be selected.
[0056] The host computer issues upgrade commands and documents via the optical communication bus.
[0057] Preferably, the current running image is determined in the following way: The ICAP primitive is called to read the FPGA register value. The register value is used to determine whether the fallback function has been triggered. If the fallback function is triggered, the current running image is the G image; otherwise, the current running image is the U image.
[0058] Preferably, upgrading non-current running images includes: S301. After the FPGA receives the upgrade command for a non-current running image sent by the host computer, it removes the write protection of the non-current running image area. S302: Erase non-currently running mirror areas by sector, and send a confirmation signal to the host computer after the erasure is completed; S303: The host computer sends upgrade versions of .bin files from non-currently running image areas frame by frame; S304. The FPGA verifies the received file. If the verification is successful, the received file is written to a non-current running image area. If there is an error, the upgrade fails and the process proceeds to step S306. S305. Perform integrity verification for upgrading non-current running image areas. If the verification passes, report successful upgrade to the host computer and complete the upgrade of non-current running image. Otherwise, report upgrade failure. S306. After receiving the upgrade failure feedback, the host computer powers off and restarts the FPGA; then returns to step S301.
[0059] Preferably, the Header sector is located in sector 0 of the FPGA; after the FPGA powers on, it reads the boot information of the Header sector and loads the functional image according to the boot information, including: After the FPGA is powered on, the Header image is read from sector 0 of the memory; The boot header information in the Header image is loaded, and the jump instruction in the boot header information is used to jump to the starting address of the U image to load and run the U image; if the U image fails to load, the fallback function is triggered, and the jump is used to jump to the starting address of the G image to load and run the G image.
[0060] Preferably, the FPGA's memory also includes a first timer mirror area and a second timer mirror area; the first timer is used to limit the maximum lookup time of the U-image synchronization header; the second timer is used to limit the maximum loading time of the U-image.
[0061] The above-described method and system embodiments are based on the same principles, and their related aspects can be referenced from each other to achieve the same technical effects. For specific implementation processes, please refer to the foregoing embodiments, which will not be repeated here.
[0062] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0063] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A dual-mirror software online upgrade method for preventing bricking based on FPGA, characterized in that, Includes the following steps: The FPGA's memory is divided into multiple partitions; these partitions include a Header sector, a G-image sector, and a U-image sector; the Header sector is used to store boot information and is always write-protected; the G-image sector and the U-image sector are both functional images that can be upgraded online. After the FPGA is powered on, the boot information of the Header sector is read, and the functional image is loaded according to the boot information. During the upgrade process, the non-current running image is upgraded first. After the integrity verification is passed, the other functional image is then upgraded, and so on, until both functional images are upgraded.
2. The FPGA-based dual-mirror software online upgrade method for preventing bricking according to claim 1, characterized in that, The currently running image is determined in the following way: The ICAP primitive is called to read the FPGA register value. The register value is used to determine whether the fallback function has been triggered. If the fallback function is triggered, the current running image is the G image; otherwise, the current running image is the U image.
3. The FPGA-based dual-mirror software online upgrade method for preventing bricking as described in claim 1, characterized in that, Upgrades to images that are not currently running, including: S301. After the FPGA receives the upgrade command for a non-current running image sent by the host computer, it removes the write protection of the non-current running image area. S302: Erase non-currently running mirror areas by sector, and send a confirmation signal to the host computer after the erasure is completed; S303: The host computer sends upgrade versions of .bin files from non-currently running image areas frame by frame; S304. The FPGA verifies the received file. If the verification is successful, the received file is written to a non-current running image area. If there is an error, the upgrade fails and the process proceeds to step S306. S305. Perform integrity verification for upgrading non-current running image areas. If the verification passes, report successful upgrade to the host computer and complete the upgrade of non-current running image. Otherwise, report upgrade failure. S306. After receiving the upgrade failure feedback, the host computer powers off and restarts the FPGA; then returns to step S301.
4. The FPGA-based dual-mirror software online upgrade method for preventing bricking according to claim 1, characterized in that, The Header sector is located in sector 0 of the FPGA; after the FPGA powers on, it reads the boot information of the Header sector and loads the functional image according to the boot information, including: After the FPGA is powered on, the Header image is read from sector 0 of the memory; The boot header information in the Header image is loaded, and the jump instruction in the boot header information is used to jump to the starting address of the U image to load and run the U image; if the U image fails to load, the fallback function is triggered, and the jump is used to jump to the starting address of the G image to load and run the G image.
5. The FPGA-based dual-mirror software online upgrade method for preventing bricking according to claim 4, characterized in that, The FPGA's memory also includes a first timer mirror area and a second timer mirror area; the first timer is used to limit the maximum lookup time of the U-image synchronization header; the second timer is used to limit the maximum loading time of the U-image.
6. A dual-mirror software online upgrade anti-bricking system based on FPGA, characterized in that, include: Host computer, FLASH memory, and FPGA chip; The FLASH memory's storage space is divided into multiple partitions; each partition includes a Header sector, a G-image sector, and a U-image sector; the Header sector is used to store boot information and is always write-protected; the G-image sector and the U-image sector are both functional images that can be upgraded online; The FPGA chip is connected to the FLASH memory via an SPI interface; after the FPGA is powered on, it reads the boot information of the Header sector and loads the function image according to the boot information. The host computer is communicatively connected to the FPGA chip and is used to issue upgrade commands and upgrade files; When upgrading the FPGA, the non-current running image is upgraded first. After the integrity verification is passed, the other functional image is upgraded, and so on, until both functional images are upgraded.
7. The FPGA-based dual-mirror software online upgrade anti-brick system according to claim 6, characterized in that, The currently running image is determined in the following way: The ICAP primitive is called to read the FPGA register value. The register value is used to determine whether the fallback function has been triggered. If the fallback function is triggered, the current running image is the G image; otherwise, the current running image is the U image.
8. The FPGA-based dual-mirror software online upgrade anti-brick system according to claim 6, characterized in that, Upgrades to images that are not currently running, including: S301. After the FPGA receives the upgrade command for a non-current running image sent by the host computer, it removes the write protection of the non-current running image area. S302: Erase non-currently running mirror areas by sector, and send a confirmation signal to the host computer after the erasure is completed; S303: The host computer sends upgrade versions of .bin files from non-currently running image areas frame by frame; S304. The FPGA verifies the received file. If the verification is successful, the received file is written to a non-current running image area. If there is an error, the upgrade fails and the process proceeds to step S306. S305. Perform integrity verification for upgrading non-current running image areas. If the verification passes, report successful upgrade to the host computer and complete the upgrade of non-current running image. Otherwise, report upgrade failure. S306. After receiving the upgrade failure feedback, the host computer powers off and restarts the FPGA; then returns to step S301.
9. The FPGA-based dual-mirror software online upgrade anti-brick system according to claim 6, characterized in that, The Header sector is located in sector 0 of the FPGA; after the FPGA powers on, it reads the boot information of the Header sector and loads the functional image according to the boot information, including: After the FPGA is powered on, the Header image is read from sector 0 of the memory; The boot header information in the Header image is loaded, and the jump instruction in the boot header information is used to jump to the starting address of the U image to load and run the U image; if the U image fails to load, the fallback function is triggered, and the jump is used to jump to the starting address of the G image to load and run the G image.
10. The FPGA-based dual-mirror software online upgrade anti-brick system according to claim 9, characterized in that, The FPGA's memory also includes a first timer mirror area and a second timer mirror area; the first timer is used to limit the maximum lookup time of the U-image synchronization header; the second timer is used to limit the maximum loading time of the U-image.
