[go: up one dir, main page]

CN117573157A - A reliable remote firmware upgrade method based on ZYNQ MPSoC - Google Patents

A reliable remote firmware upgrade method based on ZYNQ MPSoC Download PDF

Info

Publication number
CN117573157A
CN117573157A CN202311376615.XA CN202311376615A CN117573157A CN 117573157 A CN117573157 A CN 117573157A CN 202311376615 A CN202311376615 A CN 202311376615A CN 117573157 A CN117573157 A CN 117573157A
Authority
CN
China
Prior art keywords
partition
zynq
firmware
upgrade
firmware data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311376615.XA
Other languages
Chinese (zh)
Inventor
彭树生
钱志明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing University of Science and Technology
Original Assignee
Nanjing University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing University of Science and Technology filed Critical Nanjing University of Science and Technology
Priority to CN202311376615.XA priority Critical patent/CN117573157A/en
Publication of CN117573157A publication Critical patent/CN117573157A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a reliable remote firmware upgrading method based on ZYNQ MPSoC. The method uses a FLASH memory (FLASH) chip as a storage medium by partitioning the storage medium of the ZYNQ system, and divides the storage medium into a main partition, a backup partition and a log partition. And establishing communication with the server by using a TFTP protocol, and receiving, checking and programming the upgrade firmware data to the main partition according to the communication protocol. The boot loader selects the corresponding partition to start according to the flag bit in the log partition. In addition, in the process of communication protocol analysis and firmware data integrity detection, it is necessary to define the communication protocol and analyze it, and calculate the cyclic redundancy check code to ensure the correctness and integrity of the firmware data. And finally, by adopting a multi-partition starting scheme, the backup partition starting when the main partition fails to upgrade is realized, and the main partition firmware data is upgraded remotely again, so that the reliability and the safety of remote firmware upgrading are improved.

Description

一种基于ZYNQ MPSoC的可靠远程固件升级方法A reliable remote firmware upgrade method based on ZYNQ MPSoC

技术领域Technical field

本发明属于远程固件升级技术领域,具体为一种基于ZYNQ MPSoC的可靠远程固件升级方法。The invention belongs to the technical field of remote firmware upgrade, and is specifically a reliable remote firmware upgrade method based on ZYNQ MPSoC.

背景技术Background technique

在目前的ZYNQ MPSoC(多处理器系统芯片)嵌入式系统中,常常使用对应的下载器(如JTAG)进行开发和烧写。开发完成后,会生成相应的固件,并通过JTAG和特定的烧录程序将固件烧写到ZYNQ设备中的FLASH芯片中。然而,由于ZYNQ通常被封装在产品结构件中,作为数字信号处理设备使用,如果仍然采用JTAG方式对产品进行升级,则需要拆除产品结构件,这不仅非常不方便且缺乏灵活性,而且给后期的维护带来很大困难。因此,迫切需要一种远程固件升级的解决方案。In the current ZYNQ MPSoC (multi-processor system chip) embedded system, the corresponding downloader (such as JTAG) is often used for development and programming. After the development is completed, the corresponding firmware will be generated and burned into the FLASH chip in the ZYNQ device through JTAG and a specific burning program. However, since ZYNQ is usually packaged in product structural parts and used as digital signal processing equipment, if the product is still upgraded using JTAG, the product structural parts need to be dismantled. This is not only very inconvenient and lacks flexibility, but also creates problems for later stages. Maintenance brings great difficulties. Therefore, a solution for remote firmware upgrade is urgently needed.

然而,在远程固件升级过程中,可能会出现异常情况导致固件数据丢失,从而导致远程升级失败,使得产品无法正常启动。为了解决这个问题,需要设计一个回退机制,以保证产品在固件升级失败的情况下,能够利用回退功能从备份分区启动芯片。回退机制的设计思路是,在固件升级过程中,首先将当前运行的固件备份到另一个分区中。然后,将新的固件进行烧写和更新。如果固件升级成功,系统可以正常启动并使用新的固件。但如果在升级过程中发生异常导致失败,系统可以自动切换到备份分区,并重新启动芯片,以确保系统的可靠性和稳定性。However, during the remote firmware upgrade process, abnormal conditions may occur that cause firmware data to be lost, causing the remote upgrade to fail and the product to fail to start normally. In order to solve this problem, a fallback mechanism needs to be designed to ensure that the product can use the fallback function to boot the chip from the backup partition if the firmware upgrade fails. The design idea of the rollback mechanism is that during the firmware upgrade process, the currently running firmware is first backed up to another partition. Then, flash and update the new firmware. If the firmware upgrade is successful, the system can boot normally and use the new firmware. However, if an exception occurs during the upgrade process and causes failure, the system can automatically switch to the backup partition and restart the chip to ensure system reliability and stability.

通过这样的回退机制,即使在远程固件升级过程中出现问题,也能够保证设备的正常运行。当需要修复或重新尝试升级时,可以通过远程方式重新触发固件升级流程,从而实现灵活、方便的远程固件升级。Through such a rollback mechanism, even if a problem occurs during the remote firmware upgrade process, the normal operation of the device can be guaranteed. When it is necessary to repair or retry the upgrade, the firmware upgrade process can be retriggered remotely, thereby achieving flexible and convenient remote firmware upgrade.

发明内容Contents of the invention

本发明提出了一种基于ZYNQ MPSoC的可靠远程固件升级方法。The present invention proposes a reliable remote firmware upgrade method based on ZYNQ MPSoC.

