CN115756551A - Software upgrading method and device, electronic equipment and readable storage medium - Google Patents

Software upgrading method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN115756551A
CN115756551A CN202211640477.7A CN202211640477A CN115756551A CN 115756551 A CN115756551 A CN 115756551A CN 202211640477 A CN202211640477 A CN 202211640477A CN 115756551 A CN115756551 A CN 115756551A
Authority
CN
China
Prior art keywords
program
application
upgrade
upgrading
application program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211640477.7A
Other languages
Chinese (zh)
Inventor
吴帅
孙旷野
潘叶青
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Haikang Fire Technology Co ltd
Original Assignee
Hangzhou Haikang Fire Technology Co ltd
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 Hangzhou Haikang Fire Technology Co ltd filed Critical Hangzhou Haikang Fire Technology Co ltd
Priority to CN202211640477.7A priority Critical patent/CN115756551A/en
Publication of CN115756551A publication Critical patent/CN115756551A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a software upgrading method, a software upgrading device, electronic equipment and a readable storage medium, wherein the method comprises the following steps: after receiving an upgrade command, jumping from an application program to an upgrade program, wherein the application program runs on a device and controls the device to execute corresponding functions, and the upgrade program comprises: a program for performing an upgrade process and a first portion of the application programs, the first portion of the application programs including: a program required in executing the upgrade process; the upgrading program receives an updated application program; the upgrade program updates the update application to the device. The method and the device solve the problem of flash resource waste caused by the fact that space needs to be divided in the flash to serve as an IAP (inter access point) upgrading program storage area in the prior art, thereby reducing occupation of IAP (inter access point) upgrading on the flash space and saving the flash resource.

Description

