WO2022227409A1 - Embedded terminal remote software updating method - Google Patents

Embedded terminal remote software updating method Download PDF

Info

Publication number
WO2022227409A1
WO2022227409A1 PCT/CN2021/122776 CN2021122776W WO2022227409A1 WO 2022227409 A1 WO2022227409 A1 WO 2022227409A1 CN 2021122776 W CN2021122776 W CN 2021122776W WO 2022227409 A1 WO2022227409 A1 WO 2022227409A1
Authority
WO
WIPO (PCT)
Prior art keywords
bios
function
dynamic
component
dynamic command
Prior art date
Application number
PCT/CN2021/122776
Other languages
French (fr)
Chinese (zh)
Inventor
王宜怀
施连敏
章晓芳
姚望舒
刘强
Original Assignee
苏州大学
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 苏州大学 filed Critical 苏州大学
Publication of WO2022227409A1 publication Critical patent/WO2022227409A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Definitions

  • the invention relates to the technical field of software development and debugging, in particular to a remote software update method for an embedded terminal.
  • this application proposes a remote software update method for embedded terminals, so as to adapt to the software update requirements in different application scenarios and take into account the portability and reusability of the system framework itself .
  • dynamic commands provide flexibility and adaptive support for the software update function.
  • the present invention provides a remote software update method for an embedded terminal, comprising: sending dynamic command data to a user serial port and writing it into a user program; sending a system instruction for program jumping to the user serial port, and the user program receives the instruction Then, jump to the BIOS; the dynamic command function is called by default during the BIOS startup process; in the dynamic command, the program running state is first modified to complete the BIOS residency; secondly, the initialization and interrupt enable of the user serial port are completed; and the BIOS program interrupt vector is set The address of the interrupt service routine corresponding to the user serial port in the table is a dynamic command function; finally, the host computer is informed that the relevant initialization steps have been completed, and the program update starts; the host computer starts to send the user program data frame to the user serial port, and the terminal passes the user serial port.
  • the dynamic command completes receiving, checking and writing; when the dynamic command of the user serial port completes the processing of the last frame of data, the program running state is modified, the BIOS is reset, and the BIOS basic operation process
  • the outermost frame structure of the user serial port is the framing structure of the communication layer, including frame header, frame trailer, data length, communication layer data and check bit.
  • the establishment process of described dynamic command function is as follows: revise link file, increase the FLASH space corresponding to dynamic command in MEMORY field and SECTIONS field; Increase the declaration and definition of dynamic command function, function body is empty, and use attribute grammar
  • the dynamic command function is placed in the FLASH space; in the interrupt handler of the communication module receiving data, two frame marks are reserved for receiving the machine code of the dynamic command function and the execution dynamic command function respectively; In the update state judgment function Add dynamic command execution branch; add dynamic command reset step in key reset.
  • the BIOS is self-updated: the writing of the dynamic command and the program jump are completed by the system command, the takeover of the communication module is completed with the help of the dynamic command, and then the BIOS self-update process is started, and the machine code of the new version of the BIOS is first received and stored in the current BIOS. Behind the BIOS machine code, after the machine code of the new BIOS is received and verified, the machine code of the old BIOS is replaced and updated by the machine code of the new BIOS sector by sector.
  • steps of the self-update of the BIOS are as follows: (1) write a related function to make a dynamic command code; (2) send the dynamic command installation package of the BIOS self-update to the target chip user program, and write the dynamic command after the target chip receives it.
  • BIOS Send system commands to the target chip user program to make it jump and reside in the BIOS; (4) BIOS calls dynamic commands to complete the takeover of the user communication module; (5) Starts sending new messages to the target chip
  • the machine code of the BIOS project is stored in the back of the current BIOS storage space after frame-by-frame verification, and the corresponding frame header is given for the last frame of data; (6) After the target chip detects the last frame of data and verifies the storage, Do not exit the interrupt immediately, and enter the data migration work in the interrupt, so that the new BIOS officially replaces the old BIOS, and after the migration is completed, a soft reset is performed to start the new BIOS process.
  • the dynamic command can be simplified as a dynamic component library, including: a component function list area and a component function code area, wherein the component function list area is used to store the function pointer and necessary parameters of the component, and the component function code area is used to store the component.
  • the dynamic command function is responsible for the management of the data in these two areas.
  • the dynamic command can perform query operations on each component and function, and add, modify and delete operations in combination with the component function code area.
  • the query operation process includes: reading the data in the component function list area by means of a dynamic command and sending it back to the upper computer for analysis by the upper computer.
  • the operation process of the increase includes: when adding a component, first determine the recording position of the overall information of the current component in the component function list area according to the next available number field in the component function list area, and after the recording is completed. Then modify the next available number field, and determine the write address of the component machine code according to the next writable address field of the function code area, and modify the next writable address and function code area of the function code area after the writing is completed.
  • the used space field value when adding a component, first determine the recording position of the overall information of the current component in the component function list area according to the next available number field in the component function list area, and after the recording is completed. Then modify the next available number field, and determine the write address of the component machine code according to the next writable address field of the function code area, and modify the next writable address and function code area of the function code area after the writing is completed.
  • the used space field value when adding a component, first determine the recording position of the overall information of the current
  • Flash load balancing method in the dynamic component library is as follows:
  • the advantage of the present invention is that: the present invention takes serial communication as a leading research on the self-adaptation of the communication module, and based on this, summarizes the user program update method of the self-adaptation of the communication module. And for the dynamic command space problem in the implementation process, the solution of the dynamic component library is given, which simplifies the dynamic command and has certain development practicability, and also provides a complete solution for the Flash load balancing problem in the dynamic component library. solution.
  • FIG. 1 shows a schematic diagram of a frame structure of a user serial port according to an embodiment of the present invention.
  • FIG. 2 shows a flow chart of dynamic command execution based on user serial port User program update according to an embodiment of the present invention.
  • FIG. 3 shows a schematic diagram of functional dependencies of errors according to an embodiment of the present invention.
  • FIG. 4 shows a schematic diagram of function rewriting for functional dependency problems according to an embodiment of the present invention.
  • FIG. 5 shows a schematic diagram of the functional dependency of the BIOS self-update dynamic command according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram showing the trend of erasing frequency and service life of each sector under the compact principle according to an embodiment of the present invention.
  • FIG. 7 shows a schematic diagram of Flash defragmentation according to an embodiment of the present invention.
  • the invention proposes a remote software update method for an embedded terminal, so as to adapt to the software update requirements in different application scenarios and take into account the portability and reusability of the system framework itself.
  • dynamic commands provide flexibility and adaptive support for the software update function.
  • the present invention takes the communication mode of serial communication as the leading research on the self-adaptation of the communication module, and based on this, summarizes the user program update and BIOS self-update method of the self-adaptation of the communication module. And for the dynamic command space problem in the implementation process, the solution of the dynamic component library is given, which simplifies the dynamic command and has certain development practicability, and also provides a complete solution for the Flash load balancing problem in the dynamic component library. solution.
  • the present invention selects a relatively fixed BIOS program to be responsible for adapting to different communication modules, and the user program carries the changed communication module drive components. Thus, the basic software architecture under this software update method is determined.
  • the communication module selected in embedded application development often does not have the ability to communicate directly with the corresponding embedded terminal.
  • the general solution is to use the inherent communication method in the embedded terminal as a bridge to achieve the communication between the two. Data interaction.
  • the core problem of the adaptive software update of the communication module is that the BIOS realizes the program update by means of the User's communication module. Therefore, as a leading research, a relatively simple communication method should be selected.
  • Serial communication is a common peripheral interface of MCU, and the communication speed and security are guaranteed to a certain extent, and it can be easily converted to RS485/RS232 interface through a simple peripheral circuit to further ensure Communication stability and transmission distance. So choose serial communication as User's communication method to study the realization of User program update method, and prepare for summarizing the general method of communication module adaptive software update.
  • the user program update based on the user serial port is not a frequent requirement, and considering that the subsequent program update may not be limited to serial communication, the user program update based on the user serial port should be combined with dynamic commands as a temporary function. deal with.
  • the main object of the program update is still the user program, so the simpler implementation method is still to use the BIOS program as the main place to perform the update, so there is a link where the User program and the BIOS program jump to each other. All data sending and receiving are based on the serial port of the user program, which means that the user program should write dynamic commands into the BIOS dynamic command area, and considering that the sending and receiving of data is still mainly performed by the BIOS program, the BIOS program must Serial port takeover.
  • the jump from the User program to the BIOS program is still determined by the data received by the user serial port. Therefore, in the analysis of the data received by the user serial port, it is necessary to reserve certain keywords to identify this frame of data as a system command. jump.
  • the step of jumping from the BIOS program to the User program is relatively simple, and the basic User program booting method under the general embedded computer framework (hereinafter referred to as the GEC framework) can be used.
  • the GEC framework general embedded computer framework
  • BIOS program takes over the user serial port.
  • the takeover of the user serial port by the BIOS program not only needs to initialize the user serial port and enable the interrupt, but also needs to redirect the interrupt handler of the user serial port.
  • dynamic commands can be used to implement them.
  • the dynamic command function is called by default during the BIOS startup process. In the dynamic command, firstly modify the running state of the program to complete the residency of the BIOS; secondly, complete the initialization and interrupt enable of the user serial port; and set the interrupt service routine address corresponding to the user serial port in the BIOS program interrupt vector table as the dynamic command function; Finally, inform the host computer that the relevant initialization steps have been completed, and the program update can be started.
  • the host computer starts to send the User program data frame to the user serial port, and the terminal completes the reception, checksum writing through the interrupt service routine (ie dynamic command) of the user serial port.
  • the next step is to describe the specific implementation of the User program update based on the user serial port, mainly focusing on the frame structure and dynamic command system of the user serial port.
  • the outermost frame structure of the user serial port is the framing structure of the communication layer, which may include frame header, frame end, data length, communication layer data and check digit.
  • the frame structure in the communication layer data should reserve contents such as the unique serial number of the device and the software version number to assist in judging the choice of data frames in some broadcast scenarios.
  • the effective data frame structure in the communication layer data is defined by the developer, but in order to complete the software update such as the communication module adaptation, it is necessary to reserve a keyword as the frame identifier of the system command to provide rich pre- Set functions, such as program jump, device serial number query, etc.
  • the frame structure of the user serial port is shown in Figure 1.
  • Step 1 Modify the link file and add the FLASH space corresponding to the dynamic command in the MEMORY field and the SECTIONS field.
  • Step 2 Add the declaration and definition of the dynamic command function, the function body is empty, and use the attribute syntax to place the dynamic command function in the FLASH space in Step 1.
  • Step 3 Reserve two frame identifiers in the interrupt handler for receiving data of the communication module for receiving the machine code of the dynamic command function and executing the dynamic command function respectively.
  • Step 4 Add a dynamic command execution branch to the update state judgment function.
  • Step 5 Add dynamic command reset step in key reset.
  • the reset here refers to restoring the function of the dynamic command to an empty function, that is, the reset machine code corresponds to "return 0;" of the C language code.
  • the User project is the main development site of the developer.
  • the specific communication module is determined by the developer, and the dynamic command system must depend on the transmission and reception of the data of the communication module. Therefore, the writing function of the dynamic command should be placed in the system command.
  • the system command is used as a fixed file of the User project template, so that the access to the dynamic command system in different communication modules can be realized.
  • the specific content of the dynamic command should be divided into two parts.
  • the first part should be executed at the default call of the BIOS program, mainly to complete the initialization of the user serial port, interrupt enable and take over the user serial port interrupt, and reserve the code for subsequent updates;
  • the second part is the user serial port interrupt processing specific content of the program.
  • the user serial port interrupt service routine function needs to be registered when taking over the user serial port interruption.
  • the dynamic command address can be directly selected.
  • the dynamic command is divided according to whether the communication module interrupt is triggered or not. To ensure that the two parts do not interfere with each other.
  • the dynamic command execution flow based on user serial port User program update is shown in Figure 2.
  • the external communication module selected in the embedded application development often needs to establish the data connection with the help of the inherent communication module in the embedded terminal.
  • serial communication will be used as an example to serve as a bridge connecting the embedded terminal and the external communication module. Therefore, the component design of the external communication module in a specific project can be understood as the upper-level component design based on uplink communication.
  • serial communication initialization mainly including: serial communication initialization, interrupt enable, interrupt service routine address designation, data transmission and data reception. Therefore, in the communication module adaptive program update method, the common elements of the communication module are abstracted as: initialization of the communication module, interrupt enable, designation of interrupt service routine address, data transmission and data reception.
  • the adaptive User program update design method of the communication module becomes relatively clear, and the related work of the communication module is only carried out in the corresponding interrupt and dynamic commands of the User program, so a detailed design method can be given for both. .
  • the data frame of the communication module does not change in structure with the change of the communication module, so the specific frame structure still adopts the user serial port frame structure design method shown in Figure 1.
  • the adaptive User program update of the communication module is essentially the update of the User program by the BIOS program, it is still necessary to reserve a program jump instruction in the system instruction identifier in the data frame for converting the target terminal's
  • the program running state is pulled back from User to BIOS.
  • system instruction identifier still needs to be connected to the dynamic command system to provide the User program with a writing interface of the dynamic command.
  • the main functions of the dynamic commands under the communication module adaptation include: initialization of the communication module, interrupt enablement of the communication module, redirection of the communication module interrupt service routine, update process based on the communication module and BIOS interrupt vector table recovery, etc.
  • the main decision algorithm is as follows.
  • the overall process of the adaptive User program update of the communication module is designed as follows:
  • the host computer starts to send the User program data frame to the communication module, and the terminal completes the reception, checksum writing through the interrupt service routine (ie dynamic command) of the communication module.
  • BIOS self-update mechanism An important prerequisite for ensuring the stability of the embedded terminal software framework is the stability of the BIOS project.
  • BIOS is found to have fatal hidden dangers, a BIOS self-update mechanism is urgently needed.
  • the support of dynamic commands enables BIOS self-update to be realized.
  • BIOS self-update of the communication module Similar to the update of the User program, the general idea of the adaptive BIOS self-update of the communication module is: complete the writing of the dynamic command and the program jump through the system command, complete the takeover of the communication module with the help of the dynamic command, and then start the BIOS self-update.
  • the process is to first receive the machine code of the new version of BIOS and store it behind the current BIOS machine code. After the machine code of the new BIOS is received and verified, replace the machine code of the old BIOS with the machine code of the new BIOS sector by sector. .
  • the main steps of BIOS self-update are as follows:
  • BIOS invokes the dynamic command to complete the takeover of the user communication module.
  • the target chip After the target chip detects the last frame of data and verifies the storage, it does not exit the interrupt immediately, but enters the data relocation work in the interrupt, so that the new BIOS officially replaces the old BIOS. After the relocation is completed, it performs a soft reset and starts to execute the new BIOS process.
  • the initial strategy adopted is to rewrite the Flash component functions that will be used in the entire update process in the dynamic command function, and the BIOS self-update area skips the dynamic command function area, as shown in Figure 4 shown.
  • the program Since the dynamic command is essentially called in the interrupt, after the dynamic command receives the last frame of data of the new BIOS, the program does not jump out of the dynamic command and returns to the main function of the old BIOS, but continues to stay in the dynamic command area. Perform sector-by-sector replacement of the old and new BIOS, so that there is no problem of jumping back to the main program but the main program has been erased. It is only necessary to perform a software reset after the dynamic command completes the sector-by-sector replacement of the old and new BIOS. Can.
  • Dynamic component library is a component management mode provided by BIOS. In this mode, dynamic commands are responsible for adding, deleting, checking, and modifying components, and combined with the host computer, the corresponding component header files are generated for users to use.
  • the design of the dynamic component library mainly relies on two areas opened up in the BIOS link file: the component function list area and the component function code area.
  • the component function list area is used to store the function pointer and other necessary parameters of the component, and the component function code area is used for It is used to store the specific implementation of each function in the component.
  • the dynamic command function is responsible for the management of the data in these two areas.
  • the User project uses the functions in the dynamic component library through the API (Application Programming Interface) interface provided by the BIOS project.
  • the programming form of the component function list area is an array of pointer type (32-bit), which is mainly divided into three areas: component library parameter area, system related area and component area.
  • component library parameter area is mainly divided into three areas: component library parameter area, system related area and component area.
  • component area is mainly divided into three areas: component library parameter area, system related area and component area.
  • the main organization form and the function of corresponding parameters are shown in Table 3-1. Show.
  • the component function list area provides detailed records for all the data in the component library itself, so when there is a query request for the corresponding information, you only need to rely on dynamic commands to read the data in the component function list area and send it back to the host computer. machine analysis.

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 present invention provides an embedded terminal remote software updating method, used for being adapted to software updating requirements in different application scenes, and considering the portability and reusability of a system framework. A dynamic command serves as a main carrier and provides flexibility and adaptive support for a software updating function. The present invention uses a communication mode of serial communication as the preamble study of communication module adaption, and on this basis, summarizes a user program updating method and a BIOS self-updating method of the communication module adaption. For a dynamic command space problem in an implementation process, the present invention provides a solution for a dynamic component library, also has certain development practicability when simplifying the dynamic command, and also provide a perfect solution for a Flash load balancing problem in the dynamic component library.