实现本发明目的的技术方案为:一种基于ZYNQ MPSoC的可靠远程固件升级方法,包括:The technical solution to achieve the purpose of the present invention is: a reliable remote firmware upgrade method based on ZYNQ MPSoC, including:

步骤1:将ZYNQ MPSoC嵌入式系统的存储介质分为主分区、备份分区、日志分区,并对ZYNQ MPSoC嵌入式系统初始化外设及时钟;Step 1: Divide the storage medium of the ZYNQ MPSoC embedded system into the primary partition, backup partition, and log partition, and initialize the peripherals and clocks of the ZYNQ MPSoC embedded system;

步骤2:ZYNQ MPSoC嵌入式系统通过TFTP协议与服务器进行握手,建立通信;Step 2: The ZYNQ MPSoC embedded system shakes hands with the server through the TFTP protocol to establish communication;

步骤3:ZYNQ MPSoC嵌入式系统在接收到服务器发出的升级固件指令后,中断当前任务并回复服务器已准备升级;Step 3: After receiving the firmware upgrade instruction from the server, the ZYNQ MPSoC embedded system interrupts the current task and replies that the server is ready to upgrade;

步骤4:服务器收到ZYNQ发出的准备完成信号后,将升级固件按照事先约定的通信协议发送给客户端;Step 4: After receiving the preparation completion signal from ZYNQ, the server sends the upgraded firmware to the client according to the pre-agreed communication protocol;

步骤5:ZYNQ根据相应通信协议解析服务器传来的数据得到升级固件后,计算接收到的固件数据的循环冗余校验码;Step 5: After ZYNQ parses the data sent from the server according to the corresponding communication protocol to obtain the upgraded firmware, it calculates the cyclic redundancy check code of the received firmware data;

步骤6:将计算得到的循环冗余校验码与通信协议中的循环冗余校验码对比,若校验码一致,则代表接收到的升级固件数据的正确且完整;若校验码不一致,则回复服务器固件数据错误,服务器将重新发出升级固件指令,即跳转到步骤3;。Step 6: Compare the calculated cyclic redundancy check code with the cyclic redundancy check code in the communication protocol. If the check codes are consistent, it means that the received upgrade firmware data is correct and complete; if the check codes are inconsistent. , then the server firmware data error will be replied, and the server will re-issue the firmware upgrade instruction, that is, jump to step 3;.

步骤7:将接收到的升级固件数据通过FLASH控制器烧写到FLASH芯片的主分区中,并将日志分区中的升级标志位置位;Step 7: Burn the received upgraded firmware data into the main partition of the FLASH chip through the FLASH controller, and set the upgrade flag in the log partition;

步骤8:烧录完成后,ZYNQ通过看门狗实现嵌入式系统的软复位,重启系统进入ZYNQ芯片固化的引导程序;加载第一阶段引导加载程序;Step 8: After the burning is completed, ZYNQ implements a soft reset of the embedded system through the watchdog, restarts the system and enters the boot program solidified by the ZYNQ chip; loads the first-stage boot loader;

步骤9:第一阶段引导加载程序根据日志分区中的标志位,引导启动主分区并将日志分区中的首次启动标志位置位;若主分区启动失败,则由第一阶段引导加载程序重新引导备份分区启动,跳转到步骤1,重新升级ZYNQ嵌入式系统;若主分区成功启动,则代表升级完成。Step 9: The first-stage boot loader boots the primary partition according to the flag bit in the log partition and sets the first boot flag in the log partition; if the primary partition fails to start, the first-stage boot loader reboots the backup Start the partition, jump to step 1, and re-upgrade the ZYNQ embedded system; if the main partition starts successfully, the upgrade is complete.

优选地,主分区用于存放正常工作的固件数据,并且主分区始终为远程升级的目的分区;备份分区用于存放安全模式的固件数据,此固件数据能够实现远程升级的基本功能,并且备份分区的固件数据处于写保护状态,确保其中的固件数据不被改变;日志分区中存放升级和启动时的标志位信息,第一阶段引导加载程序FSBL会根据其中的标志位信息选择相应的分区启动。Preferably, the primary partition is used to store normal working firmware data, and the primary partition is always the destination partition for remote upgrade; the backup partition is used to store firmware data in safe mode, and this firmware data can realize the basic functions of remote upgrade, and the backup partition The firmware data is in a write-protected state to ensure that the firmware data is not changed; the log partition stores the flag information during upgrade and startup. The first-stage boot loader FSBL will select the corresponding partition to start based on the flag information.

优选地,所述固件数据由Boot Header、Partition Header、FSBL Image、xxx.bit、u-boot.elf和xxx.elf构成。Preferably, the firmware data consists of Boot Header, Partition Header, FSBL Image, xxx.bit, u-boot.elf and xxx.elf.

优选地,ZYNQ MPSoC嵌入式系统通过TFTP协议与服务器进行握手时ZYNQ嵌入式系统作为TFTP的客户端。Preferably, when the ZYNQ MPSoC embedded system shakes hands with the server through the TFTP protocol, the ZYNQ embedded system acts as a TFTP client.

优选地,所述通信协议数据由起始位、数据长度、固件版本号、固件数据、循环冗余校验码、结束位组成。Preferably, the communication protocol data consists of a start bit, data length, firmware version number, firmware data, cyclic redundancy check code, and end bit.

优选地,步骤7中将接收到的升级固件数据通过FLASH控制器烧写到FLASH芯片的主分区中,并将日志分区中的升级标志位置位的具体步骤为:Preferably, in step 7, the specific steps of burning the received upgraded firmware data into the main partition of the FLASH chip through the FLASH controller, and setting the upgrade flag bit in the log partition are:

步骤7.1:读取FLASH芯片ID,并根据FLASH芯片ID号读取相应的闪存页大小;Step 7.1: Read the FLASH chip ID and read the corresponding flash memory page size according to the FLASH chip ID number;

步骤7.2:向FLASH芯片中日志分区写入升级标志位,并将升级标志位置1;Step 7.2: Write the upgrade flag bit to the log partition in the FLASH chip, and set the upgrade flag bit to 1;

步骤7.3:擦除FLASH芯片中主分区的主固件数据;Step 7.3: Erase the main firmware data of the main partition in the FLASH chip;

步骤7.4:根据闪存页大小将升级固件数据划分成若干份,并依次烧写到FLASH芯片的主分区中;Step 7.4: Divide the upgraded firmware data into several parts according to the flash memory page size, and burn them into the main partition of the FLASH chip in sequence;

步骤7.5:从FLASH芯片中读取主分区中写入的固件数据,与通信协议解析出的固件数据比对,若一致,则写入固件数据的正确;若不一致,则跳转到步骤7.3。Step 7.5: Read the firmware data written in the primary partition from the FLASH chip and compare it with the firmware data parsed by the communication protocol. If they are consistent, the written firmware data is correct; if they are inconsistent, jump to step 7.3.

优选地,第一阶段引导加载程序FSBL根据日志分区的标志位信息选择相应的分区启动,具体包括如下步骤:Preferably, the first-stage boot loader FSBL selects the corresponding partition to start based on the flag information of the log partition, which specifically includes the following steps:

步骤9.1:在首次引导程序加载完成后,将第一阶段引导加载程序的程序加载到片内RAM中;Step 9.1: After the first boot loader is loaded, load the first-stage boot loader program into the on-chip RAM;

步骤9.2:第一阶段引导加载程序读取日志分区中的启动标志位;Step 9.2: The first-stage boot loader reads the boot flag in the log partition;

步骤9.3:根据标志位信息,第一阶段引导加载程序设置Multiboot寄存器的值;Step 9.3: According to the flag information, the first-stage boot loader sets the value of the Multiboot register;

步骤9.4:根据Multiboot寄存器的值,跳转到FLASH对应地址加载比特流文件和可执行文件。Step 9.4: According to the value of the Multiboot register, jump to the corresponding address of FLASH to load the bit stream file and executable file.

本发明与现有技术相比,其显著优点为:本发明采用外部通信接口(如以太网口)实现对产品固件的远程升级,避免了使用下载器进行固件烧写的复杂步骤,大大提高了升级的便捷性和效率;针对一般远程固件升级过程中可能出现的固件数据错误或丢失等问题,本发明还采取了一种多分区启动的方案。通过在系统中设置备份分区,当升级过程中出现问题时,系统可以重新启动到备份分区,并重新进行固件升级,从而保证整个升级过程的可靠性和安全性。Compared with the existing technology, the significant advantages of the present invention are: the present invention uses an external communication interface (such as an Ethernet port) to realize remote upgrade of product firmware, avoids the complicated steps of using a downloader to program firmware, and greatly improves efficiency. Convenience and efficiency of upgrade; in order to solve problems such as firmware data errors or loss that may occur during the general remote firmware upgrade process, the present invention also adopts a multi-partition startup solution. By setting a backup partition in the system, when a problem occurs during the upgrade process, the system can reboot to the backup partition and re-upgrade the firmware, thereby ensuring the reliability and security of the entire upgrade process.

下面结合附图对本发明做进一步详细的描述。The present invention will be described in further detail below in conjunction with the accompanying drawings.

附图说明Description of the drawings

图1是本发明提供的远程固件升级方法的流程示意图。Figure 1 is a schematic flowchart of the remote firmware upgrade method provided by the present invention.

图2是升级固件数据的结构示意图。Figure 2 is a schematic structural diagram of the upgraded firmware data.

图3是收到升级固件后,烧写闪存芯片(FLASH)的流程示意图。Figure 3 is a schematic diagram of the process of programming the flash memory chip (FLASH) after receiving the upgraded firmware.

图4是本发明提供的多分区启动系统的第一阶段引导加载程序FSBL流程示意图。Figure 4 is a schematic flow diagram of the first stage boot loader FSBL of the multi-partition boot system provided by the present invention.

具体实施方式Detailed ways

以下结合附图对本发明实施例的具体实施方式进行详细说明。应当理解的是,此处所描述的具体实施方式仅用于说明和解释本发明实施例,并不用于限制本发明实施例。Specific implementation modes of the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific implementations described here are only used to illustrate and explain the embodiments of the present invention, and are not used to limit the embodiments of the present invention.