Software upgrading method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of software, and in particular, to a software upgrading method, apparatus, electronic device, and readable storage medium.
Background
Currently, a host processor or processing unit is used in many devices, and the host processor or processing unit uses a flash memory (flash) for storage. flash is a type of storage processor or processing unit in which data can be modified by a specific program. Flash usually means Flash Memory in the electronic field, namely Flash Memory which is called Flash EEPROM Memory by full name. The flash not only has the performance of Electrically Erasable and Programmable (EEPROM), but also can quickly read data, so that the data can not be lost due to power failure.
For a device with a master processor or processing unit, the upgrade function is an indispensable function, and the upgrade function is performed by using IAP. IAP is an abbreviation of In Application Programming, corresponding Chinese is 'Programming In Application', IAP is a part of area of User Flash written by a program of a User In the running process, wherein the User Flash is Flash space which can be used by the User, the User Flash is System space which corresponds to the User Flash, and the User space has no way to use. The IAP is used for conveniently updating and upgrading the firmware program in the product through a reserved communication port after the product is released.
Flash resources are valuable in the device. In the flash resource occupation of a main control processor or a processing unit, in order to support IAP functions, a large flash space is used as an IAP upgrading program storage area, so that the flash consumption is large, and resources are wasted.
Disclosure of Invention
The embodiment of the application provides a software upgrading method, a software upgrading device, an electronic device and a readable storage medium, so as to at least solve the problem that in the prior art, flash resources are wasted due to the fact that a space needs to be divided in a flash to be used as an IAP (inter access point) upgrading program storage area.
According to an aspect of an embodiment of the present application, there is provided a software upgrading method, including: after receiving an upgrade command, jumping from an application program to an upgrade program, wherein the application program runs on a device and controls the device to execute corresponding functions, and the upgrade program comprises: a program for performing an upgrade process and a first portion of the application programs, the first portion of the application programs including: a program required in executing the upgrade process; the upgrading program receives an updating application program; the upgrade program updates the update application into the device.
Further, a second part program of the application program and the upgrade program are stored in a flash memory, the second part program of the application program and a first part program of the application program located in the upgrade program constitute the application program, and the application program code-multiplexes the first part program of the application program in the upgrade program when running; and/or the first part program of the application program further comprises: and the code part in the application program is kept unchanged during the upgrading process.
Further, the flash memory includes a first space and a second space, where the first space is used to store a second partial program of the application program, and the second space is used to store the upgrade program.
Further, the first space and the second space are connected storage spaces, and a start address of the first space is smaller than a start address of the second space.
Further, the updating the update application to the device by the upgrade program comprises: the upgrading program stores a third part of programs in the updating application program in the first space, wherein the third part of programs in the updating application program and the first part of programs in the application program constitute the updating application program; the update application reuses a first portion of the application stored in the second space at runtime.
Furthermore, the application program and the upgrading program are configured in the same software engineering for compiling, so that the application program can find the calling interface of the multiplexing code during running.
Further, compiling the application program and the upgrade program includes: in the scattered loading file, a section of flash memory space is separately allocated to store the codes of the upgrading program, so that the codes and the data of the upgrading program are stored separately; in the scattered loading file, a section of memory space is separately allocated to store the data of the upgrading program; and solidifying the public function interface used by the upgrading program into the pre-allocated flash memory address field.
Further, the updating program receiving the update application program comprises: the upgrading program erases other programs except the upgrading program in the flash memory and receives the updating application program after erasing; and/or after the updating program updates the updating application program into the device, the method further comprises: resetting the device.
Further, prior to erasing, the method further comprises at least one of: the upgrading program, a common function interface used by the upgrading program and/or constants used by the upgrading program are solidified in a pre-allocated flash memory address field; solidifying the readable and writable variable used by the upgrading program, the top pointer and the memory occupied by the stack into a pre-allocated memory; closing interrupts used in the application but not used in the upgrade program; after the upgrade is carried out, the upgrade program is switched to logic endless loop to be executed; and in the upgrading process, the interrupt vector table is not erased, and after the upgrading is finished, the interrupt vector table is erased and written into a new interrupt vector table.
Further, the first part program of the application program includes: a message transmission layer and a start-up file, wherein the second part of the application program comprises: the device comprises an application function, an interface driver and a system initialization, wherein the starting file is used for starting the application program in the device, the system initialization is used for initializing when the application program is started or after the application program is started, the interface driver is used for driving a hardware interface, the message transmission layer is used for transmitting messages, and the application function is used for controlling the device to execute corresponding functions.
According to another aspect of the embodiments of the present application, there is also provided a software upgrading apparatus, including: an adjusting module, located in an application program, configured to jump from the application program to an upgrade program after receiving an upgrade command, where the application program runs on a device and controls the device to execute a corresponding function, and the upgrade program includes: a program for performing an upgrade process and a first portion of the application programs, the first portion of the application programs including: a program required in executing the upgrade process; the receiving module is positioned in the upgrading program and used for receiving the updating application program; and the updating module is positioned in the upgrading program and used for updating the updating application program to the equipment.
According to another aspect of an embodiment of the present application, there is also provided an electronic device including a memory and a processor; wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the above-described method steps.
According to another aspect of the embodiments of the present application, there is also provided a readable storage medium having stored thereon computer instructions, wherein the computer instructions, when executed by a processor, implement the above-mentioned method steps.
In the embodiment of the present application, after receiving an upgrade command, jumping from an application program to an upgrade program is adopted, where the application program runs on a device and controls the device to execute a corresponding function, and the upgrade program includes: a program for performing an upgrade process and a first portion of the application programs, the first portion of the application programs comprising: a program required in executing the upgrade process; the upgrading program receives an updated application program; the upgrade program updates the update application into the device. The method and the device solve the problem of flash resource waste caused by the fact that space needs to be divided in the flash to serve as an IAP (inter access point) upgrading program storage area in the prior art, thereby reducing occupation of IAP (inter access point) upgrading on the flash space and saving the flash resource.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the application and, together with the description, serve to explain the application and are not intended to limit the application. In the drawings:
FIG. 1 is a diagram illustrating an IAP program and an APP program in a flash according to the related art;
FIG. 2 is a schematic diagram of an IAP program and an APP program in a flash according to an embodiment of the present application;
FIG. 3 is a flow chart of a method of software upgrade according to an embodiment of the present application;
FIG. 4 is a schematic diagram of an upgrade process according to the related art;
FIG. 5 is a schematic diagram of an upgrade process according to an embodiment of the present application; and the number of the first and second groups,
fig. 6 is a schematic diagram of compiling APP and IAP in the same project according to an embodiment of the present application.
Detailed Description
It should be noted that, in the present application, the embodiments and features of the embodiments may be combined with each other without conflict. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than here.
The following embodiments relate to a technical solution for upgrading a device, and first, a technical solution related to upgrading a device will be described below.
flash and RAM
Flash Chinese is a Flash Memory, and English is called Flash EEPROM Memory. The flash Memory (RAM) can be read and written at any time (except for refreshing), and is very fast and generally used as a temporary data storage medium of an operating system or other running programs.
Interrupt vector table
The interrupt vector refers to the offset and segment base of the interrupt service program entry address, and one interrupt vector occupies a predetermined number of bytes of space. The function of the interrupt vector table is to store corresponding interrupt vectors according to the order of the interrupt type numbers from small to large. In the interrupt response process, the processor calculates the position of the corresponding interrupt vector in the table according to the acquired interrupt type number (namely, the interrupt vector number), acquires the interrupt vector from the interrupt vector table, and transfers the program flow to the entry address of the interrupt service program according to the interrupt vector.
Scatter loading files
The scatter load (scatter) file is a text file that can be used to describe information required when an Advanced reduced instruction set computer (Advanced RISC Machine, ARM for short) connector generates an image file. Various source files (including assembly files, C language programs, C + + programs and the like) in the ARM are compiled by the ARM compiler to generate object files in an ELF format. After the object files and the corresponding libraries used in the C/C + + operation are processed by the ARM connector, an image file (image) in an ELF format is generated, wherein the image file in the ELF format is a binary file and is also an executable file and can be written into a ROM of the embedded device.
And (3) ARM mapping file composition: the ARM image file is a file with a hierarchical structure, and includes a domain (region), an output section (output section) and an input section (input section). An image file is composed of one or more fields; each domain consists of at most three output segments; each output segment in turn comprises one or more input segments; each input segment contains code and data in the target file. The domain refers to an area where the whole binary (bin) image file is located, and is divided into a load domain and a run domain. The load domain is a work area where the image file is statically stored, generally, an address space where the whole bin file in the flash is located is the load domain, and certainly, programs cannot be generally executed in the flash and generally are moved to the RAM to run work, and the address space where the programs are moved to the RAM to work is the run domain.
The Code (Code) input by the user generally has a Code portion and a data portion, which is a so-called input section. Each input segment has corresponding attributes, which may be read-only (ro), readable-writable (rw) and initialized to 0 (zi), wherein rw represents a static variable that has been initialized, the variable having an initial value; zi identifies a static variable that is not initialized, the variable having no initial value; ro represents a program-defined constant and constant (const) type data. The ARM connector groups the input sections according to the attributes of the input sections and then forms output sections with corresponding attributes. For output segments in the load domain, typically a ro segment is followed by an rw segment, which is followed by a zi segment. These output segments are not consecutive in the run-domain, but rw and zi must be consecutive. The data in the zi and rw segments may in fact be the rw attribute.
Typically, an image file contains several fields, each of which contains several output segments. The ARM connector needs to know the grouping information used to determine how to organize each input segment into a corresponding output segment and domain and the location information used to determine the starting address of each domain in the memory space to decide to generate the corresponding image file. This information may use a configuration file (i.e., a scatter load file) to tell the ARM connector about the address mapping.
The following embodiments may be applied to various devices using a flash save application program (e.g., a firmware program), for example, a device in the field of fire fighting. In these devices, a processor or a processing unit (such as a single chip microcomputer) with computing power is used to execute an application program, and the application program is stored in a flash, so that the application program cannot erase itself during upgrading, and thus, an IAP is required for upgrading. When upgrading with IAPs, most of codes in an IAP program and an Application (APP) program are duplicated, fig. 1 is a schematic diagram of the IAP program and the APP program in a flash according to the related art, as shown in fig. 1, a flash space is divided into three spaces from a low address to a high address: the method comprises the steps of saving space of an IAP program, saving space of an APP program and a parameter area, wherein the parameter area can save various parameters such as system parameters, operation records and alarm records. The IAP program may include the following parts: the method comprises the steps of starting files, initializing a system, driving a communication interface, transmitting a message transmission layer and realizing an upgrading protocol, wherein the starting files are used for switching a program, the initializing of the system is used for carrying out initialization configuration on a software system started by the program, the driving of the communication interface is used for driving the communication interface, the message transmission layer is used for transmitting messages, and the upgrading protocol is used for upgrading an APP according to the pre-configured upgrading protocol. The APP program may include the following: the method comprises the steps of starting a file, initializing a system, driving a communication interface, transmitting a message layer and applying functions, wherein the applying functions are used for realizing functions on equipment on which an application program runs. As can be seen from fig. 1, in the IAP program and the APP program, except for the upgrade protocol implementation part and the application function part, other codes such as the boot code, the system initialization, the communication interface driver, and the message transport layer are duplicated. However, due to IAP running mechanism problems, an extra copy of code has to be made to IAP programs for use, which results in a waste of flash space. It should be noted that the included part of the APP program or the IAP program shown in fig. 1 is only an example and is not limited thereto.
In order to solve the above problem, a software upgrading method is provided in the following embodiments, fig. 3 is a flowchart of a software upgrading method according to an embodiment of the present application, and as shown in fig. 3, the steps included in the method related to fig. 3 are described below.
Step S302, after receiving an upgrade command, skipping from an application program to an upgrade program, wherein the application program runs on a device and controls the device to execute a corresponding function, and the upgrade program includes: a program for performing an upgrade process and a first portion of the application programs, the first portion of the application programs including: the programs needed in performing the upgrade process.
In this step, two programs are involved, one is an application program, and the other is an upgrade program, where the application program may be firmware running in the device, for example, the electricity consumption monitoring device may be plugged into a socket, the electricity consumption device (such as an electrical appliance like an air conditioner) may be plugged into the electricity consumption monitoring device, and the electricity consumption condition of the electricity consumption device may be monitored by the electricity consumption monitoring device. The branch voltage, the current, the temperature, the electric leakage, the state quantity of striking sparks and the like which can be monitored by the electricity monitoring equipment in real time, and when the monitoring value is larger than the set alarm threshold value, the alarm information can be pushed to the computing equipment and/or the fire fighting platform, so that the safety monitoring of local and remote electricity utilization systems is realized. The functions of comparing the monitoring value with the alarm threshold value and sending alarm information in the electricity consumption monitoring device need to be supported by software in the electricity consumption monitoring device, and the software is the application program called in step S302.
The electricity consumption monitoring device also needs to be updated with software, for example, the alarm threshold needs to be lowered or the alarm sending mode needs to be changed, and at this time, the old application program in the electricity consumption monitoring device needs to be deleted, and then the updated application program is updated into the electricity consumption monitoring device. Old applications cannot be deleted by themselves, and therefore an upgrade program is also provided in the electricity consumption monitoring apparatus for upgrading. The upgrading program also needs to use some functions in the electricity consumption monitoring equipment, and the functions are often realized through application programs, so that the application programs can be copied once in the upgrading program and the upgrading program is convenient to use. In step S302, only a first part of the application programs is placed in the upgrade program, where the part of the application programs is a program required for executing the upgrade process, and thus the upgrade program includes: a program for performing an upgrade process and a first part program of the application programs. Namely, the step is no longer needed to copy the application program into the upgrading program again, thereby saving the internal storage space of the device.
In this step, as an optional way, in order to reduce the size of the application program upgrade package, a code portion of the application program that remains solidified during the upgrade process may also be placed in the upgrade program as the first part program of the application program. The fixed and unchangeable code part can comprise a fixed algorithm, a log interface, a driver and the like, and the fixed algorithm, the log interface, the driver and the like are also configured in the upgrading program, so that the APP upgrading packet size can be reduced. After the size of the application program upgrade package is reduced, the upgrade package can be transmitted in some low-rate environments, for example, the upgrade package can be transmitted in a fire-fighting second bus, a low-rate air interface and the like, so that the competitive advantage of the product is improved.
It should be noted that which part of the application program is the program required in the upgrade process can be configured in advance, and the part of the program required to be used in the upgrade process is put into the upgrade program according to the configuration in advance.
In step S304, the upgrade program receives the update application program.
In this step, since the upgrade program includes a program for performing the upgrade process and a first part program of the application programs required in the upgrade process, the upgrade program may receive the update application program. The updated application program is also the new application program received after receiving the upgrade command, and is used for realizing the update and upgrade of the equipment.
Step S306, the upgrade program updates the update application program to the device. By this step, the upgrade of the application program of the device can be completed.
In the above steps, the upgrading program only includes the first part of the application program, and the application program is not completely copied to the upgrading program, so that the internal storage space of the device is saved. Considering that the application programs similar to firmware are generally stored in the flash memory, the above steps solve the problem of flash resource waste caused by the need of dividing space in the flash memory to be used as an IAP upgrade program storage area in the prior art, thereby reducing the occupation of IAP upgrade on the flash space and saving the flash resource.
The second part program of the application program and the upgrade program are stored in the flash memory as an example. In the steps shown in fig. 3, part of the codes of the application programs are saved in the upgrade program, which makes the storage space occupied by the upgrade program smaller. For an application program, a complete copy of the application program may be stored in the flash memory, i.e. the second part program of the application program and the first part program of the application program located in the upgrade program constitute the application program. In this case, the first part of the application program in the upgrade program is saved twice, one time in the upgrade program and the other time in the application program. In order to further save flash memory space, part of the application program already saved in the upgrade program may not be saved in the application program, and if the application program needs to use this part of the code (for example, at runtime), the first part of the application program in the upgrade program may be code-multiplexed. Through the optional implementation mode, the storage space where the application program is located is also reduced, and the storage space can be further saved.
As can be seen from the above alternative embodiment, a part of the application program is stored in the upgrade program, and in view of that both the upgrade program and the application program are stored in the flash memory, in order to make the use of the flash memory more standard, separate storage spaces may be opened up in the flash memory for the upgrade program and the application program, that is, in this alternative embodiment, the flash memory includes a first space and a second space, where the first space is used for storing a second part of the application program, and the second space is used for storing the upgrade program. The storage mode stores the upgrading program and the application program separately, so that the content in the related flash memory space can be erased in the upgrading process, and the upgrading is performed.
Since one part of the application program is stored in the second space and the other part of the application program is stored in the first space, when the application is upgraded, the other part of the application program stored in the first space may be upgraded, that is, in an optional embodiment, the upgrading process may update the updated application program to the device, and may include the following steps: the upgrading program stores a third part of programs in the updating application program in the first space, wherein the third part of programs in the updating application program and the first part of programs in the application program constitute the updating application program; the update application reuses a first portion of the application stored in the second space at runtime. The first part program, the second part program, and the third part program in the embodiments of the present application are only used for distinguishing program objects in different contexts, and do not have any sequential limitation.
Through the optional implementation mode, only the second part of the application program needs to be upgraded during upgrading, and the upgrading efficiency is improved. Which parts of the application are saved in the upgrade program and which parts are saved as the application itself may be pre-configured, for example, a first part of the application (i.e., saved in the second space) includes: a message transmission layer and a start-up file, wherein the second part of the application program (i.e. stored in the first space) comprises: the device comprises an application function, an interface driver and a system initialization, wherein the starting file is used for starting the application program in the device, the system initialization is used for initializing when the application program is started or after the application program is started, the interface driver is used for driving a hardware interface, the message transmission layer is used for transmitting messages, and the application function is used for controlling the device to execute corresponding functions.
The application program in the above embodiment is used for controlling the device to implement the related function, various interrupts need to be processed in the device, the processing related to the interrupts is stored in the interrupt vector table, and the interrupt vector table is generally stored in a low address portion of the flash. That is, in this optional embodiment, the first space and the second space are connected storage spaces, and a start address of the first space is smaller than a start address of the second space. The alternative embodiment is more favorable for processing the interrupt vector table when the application program is upgraded. The upgrade program in the above embodiment may be an IAP program, and the IAP program (abbreviated as IAP) and the APP program (abbreviated as APP) are described below as examples.
Fig. 2 is a schematic diagram of an IAP program and an APP program in a flash according to an embodiment of the present application, as shown in fig. 2, the flash in the device may be divided into three areas, where a first space for storing the APP, a second space for storing the IAP, and a space for storing a parameter area are respectively from a low address to a high address, and parameters stored in the parameter area may include: system parameters, operational records, and/or alarm records, etc. Three parts are included in APP: the method comprises the steps that an application function, a communication interface driver (which is one of the interface drivers) and a system are initialized, a message transmission layer and a start-up file in an original APP are stored in a second space for storing IAP, and the APP is realized by multiplexing IPA codes when the message transmission layer and the start-up file are used. Three parts are included in the IAP: the upgrade protocol implementation (i.e. the program for executing the upgrade process), the message transport layer and the start-up file, the communication interface driver and the system initialization in the original APP are not needed in the upgrade process, so these two contents are cut out. As can be seen from fig. 2, the application functions, communication interface drivers and system initialization located in the first space, and the message transport layer and the start-up file located in the second space constitute the completed APP.
Because the application program is operated by a partial code mode, in order to be more convenient for the application program to find the call interface of the multiplexing code, the application program and the upgrading program can be configured in the same software engineering for compiling, so that the application program can easily find the call interface of the multiplexing code during operation. Fig. 6 is a schematic diagram of compiling APP and IAP in the same Project according to an embodiment of the present application, where as shown in fig. 6, the Project (Project) is named device IAP, and there are two folders below it, one is IAP and one is APP, and the IAP and APP codes are placed in the two folders, respectively, so that compiling and linking can be performed together.
In the compiling process, in order to enable the update application to more easily find addresses corresponding to codes and data in the IAP, the compiling may be performed by allocating a separate storage space, that is, the compiling of the application and the upgrade may include the following steps: in a scattered loading file, singly allocating a section of flash memory space to store the codes of the upgrading program so as to store the codes and the data of the upgrading program separately; in the dispersed loading file, a section of memory space is separately allocated to store the data of the upgrading program; and solidifying the common function interface used by the upgrading program into the pre-allocated flash memory address field. With this alternative embodiment, the update application can be made easier to multiplex the code in the IAP.
In another alternative embodiment, the erase of the old application program may be involved in the upgrade process, and the change of the erase and upgrade modes will be described below with reference to fig. 4 and 5.
Fig. 4 is a schematic diagram of an upgrade process according to the related art, as shown in fig. 4, an APP waits for an upgrade instruction, and the APP jumps to an IAP after receiving the upgrade instruction. The IAP erases the APP program (note that, at this time, a complete APP program is stored in the IAP), then, the IAP receives and updates the APP program, and the LAP upgrade completes and jumps to the APP operation.
Fig. 5 is a schematic diagram of an upgrade process according to an embodiment of the present application, and as shown in fig. 5, an APP waits for an upgrade instruction, and after receiving the upgrade instruction, the APP jumps to an IAP. The IAP erases other codes except for the message transport layer and the upgrade protocol implementation, receives and updates the APP program in the IAP (it should be noted that the downloaded APP may not include the first part program of the application program in the upgrade program, so that the download traffic may be reduced, the upgrade success probability may be improved), and the LAP upgrade is completed and the device is reset. As can be seen from fig. 5, there are two differences in the upgrading process from fig. 4: firstly, the upgrading program erases other programs except the upgrading program in the flash memory and receives the updating application program after erasing; and secondly, after the updating application program is updated into the equipment by the upgrading program, resetting the equipment. This is because there are no other modules of APP in the flash after erasing in the flow shown in fig. 5. In order to make the upgrade of IAP more stable, in an alternative embodiment, before erasing, at least one of the following may also be performed: the upgrading program, a common function interface used by the upgrading program and/or constants used by the upgrading program are solidified in a pre-allocated flash memory address field; solidifying the readable and writable variable used by the upgrading program, the top pointer and the memory occupied by the stack into a pre-allocated memory; closing interrupts used in the application but not used in the upgrade program; after entering upgrading, switching the upgrading program to logic endless loop execution; and in the upgrading process, the interrupt vector table is not erased, and after the upgrading is finished, the interrupt vector table is erased and written into a new interrupt vector table. The stability of the upgrade can be guaranteed by this alternative embodiment.
The above alternative embodiment is described below with reference to an example. In this example, a new software upgrade method is provided in which duplicate code may be removed without affecting the use of the APP and IAP upgrade functions.
1. The APP1 (non-upgraded APP) and the IAP are placed in the same project for compiling and linking, so that the APP1 can find the calling interface of the IAP corresponding multiplexing code when running.
After the app1 and IAP are compiled, the code (code) and data (data) addresses are denoted as IAP _ code1 and IAP _ data1. After the APP2 (upgraded APP) and the IAP are compiled, the code and data addresses are recorded as IAP _ code2 and IAP _ data2, if there is no reasonable configuration, the loading and executing addresses of the IAP _ code1 and IAP _ code2, IAP _ data1 and IAP _ data2 after normal compilation are different, which may cause the APP2 to be unable to operate normally after updating, because the IAP in the flash is the address corresponding to the APP 1. In order to solve this problem, an optional configuration is provided in this example, and other configurations may be adopted, which is not described in detail herein.
This alternative configuration is as follows:
A. in the scattered loading file, a flash space is separately allocated to store IAP codes, and the codes and data of IAP are separately stored.
B. In the scatter-load file, a block of ram space is allocated separately to execute data in the IAP program.
C. In order to ensure the stability of programs after IAP compilation, a common function interface used by the IAP needs to be solidified to a pre-allocated specified flash address segment (. MY _ segment), so that it can be prevented that after APP2 uses a new interface, the relevant address of the IAP compiled changes, which causes the APP2 to operate abnormally.
3. The IAP can be enabled to operate normally by not invoking any of the interfaces in the APP in the IAP. This is because if invoked, the IAP may run down after erasing the APP when upgraded. There are many ways to ensure that the APP interface is not called, for example:
a. the IAP upgrading protocol implementation and message transmission layer codes are solidified to the pre-allocated designated flash address (LR _ IROM 2), so that the IAP codes are not influenced after the APP is erased.
b. And solidifying a public function interface used by the IAP to a pre-allocated designated flash address (MY _ SECTION), and in the same way, after the APP is erased, not influencing an IAP code.
c. The constant variables used by the IAP are fixed to the pre-allocated designated flash address (LR _ IROM 2).
d. The readable writable variables used by IAP are fixed to the pre-allocated designated raw address (RW _ IRAW 2).
e. The top pointer and its occupied memory are fixed to a pre-allocated raw address (RW _ IRAW 2).
f. When entering the upgrade, interrupts used in the APP but not in the IAP are closed. Therefore, the problem that the interrupt is broken once the program is triggered after the APP is erased can be prevented.
g. After the upgrading is carried out, the program is switched to cause the logic of the IAP code to execute in a dead loop, and the problem that the program is broken down after the APP is erased can be prevented.
h. In the upgrading process, the first packet of data is interrupt vector table data, can be specially processed, cannot be immediately erased, and is erased and written after verification is passed when upgrading is completed. This also prevents the problem of a program crash after an interrupt in the IAP.
By the aid of the software upgrading method, repeated codes of IAP and APP in a traditional upgrading scheme can be eliminated, and the use of the functions of the APP and the IAP upgrading function is not influenced; in addition, the fixed code in APP can be: like log, public queue, solidification algorithm etc. put into IAP program section, can reduce APP upgrading procedure package size like this, save the flow, can also improve the program and upgrade the one-time pass rate, whole improvement program upgrading efficiency.
In conclusion, the alternative embodiment reduces the consumption of flash resources, and the main control processor or the processing unit with smaller resources and lower cost can be selected in the selection of the main control processor or the processing unit, so that the overall cost of the equipment is reduced, and the market competitiveness of the equipment is improved.
In this embodiment, an electronic device is provided, comprising a memory in which a computer program is stored and a processor arranged to run the computer program to perform the method in the above embodiments.
The programs described above may be run on a processor or stored in memory (or referred to as computer-readable media), which includes both non-transitory and non-transitory, removable and non-removable media, that enable storage of information by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
These computer programs may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks, and corresponding steps may be implemented by different modules.
Such an arrangement is provided in this embodiment. The device is called a software upgrading device and comprises: an adjusting module, located in an application program, configured to jump from the application program to an upgrade program after receiving an upgrade command, where the application program runs on a device and controls the device to execute a corresponding function, and the upgrade program includes: a program for performing an upgrade process and a first portion of the application programs, the first portion of the application programs including: a program required in executing the upgrade process; the receiving module is positioned in the upgrading program and used for receiving the updating application program; and the updating module is positioned in the upgrading program and used for updating the updating application program to the equipment.
The system or the apparatus is used for implementing the functions of the method in the foregoing embodiments, and each module in the system or the apparatus corresponds to each step in the method, which has been described in the method and is not described herein again.
Optionally, a second part of the application program and the upgrade program are stored in a flash memory, where the second part of the application program and a first part of the application program located in the upgrade program constitute the application program, and the application program code-multiplexes the first part of the application program in the upgrade program when running; the first part program of the application program further includes: and the code part in the application program is kept unchanged during the upgrading process.
Optionally, the flash memory includes a first space and a second space, where the first space is used to store a second partial program of the application program, and the second space is used to store the upgrade program.
Optionally, the first space and the second space are connected storage spaces, and a start address of the first space is smaller than a start address of the second space.
Optionally, the update module is configured to store a third part of the update application in the first space, where the third part of the update application and the first part of the application constitute the update application; the update application reuses a first portion of the application stored in the second space at runtime.
Optionally, the application program and the upgrade program are configured in the same software project and compiled, so that the application program can find the call interface of the multiplexing code during running.
Optionally, compiling the application program and the upgrade program includes: in the scattered loading file, a section of flash memory space is separately allocated to store the codes of the upgrading program, so that the codes and the data of the upgrading program are stored separately; in the dispersed loading file, a section of memory space is separately allocated to store the data of the upgrading program; and solidifying the public function interface used by the upgrading program into the pre-allocated flash memory address field.
Optionally, the receiving module is configured to erase other programs in the flash memory except the upgrade program, and receive the update application program after the erasing; and/or the update module is further configured to reset the device after the update application is updated into the device.
Optionally, the method further comprises: a configuration module to perform at least one of: solidifying the upgrading program, the common function interface used by the upgrading program and/or the constant used by the upgrading program in a pre-allocated flash memory address field; solidifying the readable and writable variables used by the upgrading program, the top pointer and the memory occupied by the stack into a pre-allocated memory; closing interrupts used in the application but not used in the upgrade program; after entering upgrading, switching the upgrading program to logic endless loop execution; and in the upgrading process, the interrupt vector table is not erased, and after the upgrading is finished, the interrupt vector table is erased and written into a new interrupt vector table.
Optionally, the first part of the application program includes: a message transmission layer and a start-up file, wherein the second part of the application program comprises: the device comprises an application function, an interface driver and a system initialization, wherein the starting file is used for starting the application program in the device, the system initialization is used for initializing when or after the application program is started, the interface driver is used for driving a hardware interface, the message transmission layer is used for transmitting messages, and the application function is used for controlling the device to execute corresponding functions.
Through the optional implementation mode, the problem of flash resource waste caused by the fact that space needs to be divided in the flash to serve as an IAP (inter access point) upgrading program storage area in the prior art is solved, so that the occupation of IAP (inter access point) upgrading on the flash space is reduced, and the flash resource is saved.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (13)