Description

一种嵌入式终端远程软件更新方法A kind of embedded terminal remote software update method 技术领域technical field
本发明涉及软件开发与调试技术领域,具体涉及一种嵌入式终端远程软件更新方法。The invention relates to the technical field of software development and debugging, in particular to a remote software update method for an embedded terminal.
背景技术Background technique
软件更新作为集成开发环境的核心功能,是开发者所编写的软件在嵌入式终端得以运行的主要方式。在嵌入式终端远程在线开发背景下,终端节点需要具备远程更新代码的能力,来对节点进行灵活地配置和升级以适应环境变化。As the core function of the integrated development environment, software update is the main way for the software written by the developer to run on the embedded terminal. Under the background of remote online development of embedded terminals, the terminal node needs to have the ability to update the code remotely, so that the node can be flexibly configured and upgraded to adapt to changes in the environment.
传统的开发模式下,开发者往往会针对具体的应用场景事先选取一种通信方式,并将对应的通信模组驱动构件和软件更新代码固化于BIOS程序中,以此来完成针对后续User程序的开发和更新。然而这样的开发模式往往具有以下两个弊端:In the traditional development mode, developers often select a communication method in advance for specific application scenarios, and solidify the corresponding communication module driver components and software update codes in the BIOS program, so as to complete the subsequent User program. Developed and updated. However, such a development model often has the following two disadvantages:
(1)程序可移植、可复用性差。这样的开发模式下,每当因为不同的场景需求选取了不同的通信模组后,先前的BIOS程序便在很大程度上失去了移植和复用的价值,针对不同通信模组的BIOS程序的开发会带来毫无意义的重复劳动,降低整体的开发效率、延长开发周期。(1) The program is portable and has poor reusability. In this development mode, whenever different communication modules are selected for different scenarios, the previous BIOS programs lose the value of porting and reuse to a large extent. Development will bring meaningless duplication of work, reduce the overall development efficiency and prolong the development cycle.
(2)通信方式的升级受阻。当前通信模组的发展和演化速度极快,无论是针对通信模组本身的替换还是针对同一通信模组的固件更新,在嵌入式终端的工作周期内都可能存在需求。然而传统的开发模式下,通信模组相关构件已被固化于BIOS内,难以满足更替和升级需求。(2) The upgrade of the communication method is blocked. The current development and evolution of communication modules is extremely fast. Whether it is for the replacement of the communication module itself or the firmware update for the same communication module, there may be demands within the working cycle of the embedded terminal. However, in the traditional development mode, the related components of the communication module have been solidified in the BIOS, which is difficult to meet the replacement and upgrade requirements.
因此提出一种通信模组自适应的软件更新方法就显得尤为重要。同时,在嵌入式终端的开发过程中,针对用户程序的更新需求往往更为庞大。Therefore, it is particularly important to propose an adaptive software update method for communication modules. At the same time, in the development process of the embedded terminal, the update requirements for user programs are often larger.
技术问题technical problem 技术解决方案technical solutions
本发明的目的是通过以下技术方案实现的。The object of the present invention is achieved through the following technical solutions.
本申请针对通信模组自适应的程序更新这一关键技术,提出了嵌入式终端远程软件更新方法,以此来适应不同应用场景下的软件更新需求并兼顾系统框架本身的可移植可复用性。动态命令作为主要载体,为软件更新功能提供灵活性和适应性支撑。Aiming at the key technology of adaptive program update of communication modules, this application proposes a remote software update method for embedded terminals, so as to adapt to the software update requirements in different application scenarios and take into account the portability and reusability of the system framework itself . As the main carrier, dynamic commands provide flexibility and adaptive support for the software update function.
具体的,本发明提供一种嵌入式终端远程软件更新方法,包括:向用户串口发送动态命令数据,并由用户程序写入;向用户串口发送程序跳转的系统指令,用户程序在接收到指令后,跳转至BIOS;BIOS启动过程中默认调用动态命令函数;在动态命令内首先修改程序运行状态,完成BIOS的驻留;其次完成用户串口的初始化和中断使能;并设置BIOS程序中断向量表内对应于用户串口的中断服务例程地址为动态命令函数;最后告知上位机,相关初始化步骤已执行完毕,开始程序更新;上位机开始向用户串口发送用户程序数据帧,终端通过用户串口的动态命令完成接收、校验和写入;当用户串口的动态命令完成最后一帧数据的处理工作时,修改程序运行状态,复位BIOS,由BIOS基础运行流程完成针对用户程序的后续引导。Specifically, the present invention provides a remote software update method for an embedded terminal, comprising: sending dynamic command data to a user serial port and writing it into a user program; sending a system instruction for program jumping to the user serial port, and the user program receives the instruction Then, jump to the BIOS; the dynamic command function is called by default during the BIOS startup process; in the dynamic command, the program running state is first modified to complete the BIOS residency; secondly, the initialization and interrupt enable of the user serial port are completed; and the BIOS program interrupt vector is set The address of the interrupt service routine corresponding to the user serial port in the table is a dynamic command function; finally, the host computer is informed that the relevant initialization steps have been completed, and the program update starts; the host computer starts to send the user program data frame to the user serial port, and the terminal passes the user serial port. The dynamic command completes receiving, checking and writing; when the dynamic command of the user serial port completes the processing of the last frame of data, the program running state is modified, the BIOS is reset, and the BIOS basic operation process completes the subsequent guidance for the user program.
进一步地,所述用户串口的最外层帧结构为通信层的组帧结构,包含帧头、帧尾、数据长度、通信层数据和校验位。Further, the outermost frame structure of the user serial port is the framing structure of the communication layer, including frame header, frame trailer, data length, communication layer data and check bit.
进一步地,所述动态命令函数的建立过程如下:修改链接文件,在MEMORY字段和SECTIONS字段增加对应于动态命令的FLASH空间;增加动态命令函数的声明和定义,函数体为空,并使用attribute语法将动态命令函数放置于所述FLASH空间;在通信模组接收数据的中断处理程序中预留两个帧标识分别用于接收动态命令函数的机器码和执行动态命令函数;在更新状态判断函数中增加动态命令执行分支;在按键复位中增加动态命令重置步骤。Further, the establishment process of described dynamic command function is as follows: revise link file, increase the FLASH space corresponding to dynamic command in MEMORY field and SECTIONS field; Increase the declaration and definition of dynamic command function, function body is empty, and use attribute grammar The dynamic command function is placed in the FLASH space; in the interrupt handler of the communication module receiving data, two frame marks are reserved for receiving the machine code of the dynamic command function and the execution dynamic command function respectively; In the update state judgment function Add dynamic command execution branch; add dynamic command reset step in key reset.
进一步地,进一步包括:Further, further include:
所述BIOS进行自更新:通过系统指令完成动态命令的写入和程序跳转,借助动态命令完成通信模组的接管,然后开始进行BIOS自更新流程,先接收新版BIOS的机器码并存放在当前BIOS机器码的后方,在新BIOS的机器码接收完并通过校验后,逐扇区将旧BIOS的机器码替换更新为新BIOS的机器码。The BIOS is self-updated: the writing of the dynamic command and the program jump are completed by the system command, the takeover of the communication module is completed with the help of the dynamic command, and then the BIOS self-update process is started, and the machine code of the new version of the BIOS is first received and stored in the current BIOS. Behind the BIOS machine code, after the machine code of the new BIOS is received and verified, the machine code of the old BIOS is replaced and updated by the machine code of the new BIOS sector by sector.
进一步地,所述BIOS自更新的步骤如下:(1)编写相关函数制作动态命令代码;(2)向目标芯片用户程序发送BIOS自更新的动态命令安装包,目标芯片接收到后写入动态命令区;(3)向目标芯片用户程序发送系统指令,使之跳转并驻留至BIOS内;(4)BIOS调用动态命令,完成用户通信模组的接管;(5)开始向目标芯片发送新BIOS工程的机器码,逐帧校验后保存在当前BIOS存储空间的后方,并针对最后一帧数据给出相应的帧头;(6)目标芯片检测到最后一帧数据并校验存储后,不立即退出中断,进入中断内的数据搬迁工作,使得新BIOS正式取代旧BIOS,搬迁完毕后进行软复位,开始执行新的BIOS流程。Further, the steps of the self-update of the BIOS are as follows: (1) write a related function to make a dynamic command code; (2) send the dynamic command installation package of the BIOS self-update to the target chip user program, and write the dynamic command after the target chip receives it. (3) Send system commands to the target chip user program to make it jump and reside in the BIOS; (4) BIOS calls dynamic commands to complete the takeover of the user communication module; (5) Starts sending new messages to the target chip The machine code of the BIOS project is stored in the back of the current BIOS storage space after frame-by-frame verification, and the corresponding frame header is given for the last frame of data; (6) After the target chip detects the last frame of data and verifies the storage, Do not exit the interrupt immediately, and enter the data migration work in the interrupt, so that the new BIOS officially replaces the old BIOS, and after the migration is completed, a soft reset is performed to start the new BIOS process.
进一步地,所述动态命令能够简化为动态构件库,包括:构件函数列表区和构件函数代码区,其中构件函数列表区用于存放构件的函数指针和必要参数,构件函数代码区用于存放构件内各个函数的具体实现,由动态命令函数负责对这两块区域数据的管理。Further, the dynamic command can be simplified as a dynamic component library, including: a component function list area and a component function code area, wherein the component function list area is used to store the function pointer and necessary parameters of the component, and the component function code area is used to store the component. The specific implementation of each function in the system, the dynamic command function is responsible for the management of the data in these two areas.
进一步地,所述动态命令能够对各个构件、函数进行查询操作,并结合构件函数代码区进行增加、修改和删除的操作。Further, the dynamic command can perform query operations on each component and function, and add, modify and delete operations in combination with the component function code area.
进一步地,所述查询操作过程包括:依靠动态命令读取构件函数列表区的数据并回发至上位机,由上位机解析。Further, the query operation process includes: reading the data in the component function list area by means of a dynamic command and sending it back to the upper computer for analysis by the upper computer.
进一步地,所述增加的操作过程包括:在增加一个构件时,首先要根据构件函数列表区的下一个可用编号字段来确定当前构件的总体信息在构件函数列表区的记录位置,并在记录完毕后修改下一个可用编号字段,并根据函数代码区下一次可写地址字段来确定构件机器码的写入地址,并在写入完毕后相应的修改函数代码区下一次可写地址和函数代码区已用空间字段值。Further, the operation process of the increase includes: when adding a component, first determine the recording position of the overall information of the current component in the component function list area according to the next available number field in the component function list area, and after the recording is completed. Then modify the next available number field, and determine the write address of the component machine code according to the next writable address field of the function code area, and modify the next writable address and function code area of the function code area after the writing is completed. The used space field value.
进一步地,所述动态构件库内的Flash负载均衡方法如下:Further, the Flash load balancing method in the dynamic component library is as follows:
(1)对于删除的操作,不擦除原本所占据的空间,仅修改构件函数列表区的函数代码区已用空间参数;(2)对于修改的操作,同样不擦除原本所占据的空间,直接寻找下一个可存储的空间写入,函数存储空间大小的绝对变化记录在函数代码区已用空间参数,其中(1)(2)中产生的废弃代码数据所占据的空间称为Flash碎片;(3)在进行增加操作和修改过程中的增加操作时,如若找不到可以容纳构件的连续存储空间,则根据函数代码区已用空间、函数代码区首地址和函数代码区尾地址这三个参数,计算剩余连续空闲空间和由(1)(2)产生的所有Flash碎片总和是否可以容纳该构件,若不能,则返回相应的存储空间告急提示信息,若能,一次性清理所有扇区,将所有构件整理为前后紧密连续存储,并告知对应上位机本次操作将有一定耗时。(1) For the delete operation, do not erase the space originally occupied, but only modify the used space parameters of the function code area in the component function list area; (2) For the modified operation, also do not erase the originally occupied space, Directly look for the next storable space to write, and the absolute change of the function storage space size is recorded in the used space parameter of the function code area. The space occupied by the discarded code data generated in (1) (2) is called Flash fragment; (3) When performing addition operations and addition operations in the process of modification, if there is no continuous storage space that can accommodate components, then according to the used space of the function code area, the first address of the function code area and the end address of the function code area. parameters, calculate whether the remaining continuous free space and the sum of all Flash fragments generated by (1) (2) can accommodate the component, if not, return the corresponding storage space emergency prompt information, if yes, clear all sectors at one time , organize all components into close and continuous storage before and after, and inform the corresponding upper computer that this operation will take a certain amount of time.
有益效果beneficial effect
本发明的优点在于:本发明以串行通信这一通信方式作为通信模组自适应的前导研究,并基于此总结出通信模组自适应的User程序更新方法。并针对实现过程中的动态命令空间问题,给出动态构件库的解决方案,在化简动态命令的同时也具有一定的开发实用性,对于动态构件库内的Flash负载均衡问题也提供了完善的解决方案。The advantage of the present invention is that: the present invention takes serial communication as a leading research on the self-adaptation of the communication module, and based on this, summarizes the user program update method of the self-adaptation of the communication module. And for the dynamic command space problem in the implementation process, the solution of the dynamic component library is given, which simplifies the dynamic command and has certain development practicability, and also provides a complete solution for the Flash load balancing problem in the dynamic component library. solution.
附图说明Description of drawings
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are for the purpose of illustrating preferred embodiments only and are not to be considered limiting of the invention. Also, the same components are denoted by the same reference numerals throughout the drawings. In the attached image:
附图1示出了根据本发明实施方式的用户串口的帧结构示意图。FIG. 1 shows a schematic diagram of a frame structure of a user serial port according to an embodiment of the present invention.
附图2示出了根据本发明实施方式的基于用户串口User程序更新的动态命令执行流程图。FIG. 2 shows a flow chart of dynamic command execution based on user serial port User program update according to an embodiment of the present invention.
附图3示出了根据本发明实施方式的错误的函数依赖示意图。FIG. 3 shows a schematic diagram of functional dependencies of errors according to an embodiment of the present invention.
附图4示出了根据本发明实施方式的针对函数依赖问题的函数重写示意图。FIG. 4 shows a schematic diagram of function rewriting for functional dependency problems according to an embodiment of the present invention.
附图5示出了根据本发明实施方式的BIOS自更新动态命令函数依赖关系示意图。FIG. 5 shows a schematic diagram of the functional dependency of the BIOS self-update dynamic command according to an embodiment of the present invention.
附图6示出了根据本发明实施方式的紧凑原则下各扇区的擦除频率和使用寿命趋势示意图。FIG. 6 is a schematic diagram showing the trend of erasing frequency and service life of each sector under the compact principle according to an embodiment of the present invention.
附图7示出了根据本发明实施方式的Flash碎片整理示意图。FIG. 7 shows a schematic diagram of Flash defragmentation according to an embodiment of the present invention.
本发明的实施方式Embodiments of the present invention
下面将参照附图更详细地描述本公开的示例性实施方式。虽然附图中显示了本公开的示例性实施方式,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施方式所限制。相反,提供这些实施方式是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be more thoroughly understood, and will fully convey the scope of the present disclosure to those skilled in the art.
本发明提出了一种嵌入式终端远程软件更新方法,以此来适应不同应用场景下的软件更新需求并兼顾系统框架本身的可移植可复用性。动态命令作为主要载体,为软件更新功能提供灵活性和适应性支撑。本发明以串行通信这一通信方式作为通信模组自适应的前导研究,并基于此总结出通信模组自适应的User程序更新和BIOS自更新方法。并针对实现过程中的动态命令空间问题,给出动态构件库的解决方案,在化简动态命令的同时也具有一定的开发实用性,对于动态构件库内的Flash负载均衡问题也提供了完善的解决方案。本发明选取相对固定BIOS程序来负责适应不同的通信模组,由用户程序来承载变化的通信模组驱动构件。由此,这种软件更新方法下的基础软件架构得以确定。The invention proposes a remote software update method for an embedded terminal, so as to adapt to the software update requirements in different application scenarios and take into account the portability and reusability of the system framework itself. As the main carrier, dynamic commands provide flexibility and adaptive support for the software update function. The present invention takes the communication mode of serial communication as the leading research on the self-adaptation of the communication module, and based on this, summarizes the user program update and BIOS self-update method of the self-adaptation of the communication module. And for the dynamic command space problem in the implementation process, the solution of the dynamic component library is given, which simplifies the dynamic command and has certain development practicability, and also provides a complete solution for the Flash load balancing problem in the dynamic component library. solution. The present invention selects a relatively fixed BIOS program to be responsible for adapting to different communication modules, and the user program carries the changed communication module drive components. Thus, the basic software architecture under this software update method is determined.
嵌入式应用开发中选取的通信模组,往往不具备与对应的嵌入式终端直接通信的能力,一般的解决方案是借助嵌入式终端中固有的通信方式作为桥梁,以此达成两者之间的数据交互。此外通信模组自适应软件更新的核心问题是BIOS借助User的通信模组实现程序更新。因此作为前导研究,应当挑选较为简单的通信方式,串行通信作为MCU常见外设接口,通信速度、安全性有一定保障,且通过简单的外设电路可方便转换为RS485/RS232接口,进一步保证通信稳定性与传输距离。故选择串行通信作为User的通信方式来研究针对User程序更新方式的实现,为总结出通信模组自适应软件更新的一般方法做准备。The communication module selected in embedded application development often does not have the ability to communicate directly with the corresponding embedded terminal. The general solution is to use the inherent communication method in the embedded terminal as a bridge to achieve the communication between the two. Data interaction. In addition, the core problem of the adaptive software update of the communication module is that the BIOS realizes the program update by means of the User's communication module. Therefore, as a leading research, a relatively simple communication method should be selected. Serial communication is a common peripheral interface of MCU, and the communication speed and security are guaranteed to a certain extent, and it can be easily converted to RS485/RS232 interface through a simple peripheral circuit to further ensure Communication stability and transmission distance. So choose serial communication as User's communication method to study the realization of User program update method, and prepare for summarizing the general method of communication module adaptive software update.
1 基本要点和设计思路1 Basic points and design ideas
基于用户串口的用户(User)程序更新并不是一个频繁的需求,并且考虑到后续的程序更新可能不局限于串行通信,应当结合动态命令来将基于用户串口的User程序更新作为一个临时的功能处理。此外程序更新的主体对象仍然是用户程序,因此较为简便的实现方法仍然是将BIOS程序作为执行更新的主要场所,故存在一个User程序和BIOS程序相互跳转的环节。而所有数据的收发均基于用户程序的串口,这就意味着User程序中应当向BIOS动态命令区中写入动态命令,且考虑到数据的收发仍然主要由BIOS程序进行,因此BIOS程序要进行用户串口的接管。The user program update based on the user serial port is not a frequent requirement, and considering that the subsequent program update may not be limited to serial communication, the user program update based on the user serial port should be combined with dynamic commands as a temporary function. deal with. In addition, the main object of the program update is still the user program, so the simpler implementation method is still to use the BIOS program as the main place to perform the update, so there is a link where the User program and the BIOS program jump to each other. All data sending and receiving are based on the serial port of the user program, which means that the user program should write dynamic commands into the BIOS dynamic command area, and considering that the sending and receiving of data is still mainly performed by the BIOS program, the BIOS program must Serial port takeover.
1. 基本设计要点1. Basic design points
(1)程序的跳转。用户串口的程序更新场景下,目标嵌入式终端中必然已经存在一个版本的User程序正在运行,因此程序的跳转首先是由User程序向BIOS程序的跳转。(1) Program jump. In the program update scenario of the user serial port, a version of the User program must already be running in the target embedded terminal, so the program jump is firstly the jump from the User program to the BIOS program.
由User程序向BIOS程序的跳转依然是由用户串口接收数据决定的,因此在对用户串口接收数据的解析中,需要保留一定关键字,用于标识这帧数据为系统指令,需要进行程序的跳转。The jump from the User program to the BIOS program is still determined by the data received by the user serial port. Therefore, in the analysis of the data received by the user serial port, it is necessary to reserve certain keywords to identify this frame of data as a system command. jump.
而在新版本用户程序的数据接收完毕后,从BIOS程序跳转至User程序的步骤就比较简单,沿用通用嵌入式计算机框架下(以下简称GEC框架)基本的User程序引导方式即可。After the data of the new version of the user program is received, the step of jumping from the BIOS program to the User program is relatively simple, and the basic User program booting method under the general embedded computer framework (hereinafter referred to as the GEC framework) can be used.
(2)用户程序中动态命令体系的建立。同样的,动态命令的具体功能由用户串口接收并写入,而动态命令的执行仍然由BIOS程序进行,因此与上文中的程序跳转一样,在系统指令下,同样需要预留一个关键字用于引导动态命令的写入。(2) The establishment of dynamic command system in user program. Similarly, the specific function of the dynamic command is received and written by the user serial port, and the execution of the dynamic command is still carried out by the BIOS program. Therefore, like the program jump above, under the system command, it is also necessary to reserve a keyword to use It is used to guide the writing of dynamic commands.
(3)BIOS程序对用户串口的接管。BIOS程序对用户串口的接管除了需要初始化用户串口并中断使能以外,还需要重定向用户串口的中断处理程序。而针对这些BIOS程序中并不存在的功能,利用动态命令来实现即可。(3) The BIOS program takes over the user serial port. The takeover of the user serial port by the BIOS program not only needs to initialize the user serial port and enable the interrupt, but also needs to redirect the interrupt handler of the user serial port. For functions that do not exist in these BIOS programs, dynamic commands can be used to implement them.
2. 主要设计思路2. Main design ideas
综合前文所述,基于用户串口的User程序更新主要设计思路如下:Based on the foregoing, the main design ideas of the User program update based on the user serial port are as follows:
(1)向用户程序串口发送动态命令数据,并由User程序写入。(1) Send dynamic command data to the serial port of the user program and write it in by the User program.
(2)向用户程序串口发送程序跳转的系统指令。User程序在接收到指令后,跳转至BIOS。(2) Send the system command of program jump to the serial port of the user program. After the User program receives the instruction, it jumps to the BIOS.
(3)BIOS启动过程中默认调用动态命令函数。在动态命令内首先修改程序运行状态,完成BIOS的驻留;其次完成用户串口的初始化和中断使能;并设置BIOS程序中断向量表内对应于用户串口的中断服务例程地址为动态命令函数;最后告知上位机,相关初始化步骤已执行完毕,可以开始程序更新。(3) The dynamic command function is called by default during the BIOS startup process. In the dynamic command, firstly modify the running state of the program to complete the residency of the BIOS; secondly, complete the initialization and interrupt enable of the user serial port; and set the interrupt service routine address corresponding to the user serial port in the BIOS program interrupt vector table as the dynamic command function; Finally, inform the host computer that the relevant initialization steps have been completed, and the program update can be started.
(4)上位机开始向用户串口发送User程序数据帧,终端通过用户串口的中断服务例程(即动态命令)完成接收、校验和写入。(4) The host computer starts to send the User program data frame to the user serial port, and the terminal completes the reception, checksum writing through the interrupt service routine (ie dynamic command) of the user serial port.
(5)当用户串口的中断服务例程(即动态命令)完成最后一帧数据的处理工作时,修改程序运行状态,复位BIOS,由BIOS基础运行流程完成针对User程序的后续引导。(5) When the interrupt service routine (ie dynamic command) of the user serial port completes the processing of the last frame of data, modify the running state of the program, reset the BIOS, and complete the subsequent booting of the User program by the basic running process of the BIOS.
2 具体实现方式2 Specific implementation methods
在给出基本设计思路后,接下来进行基于用户串口User程序更新具体实现的阐述,主要围绕用户串口的帧结构和动态命令体系展开。After giving the basic design ideas, the next step is to describe the specific implementation of the User program update based on the user serial port, mainly focusing on the frame structure and dynamic command system of the user serial port.
1. 用户串口的帧结构1. Frame structure of user serial port
用户串口的最外层帧结构为通信层的组帧结构,可能包含帧头、帧尾、数据长度、通信层数据和校验位等内容。在通信层数据内的帧结构应当预留设备唯一序列号和软件版本号等内容,来协助判断某些广播场景下的数据帧取舍。而通信层数据内的有效数据帧结构则是由开发者自行定义的,但是为了完成诸如通信模组自适应的软件更新,需要预留一个关键字作为系统指令的帧标识,来提供丰富的预设功能,如程序跳转、设备序列号查询等。用户串口的帧结构如图1所示。 The outermost frame structure of the user serial port is the framing structure of the communication layer, which may include frame header, frame end, data length, communication layer data and check digit. The frame structure in the communication layer data should reserve contents such as the unique serial number of the device and the software version number to assist in judging the choice of data frames in some broadcast scenarios. The effective data frame structure in the communication layer data is defined by the developer, but in order to complete the software update such as the communication module adaptation, it is necessary to reserve a keyword as the frame identifier of the system command to provide rich pre- Set functions, such as program jump, device serial number query, etc. The frame structure of the user serial port is shown in Figure 1. 
2. GEC下动态命令体系的建立2. The establishment of dynamic command system under GEC
GEC下动态命令体系的建立,同样要从BIOS工程和User工程两个角度来考虑。The establishment of the dynamic command system under GEC should also be considered from the perspectives of BIOS engineering and User engineering.
(1)BIOS工程内动态命令体系的建立。动态命令体系的软件基础为P new工程框架,因此在BIOS工程内建立动态命令体系就意味着BIOS工程对应于P new工程,针对BIOS工程的修改步骤主要如下。 (1) The establishment of the dynamic command system in the BIOS project. The software foundation of the dynamic command system is the P new project framework, so establishing a dynamic command system in the BIOS project means that the BIOS project corresponds to the P new project, and the modification steps for the BIOS project are mainly as follows.
步骤一:修改链接文件,在MEMORY字段和SECTIONS字段增加对应于动态命令的FLASH空间。Step 1: Modify the link file and add the FLASH space corresponding to the dynamic command in the MEMORY field and the SECTIONS field.
步骤二:增加动态命令函数的声明和定义,函数体为空,并使用attribute语法将动态命令函数放置于步骤一中的FLASH空间。Step 2: Add the declaration and definition of the dynamic command function, the function body is empty, and use the attribute syntax to place the dynamic command function in the FLASH space in Step 1.
步骤三:在通信模组接收数据的中断处理程序中预留两个帧标识分别用于接收动态命令函数的机器码和执行动态命令函数。Step 3: Reserve two frame identifiers in the interrupt handler for receiving data of the communication module for receiving the machine code of the dynamic command function and executing the dynamic command function respectively.
步骤四:在更新状态判断函数中增加动态命令执行分支。Step 4: Add a dynamic command execution branch to the update state judgment function.
步骤五:在按键复位中增加动态命令重置步骤。这里的重置是指将动态命令的功能还原至空函数,即复位后的机器码对应于C语言代码的“return 0;”。Step 5: Add dynamic command reset step in key reset. The reset here refers to restoring the function of the dynamic command to an empty function, that is, the reset machine code corresponds to "return 0;" of the C language code.
(2)User工程中动态命令体系的接入。在BIOS工程内建立动态命令体系后,已经可以满足绝大部分的临时功能添加需求。然而针对一些特殊的临时功能,特别是那些需要借助User工程内资源实现的功能,就必须在User工程中接入动态命令体系。基于用户通信模组的User程序更新就是一个典型的例子。(2) Access to the dynamic command system in the User project. After the dynamic command system is established in the BIOS project, most of the temporary function addition requirements can be met. However, for some special temporary functions, especially those functions that need to be implemented with resources in the User project, the dynamic command system must be connected to the User project. User program update based on user communication module is a typical example.
与在BIOS工程中建立动态命令体系不同的是,在User工程中只需要进行动态命令体系的接入,动态命令存储的空间不变仍然位于BIOS内,只是为User工程提供动态命令写入的方式,即两个工程共同维护一块动态命令空间。Different from establishing the dynamic command system in the BIOS project, only the dynamic command system needs to be accessed in the User project. The dynamic command storage space remains unchanged in the BIOS, but only provides a way to write dynamic commands for the User project. , that is, the two projects jointly maintain a dynamic command space.
User工程作为开发者的主要开发场所,具体的通信模组由开发者自行决定,而动态命令体系必然依赖于通信模组数据的收发,因此要将动态命令的写入功能放置于系统指令内,而系统指令则作为User工程模板的固定文件,这样就可以实现不同通信模组中动态命令体系的接入。The User project is the main development site of the developer. The specific communication module is determined by the developer, and the dynamic command system must depend on the transmission and reception of the data of the communication module. Therefore, the writing function of the dynamic command should be placed in the system command. The system command is used as a fixed file of the User project template, so that the access to the dynamic command system in different communication modules can be realized.
3. 基于动态命令的开发流程3. Development process based on dynamic commands
 接下来给出基于动态命令体系的开发流程。Next, the development process based on the dynamic command system is given.