如图1所示,一种基于ZYNQ MPSoC可靠的远程固件更新的方法,需要对ZYNQ系统的存储介质进行分区,在本实施例中,存储介质采用闪存(FLASH)芯片。将该FLASH芯片划分成三个分区,分别为主分区、备份分区、日志分区。其中,主分区中存放正常工作的固件数据,并且该分区始终为远程升级的目的分区;备份分区中存放安全模式的固件数据,此固件数据能够实现远程升级的基本功能,并且备份分区的固件数据处于写保护状态,确保其中的固件数据不被改变;日志分区中存放升级和启动时的标志位信息,第一阶段引导加载程序FSBL会根据其中的标志位信息选择相应的分区启动。备份分区和日志分区存在的意义在于,在升级过程中出现固件数据错误或丢失、突然断电等问题时,ZYNQ系统依然可以从备份分区启动,避免设备因升级失败导致设备无法启动的问题。具体包括以下几个步骤:As shown in Figure 1, a reliable remote firmware update method based on ZYNQ MPSoC requires partitioning the storage medium of the ZYNQ system. In this embodiment, the storage medium uses a flash memory (FLASH) chip. Divide the FLASH chip into three partitions, namely the main partition, the backup partition, and the log partition. Among them, the main partition stores normal working firmware data, and this partition is always the destination partition for remote upgrade; the backup partition stores firmware data in safe mode. This firmware data can realize the basic functions of remote upgrade, and the backup partition's firmware data It is in a write-protected state to ensure that the firmware data in it is not changed; the log partition stores the flag information during upgrade and startup. The first-stage boot loader FSBL will select the corresponding partition to start based on the flag information. The significance of the existence of backup partitions and log partitions is that when problems such as firmware data errors or loss, sudden power outages, etc. occur during the upgrade process, the ZYNQ system can still be booted from the backup partition to avoid the problem of the device being unable to start due to upgrade failure. Specifically, it includes the following steps:

步骤1:ZYNQ MPSoC嵌入式系统初始化外设及时钟。Step 1: ZYNQ MPSoC embedded system initializes peripherals and clocks.

步骤2:ZYNQ通过TFTP协议与服务器进行握手,建立通信,其中ZYNQ嵌入式系统作为TFTP的客户端。Step 2: ZYNQ shakes hands with the server through the TFTP protocol to establish communication, in which the ZYNQ embedded system serves as the TFTP client.

步骤3:ZYNQ在接收到服务器发出的升级固件指令后,中断当前任务并回复服务器已准备升级。Step 3: After receiving the firmware upgrade instruction from the server, ZYNQ interrupts the current task and replies that the server is ready to upgrade.

步骤4:服务器收到ZYNQ发出的准备完成信号后,将升级固件按照事先约定的通信协议发送给客户端。Step 4: After receiving the preparation completion signal from ZYNQ, the server sends the upgraded firmware to the client according to the pre-agreed communication protocol.

进一步地,本步骤需要事先约定好升级固件所使用的通信协议,具体地在本实施例中,通信协议数据由起始位、数据长度、固件版本号、固件数据、循环冗余校验码(CRC)、结束位等组成。其中,起始位和结束位均为固定8字节数据,数据长度表示固件数据的字节数大小,循环冗余校验码为服务器根据固件数据计算得到的循环冗余校验码。Further, this step needs to agree in advance on the communication protocol used to upgrade the firmware. Specifically in this embodiment, the communication protocol data consists of start bit, data length, firmware version number, firmware data, cyclic redundancy check code ( CRC), end bit, etc. Among them, the start bit and the end bit are fixed 8-byte data, the data length indicates the number of bytes of the firmware data, and the cyclic redundancy check code is the cyclic redundancy check code calculated by the server based on the firmware data.

步骤5:ZYNQ根据相应通信协议解析服务器传来的数据得到升级固件后,计算接收到的固件数据的循环冗余校验码(CRC)。Step 5: After ZYNQ parses the data sent from the server according to the corresponding communication protocol to obtain the upgraded firmware, it calculates the cyclic redundancy check code (CRC) of the received firmware data.

进一步地,解析出固件数据后,ZYNQ系统计算出接收到固件数据的循环冗余校验码,将该循环冗余校验码与通信协议中解析出的循环冗余校验码进行对比,若相一致,则确保固件数据完整。其中,循环冗余校验码可以用消息摘要算法或者其它自定义的校验码代替。具体地,如图2所示,完整的固件数据由引导头、分区表头、FSBL镜像、比特流文件、u-boot文件和可执行文件打包构成。Further, after parsing the firmware data, the ZYNQ system calculates the cyclic redundancy check code of the received firmware data, and compares the cyclic redundancy check code with the cyclic redundancy check code parsed in the communication protocol. If If they are consistent, the firmware data is complete. Among them, the cyclic redundancy check code can be replaced by a message digest algorithm or other customized check codes. Specifically, as shown in Figure 2, the complete firmware data consists of boot header, partition table header, FSBL image, bitstream file, u-boot file and executable file packaging.

步骤6:将计算得到的循环冗余校验码与通信协议中的循环冗余校验码对比,若校验码一致,则代表接收到的升级固件数据的正确且完整;若校验码不一致,则回复服务器固件数据错误,服务器将重新发出升级固件指令,即跳转到步骤3。Step 6: Compare the calculated cyclic redundancy check code with the cyclic redundancy check code in the communication protocol. If the check codes are consistent, it means that the received upgrade firmware data is correct and complete; if the check codes are inconsistent. , then the server firmware data error will be replied, and the server will re-issue the firmware upgrade instruction, that is, jump to step 3.