1.A method of upgrading software, comprising:
after receiving an upgrade command, jumping from an application program to an upgrade program, wherein the application program runs on a device and controls the device to execute corresponding functions, and the upgrade program comprises: a program for performing an upgrade process and a first portion of the application programs, the first portion of the application programs comprising: a program required in executing the upgrade process;
the upgrading program receives an updated application program;
the upgrade program updates the update application to the device.
2. The method of claim 1, wherein the second part of the application program and the upgrade program are stored in a flash memory, the second part of the application program and the first part of the application program located in the upgrade program constitute the application program, and the application program code-multiplexes the first part of the application program in the upgrade program at runtime; and/or the first part program of the application program further comprises: and the code part in the application program is kept unchanged during the upgrading process.
3. The method of claim 2, wherein the flash memory comprises a first space and a second space, wherein the first space is used for storing a second part of the application program, and the second space is used for storing the upgrade program.
4. The method of claim 3, wherein the first space and the second space are connected memory spaces, and wherein a start address of the first space is smaller than a start address of the second space.
5. The method of claim 3, wherein the updating the update application to the device by the upgrade program comprises:
the upgrading program stores a third part of the updated application programs in the first space, wherein the third part of the updated application programs and the first part of the application programs form the updated application programs; the update application reuses a first portion of the application stored in the second space at runtime.
6. The method of claim 2, wherein the application program and the upgrade program are configured to be compiled in the same software project so that the application program can find the call interface of the multiplexing code at runtime.
7. The method of claim 6, wherein compiling the application program and the upgrade program configuration in the same software project comprises:
in the scattered loading file, a section of flash memory space is separately allocated to store the codes of the upgrading program, so that the codes and the data of the upgrading program are stored separately;
in the scattered loading file, a section of memory space is separately allocated to store the data of the upgrading program;
and solidifying the public function interface used by the upgrading program into the pre-allocated flash memory address field.
8. The method of claim 2,
the upgrade program receiving the update application program includes: the upgrading program erases other programs except the upgrading program in the flash memory and receives the updating application program after the erasing; and/or the presence of a gas in the gas,
after the upgrade program updates the update application into the device, the method further comprises: resetting the device.
9. The method of claim 8, wherein prior to erasing, the method further comprises at least one of:
the upgrading program, a common function interface used by the upgrading program and/or constants used by the upgrading program are solidified in a pre-allocated flash memory address field;
solidifying the readable and writable variable used by the upgrading program, the top pointer and the memory occupied by the stack into a pre-allocated memory;
closing interrupts used in the application but not used in the upgrade;
after the upgrade is carried out, the upgrade program is switched to logic endless loop to be executed;
and in the upgrading process, the interrupt vector table is not erased, and after the upgrading is finished, the interrupt vector table is erased and written into a new interrupt vector table.
10. The method according to any one of claims 2 to 9, wherein the first part of the application program comprises: a message transmission layer and a start-up file, wherein the second part of the application program comprises: the device comprises an application function, an interface driver and a system initialization, wherein the starting file is used for starting the application program in the device, the system initialization is used for initializing when the application program is started or after the application program is started, the interface driver is used for driving a hardware interface, the message transmission layer is used for transmitting messages, and the application function is used for controlling the device to execute corresponding functions.
11. A software upgrading apparatus, comprising:
an adjusting module, located in an application program, configured to jump from the application program to an upgrade program after receiving an upgrade command, where the application program runs on a device and controls the device to execute a corresponding function, and the upgrade program includes: a program for performing an upgrade process and a first portion of the application programs, the first portion of the application programs comprising: a program required in executing the upgrade process;
the receiving module is positioned in the upgrading program and used for receiving the updating application program;
and the updating module is positioned in the upgrading program and used for updating the updating application program to the equipment.
12. An electronic device comprising a memory and a processor; wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps of any of claims 1 to 10.
13. A readable storage medium having stored thereon computer instructions, wherein the computer instructions, when executed by a processor, implement the method steps of any one of claims 1 to 10.
CN202211640477.7A 2022-12-20 2022-12-20 Software upgrading method and device, electronic equipment and readable storage medium Pending CN115756551A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211640477.7A CN115756551A (en) 2022-12-20 2022-12-20 Software upgrading method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211640477.7A CN115756551A (en) 2022-12-20 2022-12-20 Software upgrading method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN115756551A true CN115756551A (en) 2023-03-07