(1)P new的烧录。前文已经讨论过,建立好动态命令体系的BIOS工程即为P new工程,编译后获得H new,烧录至目标嵌入式终端即可。 (1) The programming of P new . As discussed above, the BIOS project that has established the dynamic command system is the P new project. After compiling, H new is obtained, and it can be burned into the target embedded terminal.
(2)动态命令的编写、校验和提取。首先在 P new工程的副本P copy中编写动态命令的具体功能,并进行初步的动态命令语法规则检查。编译后对比H new和H copy确保除动态命令区域以外的机器码完全一致。利用编写好的上位机软件提取对应动态命令区域的机器码,并发送至运行着P new工程的目标嵌入式终端,最后发送运行动态命令的指令,观察动态命令运行结果。 (2) Compilation, verification and extraction of dynamic commands. Firstly, the specific functions of the dynamic commands are written in the copy P copy of the P new project, and the preliminary dynamic command syntax rules are checked. After compiling, compare H new and H copy to ensure that the machine code except the dynamic command area is completely consistent. The machine code corresponding to the dynamic command area is extracted by the written host computer software, and sent to the target embedded terminal running the P new project, and finally the command to run the dynamic command is sent to observe the running result of the dynamic command.
(3)动态命令与上位机软件的融合。根据运行结果,确认动态命令制作无误后,根据需要将动态命令机器码的提取、发送和运行加入指定上位机窗口的事件内。由此来实现依靠上位机使得运行着P new工程的目标嵌入式终端得以运行动态命令。 (3) Integration of dynamic commands and host computer software. According to the running result, after confirming that the dynamic command is made correctly, the extraction, sending and running of the dynamic command machine code are added to the event of the specified host computer window as required. In this way, the target embedded terminal running the P new project can run dynamic commands by relying on the host computer.
4. 动态命令的具体设计4. The specific design of dynamic commands
前文已经提到动态命令的具体内容应该分为两部分。其中第一部分应该是在BIOS程序的默认调用处执行的,主要完成对用户串口的初始化、中断使能和接管用户串口中断,并预留配合后续更新的代码;第二部分则是用户串口中断处理程序的具体内容。其中,在接管用户串口中断时需要注册用户串口中断服务例程函数,这里直接选取动态命令地址即可,而针对动态命令的两部分内容,以是否触发通信模组中断为条件将动态命令一分为二来保证两部分内容互不干扰。基于用户串口User程序更新的动态命令执行流程如图2所示。As mentioned above, the specific content of the dynamic command should be divided into two parts. The first part should be executed at the default call of the BIOS program, mainly to complete the initialization of the user serial port, interrupt enable and take over the user serial port interrupt, and reserve the code for subsequent updates; the second part is the user serial port interrupt processing specific content of the program. Among them, the user serial port interrupt service routine function needs to be registered when taking over the user serial port interruption. Here, the dynamic command address can be directly selected. For the two parts of the dynamic command, the dynamic command is divided according to whether the communication module interrupt is triggered or not. To ensure that the two parts do not interfere with each other. The dynamic command execution flow based on user serial port User program update is shown in Figure 2.
通信模组自适应的User程序更新方法Communication module adaptive user program update method
嵌入式应用开发中选取的外部通信模组,往往需要借助嵌入式终端中固有的通讯模组来进行数据连接的建立。后文将以串行通信为例,使之作为连接嵌入式终端与外部通信模组的桥梁,因此外部通讯模组在具体工程内的构件设计可以理解为基于上行通信的上层构件设计。The external communication module selected in the embedded application development often needs to establish the data connection with the help of the inherent communication module in the embedded terminal. In the following text, serial communication will be used as an example to serve as a bridge connecting the embedded terminal and the external communication module. Therefore, the component design of the external communication module in a specific project can be understood as the upper-level component design based on uplink communication.
通过深入分析前文基于用户串口的User程序更新方法,总结并提取出涉及串行通信的主要工作,主要包括:串行通信的初始化、中断使能、中断服务例程地址的指定、数据的发送和数据的接收。由此在通信模组自适应的程序更新方法中,抽象出通信模组的公共要素为:通信模组的初始化、中断使能、中断服务例程地址的指定、数据的发送和数据的接收。Through in-depth analysis of the previous user program update method based on user serial port, the main work related to serial communication is summarized and extracted, mainly including: serial communication initialization, interrupt enable, interrupt service routine address designation, data transmission and data reception. Therefore, in the communication module adaptive program update method, the common elements of the communication module are abstracted as: initialization of the communication module, interrupt enable, designation of interrupt service routine address, data transmission and data reception.
由此通信模组自适应的User程序更新设计方法就变得相对清晰,通信模组的相关工作只在User程序的对应中断和动态命令内进行,因此针对两者给出详细的设计方法即可。As a result, the adaptive User program update design method of the communication module becomes relatively clear, and the related work of the communication module is only carried out in the corresponding interrupt and dynamic commands of the User program, so a detailed design method can be given for both. .
User程序内的通信模组数据接收中断Communication module data reception interruption in User program
针对User程序内的通信模组数据接收中断,主要从数据帧来说明。For the data reception interruption of the communication module in the User program, it is mainly explained from the data frame.
通信模组的数据帧并不随着通信模组的改变而发生结构上的变动,因此具体的帧结构仍然采用图1所示的用户串口帧结构设计方法即可。The data frame of the communication module does not change in structure with the change of the communication module, so the specific frame structure still adopts the user serial port frame structure design method shown in Figure 1.
并且同样的,由于通信模组自适应的User程序更新本质上还是BIOS程序对User程序的更新,因此数据帧内的系统指令标识中,仍然需要预留程序跳转指令,用于将目标终端的程序运行状态从User拉回至BIOS。In the same way, since the adaptive User program update of the communication module is essentially the update of the User program by the BIOS program, it is still necessary to reserve a program jump instruction in the system instruction identifier in the data frame for converting the target terminal's The program running state is pulled back from User to BIOS.
此外由于通信模组驱动构件的依赖和程序执行流程的需要,系统指令标识中仍然需要接入动态命令体系,向User程序提供动态命令的写入接口。In addition, due to the dependence of the communication module driving component and the need of the program execution process, the system instruction identifier still needs to be connected to the dynamic command system to provide the User program with a writing interface of the dynamic command.
动态命令的设计Design of Dynamic Commands
通信模组自适应下的动态命令主要功能包含:通信模组的初始化、通信模组的中断使能、通信模组中断服务例程的重定向、基于通信模组的更新流程和BIOS中断向量表的复原等。主要决策算法如下。The main functions of the dynamic commands under the communication module adaptation include: initialization of the communication module, interrupt enablement of the communication module, redirection of the communication module interrupt service routine, update process based on the communication module and BIOS interrupt vector table recovery, etc. The main decision algorithm is as follows.
Figure 446545dest_path_image001
Figure 446545dest_path_image001
.
整体流程设计Overall process design
通信模组自适应的User程序更新整体流程设计如下:The overall process of the adaptive User program update of the communication module is designed as follows:
(1)向通信模组发送动态命令数据,并由User程序写入。(1) Send dynamic command data to the communication module and write it in by the User program.
(2)向通信模组发送程序跳转的系统指令。User程序接收指令,跳转至BIOS。(2) Send the system command of program jump to the communication module. The User program receives the instruction and jumps to the BIOS.
(3)BIOS启动过程中默认调用动态命令函数。(3) The dynamic command function is called by default during the BIOS startup process.
(4)在动态命令内首先修改程序运行状态,完成BIOS的驻留;其次完成通信模组的初始化和中断使能;并设置BIOS程序中断向量表内对应于通信模组的中断服务例程地址为动态命令函数;最后告知上位机,相关初始化步骤已执行完毕,可以开始程序更新。(4) In the dynamic command, first modify the program running state to complete the BIOS residency; secondly complete the initialization and interrupt enable of the communication module; and set the interrupt service routine address corresponding to the communication module in the BIOS program interrupt vector table It is a dynamic command function; finally inform the host computer that the relevant initialization steps have been executed, and the program update can be started.
(5)上位机开始向通信模组发送User程序数据帧,终端通过通信模组的中断服务例程(即动态命令)完成接收、校验和写入。(5) The host computer starts to send the User program data frame to the communication module, and the terminal completes the reception, checksum writing through the interrupt service routine (ie dynamic command) of the communication module.
(6)当通信模组的中断服务例程(即动态命令)完成最后一帧数据的处理工作时,修改程序运行状态,复位BIOS,由BIOS基础运行流程完成针对User程序的后续引导。(6) When the interrupt service routine (that is, the dynamic command) of the communication module completes the processing of the last frame of data, the program running state is modified, the BIOS is reset, and the BIOS basic operation process completes the subsequent guidance for the User program.
通信模组自适应的BIOS自更新方法BIOS self-update method for adaptive communication module
保证嵌入式终端软件框架稳定性的重要前提是BIOS工程的稳定,在当发现BIOS存在致命隐患的情况下急需一种BIOS自我更新的机制,动态命令的支撑使得BIOS自更新得以实现。An important prerequisite for ensuring the stability of the embedded terminal software framework is the stability of the BIOS project. When the BIOS is found to have fatal hidden dangers, a BIOS self-update mechanism is urgently needed. The support of dynamic commands enables BIOS self-update to be realized.
主要方法设计main method design
与User程序的更新类似,通信模组自适应的BIOS自更新大致思想是:通过系统指令完成动态命令的写入和程序跳转,借助动态命令完成通信模组的接管,然后开始进行BIOS自更新流程,先接收新版BIOS的机器码并存放在当前BIOS机器码的后方,在新BIOS的机器码接收完并通过校验后,逐扇区将旧BIOS的机器码替换更新为新BIOS的机器码。BIOS自更新的主要步骤如下:Similar to the update of the User program, the general idea of the adaptive BIOS self-update of the communication module is: complete the writing of the dynamic command and the program jump through the system command, complete the takeover of the communication module with the help of the dynamic command, and then start the BIOS self-update. The process is to first receive the machine code of the new version of BIOS and store it behind the current BIOS machine code. After the machine code of the new BIOS is received and verified, replace the machine code of the old BIOS with the machine code of the new BIOS sector by sector. . The main steps of BIOS self-update are as follows:
(1)编写相关函数制作动态命令代码。(1) Write related functions to make dynamic command codes.
(2)向目标芯片User程序发送BIOS自更新的动态命令安装包,目标芯片接收到后写入动态命令区。(2) Send the dynamic command installation package of BIOS self-update to the target chip User program, and the target chip writes the dynamic command area after receiving it.
(3)向目标芯片User程序发送系统指令,使之跳转并驻留至BIOS内。(3) Send a system command to the target chip User program to make it jump and reside in the BIOS.
(4)BIOS调用动态命令,完成用户通信模组的接管。(4) The BIOS invokes the dynamic command to complete the takeover of the user communication module.
(5)开始向目标芯片发送新BIOS工程的机器码,逐帧校验后保存在当前BIOS存储空间的后方,并针对最后一帧数据给出特殊的帧头。(5) Start sending the machine code of the new BIOS project to the target chip, check it frame by frame and save it in the back of the current BIOS storage space, and give a special frame header for the last frame of data.
(6)目标芯片检测到最后一帧数据并校验存储后,不立即退出中断,进入中断内的数据搬迁工作,使得新BIOS正式取代旧BIOS,搬迁完毕后进行软复位,开始执行新的BIOS流程。(6) After the target chip detects the last frame of data and verifies the storage, it does not exit the interrupt immediately, but enters the data relocation work in the interrupt, so that the new BIOS officially replaces the old BIOS. After the relocation is completed, it performs a soft reset and starts to execute the new BIOS process.
动态命令内的主要决策算法如下所示。The main decision-making algorithm within the dynamic command is shown below.
Figure 98106dest_path_image002
Figure 98106dest_path_image002
.
函数依赖问题functional dependency problem
在逐扇区替换旧BIOS的过程中,遇到的关键问题是:在使用旧BIOS中Flash构件的擦除函数进行旧BIOS的擦除时,当擦除函数试图对擦除函数本身所在扇区进行擦除时必然会出现致命错误,也会导致后续旧BIOS中Flash构件的其他函数无法使用,如图3所示。In the process of replacing the old BIOS sector by sector, the key problem encountered is: when using the erasing function of the Flash component in the old BIOS to erase the old BIOS, when the erasing function tries to erase the sector where the erasing function itself is located When erasing, a fatal error will inevitably occur, and other functions of the Flash component in the subsequent old BIOS will not be available, as shown in Figure 3.
为了避免对旧BIOS的函数依赖,采取的初步策略是在动态命令函数中重写整个更新过程中的会使用到的Flash构件函数,并且BIOS自更新的区域跳过动态命令函数区域,如图4所示。In order to avoid the function dependence on the old BIOS, the initial strategy adopted is to rewrite the Flash component functions that will be used in the entire update process in the dynamic command function, and the BIOS self-update area skips the dynamic command function area, as shown in Figure 4 shown.
由于动态命令本质上是在中断内被调用,在动态命令接收到新BIOS的最后一帧数据后,使得程序不从动态命令中跳出回到旧BIOS的主函数,而是继续停留在动态命令区域进行新旧BIOS的逐扇区替换,这样也就不存在想要跳回主程序但主程序已被擦除的问题了,只需当动态命令完成新旧BIOS的逐扇区替换后进行一次软件复位即可。Since the dynamic command is essentially called in the interrupt, after the dynamic command receives the last frame of data of the new BIOS, the program does not jump out of the dynamic command and returns to the main function of the old BIOS, but continues to stay in the dynamic command area. Perform sector-by-sector replacement of the old and new BIOS, so that there is no problem of jumping back to the main program but the main program has been erased. It is only necessary to perform a software reset after the dynamic command completes the sector-by-sector replacement of the old and new BIOS. Can.
进一步分析以上问题可以发现,针对欲擦除代码的函数依赖问题只开始于逐扇区替换旧BIOS数据这一过程,因此一个更加简易的应对策略是,只需要针对从这一过程开始的、具有依赖问题的函数进行重写即可。BIOS自更新动态命令函数依赖关系如图5所示。Further analysis of the above problems can be found that the functional dependency problem of the code to be erased only begins with the process of replacing the old BIOS data sector by sector. The function that depends on the problem can be rewritten. The functional dependencies of the BIOS self-update dynamic commands are shown in Figure 5.
动态命令的化简:动态构件库Simplification of Dynamic Commands: Dynamic Component Library
前文给出的一系列程序更新方式,都是依赖动态命令来完成核心功能的实现。然而动态命令的初衷是通过多个临时功能对一块小区域空间的共同使用,达到有限空间内多种功能动态加载的效果。前文中的程序更新场景下,由于通信模组在软件框架内隶属于User程序的资源,这样就使得向BIOS传输通信模组相关功能的动态命令时,需要在动态命令内重写一个通信模组的函数副本或将通信模组函数展开。由此必然导致动态命令的代码量过大,甚至在面对实现方式复杂的通信模组,可能会出现空间不足的问题。A series of program update methods given above all rely on dynamic commands to complete the realization of core functions. However, the original intention of the dynamic command is to achieve the effect of dynamic loading of multiple functions in a limited space through the common use of a small area of space by multiple temporary functions. In the program update scenario mentioned above, since the communication module belongs to the resource of the User program in the software framework, it is necessary to rewrite a communication module in the dynamic command when transmitting the dynamic command of the related functions of the communication module to the BIOS. function copy or expand the communication module function. This will inevitably lead to an excessively large amount of code for dynamic commands, and even in the face of communication modules with complex implementations, there may be a problem of insufficient space.
动态构件库的提出The Proposition of Dynamic Component Library
在动态命令由于大量的函数依赖问题而进行函数重写和展开的情况下,动态命令本身的存储空间可能不足以容纳庞大的代码,因此急需一种方法来进行函数、构件的集中管理存储,以便动态命令调用。此外,GEC软件框架中的BIOS工程在开发者获取到嵌入式终端时,就已经被固化在芯片内部,由GEC框架开发者维护,因此GEC框架也存在发布稳定的构件供开发者使用的需求,并且需要一种不泄露源代码的发布方式。由此引入基于动态命令的动态构件库技术。In the case of function rewriting and expansion of dynamic commands due to a large number of functional dependencies, the storage space of dynamic commands may not be enough to accommodate huge codes. Dynamic command invocation. In addition, the BIOS project in the GEC software framework has been solidified inside the chip when the developer obtains the embedded terminal, and is maintained by the GEC framework developer. Therefore, the GEC framework also needs to release stable components for developers to use. And there needs to be a way of publishing that doesn't reveal the source code. Therefore, the technology of dynamic component library based on dynamic command is introduced.
动态构件库是BIOS提供的一种构件管理模式,该模式下由动态命令负责构件的增、删、查、改等工作,结合上位机生成对应的构件头文件供用户使用。Dynamic component library is a component management mode provided by BIOS. In this mode, dynamic commands are responsible for adding, deleting, checking, and modifying components, and combined with the host computer, the corresponding component header files are generated for users to use.
动态构件库的设计方法Design Method of Dynamic Component Library
动态构件库的设计主要依靠在BIOS链接文件中开辟的两块区域:构件函数列表区和构件函数代码区,其中构件函数列表区用于存放构件的函数指针和其他必要参数,构件函数代码区用于存放构件内各个函数的具体实现,此外由动态命令函数来负责对这两块区域数据的管理,User工程对动态构件库内函数的使用则通过BIOS工程提供的API(Application Programming Interface)接口。The design of the dynamic component library mainly relies on two areas opened up in the BIOS link file: the component function list area and the component function code area. The component function list area is used to store the function pointer and other necessary parameters of the component, and the component function code area is used for It is used to store the specific implementation of each function in the component. In addition, the dynamic command function is responsible for the management of the data in these two areas. The User project uses the functions in the dynamic component library through the API (Application Programming Interface) interface provided by the BIOS project.
1. 构件函数列表区的设计1. Design of the component function list area
构件函数列表区的编程形式为指针类型(32位)的数组,主要划分为三个区域:构件库参数区、系统相关区和构件区,主要组织形式及对应参数的功能如表3-1所示。The programming form of the component function list area is an array of pointer type (32-bit), which is mainly divided into three areas: component library parameter area, system related area and component area. The main organization form and the function of corresponding parameters are shown in Table 3-1. Show.
Figure dest_path_image003
Figure dest_path_image003
Figure 346685dest_path_image004
Figure 346685dest_path_image004
.
2. 主要管理方式的初步设计2. Preliminary design of main management methods
有了构件函数列表区的索引和相关参数,动态命令就可以很方便的对各个构件、甚至是各个函数,进行查询操作,并结合构件函数代码区进行增加、修改和删除的操作。With the index and related parameters in the component function list area, dynamic commands can easily query each component and even each function, and add, modify and delete operations in combination with the component function code area.
(1)查询。构件函数列表区针对构件库本身的所有数据给出了详细的记录,因此在出现相应信息的查询需求时,只需依靠动态命令读取构件函数列表区的数据并回发至上位机,由上位机解析即可。(1) Query. The component function list area provides detailed records for all the data in the component library itself, so when there is a query request for the corresponding information, you only need to rely on dynamic commands to read the data in the component function list area and send it back to the host computer. machine analysis.
(2)增加。在增加一个构件时,首先要根据构件函数列表区的“下一个可用编号”字段来确定当前构件的总体信息在构件函数列表区的记录位置,并在记录完毕后修改“下一个可用编号”字段。此外还需根据“函数代码区下一次可写地址”字段来确定构件机器码的写入地址,并在写入完毕后相应的修改“函数代码区下一次可写地址”和“函数代码区已用空间”字段值。(2) Increase. When adding a component, first determine the record position of the overall information of the current component in the component function list area according to the "next available number" field in the component function list area, and modify the "next available number" field after the recording is completed . In addition, it is necessary to determine the write address of the component machine code according to the field of "Next Writable Address of Function Code Area", and modify the "Next Writable Address of Function Code Area" and "Function Code Area Has Been Written" accordingly after the writing is completed. Use space" field value.
(3)删除。在存在构件删除需求时,首先要根据构件函数列表区内各区域的“区域占用编号”字段依次链式查询构件名,在定位到欲删除构件时,删除对应的构件函数列表区和构件函数代码区的数据,并修改“下一个可用编号”、“函数代码区下一次可写地址”和“函数代码区已用空间”字段。(3) Delete. When there is a need for component deletion, firstly, according to the "area occupancy number" field of each area in the component function list area, you need to chain query component names in sequence. When the component to be deleted is located, delete the corresponding component function list area and component function code. and modify the fields of "Next Available Number", "Next Writable Address of Function Code Area" and "Used Space of Function Code Area".
(4)修改。由于Flash以扇区为最小擦除单位的机制,针对构件的修改操作可以简单的拆解为先删除后添加。不同的是在删除后不立即进行两个区域的Flash写入操作,而是在进行增加操作后一同写入。具体方法已在(2)(3)中阐述。(4) Modification. Due to the mechanism that Flash uses sectors as the minimum erasing unit, the modification operation for components can be simply disassembled as first delete and then add. The difference is that the Flash write operation of the two areas is not performed immediately after deletion, but is written together after the addition operation is performed. The specific method has been described in (2)(3).
得益于动态命令本身的机制,这些操作不会影响系统当前的运行状态,也不会过多的影响实时性,免去了停机和重复烧写程序的繁琐。Thanks to the mechanism of the dynamic command itself, these operations will not affect the current running state of the system, nor will it affect the real-time performance too much, eliminating the cumbersome shutdown and repeated programming of the program.
Flash负载均衡Flash load balancing
考虑到Flash本身的使用寿命,如果在多次的构件增删改操作中,每一次操作都保证构件函数代码区的紧凑,那么这些操作往往会导致构件函数代码区寿命的两极分化严重,这是因为常规场景下,构件函数代码区的实际使用占比不会接近100%,以50%的平均实际使用空间为例,构件函数代码区的各扇区的擦除频率及对应的寿命将大致呈现如图6的分布。且构件函数代码区的平均实际使用空间占比越小、构件增删改操作的次数越多,这样的两级分化将越严重。Considering the service life of Flash itself, if each operation ensures the compactness of the component function code area in multiple component addition, deletion and modification operations, these operations will often lead to serious polarization of the component function code area life. This is because In normal scenarios, the actual usage ratio of the component function code area will not be close to 100%. Taking 50% of the average actual usage space as an example, the erasure frequency and corresponding life of each sector in the component function code area will roughly appear as follows: Figure 6. Distribution. And the smaller the average actual use space of the component function code area, and the more the number of component additions, deletions and modifications, the more serious this dichotomy will be.
针对这个问题,本申请提出了一种Flash负载均衡方案:In response to this problem, this application proposes a Flash load balancing solution:
(1)对于删除的操作,不擦除原本所占据的空间,仅修改构件函数列表区的“函数代码区已用空间”这一参数;(1) For the delete operation, the original occupied space is not erased, and only the parameter "used space of function code area" in the component function list area is modified;
(2)对于修改的操作,同样不擦除原本所占据的空间,改而直接寻找下一个可存储的空间写入,该函数存储空间大小的绝对变化记录在“函数代码区已用空间”这一参数。(1)(2)中产生的废弃代码数据所占据的空间以下称为Flash碎片。(2) For the modified operation, the original occupied space is also not erased, but the next storable space to write is directly searched for. The absolute change in the size of the function storage space is recorded in the "used space in the function code area". a parameter. (1) The space occupied by the discarded code data generated in (2) is hereinafter referred to as Flash fragment.
(3)在进行增加操作和修改过程中的增加操作时,如若找不到可以容纳该构件的连续存储空间,则根据“函数代码区已用空间”、“函数代码区首地址”和“函数代码区尾地址”这三个参数,计算剩余连续空闲空间和由(1)(2)产生的所有Flash碎片总和是否可以容纳该构件,若不能,则返回相应的存储空间告急提示信息,若能,一次性清理所有扇区,将所有构件整理为前后紧密连续存储如图7所示,并告知对应上位机本次操作将有一定耗时。(3) When adding operations and adding operations during modification, if there is no continuous storage space that can accommodate the component, according to the "used space in the function code area", "the first address of the function code area" and "function code area" The three parameters of "code area tail address", calculate whether the remaining continuous free space and the sum of all Flash fragments generated by (1) (2) can accommodate the component, if not, return the corresponding storage space emergency prompt information, if yes , clean up all sectors at one time, organize all components into close and continuous storage before and after as shown in Figure 7, and inform the corresponding upper computer that this operation will take a certain amount of time.
该方案的核心思想是,在存储空间足够的情况下,优先使用后方空闲的存储空间,在提升尾部扇区的使用率的同时,很大程度上避免了擦除Flash操作,直至空闲存储空间不足时,才考虑对Flash碎片进行整体的处理。详细的算法表示如下:The core idea of this scheme is that when there is enough storage space, the free storage space in the rear is used first, and while the utilization rate of the tail sector is improved, the flash erase operation is largely avoided until the free storage space is insufficient. Only consider the overall processing of Flash fragments. The detailed algorithm is expressed as follows:
Figure dest_path_image005
Figure dest_path_image005
.
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。The above description is only a preferred embodiment of the present invention, but the protection scope of the present invention is not limited to this. Substitutions should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims (9)

  1. 一种嵌入式终端远程软件更新方法,其特征在于,包括:向用户串口发送动态命令数据,并由用户程序写入;向用户串口发送程序跳转的系统指令,用户程序在接收到指令后,跳转至BIOS;BIOS启动过程中默认调用动态命令函数;在动态命令内首先修改程序运行状态,完成BIOS的驻留;其次完成用户串口的初始化和中断使能;并设置BIOS程序中断向量表内对应于用户串口的中断服务例程地址为动态命令函数;最后告知上位机,相关初始化步骤已执行完毕,开始程序更新;上位机开始向用户串口发送用户程序数据帧,终端通过用户串口的动态命令完成接收、校验和写入;当用户串口的动态命令完成最后一帧数据的处理工作时,修改程序运行状态,复位BIOS,由BIOS基础运行流程完成针对用户程序的后续引导;所述动态命令函数的建立过程如下:修改链接文件,在MEMORY字段和SECTIONS字段增加对应于动态命令的FLASH空间;增加动态命令函数的声明和定义,函数体为空,并使用attribute语法将动态命令函数放置于所述FLASH空间;在通信模组接收数据的中断处理程序中预留两个帧标识分别用于接收动态命令函数的机器码和执行动态命令函数;在更新状态判断函数中增加动态命令执行分支;在按键复位中增加动态命令重置步骤。A method for remote software updating of an embedded terminal, comprising: sending dynamic command data to a user serial port and writing it in by a user program; sending a system instruction for program jumping to the user serial port, and after the user program receives the instruction, Jump to BIOS; the dynamic command function is called by default during the BIOS startup process; in the dynamic command, the program running state is first modified to complete the BIOS residency; secondly, the initialization and interrupt enable of the user serial port are completed; and the BIOS program interrupt vector table is set The address of the interrupt service routine corresponding to the user serial port is a dynamic command function; finally, the host computer is informed that the relevant initialization steps have been completed, and the program update is started; the host computer starts to send the user program data frame to the user serial port, and the terminal passes the user serial port. Dynamic commands Complete receiving, checking and writing; when the dynamic command of the user serial port completes the processing of the last frame of data, modify the program running state, reset the BIOS, and complete the follow-up guidance for the user program by the BIOS basic running process; the dynamic command The creation process of the function is as follows: modify the link file, add the FLASH space corresponding to the dynamic command in the MEMORY field and the SECTIONS field; add the declaration and definition of the dynamic command function, leave the function body empty, and use the attribute syntax to place the dynamic command function in all places. Describe the FLASH space; Reserve two frame marks in the interrupt processing program that the communication module receives data respectively for receiving the machine code of the dynamic command function and executing the dynamic command function; In the update state judgment function, increase the dynamic command execution branch; Added dynamic command reset steps in key reset.
  2. 根据权利要求1所述的一种嵌入式终端远程软件更新方法,其特征在于,所述用户串口的最外层帧结构为通信层的组帧结构,包含帧头、帧尾、数据长度、通信层数据和校验位。The method for remote software updating of an embedded terminal according to claim 1, wherein the outermost frame structure of the user serial port is a framing structure of a communication layer, comprising a frame header, a frame trailer, a data length, a communication Layer data and check digit.
  3. 根据权利要求1所述的一种嵌入式终端远程软件更新方法,其特征在于,进一步包括:所述BIOS进行自更新:通过系统指令完成动态命令的写入和程序跳转,借助动态命令完成通信模组的接管,然后开始进行BIOS自更新流程,先接收新版BIOS的机器码并存放在当前BIOS机器码的后方,在新BIOS的机器码接收完并通过校验后,逐扇区将旧BIOS的机器码替换更新为新BIOS的机器码。The method for remote software updating of an embedded terminal according to claim 1, further comprising: the BIOS is self-updated: writing of dynamic commands and program jumping are completed through system instructions, and communication is completed by means of dynamic commands The module takes over, and then starts the BIOS self-update process. First, the machine code of the new BIOS is received and stored in the back of the current BIOS machine code. After the machine code of the new BIOS is received and verified, the old BIOS is updated sector by sector. Replace the machine code of the updated BIOS with the machine code of the new BIOS.
  4. 根据权利要求3所述的一种嵌入式终端远程软件更新方法,其特征在于,所述BIOS自更新的步骤如下:(1)编写相关函数制作动态命令代码;(2)向目标芯片用户程序发送BIOS自更新的动态命令安装包,目标芯片接收到后写入动态命令区;(3)向目标芯片用户程序发送系统指令,使之跳转并驻留至BIOS内;(4)BIOS调用动态命令,完成用户通信模组的接管;(5)开始向目标芯片发送新BIOS工程的机器码,逐帧校验后保存在当前BIOS存储空间的后方,并针对最后一帧数据给出相应的帧头;(6)目标芯片检测到最后一帧数据并校验存储后,不立即退出中断,进入中断内的数据搬迁工作,使得新BIOS正式取代旧BIOS,搬迁完毕后进行软复位,开始执行新的BIOS流程。The method for remote software update of an embedded terminal according to claim 3, wherein the steps of the BIOS self-update are as follows: (1) write a related function to make a dynamic command code; (2) send the target chip user program BIOS self-updated dynamic command installation package, the target chip will write the dynamic command area after receiving it; (3) Send system commands to the target chip user program to make it jump and reside in the BIOS; (4) The BIOS calls the dynamic command , complete the takeover of the user communication module; (5) Start to send the machine code of the new BIOS project to the target chip, check frame by frame and save it in the back of the current BIOS storage space, and give the corresponding frame header for the last frame of data ; (6) After the target chip detects the last frame of data and verifies the storage, it does not exit the interrupt immediately, and enters the data relocation work in the interrupt, so that the new BIOS officially replaces the old BIOS. BIOS flow.
  5. 根据权利要求1所述的一种嵌入式终端远程软件更新方法,其特征在于,所述动态命令能够简化为动态构件库,包括:构件函数列表区和构件函数代码区,其中构件函数列表区用于存放构件的函数指针和必要参数,构件函数代码区用于存放构件内各个函数的具体实现,由动态命令函数负责对这两块区域数据的管理。The method for remote software updating of an embedded terminal according to claim 1, wherein the dynamic command can be simplified into a dynamic component library, comprising: a component function list area and a component function code area, wherein the component function list area uses In order to store the function pointer and necessary parameters of the component, the component function code area is used to store the specific implementation of each function in the component, and the dynamic command function is responsible for the management of the data in these two areas.
  6. 根据权利要求5所述的一种嵌入式终端远程软件更新方法,其特征在于,所述动态命令能够对各个构件、函数进行查询操作,并结合构件函数代码区进行增加、修改和删除的操作。The method for remote software updating of an embedded terminal according to claim 5, wherein the dynamic command can perform query operations on each component and function, and add, modify and delete operations in combination with the component function code area.
  7. 根据权利要求6所述的一种嵌入式终端远程软件更新方法,其特征在于,所述查询操作过程包括:依靠动态命令读取构件函数列表区的数据并回发至上位机,由上位机解析。The method for remote software updating of an embedded terminal according to claim 6, wherein the query operation process comprises: reading the data in the component function list area by means of dynamic commands and sending it back to the host computer, and the host computer parses it. .
  8. 根据权利要求6所述的一种嵌入式终端远程软件更新方法,其特征在于,所述增加的操作过程包括:在增加一个构件时,首先要根据构件函数列表区的下一个可用编号字段来确定当前构件的总体信息在构件函数列表区的记录位置,并在记录完毕后修改下一个可用编号字段,并根据函数代码区下一次可写地址字段来确定构件机器码的写入地址,并在写入完毕后相应的修改函数代码区下一次可写地址和函数代码区已用空间字段值。The method for remote software updating of an embedded terminal according to claim 6, wherein the operation process of adding comprises: when adding a component, firstly, it is determined according to the next available number field in the component function list area. The overall information of the current component is in the record position of the component function list area, and after the recording is completed, the next available number field is modified, and the write address of the component machine code is determined according to the next writable address field in the function code area, and when writing After the entry is completed, modify the next writable address of the function code area and the field value of the used space in the function code area accordingly.
  9. 根据权利要求5所述的一种嵌入式终端远程软件更新方法,其特征在于,所述动态构件库内的Flash负载均衡方法如下:(1)对于删除的操作,不擦除原本所占据的空间,仅修改构件函数列表区的函数代码区已用空间参数;(2)对于修改的操作,同样不擦除原本所占据的空间,直接寻找下一个可存储的空间写入,函数存储空间大小的绝对变化记录在函数代码区已用空间参数,其中(1)(2)中产生的废弃代码数据所占据的空间称为Flash碎片;(3)在进行增加操作和修改过程中的增加操作时,如若找不到可以容纳构件的连续存储空间,则根据函数代码区已用空间、函数代码区首地址和函数代码区尾地址这三个参数,计算剩余连续空闲空间和由(1)(2)产生的所有Flash碎片总和是否可以容纳该构件,若不能,则返回相应的存储空间告急提示信息,若能,一次性清理所有扇区,将所有构件整理为前后紧密连续存储,并告知对应上位机本次操作将有一定耗时。A method for remote software updating of an embedded terminal according to claim 5, wherein the Flash load balancing method in the dynamic component library is as follows: (1) For the deletion operation, the space originally occupied is not erased , only modify the used space parameters of the function code area in the component function list area; (2) For the modified operation, also do not erase the originally occupied space, directly find the next storable space to write, the function storage space size The absolute change is recorded in the used space parameter of the function code area, of which (1) the space occupied by the discarded code data generated in (2) is called Flash fragment; (3) When performing addition operations and addition operations in the modification process, If there is no continuous storage space that can accommodate the component, then according to the three parameters of the used space of the function code area, the first address of the function code area and the end address of the function code area, calculate the remaining continuous free space and by (1) (2) Whether the sum of all generated Flash fragments can accommodate the component, if not, return the corresponding storage space emergency prompt information, if yes, clear all sectors at one time, organize all components into close and continuous storage before and after, and inform the corresponding host computer This operation will take some time.