本步骤采用CRC校验确保固件数据的正确性和完整性,ZYNQ根据事先定好的通信协议解析服务器传来的数据,通信协议数据由起始位、数据长度、固件版本号、固件数据、循环冗余校验码(CRC)、结束位等组成。ZYNQ系统根据该通信协议即可解析出所需要升级的固件数据和循环冗余校验码。ZYNQ系统计算出接收到固件数据的循环冗余校验码,将该循环冗余校验码与通信协议中解析出的循环冗余校验码进行对比,若相一致,则确保固件数据完整。其中,循环冗余校验码可以用消息摘要算法或者其它自定义的校验码代替。This step uses CRC check to ensure the correctness and integrity of the firmware data. ZYNQ parses the data sent from the server according to the predetermined communication protocol. The communication protocol data consists of start bit, data length, firmware version number, firmware data, cyclic redundancy It is composed of remainder check code (CRC), end bit, etc. The ZYNQ system can parse out the firmware data and cyclic redundancy check codes that need to be upgraded based on this communication protocol. The ZYNQ system calculates the cyclic redundancy check code of the received firmware data, and compares the cyclic redundancy check code with the cyclic redundancy check code parsed in the communication protocol. If they are consistent, the integrity of the firmware data is ensured. Among them, the cyclic redundancy check code can be replaced by a message digest algorithm or other customized check codes.

步骤7:将接收到的升级固件数据通过FLASH控制器烧写到FLASH芯片的主分区中,并将日志分区中的升级标志位置位。Step 7: Program the received upgraded firmware data into the main partition of the FLASH chip through the FLASH controller, and set the upgrade flag in the log partition.

进一步的实施例中,如图3所示,步骤7中通过FLASH控制器烧写FLASH芯片的具体步骤如下:In a further embodiment, as shown in Figure 3, the specific steps of programming the FLASH chip through the FLASH controller in step 7 are as follows:

步骤7.1:读取FLASH芯片ID,并根据其ID号读取相应的闪存页大小;Step 7.1: Read the FLASH chip ID and read the corresponding flash memory page size according to its ID number;

步骤7.2:向FLASH芯片中日志分区写入升级标志位,并将其置1;Step 7.2: Write the upgrade flag bit to the log partition in the FLASH chip and set it to 1;

步骤7.3:擦除FLASH芯片中主分区的主固件数据;Step 7.3: Erase the main firmware data of the main partition in the FLASH chip;

步骤7.4:根据闪存页大小将升级固件数据划分成若干份,并依次烧写到FLASH芯片的主分区中;Step 7.4: Divide the upgraded firmware data into several parts according to the flash memory page size, and burn them into the main partition of the FLASH chip in sequence;

步骤7.5:从FLASH芯片中读取主分区中写入的固件数据,与通信协议解析出的固件数据比对,若一致,则写入固件数据的正确;若不一致,则跳转到步骤7.3。Step 7.5: Read the firmware data written in the primary partition from the FLASH chip and compare it with the firmware data parsed by the communication protocol. If they are consistent, the written firmware data is correct; if they are inconsistent, jump to step 7.3.

步骤8:烧录完成后,ZYNQ通过看门狗实现嵌入式系统的软复位,重启系统进入ZYNQ芯片固化的引导程序(BootRom),加载第一阶段引导加载程序(FSBL)。Step 8: After the burning is completed, ZYNQ implements a soft reset of the embedded system through the watchdog, restarts the system and enters the boot program (BootRom) solidified by the ZYNQ chip, and loads the first-stage boot loader (FSBL).

步骤9:第一阶段引导加载程序(FSBL)根据日志分区中的标志位,引导启动主分区并将日志分区中的首次启动标志位置位。若主分区启动失败,则由第一阶段引导加载程序(FSBL)重新引导备份分区启动,跳转到步骤1,重新升级ZYNQ嵌入式系统;若主分区成功启动,则代表升级完成。Step 9: The first-stage boot loader (FSBL) boots the main partition according to the flag bit in the log partition and sets the first boot flag bit in the log partition. If the primary partition fails to start, the first-stage boot loader (FSBL) will reboot the backup partition and jump to step 1 to re-upgrade the ZYNQ embedded system; if the primary partition starts successfully, the upgrade is complete.

进一步地,如图4所示,第一阶段引导加载程序(FSBL)通过日志分区中的标志位来确定引导主分区启动或者引导备份分区启动,其实施步骤如下:Further, as shown in Figure 4, the first-stage boot loader (FSBL) determines whether to boot the primary partition or boot the backup partition through the flag bit in the log partition. The implementation steps are as follows:

步骤9.1:在首次引导程序(BootRom)加载完成后,会将第一阶段引导加载程序(FSBL)的程序加载到片内RAM(OCM)中;Step 9.1: After the first boot program (BootRom) is loaded, the first-stage boot loader (FSBL) program will be loaded into the on-chip RAM (OCM);

步骤9.2:第一阶段引导加载程序(FSBL)读取日志分区中的启动标志位;Step 9.2: The first-stage boot loader (FSBL) reads the boot flag in the log partition;

步骤9.3:根据标志位信息,第一阶段引导加载程序(FSBL)设置Multiboot寄存器的值;Step 9.3: Based on the flag information, the first-stage boot loader (FSBL) sets the value of the Multiboot register;

步骤9.4:根据Multiboot寄存器的值,跳转到FLASH对应地址加载比特流文件和可执行文件。Step 9.4: According to the value of the Multiboot register, jump to the corresponding address of FLASH to load the bit stream file and executable file.

ZYNQ系统根据该通信协议即可解析出所需要升级的固件数据和循环冗余校验码。The ZYNQ system can parse out the firmware data and cyclic redundancy check codes that need to be upgraded based on this communication protocol.

优选地,本发明提出的基于ZYNQ的可靠远程固件升级方法,采用了多分区的方案,具体地涉及一种多分区启动的方法。Preferably, the reliable remote firmware upgrade method based on ZYNQ proposed by the present invention adopts a multi-partition solution, and specifically relates to a multi-partition startup method.