Family

ID=85348570

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211640477.7A Pending CN115756551A (en) 2022-12-20 2022-12-20 Software upgrading method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115756551A (en)

Similar Documents

Publication Publication Date Title
US5537596A (en) Method and apparatus for overriding resource maps in a computer system
US6314567B1 (en) Apparatus and method for transferring state data when performing on-line replacement of a running program code and data
KR100415371B1 (en) Computer
CN111258587B (en) Android application plug-in implementation method, device, equipment and storage medium
JPH10111837A (en) Memory device
CN108509215B (en) System software replacing method and device, terminal equipment and storage medium
US20050071856A1 (en) Dynamically loadable stub modules
CN113110853B (en) Configuration data online downloading method and device and electronic equipment
JP2012164350A (en) Memory management for portable data storage medium
CN112306540A (en) Multi-project independent compiling method, system, terminal and medium
CN110764486B (en) Method and device for operating vehicle-mounted controller, vehicle-mounted controller and storage medium
CN114691178A (en) Firmware upgrading method and device based on EtherCAT communication driver
CN110471675B (en) Program burning method, system, device and computer readable storage medium
CN115756551A (en) Software upgrading method and device, electronic equipment and readable storage medium
CN103761118A (en) Intelligent card and method for deploying applications in same
CN115934213A (en) Controller stack calling method, device, equipment and storage medium
CN104572218A (en) Application operation control method and system and terminal
CN114756296A (en) Read-write mounting starting method and device, storage medium and electronic equipment
US20190384590A1 (en) Control apparatus and program updating method
CN114428633A (en) Firmware upgrading method, device and equipment
JP6676791B2 (en) Information processing device
CN113127852A (en) SE application management method and device based on chip card and storage medium
KR20000003162A (en) Effective operation method of flash memory
CN115061738B (en) Service module initialization method, equipment and medium for android componentization
JP4026383B2 (en) Information processing system, information processing terminal, external storage device, information processing terminal control program, and external storage device control program

Legal Events

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