PCT/CN2021/122776 2021-04-29 2021-10-09 Embedded terminal remote software updating method WO2022227409A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110472878.5A CN113110860B (en) 2021-04-29 2021-04-29 Remote software updating method for embedded terminal
CN202110472878.5 2021-04-29

Publications (1)

Publication Number Publication Date
WO2022227409A1 true WO2022227409A1 (en) 2022-11-03

Family

ID=76720405

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/122776 WO2022227409A1 (en) 2021-04-29 2021-10-09 Embedded terminal remote software updating method

Country Status (2)

Country Link
CN (1) CN113110860B (en)
WO (1) WO2022227409A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115469912A (en) * 2022-11-02 2022-12-13 中国人民解放军国防科技大学 Heterogeneous real-time information processing system design method

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113110860B (en) * 2021-04-29 2024-05-24 苏州大学 Remote software updating method for embedded terminal
CN115033264A (en) * 2022-05-25 2022-09-09 苏州大学 Remote updating method of heating valve control system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104090796A (en) * 2014-07-08 2014-10-08 成都万维图新信息技术有限公司 Embedded device program updating method and system
US20170255459A1 (en) * 2016-03-01 2017-09-07 Renesas Electronics Corporation Embedded device and program updating method
CN113110860A (en) * 2021-04-29 2021-07-13 苏州大学 Remote software updating method for embedded terminal

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104090796A (en) * 2014-07-08 2014-10-08 成都万维图新信息技术有限公司 Embedded device program updating method and system
US20170255459A1 (en) * 2016-03-01 2017-09-07 Renesas Electronics Corporation Embedded device and program updating method
CN113110860A (en) * 2021-04-29 2021-07-13 苏州大学 Remote software updating method for embedded terminal

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CHENG HONGYU: "Research and Design of Embedded Integrated Development Environment for ARM Cortex-M Series MCU", MASTER THESIS, TIANJIN POLYTECHNIC UNIVERSITY, CN, no. 2, 15 February 2021 (2021-02-15), CN , XP055981623, ISSN: 1674-0246 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115469912A (en) * 2022-11-02 2022-12-13 中国人民解放军国防科技大学 Heterogeneous real-time information processing system design method
CN115469912B (en) * 2022-11-02 2023-01-24 中国人民解放军国防科技大学 Heterogeneous real-time information processing system design method