当在升级的过程中出现一些不可控因素,导致主固件数据出现错误,升级失败,主分区无法启动后,ZYNQ可以通过第一阶段引导加载程序(FSBL)跳转到备份分区启动,可以从备份分区重新升级主分区的固件,避免了在升级失败后需要拆除产品结构件的风险,极大提升了整个升级过程的可靠性和安全性。When some uncontrollable factors occur during the upgrade process, causing the main firmware data to be incorrect, the upgrade fails, and the main partition cannot be started, ZYNQ can jump to the backup partition through the first-stage boot loader (FSBL) and start from the backup Re-upgrading the firmware of the main partition by partition avoids the risk of needing to dismantle product structural parts after an upgrade fails, greatly improving the reliability and security of the entire upgrade process.

本实施例提出的基于ZYNQ的可靠远程固件升级方法,采用了多分区的方案,具体地涉及一种多分区启动的方法,下面对ZYNQ的启动流程进行阐述:The reliable remote firmware upgrade method based on ZYNQ proposed in this embodiment adopts a multi-partition solution, specifically involving a multi-partition startup method. The ZYNQ startup process is described below:

ZYNQ在上电之后会首先从固化的引导程序(BootRom)中的启动,从FLASH芯片中检索有效的引导头,每次搜索地址增加32KB,直到检索到有效的引导头为止。在读取到有效的引导头后,将第一阶段引导加载程序(FSBL)代码加载到片内RAM(OCM)中。因此在划分备份分区首地址时,应确保备份固件数据从整数倍的32KB地址开始,使引导程序(BootRom)中的程序能够检索到备份固件数据的引导头。After powering on, ZYNQ will first start from the solidified boot program (BootRom) and retrieve a valid boot header from the FLASH chip. The search address increases by 32KB each time until a valid boot header is retrieved. After reading a valid boot header, the first-stage boot loader (FSBL) code is loaded into on-chip RAM (OCM). Therefore, when dividing the first address of the backup partition, you should ensure that the backup firmware data starts from an integer multiple of the 32KB address so that the program in the boot program (BootRom) can retrieve the boot header of the backup firmware data.

具体地,在步骤8、9中日志分区中的标志位变化如下表中所示,第一阶段引导加载程序(FSBL)在第一次加载后,读取到升级标志位为1,为防止主分区升级出错,将预启动备份分区标志位置1并清除升级标志位。若主分区启动成功,则在启动成功后,将预启动备份分区标志位清除并将启动主分区标志位置1。若主分区启动失败,则重新上电,第二次FSBL在读到预启动备份分区标志位为1后,会重新设置Multiboot寄存器的值,并复位芯片,使引导程序(BootRom)重新运行,引导程序(BootRom)根据Multiboot寄存器的值找到备份分区的引导头,从而启动备份分区,备份分区启动成功后,将预启动备份分区标志位清除并将启动备份分区标志位置1。Specifically, the flag bit changes in the log partition in steps 8 and 9 are as shown in the table below. After the first stage boot loader (FSBL) is loaded for the first time, it reads that the upgrade flag bit is 1. In order to prevent the main An error occurred during partition upgrade. Set the pre-boot backup partition flag to 1 and clear the upgrade flag. If the primary partition starts successfully, the pre-boot backup partition flag will be cleared and the primary partition flag will be set to 1. If the primary partition fails to start, power on again. After reading the pre-boot backup partition flag bit to 1 for the second time, FSBL will reset the value of the Multiboot register and reset the chip to re-run the boot program (BootRom). (BootRom) Find the boot header of the backup partition based on the value of the Multiboot register to start the backup partition. After the backup partition is successfully started, the pre-start backup partition flag will be cleared and the startup backup partition flag will be set to 1.

表1日志分区中的标志位变化Table 1 Flag bit changes in log partition

通过本实施例提出的基于ZYNQ的可靠远程固件升级方法,可以有效避免在升级过程中遇到意外情况使主分区无法正常启动的问题,在备份分区启动之后,依旧可以利用备份分区的程序重新远程升级主分区中的固件数据,极大提升了产品的安全性和可靠性。Through the reliable remote firmware upgrade method based on ZYNQ proposed in this embodiment, the problem of the main partition being unable to start normally due to unexpected situations encountered during the upgrade process can be effectively avoided. After the backup partition is started, the program of the backup partition can still be used to remotely restart the firmware. Upgrading the firmware data in the primary partition greatly improves product security and reliability.

以上所述实施例仅表达了本发明的优选实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。The above-mentioned embodiments only express preferred embodiments of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention. It should be noted that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention.

Claims (7)

