Program upgrading method and device, storage medium and electronic equipment
By setting the first program in the target system to directly receive and process the upgrade file, the problem of low update efficiency through emulators in the prior art is solved, and more efficient and flexible program updates are achieved.
Patent Information
- Application Number
- CN202510514369.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-04-23
AI Technical Summary
In the prior art, it is necessary to update applications in the processor by connecting to an emulator, resulting in low update efficiency.
By setting the first program in the target system, receiving and parsing the upgrade file, and directly performing program upgrade processing in the target system, the dependence on the dedicated emulator is avoided.
Improves the efficiency of program updates, reduces hardware costs, and enhances the flexibility of updates, allowing for faster and more efficient updates.
Smart Images

Figure CN120029650A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a program upgrade method and device, a storage medium, and an electronic device. Background Art
[0002] For DSP (Digital Signal Processor) embedded systems that have been put into use, when the application code needs to be changed or further improved and upgraded according to actual conditions, the current solution is to connect an emulator and use simulation software to enter the simulation to program the DSP chip's FLASH. This process is cumbersome and time-consuming, and there is a problem of low efficiency in updating the application.
[0003] With regard to the problem in the related art that the application program in the processor needs to be updated by connecting to an emulator, resulting in relatively low updating efficiency of the application program, no effective solution has been proposed so far. Summary of the invention
[0004] The main purpose of the present application is to provide a program upgrade method and device, a storage medium and an electronic device to solve the problem in the related art that the application program in the processor needs to be updated by connecting an emulator, resulting in relatively low update efficiency of the application program.
[0005] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a method for upgrading a program is provided. The method comprises: receiving an upgrade file through a first program in a target system, wherein the upgrade file is used to upgrade a second program in the target system; parsing and reading the upgrade file through the first program to obtain code data corresponding to the upgrade file; and upgrading the second program in the target system according to the code data corresponding to the upgrade file.
[0006] Furthermore, upgrading the second program in the target system according to the code data corresponding to the upgrade file includes: reading the current line of code data in the upgrade file, and if the data type corresponding to the current line of code data is a preset first value, obtaining a starting address from the current line of code data, determining the sector corresponding to the starting address as the current sector, and erasing the current sector, wherein the starting address is a flag address of the current sector storing the second program; reading the next line of code data in the upgrade file, and if the data type corresponding to the next line of code data is a preset second value, obtaining an offset address from the next line of code data; determining a target address based on the offset address and the starting address, and burning the next line of code data to the target address to upgrade the second program.
[0007] Further, burning the next line of code data to the target address includes: determining whether the target address is within the current sector to obtain a first determination result; if the first determination result indicates that the target address is within the current sector, burning the next line of code data to the target address.
[0008] Furthermore, after determining whether the target address is within the current sector and obtaining a first determination result, the method further includes: if the first determination result indicates that the target address is not within the current sector, setting an erase flag to a preset third value; when the erase flag is set to the preset third value, updating the current sector to a sector corresponding to the target address, and performing an erase process on the current sector; after performing an erase process on the current sector row, burning the next row of code data to the target address.
[0009] Furthermore, burning the next line of code data to the target address to upgrade the second program includes: after burning the next line of code data to the target address, repeating the step of reading the next line of code data in the upgrade file until the data type corresponding to the next line of code data is a preset fourth value, then determining that the upgrade process of the second program by the upgrade file has been completed.
[0010] Furthermore, after the second program in the target system is upgraded according to the code data corresponding to the upgrade file, the method further includes: determining whether there is a next upgrade file to obtain a second determination result; if the second determination result indicates that there is the next upgrade file, upgrading the second program in the target system based on the next upgrade file until there is no next upgrade file; if the second determination result indicates that there is no next upgrade file, triggering a target signal, wherein the target signal is used to indicate that the upgrade process for the second program has been completed.
[0011] Furthermore, after receiving the upgrade file through the first program in the target system, the method also includes: storing the upgrade file in a receiving buffer area; determining whether there is an error in the upgrade file in the receiving buffer area; if there is an error in the upgrade file in the receiving buffer area, resetting the receiving buffer area and re-receiving the upgrade file.
[0012] Furthermore, before upgrading the second program in the target system according to the code data corresponding to the upgrade file, the method also includes: reading the upgrade file from the receiving buffer area through the first program; when reading the upgrade file, determining whether there is an overflow in the receiving buffer area; if there is an overflow in the receiving buffer area, resetting the receiving buffer area and re-receiving the upgrade file.
[0013] Furthermore, before receiving the upgrade file through the first program in the target system, the method also includes: generating an initial upgrade file based on the functional information to be upgraded through the target host computer; judging whether the initial upgrade file needs to be split based on the target threshold through the target host computer; if the initial upgrade file needs to be split, splitting the initial upgrade file based on the target threshold through the target host computer to obtain multiple upgrade files; and transmitting each upgrade file to the first program through the target host computer.
[0014] Furthermore, before receiving the upgrade file through the first program in the target system, the method also includes: starting the boot loader after the target system receives a power-on signal; starting the first program through the boot loader, and establishing a communication mechanism between the first program and the target host computer so that the first program can receive the upgrade file.
[0015] Furthermore, upgrading the second program in the target system based on the code data corresponding to the upgrade file includes: determining whether the frame header mark corresponding to the upgrade file is a preset character; when the frame header mark is the preset character, upgrading the second program in the target system based on the code data corresponding to the upgrade file.
[0016] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a program upgrade system is provided. The system comprises: a target host computer, wherein the target host computer is used to generate an upgrade file and transfer the upgrade file to a first program; and a first program, wherein the first program upgrades a second program in the target system based on the upgrade file.
[0017] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a program upgrade device is provided. The device comprises: a receiving unit, configured to receive an upgrade file through a first program in a target system, wherein the upgrade file is used to upgrade a second program in the target system; a processing unit, configured to parse and read the upgrade file through the first program to obtain code data corresponding to the upgrade file; and a first upgrade unit, configured to perform upgrade processing on the second program in the target system according to the code data corresponding to the upgrade file.
[0018] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned program upgrade methods when executing the computer program.
[0019] The present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the upgrade method of any of the above programs are implemented.
[0020] In an embodiment of the present application, the following steps are adopted: an upgrade file is received through a first program in a target system, wherein the upgrade file is used to upgrade a second program in the target system; the upgrade file is parsed and read through the first program to obtain code data corresponding to the upgrade file; and the second program in the target system is upgraded based on the code data corresponding to the upgrade file, thereby solving a technical problem in the related art that an application program in a processor needs to be updated by connecting an emulator, resulting in relatively low update efficiency of the application program.
[0021] In this solution, the first program set in the target system is used to receive the upgrade file, and the first program eliminates the dependence on the dedicated emulator. The first program parses and reads the upgrade file to obtain the corresponding code data. After extracting the code data of the upgrade file, the first program burns the read code data to the corresponding position to upgrade the second program. Since the upgrade process does not require connecting a dedicated emulator, but is completed through the first program in the target system, the dependence on additional hardware devices is reduced, the hardware cost is reduced, and the upgrade file is directly received and processed by the internal program of the target system, which can significantly improve the efficiency of program updates, and the upgrade file can be used to achieve directional function updates and enhance the flexibility of updates. For a small number of updates, the method of specifying address updates in the upgrade file can complete the update work more quickly and efficiently. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0023] Figure 1 A hardware structure block diagram of a computer terminal for implementing a program upgrade method is shown;
[0024] Figure 2 The following is a flow chart of the method for upgrading the program provided in the embodiment of the present application: Figure 1 ;
[0025] Figure 3The following is a flow chart of the method for upgrading the program provided in the embodiment of the present application: Figure 2 ;
[0026] Figure 4 The following is a flow chart of the method for upgrading the program provided in the embodiment of the present application: Figure 3 ;
[0027] Figure 5 This is a waveform diagram provided according to an embodiment of the present application. Figure 1 ;
[0028] Figure 6 This is a waveform diagram provided according to an embodiment of the present application. Figure 2 ;
[0029] Figure 7 The following is a flow chart of the method for upgrading the program provided in the embodiment of the present application: Figure 4 ;
[0030] Figure 8 The following is a flow chart of the method for upgrading the program provided in the embodiment of the present application: Figure 5 ;
[0031] Fig. 9 This is a schematic diagram of code burning provided in accordance with the embodiment of the present application. Figure 1 ;
[0032] Fig.10 This is a schematic diagram of code burning provided in accordance with the embodiment of the present application. Figure 2 ;
[0033] Fig.11 is a schematic diagram of an upgrade system of a program provided according to an embodiment of the present application;
[0034] Fig.12 is a schematic diagram of an upgrade device for a program provided in an embodiment of the present application;
[0035] Fig.13 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0037] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0038] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0039] DSP, Digital Signal Processor, is a microprocessor with a special architecture, specially designed to perform digital signal processing tasks, such as filtering, encoding, decoding, compression and decompression, etc., and is particularly suitable for real-time processing of large amounts of data. DSP has high-speed data processing capabilities, powerful computing capabilities (especially for multiplication and accumulation operations), efficient memory management, and flexible I / O interfaces. These features make it play an important role in communications, audio, video, image processing, biomedical engineering, radar, seismic data processing, instrument measurement and other fields.
[0040] Boot ROM, Boot Read-Only Memory, is a special type of memory in embedded systems. Its main function is to execute the initial boot program when the device is powered on or reset.
[0041] Boot Loader is a key component in computer hardware systems, especially in embedded systems. It is between the operating system and the hardware and is responsible for loading and initializing the operating system or other executable software at the initial stage of system startup.
[0042] It should be noted that the collected information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with relevant laws, regulations and standards, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation entrances are provided for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or institutions, providing users with corresponding operation entrances for users to choose to agree or refuse the results of automated decision-making; if the user chooses to refuse, the expert decision-making process will be entered.
[0043] Example 1
[0044] According to an embodiment of the present application, a method embodiment of upgrading a program is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0045] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 The hardware structure block diagram of a computer terminal (or mobile device) for implementing a program upgrade method is shown. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0046] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0047] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the program upgrade method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the above-mentioned program upgrade method is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0048] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0049] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0050] Under the above operating environment, this application provides Figure 2 How to upgrade the program shown. Figure 2 It is a flowchart of the method for upgrading the program according to Example 1 of the present application.
[0051] Step S201: receiving an upgrade file through a first program in a target system, wherein the upgrade file is used to upgrade a second program in the target system.
[0052] Optionally, when it is necessary to upgrade the program (i.e., the second program) in the DSP embedded system (i.e., the target system), the first program in the DSP embedded system receives the upgrade file for upgrading the second program in the target system. The first program can start running after the DSP embedded system is started.
[0053] In an optional embodiment, the first program can be implemented using a main function and a timer, wherein the main function determines the upgrade instruction, and the timer performs corresponding instruction processing and upgrade file parsing and burning functions.
[0054] In an optional embodiment, the upgrade file can be sent to the first program through a host computer. The host computer can exchange data with the first program through a serial port.
[0055] It should be noted that the first program and the second program can be stored separately in different sectors of the Flash. The CMD file is used to constrain the program storage space and segment allocation. The entry address of the first program is 0x80000, and the entry address of the second program is 0x088000. CMD files are link command files (Link Command Files), which end with the suffix .cmd and are referred to as CMD files. The two major functions of CMD files are to indicate storage space and allocate segments to storage space. The CMD file constraint specification is the default mode of the DSP chip. Generally, this mode cannot be changed, and memory space can only be allocated on demand.
[0056] After the target system is powered on and reset, the target system obtains the reset vector from the internal Boot Rom. The reset vector points to the Boot Rom and executes the internal Boot loader program. After the execution is completed, it is determined to start the first program from the internal Flash, and the program pointer jumps to 0x080000 of the Flash, and the address is changed to the fixed program entry address of the Flash. The storage space of the program is constrained by the CMD file and the segments are allocated to the storage space. The first program uses 0x080000 as the entry address, and the first program is stored in the PROGRAM_SECTOR sector. When the second program does not need to be upgraded, the first program jumps to the second program. The entry address of the second program is configured to 0x088000, and the program is stored in the sector after the first program.
[0057] By storing the first program and the second program in different sectors of FLASH respectively, the interference between the two programs can be avoided in the design. For application developers, they only need to focus on the functional implementation of the business code. For the first program porting personnel, hardware compatibility is more required. The first program is not affected by the application program, and the later project is more portable. In addition, in terms of security, the integrity of the first program can always be guaranteed. During the upgrade process, only the memory space of the second program is operated. Based on the handshake mechanism and error retransmission, even if the second program fails to upgrade, the firmware can be downloaded and upgraded again, and the first program will not crash and fail to run, and the reliability of the first program is always guaranteed. Based on the above two points, the portability and security of the upgrade mechanism can be guaranteed.
[0058] Step S202: parsing and reading the upgrade file through the first program to obtain code data corresponding to the upgrade file.
[0059] Optionally, after receiving the upgrade file, the upgrade file is parsed and read by the first program. For example, the first program reads each line of code data in the upgrade file, extracts the starting address therefrom, parses the data length field in each line and the code data that needs to be updated in the target system, etc.
[0060] In an optional embodiment, the format of the upgrade file can be an upgrade file in .hex format, which is usually used to store program code or data so that these codes and data can be written into the DSP embedded system using a programmer or software tool during the production process or during system maintenance.
[0061] Step S203: upgrading the second program in the target system according to the code data corresponding to the upgrade file.
[0062] Optionally, the first program will upgrade the second program in the target system according to the code data corresponding to the read upgrade file. For example, the first program finds the code that needs to be upgraded in the second program in the target system, and then burns the code according to the read code, thereby upgrading the second program in the target system.
[0063] In summary, in this solution, the first program set in the target system is used to receive the upgrade file, and the first program eliminates the dependence on the dedicated emulator. The first program parses and reads the upgrade file to obtain the corresponding code data. After extracting the code data of the upgrade file, the first program burns the read code data to the corresponding position to implement the upgrade process of the second program. Since the upgrade process does not require the connection of a dedicated emulator, but is completed by the first program in the target system, the dependence on additional hardware devices is reduced, the hardware cost is reduced, and the upgrade file is directly received and processed by the internal program of the target system, which can significantly improve the efficiency of program updates, and the upgrade file can realize directional function updates to enhance the flexibility of updates. For a small number of updates, the method of specifying address updates in the upgrade file can complete the update work more quickly and efficiently.
[0064] Optionally, in the program upgrade method provided in the embodiment of the present application, upgrading the second program in the target system according to the code data corresponding to the upgrade file includes: reading the current line of code data in the upgrade file, if the data type corresponding to the current line of code data is a preset first value, obtaining the starting address from the current line of code data, determining the sector corresponding to the starting address as the current sector, and erasing the current sector, wherein the starting address is the mark address of the current sector storing the second program; reading the next line of code data in the upgrade file, if the data type corresponding to the next line of code data is a preset second value, obtaining the offset address from the next line of code data; determining the target address based on the offset address and the starting address, and burning the next line of code data to the target address to upgrade the second program.
[0065] In an optional embodiment, upgrading the second program in the target system according to the code data corresponding to the upgrade file includes the following steps: reading the current line of code data in the upgrade file, and checking the data type of the line record. If the data type of the current line of code data is equal to a preset first value (for example, 4), it means that the current line of code data is the first line and contains a new starting address in the line of code data, which is used to identify the beginning of a new sector, and this sector needs to be erased in order to update the second program.
[0066] When it is determined that the data type of the current line of code data is equal to the preset first value, the starting address is extracted from the current line of code data, and this address indicates the starting position of the current sector. After obtaining the starting address, the current sector can be directly erased. After the erasure is completed, the next line of code data in the upgrade file is read. After reading the next line of code data, it is determined whether the data type corresponding to the next line of code data is the preset second value (for example, 0).
[0067] If the data type corresponding to the next line of code data is a preset second value, it indicates that the line of code data includes an upgrade code. First, parse the offset address from this line of data. The offset address refers to the offset relative to the previously determined starting address. Add the offset address to the starting address to calculate the actual target address, which indicates where to burn the new data in the Flash. Finally, burn the new code data in the next line of code data to the target address to upgrade the second program. It should be noted that the first program can realize the burning of code data by calling the Flash API.
[0068] It should be noted that the above process will be repeated until all row data in the upgrade file are processed or the end identifier of the file is encountered.
[0069] In an optional embodiment, the Figure 3 The flowchart shown implements the upgrade process of the second program, which specifically includes: the target system is powered on, the Boot loader program is run first, the first program is started in the Flash, and then communication is established with the host computer to obtain the upgrade file. SCI serial port communication can be used between the host computer and the first program. When an online upgrade is required, the first program erases the corresponding sector according to the upgrade file, and then burns the data into the corresponding sector. When no upgrade is required, the first program directly jumps to the second program. Figure 3 As shown, the first program uses 0x080000 as the entry address, and the first program is stored in the PROGRAM_SECTOR sector (from 0x080002-0x087FFF). The second program entry address is configured as 0x088000, and the program is stored in the FLASHE sector (starting from 0x088010).
[0070] In summary, by erasing and burning only necessary sectors and data, the efficiency of the second program is improved.
[0071] Optionally, in the program upgrade method provided in the embodiment of the present application, burning the next line of code data to the target address includes: determining whether the target address is within the current sector to obtain a first judgment result; if the first judgment result indicates that the target address is within the current sector, burning the next line of code data to the target address.
[0072] If the first judgment result indicates that the target address is not within the current sector, the erase flag is set to a preset third value; when the erase flag is set to the preset third value, the current sector is updated to the sector corresponding to the target address, and the current sector is erased; after the current sector row is erased, the next line of code data is burned to the target address.
[0073] In an optional embodiment, the sector needs to be erased before burning. The sector can only be erased for a continuous address (a sector). Before burning, it is necessary to ensure that it has been erased and cannot be erased repeatedly, otherwise the previous address data will be erased for each address data burned. Therefore, before burning the next line of code data to the target address, in order to avoid repeated erasing of the current sector, it also includes: determining whether the target address is within the current sector. If the target address is indeed within the current sector, then the burning operation can be performed directly to write the next line of code data to the target address.
[0074] When the target address is not within the current sector, it means that the new data needs to be written to a different sector, so the erase flag needs to be set to a preset third value (eg, 1) to indicate that the sector corresponding to the target address needs to be erased.
[0075] After setting the erase flag, when the erase flag is set to a preset third value, the current sector is updated to the sector corresponding to the target address, that is, in the subsequent code data burning process, it is necessary to compare whether the address corresponding to the subsequent code data is in the sector corresponding to the target address. After the current sector is updated to the sector corresponding to the target address and determined as the current sector, the current sector is erased according to the erase flag, and after the erasure is completed, the next line of code data is burned to the target address, thereby completing the data update of the new sector. It should be noted that after the current sector is erased, the erase flag needs to be set to a preset value (for example, 0) to avoid the current sector being erased again in the future.
[0076] By dynamically updating the current sector and performing the erase operation in a timely manner, it is possible to handle program updates across multiple sectors without affecting the data in other sectors, thereby improving the accuracy of program upgrades.
[0077] Optionally, in the program upgrade method provided in the embodiment of the present application, burning the next line of code data to the target address to upgrade the second program includes: after burning the next line of code data to the target address, repeating the step of reading the next line of code data in the upgrade file until the data type corresponding to the next line of code data is a preset fourth value, then determining that the upgrade process of the second program by the upgrade file has been completed.
[0078] In an optional embodiment, as described above, after the first program burns the next line of code data to the target address, it will continue to read the next line of code data in the upgrade file, that is, repeat the step of reading the next line of code data in the upgrade file until the data type corresponding to the next line of code data is a preset fourth value (for example, 1). When it is determined that the data type corresponding to the next line of code data is the preset fourth value, it indicates that all data records in the upgrade file have been read, and the upgrade process of the upgrade file for the second program has been completed.
[0079] By parsing and burning the code data in the upgrade file line by line, it is possible to ensure that the upgrade process of the second program is complete and correct, thereby improving the accuracy of the program upgrade.
[0080] Optionally, in the program upgrade method provided in the embodiment of the present application, upgrading the second program in the target system based on the code data corresponding to the upgrade file includes: determining whether the frame header mark corresponding to the upgrade file is a preset character; if the frame header mark is a preset character, upgrading the second program in the target system based on the code data corresponding to the upgrade file.
[0081] In a readable embodiment, in order to avoid the received upgrade file having problems, when performing upgrade processing on the second program in the target system according to the code data corresponding to the upgrade file, the first program needs to determine whether the frame header mark corresponding to the upgrade file is a preset character (for example, 0x3A). If the frame header mark is a preset character, the second program in the target system is upgraded according to the code data corresponding to the upgrade file.
[0082] It should be noted that if the frame header mark corresponding to the upgrade file is not a preset character, it indicates that there may be a problem with the upgrade file, and therefore, the upgrade file needs to be obtained again.
[0083] By checking the frame header flag, you can ensure that the transmission and reception of the upgrade file is correct, and at the same time prevent erroneous data streams from being mistaken for valid upgrade files, thereby avoiding unnecessary errors and possible system damage.
[0084] In an optional embodiment, the Figure 4The flowchart shown realizes the burning of the code file. First, the first program determines whether the frame header flag corresponding to the upgrade file is 0x3A. If it is 0x3A, the current line of code data is read to determine whether the corresponding data type is 1. If it is not 1, the length, address and check code of the current line of code data are read. According to the check code, it is determined whether there is an error in the current line of code data. If there is no error, the data to be burned is read from the current line of code data to determine whether the end of the line is read. If it is determined that the end of the line has been reached, it is determined whether the data type corresponding to the current line of code data is 4. If it is 4, it is currently the first line of code data. The starting address is read from the current line of code data and recorded, and the next line of code data is read. If the end of the line has not been reached, Received_Data_Index++ (used to increase the index or count of the received data when processing the received data in the program) is read until the end of the line is read. If the data type corresponding to the current line of code data is 0, then read the offset address in the current line of code data, and calculate the absolute address corresponding to the current line of code data (i.e., the above-mentioned target address) based on the offset address and the recorded starting address, and determine whether to set the sector erase flag to 1 based on the absolute address. If the sector erase flag is 1, the sector erases and burns the data to be burned in the current line of code data. After the burning is completed, the upgrade file offset is used to read the next line of code data, and the processing completion flag is set for the current line of code data. Repeat the above process until the data type corresponding to the read code data is 1. When the data type corresponding to the read code data is 1, clear the cache area used to store the upgrade file, and set the flag of the cache area to 1, indicating that the current upgrade file has been processed.
[0085] If the frame header flag corresponding to the upgrade file is not 0x3A, it indicates that there may be a problem with the upgrade file, so the buffer used to store the upgrade file is cleared and an error (HEXFILE_ERR) is reported. If the current line code data is judged to have an error based on the check code, the number of error lines is sent, the buffer used to store the upgrade file is cleared, and an error (HEX CHECK_ERR) is reported.
[0086] Through data type recognition, automatic sector erasing and data burning, as well as sophisticated error handling and upgrade progress control, the efficiency and security of program upgrades are greatly improved. Especially in the scenario of online upgrades, it can effectively reduce the risks in the upgrade process and improve the success rate of upgrades, thereby supporting the maintainability and flexibility of embedded systems.
[0087] Optionally, in the program upgrade method provided in the embodiment of the present application, after the second program in the target system is upgraded according to the code data corresponding to the upgrade file, the method further includes: determining whether there is a next upgrade file to obtain a second judgment result; if the second judgment result indicates that there is a next upgrade file, upgrading the second program in the target system based on the next upgrade file until there is no next upgrade file; if the second judgment result indicates that there is no next upgrade file, triggering a target signal, wherein the target signal is used to indicate that the upgrade process for the second program has been completed.
[0088] In an optional embodiment, after the second program in the target system is upgraded by the code data corresponding to the upgrade file, the first program will determine whether there is a next upgrade file to be processed. If there is a next upgrade file, the first program will start processing the file, including steps such as reading the file, parsing the data, erasing the sectors, burning the data, and verifying the integrity. The above process will be repeated until all upgrade files are processed correctly.
[0089] After determining that there is no next upgrade file, that is, all files to be upgraded have been burned, the first program can send a target signal to indicate that the program upgrade process has been completed. The target signal can be implemented in many ways, such as sending a confirmation message through the serial port.
[0090] In an optional embodiment, after the upgrade process of the second program is completed, the waveform can be captured by an oscilloscope to compare whether the second program has been successfully upgraded. If different flip frequencies are seen, it means that the upgrade is successful. For example, before the upgrade, the waveform of the second program is as follows: Figure 5 As shown, the duration of the high level is about 1s. The waveform of the second program after the upgrade is as follows Figure 6 As shown, the duration of the high level is about 4 seconds. Through the above steps, it can be accurately evaluated whether the second program is upgraded.
[0091] Optionally, in the program upgrade method provided in the embodiment of the present application, after receiving the upgrade file through the first program in the target system, the method also includes: storing the upgrade file in a receiving cache area; determining whether there is an error in the upgrade file in the receiving cache area; if there is an error in the upgrade file in the receiving cache area, resetting the receiving cache area and receiving the upgrade file again.
[0092] The program upgrade method provided in the embodiment of the present application also includes: reading the upgrade file from the receiving buffer area through the first program; when reading the upgrade file, determining whether there is an overflow in the receiving buffer area; if there is an overflow in the receiving buffer area, resetting the receiving buffer area and re-receiving the upgrade file.
[0093] In an optional embodiment, the first program can implement the reception and storage of the upgrade file by the following steps: The reception of the upgrade file can be implemented by using a 3s timer interrupt. The 3s timer is an actual test value of the project to ensure the complete reception of the upgrade file. For example, Figure 7 As shown, first, it is determined whether a new message is received (i.e., whether the upgrade file is received). When a new message is received, the receiving data timestamp is reset, and the received upgrade file is stored in the receiving buffer. Then, it is determined whether there is an error in the received upgrade file. If there is an error, the receiving buffer is reset, and the upgrade file is accurately received again.
[0094] If the received upgrade file does not contain errors, determine whether to read the upgrade file in the receive buffer. If read, determine whether the receive buffer overflows. If not, process the upgrade file normally. If overflow occurs, reset the receive data flag (accurately re-receive the upgrade file) and clear the receive buffer.
[0095] In an optional embodiment, after the first program receives the data and puts it into the receiving buffer, the timer interrupts the scanning buffer data with 3s. If there is new data, the data content is judged and processed. The first program can also receive Modbus instructions other than the upgrade file. Modbus instructions are specific commands or functions used to send and receive data in the Modbus communication protocol. They define how to exchange information between the Modbus master device (Master) and the slave device (Slave). The Modbus protocol is a serial communication protocol widely used in the field of industrial automation. It allows different devices to exchange data through standard interfaces and commands. Modbus instructions can include read instructions and write instructions.
[0096] Therefore, when the first program starts to process the received data, it is necessary to first determine whether it is a Modbus instruction or a HEX upgrade file, such as Figure 8 As shown, first determine whether the first character is SlaveID. If it is SlaveID, it indicates that it is a Modbus instruction. For Modbus instructions, set the Modbus receive flag, and then determine whether the function code is correct. If the function code is correct, receive the complete message and perform a check (i.e. Check CRC). If there is an error, report an error and clear the cache. If the verification is correct, it means that the data frame is correct, and perform the corresponding function processing.
[0097] For HEX upgrade files, set the HEX receiving flag and process the HEX upgrade file every 400us, that is, determine the data type of the data line, calculate the data length, address, and checksum. Determine the erase sector flag based on the address, and then erase or burn the data.
[0098] Through the above steps, the program upgrade method provided in the embodiment of the present application can effectively handle and avoid common errors in data transmission, such as data corruption, data overflow, etc., thereby ensuring the integrity of the upgrade file and the reliability of data transmission.
[0099] Optionally, in the program upgrade method provided in the embodiment of the present application, before receiving the upgrade file through the first program in the target system, the method also includes: generating an initial upgrade file based on the functional information to be upgraded through the target host computer; judging whether the initial upgrade file needs to be split based on the target threshold through the target host computer; if the initial upgrade file needs to be split, splitting the initial upgrade file based on the target threshold through the target host computer to obtain multiple upgrade files; and transmitting each upgrade file to the first program through the target host computer.
[0100] In an optional embodiment, in the program upgrade method provided in the present application, the upgrade file can be transferred to the first program in the following manner: in the target host computer, an initial upgrade file is generated by compiling software based on the functional information to be upgraded (such as new features, fixed bugs, optimized performance parameters, etc.). This file can include all necessary update data and is stored in .hex format.
[0101] Since the first program has limited ability to process upgrade files at one time, it is necessary to determine whether the initial upgrade file needs to be split based on the target threshold by the target host computer. It should be noted that the target threshold may be the ability threshold of the first program to process upgrade files at one time.
[0102] If the initial upgrade file needs to be split, the target host computer splits the initial upgrade file based on the target threshold, and finally transmits each upgrade file obtained by the split to the first program through the target host computer. It should be noted that since the first line of the complete initial upgrade file is the starting address of the sector and the last line is the end mark, when splitting the upgrade file, it is necessary to perform supplementary processing on the upgrade file that lacks the starting address or the end mark.
[0103] It should be noted that the target host computer needs to read the response of the register corresponding to the first program according to a preset time period to determine whether the upgrade file is successfully sent.
[0104] By splitting a large file into multiple small files for transmission, transmission delays or failures caused by excessive single data transmission can be avoided, especially when the network bandwidth is limited or unstable, which can improve the efficiency and success rate of data transmission. It is easier to operate by splitting the hex file through the target host computer, and for the first program, it only needs to receive the split small files sent by the target host computer, and the processing logic of the file remains unchanged (burning data according to the address), which improves the processing efficiency of the first program for the upgrade file.
[0105] Optionally, in the program upgrade method provided in the embodiment of the present application, before receiving the upgrade file through the first program in the target system, the method also includes: starting the boot loader after the target system receives a power-on signal; starting the first program through the boot loader, and establishing a communication mechanism between the first program and the target host computer so that the first program can receive the upgrade file.
[0106] In an optional embodiment, after the target system receives the power-on signal, the boot loader (i.e., Boot loader program) is started. Once the boot loader completes the initialization, it will start the first program and perform initialization operations on the first program, for example, GPIO (general purpose input and output port) initialization settings related pin functions, configuration interrupt functions and enabling serial port interrupts, timer initialization configuration frequency and enabling interrupts, etc. And the above-mentioned communication mechanism between the first program and the target host computer is established so that the first program can receive the upgrade file. In an optional embodiment, RS485 serial port communication can be used between the first program and the target host computer.
[0107] In an optional embodiment, the initialization part includes GPIO (general purpose input and output port) initialization, initialization of SCI serial port for RS485 communication, setting baud rate to 115200, 8 data bits, 1 stop bit, even parity, timer 0 initialization, configuring timer 0 frequency to 200us, and enabling timer interrupt, etc.
[0108] In an optional embodiment, the upgrade method of the program provided in the embodiment of the present application mainly involves two subjects, one is the bottom program (i.e. the first program mentioned above) and the upper computer. The bottom program is implemented by main function + timer. The main function judges the upgrade instruction, and the timer performs corresponding instruction processing and upgrade file parsing and burning functions, including system hardware interface initialization, serial communication data processing, HEX data extraction (i.e. upgrade file extraction), on-chip Flash erasing and burning, and application program (i.e. the second program mentioned above) jump; the upper computer is divided into serial port configuration module and upgrade test module, which are responsible for serial port configuration, open-loop control and firmware upgrade file selection, splitting, issuing and progress display.
[0109] When the target system is powered on, it first runs the Boot loader program. The underlying program and the host computer establish serial communication through an RS485-USB connection. The underlying program receives instructions and HEX upgrade files from the host computer, and performs sector erasure, programming, or jumps to the application program according to requirements. After the host computer selects the local HEX upgrade file, it automatically splits and distributes it in batches and displays the upgrade process.
[0110] The underlying program is used to perform the following steps: Serial communication data processing: Initialize the SCI serial port, follow the Modbus protocol, and implement data reception (store in the receive buffer), processing (distinguish Modbus instructions and HEX upgrade files and process them separately), and transmission (process in the timer interrupt, delay 200 us before transmission) through timer interrupts. HEX data extraction: Use a 400 us timer interrupt to process the HEX upgrade file line by line, judge the data type, calculate relevant parameters, and judge the sector operation according to the address. CMD file constraint: The underlying program and the application program are stored separately in different sectors of the FLASH. The program storage space and segment allocation are constrained by the CMD file. The entry address of the underlying program is 0x80000, and the entry address of the application program is 0x088000. On-chip Flash erasure and programming: According to the input programming address, data, and quantity, initialize the FLASHAPI, judge the sector erasure flag, and then perform the erasure and programming operations and release the Flash pump. Application program jump: Use assembly code to jump to the start address of the application program.
[0111] The host computer is used to perform the following steps: CCS generates HEX files: Perform corresponding configurations in the simulation software to generate HEX format files. Host computer file processing: The host computer splits the file. The underlying program only needs to process standard HEX files. After the host computer sends the file, it judges the upgrade status and displays the progress according to the reply from the underlying program and the set timeout. Upgrade test: Verify the firmware upgrade function through steps such as programming by the underlying program, receiving test of the upgrade file, FLASH erasure and programming test, and waveform test of the system status light pin.
[0112] In an optional embodiment, the upgrade test of the application program can be implemented through the following steps. First, the underlying program can be programmed into the Flash of the target program. Click the upgrade file on the host computer, select the HEX upgrade file, click Start Download, and start sending data. Compare the received buffer data (i.e., the HEX upgrade file received by the underlying program) with the source data to determine that the received test data is correct. When the application program processes the HEX file, if the sector erasure flag is 1, erase the corresponding sector. As Fig. 9 shown, erase the sector Flash, Fig. 9 where FFFF indicates that it has been erased. After the sector erasure is completed, program the data at the corresponding address. As Fig.10As shown in the figure, the selected part is the data to be burned in. Open the host computer, send the upgrade file, and the progress bar will display the upgrade process. When the download is completed, it will prompt "Upgrade Successful". By capturing the waveform through the oscilloscope, different flip frequencies can be seen, indicating that the upgrade is successful.
[0113] The program upgrade method provided in the embodiment of the present application receives an upgrade file through a first program in a target system, wherein the upgrade file is used to upgrade a second program in the target system; the upgrade file is parsed and read by the first program to obtain code data corresponding to the upgrade file; and the second program in the target system is upgraded based on the code data corresponding to the upgrade file, thereby solving the technical problem in the related art that an application program in a processor needs to be updated by connecting an emulator, resulting in relatively low update efficiency of the application program.
[0114] In this solution, the first program set in the target system is used to receive the upgrade file, and the dependence on the dedicated emulator is eliminated through the first program. The upgrade file is parsed and read by the first program to obtain the corresponding code data. After extracting the code data of the upgrade file, the first program burns the read code data to the corresponding position to implement the upgrade process of the second program. Since the upgrade process does not require the connection of a dedicated emulator, but is completed through the first program in the target system, the dependence on additional hardware devices is reduced, the hardware cost is reduced, and the upgrade file is directly received and processed by the internal program of the target system, which can significantly improve the efficiency of program updates and enhance the flexibility of updates.
[0115] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0116] Example 2
[0117] According to the embodiment of the present application, a program upgrade system is also provided. It should be noted that the program upgrade system of the embodiment of the present application can be used to execute the program upgrade method provided by the embodiment of the present application. The program upgrade system provided by the embodiment of the present application is introduced below.
[0118] According to an embodiment of the present application, a program upgrade system for implementing the above program upgrade method is also provided. Fig.11 As shown, the upgrade system includes: a target host computer 1101 and a first program 1102 .
[0119] A target host computer 1101, wherein the target host computer is used to generate an upgrade file and transmit the upgrade file to the first program;
[0120] The first program 1102 upgrades the second program in the target system based on the upgrade file.
[0121] like Fig.11 As shown, the upgrade system includes: a target host computer 1101 and a first program 1102. The first program 1102 is implemented by a main function + timer. The main function determines the upgrade instruction, and the timer performs corresponding instruction processing and upgrade file parsing and burning functions, including system hardware interface initialization, serial port communication data processing, HEX data extraction (i.e., upgrade file extraction), on-chip Flash erasing and burning, and application program (i.e., the second program mentioned above) jump; the target host computer 1101 is divided into a serial port configuration module and an upgrade test module, which are responsible for serial port configuration, open-loop control, and the selection, splitting, distribution, and progress display of firmware upgrade files.
[0122] When the target system is powered on, the Boot loader program is first run. The first program 1102 establishes serial communication with the target host computer 1101 through the RS485-USB connection. The first program 1102 receives the target host computer 1101 instructions and HEX upgrade files, and performs sector erase and burn or jump application programs as required. After the target host computer 1101 selects the local HEX upgrade file, it automatically splits and sends it in batches, and displays the upgrade process.
[0123] The first program 1102 is used to perform the following steps: Serial communication data processing: Initialize the SCI serial port, follow the Modbus protocol, and realize data reception (stored in the receiving buffer), processing (distinguishing Modbus instructions and HEX upgrade files and processing them separately) and sending (processing in the timer interrupt, delaying 200us before sending) through the timer interrupt. HEX data extraction: Use 400us timer interrupt to process the HEX upgrade file line by line, determine the data type, calculate related parameters and determine the sector operation according to the address. CMD file constraints: The first program 1102 and the application are stored separately in different sectors of FLASH. The program storage space and segment allocation are constrained by the CMD file. The entry address of the first program 1102 is 0x80000, and the entry address of the application is 0x088000. On-chip FLASH erase and burn: According to the input address, data and quantity to be burned, the FLASH API is initialized, and the erase and burn operation is performed after determining the sector erase flag and releasing the Flash pump. Application jump: Use assembly code to jump to the application start address.
[0124] The target host computer 1101 is used to perform the following steps: CCS generates HEX files: perform corresponding configurations in the simulation software to generate HEX format files. Target host computer 1101 file processing: The target host computer 1101 splits the files, and the first program 1102 only needs to process standard HEX files. After the target host computer 1101 sends the file, it determines the upgrade status and displays the progress according to the reply of the first program 1102 and the set timeout time. Upgrade test: The firmware upgrade function is verified through the steps of first program 1102 burning, upgrade file reception test, Flash erasing and burning test, system status light pin waveform test, etc.
[0125] In summary, in this solution, the first program set in the target system is used to receive the upgrade file, and the first program eliminates the dependence on the dedicated emulator. The first program parses and reads the upgrade file to obtain the corresponding code data. After extracting the code data of the upgrade file, the first program burns the read code data to the corresponding position to implement the upgrade process of the second program. Since the upgrade process does not require the connection of a dedicated emulator, but is completed through the first program in the target system, the dependence on additional hardware devices is reduced, the hardware cost is reduced, and the upgrade file is directly received and processed by the internal program of the target system, which can significantly improve the efficiency of program updates and enhance the flexibility of updates.
[0126] Example 3
[0127] The embodiment of the present application also provides a program upgrade device. It should be noted that the program upgrade device of the embodiment of the present application can be used to execute the program upgrade method provided by the embodiment of the present application. The program upgrade device provided by the embodiment of the present application is introduced below.
[0128] According to an embodiment of the present application, a program upgrade device for implementing the above program upgrade method is also provided, such as Fig.12 As shown, the device includes: a receiving unit 1201, a processing unit 1202 and a first upgrading unit 1203.
[0129] A receiving unit 1201 is used to receive an upgrade file through a first program in a target system, wherein the upgrade file is used to upgrade a second program in the target system;
[0130] The processing unit 1202 is used to parse and read the upgrade file through the first program to obtain code data corresponding to the upgrade file;
[0131] The first upgrading unit 1203 is used to upgrade the second program in the target system according to the code data corresponding to the upgrading file.
[0132] The program upgrade device provided in the embodiment of the present application receives an upgrade file through a first program in a target system through a receiving unit 1201, wherein the upgrade file is used to upgrade a second program in the target system; a processing unit 1202 parses and reads the upgrade file through the first program to obtain code data corresponding to the upgrade file; and a first upgrade unit 1203 upgrades the second program in the target system according to the code data corresponding to the upgrade file, thereby solving the technical problem in the related art that an application program in a processor needs to be updated by connecting an emulator, resulting in relatively low update efficiency of the application program.
[0133] In this solution, the first program set in the target system is used to receive the upgrade file, and the first program eliminates the dependence on the dedicated emulator. The first program parses and reads the upgrade file to obtain the corresponding code data. After extracting the code data of the upgrade file, the first program burns the read code data to the corresponding position to upgrade the second program. Since the upgrade process does not require connecting a dedicated emulator, but is completed through the first program in the target system, the dependence on additional hardware devices is reduced, the hardware cost is reduced, and the upgrade file is directly received and processed by the internal program of the target system, which can significantly improve the efficiency of program updates, and the upgrade file can be used to achieve directional function updates and enhance the flexibility of updates. For a small number of updates, the method of specifying address updates in the upgrade file can complete the update work more quickly and efficiently.
[0134] Optionally, in the upgrade device of the program provided in the embodiment of the present application, the first upgrade unit includes: a first reading module, used to read the current line of code data in the upgrade file, if the data type corresponding to the current line of code data is a preset first value, then obtain the starting address from the current line of code data, determine the sector corresponding to the starting address as the current sector, and erase the current sector, wherein the starting address is a mark address of the current sector storing the second program; a second reading module, used to read the next line of code data in the upgrade file, if the data type corresponding to the next line of code data is a preset second value, then obtain the offset address from the next line of code data; a determination module, used to determine the target address based on the offset address and the starting address, and burn the next line of code data to the target address to upgrade the second program.
[0135] Optionally, in the upgrade device of the program provided in the embodiment of the present application, the determination module includes: a judgment submodule, used to judge whether the target address is within the current sector and obtain a first judgment result; and a burning submodule, used to burn the next line of code data to the target address if the first judgment result indicates that the target address is within the current sector.
[0136] Optionally, in the upgrade device of the program provided in the embodiment of the present application, the device also includes: a setting unit, which is used to determine whether the target address is in the current sector, and after obtaining a first judgment result, if the first judgment result indicates that the target address is not in the current sector, set the erase flag to a preset third value; an update unit, which is used to update the current sector to the sector corresponding to the target address and erase the current sector when the erase flag is set to the preset third value; and a burning unit, which is used to burn the next line of code data to the target address after erasing the current sector.
[0137] Optionally, in the upgrade device of the program provided in the embodiment of the present application, the determination module includes: an execution sub-module, which is used to repeatedly execute the step of reading the next line of code data in the upgrade file after burning the next line of code data to the target address, until the data type corresponding to the next line of code data is a preset fourth value, then it is determined that the upgrade processing of the second program by the upgrade file has been completed.
[0138] Optionally, in the program upgrade device provided in the embodiment of the present application, the device also includes: a first judgment unit, used to judge whether there is a next upgrade file after the second program in the target system is upgraded according to the code data corresponding to the upgrade file, and obtain a second judgment result; a second upgrade unit, used to upgrade the second program in the target system based on the next upgrade file if the second judgment result indicates that there is a next upgrade file, until there is no next upgrade file; a trigger unit, used to trigger a target signal if the second judgment result indicates that there is no next upgrade file, wherein the target signal is used to indicate that the upgrade process of the second program has been completed.
[0139] Optionally, in the upgrade device of the program provided in the embodiment of the present application, the device also includes: a storage unit, used to store the upgrade file in a receiving cache area after receiving the upgrade file through the first program in the target system; a second judgment unit, used to judge whether there is an error in the upgrade file in the receiving cache area; and a first reset unit, used to reset the receiving cache area and re-receive the upgrade file if there is an error in the upgrade file in the receiving cache area.
[0140] Optionally, in the program upgrade device provided in the embodiment of the present application, the device also includes: a reading unit, used to read the upgrade file from the receiving buffer area through the first program before upgrading the second program in the target system according to the code data corresponding to the upgrade file; a third judgment unit, used to judge whether there is an overflow phenomenon in the receiving buffer area when reading the upgrade file; and a second reset unit, used to reset the receiving buffer area and re-receive the upgrade file if there is an overflow phenomenon in the receiving buffer area.
[0141] Optionally, in the upgrade device of the program provided in the embodiment of the present application, the device also includes: a generation unit, which is used to generate an initial upgrade file based on the functional information to be upgraded through the target host computer before receiving the upgrade file through the first program in the target system; a fourth judgment unit, which is used to judge whether the initial upgrade file needs to be split based on the target threshold through the target host computer; a splitting unit, which is used to split the initial upgrade file based on the target threshold through the target host computer to obtain multiple upgrade files if the initial upgrade file needs to be split; and a transmission unit, which is used to transmit each upgrade file to the first program through the target host computer.
[0142] Optionally, in the program upgrade device provided in the embodiment of the present application, the device also includes: a first startup unit, used to start the boot loader program before receiving the upgrade file through the first program in the target system and after the target system receives a power-on signal; a second startup unit, used to start the first program through the boot loader program and establish a communication mechanism between the first program and the target host computer so that the first program can receive the upgrade file.
[0143] Optionally, in the program upgrade device provided in the embodiment of the present application, the first upgrade unit includes: a judgment module, used to judge whether the frame header mark corresponding to the upgrade file is a preset character; an upgrade module, used to upgrade the second program in the target system according to the code data corresponding to the upgrade file when the frame header mark is the preset character.
[0144] It should be noted that the above-mentioned receiving unit 1201, processing unit 1202 and first upgrading unit 1203 correspond to steps S201 to S203 in Embodiment 1, and the three units and corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Embodiment 1. It should be noted that the above-mentioned modules or units may be hardware components or software components stored in a memory (e.g., memory 124) and processed by one or more processors (e.g., processors 122a, 122b, ..., 122n), and the above-mentioned modules may also be part of the device and may be run in the computer terminal 10 provided in Embodiment 1.
[0145] Example 4
[0146] An embodiment of the present application may provide an electronic device, Fig.13 is a structural block diagram of an electronic device according to an embodiment of the present application. Fig.13 As shown, the electronic device may include: one or more ( Fig.13 Only one is shown) processor 1302, memory 1304, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0147] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0148] The processor can call the information and application program stored in the memory through the transmission device to execute the program upgrade method steps.
[0149] It can be understood by those skilled in the art that Fig.13 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as , tablet computers, PDAs, mobile Internet devices (MID), PADs and other terminal devices. Fig.13 The structure of the electronic device is not limited. Fig.13 More or fewer components (such as network interfaces, display devices, etc.) shown in, or with Fig.13 Different configurations are shown.
[0150] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0151] Example 5
[0152] The embodiment of the present application also provides a computer-readable storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the program upgrade method provided in the first embodiment.
[0153] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0154] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the program of the upgrade method steps of the program.
[0155] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0156] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0157] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0158] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0159] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0160] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc., various media that can store program codes.
[0161] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A program upgrade method, characterized in that: include: Receiving an upgrade file through a first program in a target system, wherein the upgrade file is used to upgrade a second program in the target system; Parsing and reading the upgrade file through the first program to obtain code data corresponding to the upgrade file; The second program in the target system is upgraded according to the code data corresponding to the upgrade file.
2. The method according to claim 1, characterized in that: The step of performing an upgrade process on the second program in the target system according to the code data corresponding to the upgrade file includes: Reading the current line code data in the upgrade file, if the data type corresponding to the current line code data is a preset first value, obtaining a starting address from the current line code data, determining a sector corresponding to the starting address as a current sector, and erasing the current sector, wherein the starting address is a flag address of the current sector storing the second program; Reading the next line of code data in the upgrade file, and if the data type corresponding to the next line of code data is a preset second value, obtaining an offset address from the next line of code data; A target address is determined according to the offset address and the start address, and the next line of code data is burned to the target address to upgrade the second program.
3. The method according to claim 2, characterized in that Burning the next line of code data to the target address includes: Determine whether the target address is within the current sector to obtain a first determination result; If the first determination result indicates that the target address is within the current sector, the next line of code data is burned to the target address.
4. The method according to claim 3, characterized in that After determining whether the target address is within the current sector and obtaining a first determination result, the method further includes: If the first judgment result indicates that the target address is not within the current sector, setting the erase flag to a preset third value; When the erase flag is set to a preset third value, updating the current sector to a sector corresponding to the target address, and performing an erase process on the current sector; After erasing the current sector row, the next row of code data is burned to the target address.
5. The method according to claim 2, characterized in that: Burning the next line of code data to the target address to upgrade the second program includes: After burning the next line of code data to the target address, repeat the step of reading the next line of code data in the upgrade file until the data type corresponding to the next line of code data is a preset fourth value, then it is determined that the upgrade processing of the second program by the upgrade file has been completed.
6. The method according to claim 1, characterized in that After upgrading the second program in the target system according to the code data corresponding to the upgrade file, the method further includes: Determine whether there is a next upgrade file, and obtain a second determination result; If the second judgment result indicates that the next upgrade file exists, upgrading the second program in the target system based on the next upgrade file until the next upgrade file does not exist; If the second judgment result indicates that the next upgrade file does not exist, a target signal is triggered, wherein the target signal is used to indicate that the upgrade process of the second program has been completed.
7. The method according to claim 1, characterized in that After receiving the upgrade file through the first program in the target system, the method further includes: Storing the upgrade file in a receiving buffer area; Determine whether there is an error in the upgrade file in the receiving buffer area; If there is an error in the upgrade file in the receiving buffer area, the receiving buffer area is reset and the upgrade file is received again.
8. The method according to claim 7, characterized in that Before performing an upgrade process on the second program in the target system according to the code data corresponding to the upgrade file, the method further includes: Reading the upgrade file from the receiving buffer area through the first program; When reading the upgrade file, determining whether the receiving buffer area has an overflow phenomenon; If the receiving buffer overflows, the receiving buffer is reset and the upgrade file is received again.
9. The method according to claim 1, characterized in that: Before receiving the upgrade file through the first program in the target system, the method further includes: Generate an initial upgrade file based on the function information to be upgraded through the target host computer; Determining whether the initial upgrade file needs to be split based on a target threshold by the target host computer; If the initial upgrade file needs to be split, the target host computer splits the initial upgrade file based on the target threshold to obtain multiple upgrade files; Each upgrade file is transmitted to the first program via the target host computer.
10. The method according to claim 9, characterized in that Before receiving the upgrade file through the first program in the target system, the method further includes: After the target system receives a power-on signal, starting a boot loader; The first program is started by the boot loader, and a communication mechanism is established between the first program and the target host computer, so that the first program can receive the upgrade file.
11. The method according to claim 1, characterized in that The step of performing an upgrade process on the second program in the target system according to the code data corresponding to the upgrade file includes: Determine whether the frame header mark corresponding to the upgrade file is a preset character; In the case where the frame header mark is the preset character, the second program in the target system is upgraded according to the code data corresponding to the upgrade file.
12. A program upgrade system, characterized in that: include: A target host computer, wherein the target host computer is used to generate an upgrade file and transfer the upgrade file to the first program; A first program, wherein the first program performs an upgrade process on a second program in a target system based on the upgrade file.
13. A program upgrade device, characterized in that: include: A receiving unit, configured to receive an upgrade file through a first program in a target system, wherein the upgrade file is used to upgrade a second program in the target system; A processing unit, configured to parse and read the upgrade file through the first program to obtain code data corresponding to the upgrade file; The first upgrading unit is used to upgrade the second program in the target system according to the code data corresponding to the upgrading file.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the program upgrade method described in any one of claims 1 to 11.
15. An electronic device, characterized in that: include: A memory storing an executable program; A processor, used to run the program, wherein the program upgrade method described in any one of claims 1 to 11 is executed when the program is running.
Citation Information
Patent Citations
Quick and stable serial port software upgrading method
CN107885523A
Screen display program upgrading method and system and terminal equipment
CN110780908A
Application program upgrading method and device
CN113608772A
Program upgrading method, device and equipment for air conditioner outdoor unit and readable storage medium
CN115268972A
Remote program upgrading method based on FPGA
CN116466976A