Also Published As

Publication number Publication date
CN113110860A (en) 2021-07-13
CN113110860B (en) 2024-05-24

Similar Documents

Publication Publication Date Title
WO2022227409A1 (en) Embedded terminal remote software updating method
US5623661A (en) System for and method of providing delta-versioning of the contents of PCTE file objects
JP4936654B2 (en) How to create language-independent files and corresponding language-specific resource files for components
US7243346B1 (en) Customized library management system
CN102279765B (en) Pre-compiling hosted managed code
US7305376B2 (en) Multiple language-dependent resources compacted into a single resource file
US20060064576A1 (en) Boot systems and methods
JP2005182809A (en) Creating file system within file in storage technology-abstracted manner
JP2002518732A (en) Type implementation method with parameters compatible with existing library without parameters
CN106909441B (en) Disk direct I/O access method based on JVM
JP2004530201A (en) Methods for loading and running applications in embedded environments
WO2024113717A1 (en) Zns ssd-based file system control method, apparatus and device
CN101334737A (en) Embedded equipment start-up or reset method
CN110716721A (en) TMS320C6748 program loading method compatible with network port and serial port
CN101425052B (en) Method for implementing transactional memory
WO2023169164A1 (en) Method and apparatus for restoring application program, and computer device and storage medium
CN116028267A (en) Dual-system secure mobile phone resetting method and device, server and storage medium
US7389515B1 (en) Application deflation system and method
CN111290765B (en) Firmware quick burning method, system and storage medium
JP4125056B2 (en) Log acquisition method
US20050149270A1 (en) Componentware creating method, apparatus and recording medium
US11513792B2 (en) Tracking history of firmware program updates
US10185653B2 (en) Integrated systems and methods for the transactional management of main memory and data storage
CN115640269B (en) Android application installation acceleration method based on-demand copying
JP2005251045A (en) Information processor, housing position management method, and program

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21938872

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21938872

Country of ref document: EP

Kind code of ref document: A1