1.一种基于ZYNQ MPSoC的可靠远程固件升级方法,其特征在于,包括:1. A reliable remote firmware upgrade method based on ZYNQ MPSoC, which is characterized by: 步骤1:将ZYNQ MPSoC嵌入式系统的存储介质分为主分区、备份分区、日志分区,并对ZYNQ MPSoC嵌入式系统初始化外设及时钟;Step 1: Divide the storage medium of the ZYNQ MPSoC embedded system into the primary partition, backup partition, and log partition, and initialize the peripherals and clocks of the ZYNQ MPSoC embedded system; 步骤2:ZYNQ MPSoC嵌入式系统通过TFTP协议与服务器进行握手,建立通信;Step 2: The ZYNQ MPSoC embedded system shakes hands with the server through the TFTP protocol to establish communication; 步骤3:ZYNQ MPSoC嵌入式系统在接收到服务器发出的升级固件指令后,中断当前任务并回复服务器已准备升级;Step 3: After receiving the firmware upgrade instruction from the server, the ZYNQ MPSoC embedded system interrupts the current task and replies that the server is ready to upgrade; 步骤4:服务器收到ZYNQ发出的准备完成信号后,将升级固件按照事先约定的通信协议发送给客户端;Step 4: After receiving the preparation completion signal from ZYNQ, the server sends the upgraded firmware to the client according to the pre-agreed communication protocol; 步骤5:ZYNQ根据相应通信协议解析服务器传来的数据得到升级固件后,计算接收到的固件数据的循环冗余校验码;Step 5: After ZYNQ parses the data sent from the server according to the corresponding communication protocol to obtain the upgraded firmware, it calculates the cyclic redundancy check code of the received firmware data; 步骤6:将计算得到的循环冗余校验码与通信协议中的循环冗余校验码对比,若校验码一致,则代表接收到的升级固件数据的正确且完整;若校验码不一致,则回复服务器固件数据错误,服务器将重新发出升级固件指令,即跳转到步骤3;Step 6: Compare the calculated cyclic redundancy check code with the cyclic redundancy check code in the communication protocol. If the check codes are consistent, it means that the received upgrade firmware data is correct and complete; if the check codes are inconsistent. , then the server firmware data error will be replied, and the server will re-issue the firmware upgrade instruction, that is, jump to step 3; 步骤7:将接收到的升级固件数据通过FLASH控制器烧写到FLASH芯片的主分区中,并将日志分区中的升级标志位置位;Step 7: Burn the received upgraded firmware data into the main partition of the FLASH chip through the FLASH controller, and set the upgrade flag in the log partition; 步骤8:烧录完成后,ZYNQ通过看门狗实现嵌入式系统的软复位,重启系统进入ZYNQ芯片固化的引导程序;加载第一阶段引导加载程序;Step 8: After the burning is completed, ZYNQ implements a soft reset of the embedded system through the watchdog, restarts the system and enters the boot program solidified by the ZYNQ chip; loads the first-stage boot loader; 步骤9:第一阶段引导加载程序根据日志分区中的标志位,引导启动主分区并将日志分区中的首次启动标志位置位;若主分区启动失败,则由第一阶段引导加载程序重新引导备份分区启动,跳转到步骤1,重新升级ZYNQ嵌入式系统;若主分区成功启动,则代表升级完成。Step 9: The first-stage boot loader boots the primary partition according to the flag bit in the log partition and sets the first boot flag in the log partition; if the primary partition fails to start, the first-stage boot loader reboots the backup Start the partition, jump to step 1, and re-upgrade the ZYNQ embedded system; if the main partition starts successfully, the upgrade is complete. 2.根据权利要求1所述的基于ZYNQ MPSoC的可靠远程固件升级方法,其特征在于,主分区用于存放正常工作的固件数据,并且主分区始终为远程升级的目的分区;备份分区用于存放安全模式的固件数据,此固件数据能够实现远程升级的基本功能,并且备份分区的固件数据处于写保护状态,确保其中的固件数据不被改变;日志分区中存放升级和启动时的标志位信息,第一阶段引导加载程序FSBL会根据其中的标志位信息选择相应的分区启动。2. The reliable remote firmware upgrade method based on ZYNQ MPSoC according to claim 1, characterized in that the main partition is used to store normal working firmware data, and the main partition is always the destination partition for remote upgrade; the backup partition is used to store Safe mode firmware data, this firmware data can realize the basic function of remote upgrade, and the firmware data of the backup partition is in a write-protected state to ensure that the firmware data in it is not changed; the log partition stores the flag information during upgrade and startup. The first-stage boot loader FSBL will select the corresponding partition to start based on the flag information. 3.根据权利要求2所述的基于ZYNQ MPSoC的可靠远程固件升级方法,其特征在于,所述固件数据由Boot Header、Partition Header、FSBL Image、xxx.bit、u-boot.elf和xxx.elf构成。3. The reliable remote firmware upgrade method based on ZYNQ MPSoC according to claim 2, characterized in that the firmware data consists of Boot Header, Partition Header, FSBL Image, xxx.bit, u-boot.elf and xxx.elf constitute. 4.根据权利要求1所述的基于ZYNQ MPSoC的可靠远程固件升级方法,其特征在于,ZYNQMPSoC嵌入式系统通过TFTP协议与服务器进行握手时ZYNQ嵌入式系统作为TFTP的客户端。4. The reliable remote firmware upgrade method based on ZYNQ MPSoC according to claim 1, characterized in that when the ZYNQMPSoC embedded system shakes hands with the server through the TFTP protocol, the ZYNQ embedded system acts as a TFTP client. 5.根据权利要求1所述的基于ZYNQ MPSoC的可靠远程固件升级方法,其特征在于,所述通信协议数据由起始位、数据长度、固件版本号、固件数据、循环冗余校验码、结束位组成。5. The reliable remote firmware upgrade method based on ZYNQ MPSoC according to claim 1, characterized in that the communication protocol data consists of a start bit, data length, firmware version number, firmware data, cyclic redundancy check code, Composed of end bits. 6.根据权利要求1所述的基于ZYNQ MPSoC的可靠远程固件升级方法,其特征在于,步骤7中将接收到的升级固件数据通过FLASH控制器烧写到FLASH芯片的主分区中,并将日志分区中的升级标志位置位的具体步骤为:6. The reliable remote firmware upgrade method based on ZYNQ MPSoC according to claim 1, characterized in that in step 7, the received upgraded firmware data is burned into the main partition of the FLASH chip through the FLASH controller, and the log The specific steps to set the upgrade flag bit in the partition are: 步骤7.1:读取FLASH芯片ID,并根据FLASH芯片ID号读取相应的闪存页大小;Step 7.1: Read the FLASH chip ID and read the corresponding flash memory page size according to the FLASH chip ID number; 步骤7.2:向FLASH芯片中日志分区写入升级标志位,并将升级标志位置1;Step 7.2: Write the upgrade flag bit to the log partition in the FLASH chip, and set the upgrade flag bit to 1; 步骤7.3:擦除FLASH芯片中主分区的主固件数据;Step 7.3: Erase the main firmware data of the main partition in the FLASH chip; 步骤7.4:根据闪存页大小将升级固件数据划分成若干份,并依次烧写到FLASH芯片的主分区中;Step 7.4: Divide the upgraded firmware data into several parts according to the flash memory page size, and burn them into the main partition of the FLASH chip in sequence; 步骤7.5:从FLASH芯片中读取主分区中写入的固件数据,与通信协议解析出的固件数据比对,若一致,则写入固件数据的正确;若不一致,则跳转到步骤7.3。Step 7.5: Read the firmware data written in the primary partition from the FLASH chip and compare it with the firmware data parsed by the communication protocol. If they are consistent, the written firmware data is correct; if they are inconsistent, jump to step 7.3. 7.根据权利要求1所述的基于ZYNQ MPSoC的可靠远程固件升级方法,其特征在于,第一阶段引导加载程序FSBL根据日志分区的标志位信息选择相应的分区启动,具体包括如下步骤:7. The reliable remote firmware upgrade method based on ZYNQ MPSoC according to claim 1, characterized in that the first-stage boot loader FSBL selects the corresponding partition to start based on the flag information of the log partition, specifically including the following steps: 步骤9.1:在首次引导程序加载完成后,将第一阶段引导加载程序的程序加载到片内RAM中;Step 9.1: After the first boot loader is loaded, load the first-stage boot loader program into the on-chip RAM; 步骤9.2:第一阶段引导加载程序读取日志分区中的启动标志位;Step 9.2: The first-stage boot loader reads the boot flag in the log partition; 步骤9.3:根据标志位信息,第一阶段引导加载程序设置Multiboot寄存器的值;Step 9.3: According to the flag information, the first-stage boot loader sets the value of the Multiboot register; 步骤9.4:根据Multiboot寄存器的值,跳转到FLASH对应地址加载比特流文件和可执行文件。Step 9.4: According to the value of the Multiboot register, jump to the corresponding address of FLASH to load the bit stream file and executable file.
CN202311376615.XA 2023-10-23 2023-10-23 A reliable remote firmware upgrade method based on ZYNQ MPSoC Pending CN117573157A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311376615.XA CN117573157A (en) 2023-10-23 2023-10-23 A reliable remote firmware upgrade method based on ZYNQ MPSoC

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311376615.XA CN117573157A (en) 2023-10-23 2023-10-23 A reliable remote firmware upgrade method based on ZYNQ MPSoC

Publications (1)

Publication Number Publication Date
CN117573157A true CN117573157A (en) 2024-02-20

Family

ID=89894408

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311376615.XA Pending CN117573157A (en) 2023-10-23 2023-10-23 A reliable remote firmware upgrade method based on ZYNQ MPSoC

Country Status (1)

Country Link
CN (1) CN117573157A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119938106A (en) * 2025-04-10 2025-05-06 联想长风科技(北京)有限公司 A method for firmware upgrade with rollback capability

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119938106A (en) * 2025-04-10 2025-05-06 联想长风科技(北京)有限公司 A method for firmware upgrade with rollback capability

Similar Documents

Publication Publication Date Title
US20110099544A1 (en) Information processing apparatus and system setting method
US20100169709A1 (en) System Of Updating Firmware And Method Thereof, And Method Of Creating Firmware
CN102622253B (en) A kind of method of single-chip microcomputer and online upgrading thereof
CN105260215A (en) Method of updating vehicle-mounted automobile data recorder terminal by USB flash disk
US20070055969A1 (en) System and method for updating firmware
US7941658B2 (en) Computer system and method for updating program code
US20090271660A1 (en) Motherboard, a method for recovering the bios thereof and a method for booting a computer
WO2020094065A1 (en) Method and apparatus for upgrading vehicle-mounted tbox, device, and storage medium
CN108345464A (en) A kind of the startup method and Android vehicle device of Android system
EP1691281B1 (en) Memory dump program boot method
CN117573157A (en) A reliable remote firmware upgrade method based on ZYNQ MPSoC
CN115840579A (en) FPGA remote updating method, system, chip mounter and storage medium
CN104991805B (en) Smart machine and its system calamity are for control method
CN116301995A (en) Firmware upgrading method based on bootloader architecture
CN118626119A (en) System upgrade method and device based on image file
US12340201B2 (en) Server and updating method for MAC address
US10691465B2 (en) Method for synchronization of system management data
CN114625389A (en) Embedded equipment upgrading method, embedded equipment and storage device
CN115437674B (en) Firmware upgrading method, device, medium and electronic equipment
CN113377425B (en) Method and device for generating BMC firmware, method and device for starting BMC, and storage medium
US9529581B2 (en) Circuit and method for writing program codes of basic input/output system
TWI556172B (en) Computer and booting method thereof
CN120179321B (en) Firmware loading method, device, electronic device and storage medium
CN112486742B (en) Method for remotely checking starting state of server and server
CN104834574A (en) Method and device for solving damage of system partition

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination