CN113495746A - Program upgrading method, device, medium and electronic equipment - Google Patents
Program upgrading method, device, medium and electronic equipment Download PDFInfo
- Publication number
- CN113495746A CN113495746A CN202110604261.4A CN202110604261A CN113495746A CN 113495746 A CN113495746 A CN 113495746A CN 202110604261 A CN202110604261 A CN 202110604261A CN 113495746 A CN113495746 A CN 113495746A
- Authority
- CN
- China
- Prior art keywords
- user data
- data area
- backup
- area
- target user
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 55
- 238000005192 partition Methods 0.000 claims abstract description 117
- 230000002159 abnormal effect Effects 0.000 claims abstract description 13
- 238000004590 computer program Methods 0.000 claims description 13
- 230000004044 response Effects 0.000 claims description 9
- 238000000638 solvent extraction Methods 0.000 claims description 8
- 238000013500 data storage Methods 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 8
- 230000008901 benefit Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/654—Updates using techniques specially adapted for alterable solid state memories, e.g. for EEPROM or flash memories
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1448—Management of the data involved in backup or backup restore
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Quality & Reliability (AREA)
- Stored Programmes (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application provides a program upgrading method, a program upgrading device, a program upgrading medium and electronic equipment, and relates to the field of data storage. The program upgrading method comprises the steps of responding to a received program upgrading instruction input by a user, and updating version file partitions and partition tables contained in a flash memory according to an upgrading data packet; dividing a user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table; integrating the data of the target user data area and the data of each backup user data area into a spliced file; respectively writing the spliced file into a target user data area and each backup user data area; the backup user data area is used for enabling the program to be started normally when the data of the target user data area is abnormal. When the method is used for upgrading the program of the terminal equipment of the backup area without the user data area, the original user data is reserved and further backed up, so that the terminal equipment without the backup area can obtain the backup area.
Description
Technical Field
The embodiment of the application relates to the field of data storage, in particular to a program upgrading method, a program upgrading device, a program upgrading medium and electronic equipment.
Background
Terminal equipment using a Linux system, such as an internet protocol Camera (IP Camera, IPC), is currently widely used in various scenes in the industry, and with higher and higher cost requirements, a FLASH memory (FLASH) is generally adopted as a storage device, and a low-capacity NOR FLASH is adopted for storage in a mainstream low-cost scheme at present. Flash memory is often divided into a BOOT area, a partition table, a kernel area, a ROOTFS area, and a user data area, and all partitions are writable only with the user data area and the partition table. In small capacity NOR FLASH, the JFFS2 file system is often used for mounting.
In the existing program upgrading method, if the terminal equipment has a backup area of user data, if the user data is updated and the conditions such as power failure and abnormal restart occur, the user data can be recovered when lost. However, this type of terminal device generally does not have a backup area for the user data area for reasons of storage space and the like. Therefore, how to provide a program upgrading method for enabling terminal equipment without a backup area to obtain the backup area has important practical significance.
Disclosure of Invention
The embodiment of the application provides a program upgrading method, a device, a medium and electronic equipment, which can enable terminal equipment to obtain a backup area when the program of the terminal equipment of the backup area without a user data area is upgraded.
In order to achieve the above purpose, the technical solution of the embodiment of the present application is implemented as follows:
in a first aspect, an embodiment of the present application provides a program upgrading method, including:
updating version file partitions and partition tables contained in a flash memory according to an upgrading data packet in response to a received program upgrading instruction input by a user;
dividing the user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table;
integrating the data of the target user data area and the data of each backup user data area into a spliced file;
writing the spliced file into the target user data area and each backup user data area respectively; and the backup user data area is used for enabling the program to be started normally when the data of the target user data area are abnormal.
According to the program upgrading method provided by the embodiment of the application, when the program upgrading is carried out on the terminal equipment of the backup area without the user data area, the user data area of the flash memory is divided into the target user data area and at least one backup user data area according to the updated partition table, the data of the target user data area and the data of each backup user data area are integrated into the spliced file, the original user data are reserved according to the spliced file and further backed up, and therefore the terminal equipment without the backup area can obtain the backup area.
In an optional embodiment, the dividing the user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table includes:
and adjusting the storage address of the user data area according to the user data area parameters in the updated partition table so as to divide the user data area of the flash memory into a target user data area and at least one backup user data area.
According to the method, the storage address of the user data area is adjusted according to the user data area parameters in the updated partition table, so that the user data area of the flash memory is divided into the target user data area and at least one backup user data area, the user data area parameters in the partition table can be set according to specific needs during program upgrading, flexible data backup is achieved, and the running stability of the system is improved more efficiently.
In an optional embodiment, the integrating the data of the target user data area and the data of each backup user data area into a spliced file includes:
and reading data from the target user data area and each backup user data area according to the sequence of the storage addresses, and integrating the data into a spliced file based on the reading sequence.
In the method of the embodiment, data are read from the target user data area and each backup user data area according to the sequence of the storage addresses, and are integrated into the spliced file based on the reading sequence, so that the storage sequence of the physical addresses of the data in the spliced file is regular, the splicing time is reduced, and the subsequent reading of the spliced file is facilitated, thereby more effectively preventing the normal starting of a program from being influenced due to abnormal data during upgrading, and improving the running stability of the system.
In an optional embodiment, the writing the splicing file into the target user data area and each of the backup user data areas respectively includes:
if the data in the target user data area and the data in the backup user data area are different, the data in the target user data area and the data in the backup user data area are erased respectively, and the splicing file is written into the target user data area and the backup user data area respectively.
According to the method, whether the data in the target user data area and the data in the backup user data area are different or not is determined, unnecessary writing of the spliced file can be avoided, so that the efficiency of backing up the user data is improved, and the stability of system operation is improved more effectively.
In an optional embodiment, before the determining that the data in the target user data area and the backup user data area are different, the method further includes:
mounting the data of the target user data area into a preset first directory, and mounting the data of each backup user data area into a corresponding second directory respectively;
judging whether the data in the target user data area and the backup user data area are the same or not by the following modes:
for any one second directory, detecting whether the data of the first directory and the second directory are the same, and if so, determining that the data in the target user data area and the backup user data area corresponding to the second directory are the same;
the erasing and writing the data of the target user data area and the backup user data area into the splicing file respectively comprises:
and respectively erasing the data mounted by the first directory and each second directory, and writing the data mounted by a third directory, wherein the third directory is a directory mounted with the spliced file.
According to the method, the preset three directory files are adopted, the data are efficiently read and compared, the original user data are reserved and further backed up, the overall efficiency of backing up the user data is improved, and the stability of system operation is effectively improved.
In a second aspect, an embodiment of the present application further provides a program upgrading apparatus, including:
the program upgrading module is used for responding to a received program upgrading instruction input by a user and updating version file partitions and partition tables contained in the flash memory according to an upgrading data packet;
the data partition module is used for dividing the user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table;
the data splicing module is used for integrating the data of the target user data area and the data of each backup user data area into a spliced file;
the data backup module is used for respectively writing the spliced files into the target user data area and each backup user data area; and the backup user data area is used for enabling the program to be started normally when the data of the target user data area are abnormal.
In an optional embodiment, the data partitioning module is specifically configured to:
and adjusting the storage address of the user data area according to the user data area parameters in the updated partition table so as to divide the user data area of the flash memory into a target user data area and at least one backup user data area.
In an optional embodiment, the data splicing module is specifically configured to:
and reading data from the target user data area and each backup user data area according to the sequence of the storage addresses, and integrating the data into a spliced file based on the reading sequence.
In an optional embodiment, the data backup module is specifically configured to:
if the data in the target user data area and the data in the backup user data area are different, the data in the target user data area and the data in the backup user data area are erased respectively, and the splicing file is written into the target user data area and the backup user data area respectively.
In an optional embodiment, the apparatus further comprises a data mount module configured to:
mounting the data of the target user data area into a preset first directory, and mounting the data of each backup user data area into a corresponding second directory respectively;
the data backup module is specifically configured to:
for any one second directory, detecting whether the data of the first directory and the second directory are the same, and if so, determining that the data in the target user data area and the backup user data area corresponding to the second directory are the same;
respectively erasing the data mounted in the first directory and the second directories, and writing the data mounted in a third directory;
and the data mounting module is also used for mounting the third directory and the splicing file.
In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the program upgrading method of the first aspect is implemented.
In a fourth aspect, an embodiment of the present application further provides an electronic device, including a flash memory and a processor, where the flash memory stores thereon a computer program that is executable on the processor, and when the computer program is executed by the processor, the processor is caused to implement the program upgrading method of the first aspect.
For technical effects brought by any one implementation manner in the second aspect to the fourth aspect, reference may be made to technical effects brought by a corresponding implementation manner in the first aspect, and details are not described here.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application;
FIG. 2 is a diagram illustrating a partition of a flash memory according to an embodiment of the present disclosure;
fig. 3 is a flowchart of a program upgrading method according to an embodiment of the present application;
fig. 4 is a schematic diagram illustrating a user data partition being divided into two parts when a program is updated according to an embodiment of the present application;
fig. 5 is a flowchart of another program upgrading method provided in an embodiment of the present application;
fig. 6 is a flowchart of another program upgrading method provided in an embodiment of the present application;
fig. 7 is a flowchart of another program upgrading method provided in an embodiment of the present application;
fig. 8 is a schematic structural diagram of a program upgrading apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of another program upgrading device provided in an embodiment of the present application;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be described in further detail with reference to the accompanying drawings, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that references in the specification of the present application to the terms "comprises" and "comprising," and variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Some of the words that appear in the text are explained below:
(1) and Linux: the general name GNU/Linux is a UNIX-like operating system which is free to use and spread freely. It can run major Unix tool software, applications, and network protocols. It supports 32-bit and 64-bit hardware. Linux inherits the design idea of Unix with network as core, and is a multi-user network operating system with stable performance. There are hundreds of different releases for Linux, such as debian, archlinux based on community development, and Red Hat Enterprise Linux, SUSE, Oracle Linux, etc. based on commercial development. The Linux operating system treats all devices as files, and integrates the resources of the entire computer into a large file directory. To access a file on a storage device, a user must mount the partition in which the file resides on an existing directory and then access the storage device by accessing the directory.
(2) NOR Flash: NOR Flash is a memory that uses non-volatile Flash technology and is characterized by on-chip execution (XIP), so that applications can run directly In Flash without having to read the code into the system RAM. NOR Flash has high transmission efficiency and has high cost benefit when the capacity is small, namely 1-4 MB.
(3) Mounting (Mounting): refers to a process by which computer files and directories on a storage device (such as a hard disk, CD-ROM, or shared resource) are made available to a user through the computer's file system by an operating system. Generally, when a computer is shut down, each mounted storage will undergo an offload to ensure that all queued data is written and to ensure the integrity of the file system structure on the media. In the Linux operating system, mounting is a very important function, which is used very frequently, and is specifically to mount a device (usually a storage device) to an existing directory.
(4) Flash Memory (Flash Memory): is a long-lived, non-volatile (maintaining stored data information in the event of a power failure) memory, with data erasures not in individual bytes but in fixed blocks (note: NOR Flash is a byte store), typically 256KB to 20MB in block size. Flash memory is a variation of electrically erasable read-only memory (EEPROM) which, unlike EEPROM, can be erased and rewritten on a byte level rather than being erased on an entire chip, whereas most chips of flash memory require block erasure. Flash memory is commonly used to store setup information, such as BIOS (basic program) of a computer, PDA (personal digital assistant), digital camera, etc., because it can still store data when it is powered off.
Terminal equipment using a Linux system, such as an internet protocol Camera (IP Camera, IPC), is currently widely used in various scenes in the industry, and with higher and higher cost requirements, a FLASH memory (FLASH) is generally adopted as a storage device, and a low-capacity NOR FLASH is adopted for storage in a mainstream low-cost scheme at present. FLASH memory (FLASH) is often divided into a BOOT area, a partition table, a kernel area, a ROOTFS area, and a user data area. All partitions are writable only with user data areas and partition tables, and in small-capacity NOR FLASH, the JFFS2 file system is often used for mounting. This type of terminal device is not normally provided with a backup area for the user data area for reasons such as storage space.
In the existing program upgrading method, if the terminal equipment has a backup area of user data, if the user data is updated and the conditions such as power failure and abnormal restart occur, the user data can be recovered when lost. However, this type of terminal device generally does not have a backup area for the user data area for reasons of storage space and the like. Therefore, how to provide a program upgrading method for enabling terminal equipment without a backup area to obtain the backup area has important practical significance.
In order to solve the existing technical problems, embodiments of the present application provide a method, an apparatus, a medium, and an electronic device for program upgrade, in which a version file partition and a partition table included in a flash memory are updated according to an upgrade data packet by responding to a received program upgrade instruction input by a user; dividing the user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table; integrating the data of the target user data area and the data of each backup user data area into a spliced file; writing the spliced file into the target user data area and each backup user data area respectively; and the backup user data area is used for enabling the program to be started normally when the data of the target user data area are abnormal. When the program of the terminal equipment of the backup area without the user data area is upgraded, the method divides the user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table, integrates the data of the target user data area and each backup user data area into a splicing file, and realizes the retention and further backup of the original user data according to the splicing file, thereby leading the terminal equipment without the backup area to obtain the backup area.
In order to make the objects, technical solutions and advantages of the embodiments of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings, and it is to be understood that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the following application scenarios described in the embodiments of the present application are for more clearly illustrating the technical solutions in the embodiments of the present application, and do not constitute limitations on the technical solutions provided in the embodiments of the present application, and it is obvious to a person skilled in the art that the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems with the occurrence of new application scenarios.
Fig. 1 shows an application scenario provided in an embodiment of the present application, and referring to fig. 1, the application scenario includes a terminal device 200 and a server 100. The server 100 and the terminal device 200 are in the same data network, which may be a wired network or a wireless network. When the server 100 and the terminal device 200 are in the same data network, the terminal device 200 can communicate with the server 100. The server 100 may be a cloud server that performs an upgrade service on the terminal device 200. The terminal device 200 includes a flash memory 201. It is understood that the server 100 and the terminal device 200 may also be respectively in a state of interconnecting different data networks, and the same data network of the application scenario depicted in fig. 1 does not constitute a limitation to the technical solution provided in the embodiment of the present application. Fig. 2 is a schematic diagram illustrating a partition of a flash memory according to an embodiment of the present application. As shown in fig. 2, the flash memory is mainly divided into a BOOT area, a partition table, a kernel area, a ROOTFS area, and a user data area. The BOOT area is generally used for storing a core file used when Linux is started; the partition table is a guide file for uniformly managing the partition of the flash memory; the kernel area is used for storing kernel files; the ROOTFS area contains directories and critical files necessary for system startup and files necessary for other file systems to be mounted; the user data area typically stores user data. Only the user data area and the partition table are writable in the above partition divided by the flash memory. The other partitions obtained by partitioning the flash memory except the user data partition and the partition table may be collectively referred to as version file partitions. When the program of the terminal device 200 is upgraded, the update version program may be implemented by updating a BOOT area, a partition table, a kernel area, a ROOTFS area, and a user data area included in the flash memory 201 of the terminal device 200. In the following embodiments of the present application, the flash memory 201 of the terminal device 200 is partitioned to include a version file partition, a user data partition, and a partition table, where the version file partition includes a BOOT area, a kernel area, and a ROOTFS area.
The server 100 may not periodically push the program upgrade alert message to the terminal device 200, and the user may click to confirm the received program upgrade alert message through the terminal device 200, thereby inputting the program upgrade instruction to the terminal device 200. The terminal device 200 updates the version file partition and the partition table included in the flash memory 201 according to the upgrade data packet in response to the received program upgrade instruction input by the user; dividing the user data area of the flash memory 201 into a target user data area and at least one backup user data area according to the updated partition table; integrating the data of the target user data area and the data of each backup user data area into a spliced file; respectively writing the spliced file into a target user data area and each backup user data area; the backup user data area is used for enabling the program to be started normally when the data of the target user data area is abnormal.
An embodiment of the present application provides a program upgrading method, as shown in fig. 3, including the following steps:
step S301, in response to a received program upgrade instruction input by a user, updating a version file partition and a partition table included in the flash memory according to the upgrade data packet.
The flash memory comprises a plurality of preset partitions for storing program data of a program; the plurality of preset partitions comprise a version file partition, a partition table and a user data area for storing user data; the partition table is used for determining the storage position of each preset partition.
Optionally, the version file partition includes a BOOT area, a kernel area, and a ROOTFS area.
Illustratively, the terminal device 200 downloads an upgrade data package from the server 100 in response to a received program upgrade instruction input by a user, and updates the version file partition and the partition table included in the flash memory 201 according to the upgrade data package, wherein the version file partition is a partition other than the partition table and the user data partition, among a plurality of preset partitions included in the flash memory 201 for storing program data of the program: a BOOT area, a kernel area and a ROOTFS area.
Step S302, according to the updated partition table, the user data area of the flash memory is divided into a target user data area and at least one backup user data area.
In the embodiment of the application, the process of dividing the user data area in the flash memory according to the updated partition table may be divided into a target user data area and one backup user data area, or divided into the target user data area and a plurality of backup user data areas. The number of the divided backup user data areas is not particularly limited.
In some optional embodiments, dividing the user data area of the flash memory into the target user data area and the at least one backup user data area according to the updated partition table may be implemented by:
and adjusting the storage address of the user data area according to the user data area parameters in the updated partition table so as to divide the user data area of the flash memory into a target user data area and at least one backup user data area.
The user data area parameters are obtained when the terminal device updates the partition table. The obtaining method of the user data area parameters includes but is not limited to: collecting user input data and acquiring preset default parameters.
When the terminal acquires the user data area parameters by collecting the user input data, the number of divisions input by the user, the start address and the storage capacity corresponding to each new divided user data area may be acquired. The division quantity indicates that the whole storage area of the user data area before the upgrade needs to be divided into several user data areas.
Illustratively, the user data area parameters include a start address and a storage capacity of the user data area. When updating the partition table, the terminal device acquires and stores the number of partitions, the start address, and the storage capacity of the user data area, which are input by the user in response to prompt information prompting the user to input parameters of the user data area.
When the terminal acquires the user data area parameters by acquiring the preset default parameters, the number of partitions of the preset user data area, the start address of each partitioned new user data area, and the storage capacity can be directly acquired.
For example, when updating the partition table, the terminal device 200 may directly obtain the number of partitions of the user data area, the start address and the storage capacity of each new partitioned user data area according to the preset data, and obtain the updated partition table.
Fig. 4 is a schematic diagram illustrating a user data partition in two during program update according to an embodiment of the present application. As shown in fig. 4, after the BOOT area, the kernel area, the ROOTFS area, and the partition table are updated according to the program update package, the terminal device 200 adjusts the positions of the partitions according to the new partition table, so that the user data area before the update can be divided into two, and the user data area 1 and the user data area 2 are obtained. It can be understood that, the division of the user data area before the upgrade in fig. 4 is merely an example, the program upgrade method provided in the embodiment of the present application may further divide the user data area before the upgrade into more user data areas, and fig. 4 does not constitute a limitation to the technical solution provided in the embodiment of the present application.
It can be understood that the program upgrading method provided in this embodiment is also applicable to upgrading a terminal device without setting a backup area of a user data area for multiple times. If the user data area of the flash memory is divided into two or more partitions during the previous upgrade of the terminal equipment, the user data area of the flash memory is still divided into a target user data area and at least one backup user data area according to the partition table updated by the upgrade during the upgrade: if the user data area parameters of the updated partition table during the upgrade are unchanged from the user data area parameters during the previous upgrade, the target user data area and at least one backup user data area obtained by the partition of the upgrade are consistent with the partition of the upgrade at the previous time; if the user data area parameters of the updated partition table during the upgrade are changed compared with the previous upgrade, the target user data area and the at least one backup user data area obtained by the partition of the upgrade are different from the partition of the previous upgrade, that is, the user data area parameters are obtained according to the updated partition table of the upgrade, and the user data area of the terminal equipment is re-partitioned, so that a new target user data area and a new at least one backup user data area are obtained.
In some embodiments of the present application, when the user data area of the flash memory is divided into the target user data area and the at least one backup user data area according to the updated partition table, if it is determined that only one user data area exists in the updated partition table, an alarm message is generated.
Illustratively, the terminal device 200 determines whether the updated partition table has only one user data area when the user data area of the flash memory is divided into the target user data area and the at least one backup user data area according to the updated partition table, and generates an alarm message to indicate a reminder if the updated partition table has only one user data area. For example, a prompt message "error, only in one user data area" is displayed.
Step S303, integrating the data of the target user data area and each backup user data area into a spliced file.
Illustratively, the terminal device 200 integrates the data of the target user data area and the respective backup user data areas into a spliced file data. It is understood that the concatenation file is only an example, and other file types of concatenation files are also applicable to the embodiment of the present application. The following embodiments of the present application are all described by taking the concatenation file data.
In some embodiments of the present application, integrating the data of the target user data area and each backup user data area into a spliced file specifically includes: and reading data from the target user data area and each backup user data area according to the sequence of the storage addresses, and integrating the data into a spliced file based on the reading sequence.
Illustratively, the terminal device 200 continuously reads the partition data of the target user data area and each backup user data area according to the sequence of the storage addresses, and integrates into the mosaic file data.
Step S304, the splicing file is respectively written into the target user data area and each backup user data area.
The backup user data area is used for enabling the program to be started normally when the data of the target user data area are abnormal.
Illustratively, the terminal device writes the splicing file data.img into the target user data area and each backup user data area respectively, wherein the backup user data area is used for enabling the program to be started normally when the data of the target user data area is abnormal.
In some optional embodiments, in step S304, the splicing file is written into the target user data area and each backup user data area respectively, as shown in fig. 5, which may be implemented by the following steps:
step S501, if the data in the target user data area and the data in the backup user data area are different, the data in the target user data area and the data in the backup user data area are respectively erased, and the splicing file is respectively written into the target user data area and the backup user data area.
Illustratively, the terminal device may mount the target user data area and each backup user data area to a preset target directory file and a plurality of backup directory files, respectively, so that the target directory file mounts the target user data area, and the plurality of backup directory files mount one backup user data area, then select the backup directory files one by one according to the sequence of storage addresses of the partitions corresponding to the directory files and compare the backup directory files with the data of the target directory file, if the backup directory files are the same, determine that the data in the target user data area and the backup user data area are the same; and if the data in the target user data area and the data in the backup user data area are different, respectively erasing the data in the target user data area and the data in the backup user data area, and respectively writing the spliced file into the target user data area and the backup user data area.
According to the program upgrading method provided by the embodiment of the application, when the program is upgraded for the terminal device of the backup area without the user data area, the user data before upgrading is reserved through the target user data area, and the user data before upgrading is further backed up through each backup user data area. According to the program upgrading method, when the program is upgraded for the terminal equipment of the backup area without the user data area, at least one backup user data area is set, so that the original user data is reserved and further backed up, the terminal equipment without the backup area can obtain the backup area, and the data recoverability of the terminal equipment is improved.
In an alternative embodiment, before determining that the data in the target user data area and the backup user data area are different in step S501, as shown in fig. 6, the method includes:
s601, mounting the data of the target user data area into a preset first directory, and mounting the data of each backup user data area into a corresponding second directory respectively.
Illustratively, the terminal device 200 mounts the data of the target user data area into a preset first directory a, and mounts the data of each backup user data area into a corresponding second directory B, respectively.
S602, judging whether the data in the target user data area and the backup user data area are the same or not through the following modes:
and aiming at any one second directory, detecting whether the data of the first directory and the second directory are the same, and if so, determining that the data in the target user data area and the backup user data area corresponding to the second directory are the same.
Illustratively, the terminal device 200 determines whether the data in the target user data area and the backup user data area are the same by:
and aiming at any one second directory B, detecting whether the data of the first directory A and the second directory B are the same, and if so, determining that the data in the target user data area and the backup user data area corresponding to the second directory B are the same.
In this embodiment, in step S501, if the data in the target user data area and the data in the backup user data area are different, the data in the target user data area and the data in the backup user data area are erased and written into the mosaic file, which may be implemented by the following steps:
and S603, if the data in the target user data area and the data in the backup user data area are different, respectively erasing the data mounted in the first directory and the second directories, and writing the data mounted in a third directory, wherein the third directory is a directory mounted with the spliced file.
Illustratively, if the terminal device 200 determines that the data in the target user data area and the backup user data area are different, the data mounted in the first directory a and the second directories B are respectively erased, and the data mounted in the third directory C, which is a directory mounted with the splicing file data.
In some other embodiments, the terminal device 200 may use a counter to record the number of times of mounting the backup user data area on the second directory B after the power-off restart of the program upgrade is performed and the kernel is started, and when it is determined that the data mounted in the target user data area is different from the data mounted in the backup user data area, if the number of times of mounting the backup user data area on the second directory B is greater than a preset threshold, for example, the preset threshold is 2, only the data mounted on the second directory is erased, and the data mounted on the third directory is written into the partition mounted on the second directory B. This embodiment may control the number of times data is erased and written to the first directory.
In another embodiment, the program upgrade process, as shown in FIG. 7, performs the following steps:
step S701, in response to the received program upgrade instruction input by the user, downloads an upgrade data package.
Step S702, updating the version file partition and partition table contained in the flash memory according to the upgrade data packet.
Wherein the version file partition includes: a BOOT area, a kernel area and a ROOTFS area.
Specifically, when the partition table is updated, the user data parameters are obtained.
In step S703, the flash memory is restarted by powering down in response to the power down restart instruction.
Step S704, according to the updated partition table, the user data area of the flash memory is divided into a target user data area and a backup user data area.
Specifically, according to the user data area parameters in the updated partition table, the storage address of the user data area is adjusted to divide the user data area of the flash memory into a target user data area and a backup user data area.
Alternatively, the number of the backup user data areas is plural.
Step S705, determining that the updated partition table has only one user data area. If yes, go to step S711; if not, go to step S706.
Step S706, continuously reading the partition contents of the target user data area and the backup user data area, forming a spliced file, and storing the spliced file in the memory.
Step S707, the target user data area is mounted in the first directory, the backup user data area is mounted in the second directory, and the merged file is mounted in the third directory.
In step S708, it is checked whether the data in the first directory and the second directory exist and are the same. If yes, go to step S710; if not, go to step S709.
Step S709, copying the merged file to the first directory and the second directory according to the third directory.
And step S710, deleting the spliced file corresponding to the third directory.
Exemplarily, the terminal device 200 deletes the splicing file data.img corresponding to the third directory to save the memory space.
In step S711, an alarm message is generated.
The specific processes of steps S701 to S711 may be executed by referring to the method steps in the foregoing embodiments, and are not described herein again.
Based on the same inventive concept, the embodiment of the application also provides a program upgrading device. Because the device is a device corresponding to the program upgrading method provided by the embodiment of the application, and the principle of the device for solving the problem is similar to that of the method, the implementation of the device can refer to the implementation of the method, and repeated parts are not described again.
Fig. 8 shows a schematic structural diagram of a program upgrading apparatus provided in an embodiment of the present application, and as shown in fig. 8, the program upgrading apparatus includes a program upgrading module 801, a data partitioning module 802, a data splicing module 803, and a data backup module 804.
The program upgrading module 801 is configured to update version file partitions and partition tables included in the flash memory according to an upgrading data packet in response to a received program upgrading instruction input by a user;
a data partitioning module 802, configured to partition a user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partitioning table;
a data splicing module 803, configured to integrate data in the target user data area and the data in each backup user data area into a spliced file;
the data backup module 804 is configured to write the spliced files into the target user data area and each backup user data area respectively; the backup user data area is used for enabling the program to be started normally when the data of the target user data area is abnormal.
In an alternative embodiment, the data partitioning module 802 is specifically configured to:
and adjusting the storage address of the user data area according to the user data area parameters in the updated partition table so as to divide the user data area of the flash memory into a target user data area and at least one backup user data area.
In an alternative embodiment, the data splicing module 803 is specifically configured to:
and reading data from the target user data area and each backup user data area according to the sequence of the storage addresses, and integrating the data into a spliced file based on the reading sequence.
In an alternative embodiment, the data backup module 804 is specifically configured to:
and if the data in the target user data area and the data in the backup user data area are different, respectively erasing the data in the target user data area and the data in the backup user data area, and respectively writing the spliced file into the target user data area and the backup user data area.
In an alternative embodiment, as shown in fig. 9, the apparatus further includes a data mounting module 901, configured to:
mounting the data of the target user data area into a preset first directory, and mounting the data of each backup user data area into a corresponding second directory respectively;
the data backup module 804 is specifically configured to:
for any second directory, detecting whether the data of the first directory and the second directory are the same, and if so, determining that the data in the target user data area and the backup user data area corresponding to the second directory are the same;
respectively erasing the data mounted in the first directory and the second directories, and writing the data mounted in the third directory;
the data mounting module 901 is further configured to mount the third directory and the splicing file.
The electronic equipment is based on the same inventive concept as the method embodiment, and the embodiment of the application also provides the electronic equipment. The electronic device may be used for program upgrades. In one embodiment, the electronic device is a terminal device, such as terminal device 200 in FIG. 1. In this embodiment, the electronic device may be configured as shown in fig. 10, and include a memory 101, a communication module 103, and one or more processors 102. The memory 101 is a flash memory.
A memory 101 for storing a computer program for execution by the processor 102. The memory 101 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, a program required for running an instant messaging function, and the like; the storage data area can store various instant messaging information, operation instruction sets and the like.
The memory 101 may be a volatile memory (volatile memory), such as a random-access memory (RAM); the memory 101 may also be a non-volatile memory (non-volatile memory) such as, but not limited to, a read-only memory (rom), a flash memory (flash memory), a Hard Disk Drive (HDD) or a solid-state drive (SSD), or the memory 101 may be any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. Memory 101 may be a combination of the above.
The processor 102 may include one or more Central Processing Units (CPUs), or be a digital processing unit, etc. And a processor 102, configured to implement the program upgrading method when calling the computer program stored in the memory 101.
The communication module 103 is used for communicating with terminal equipment and other servers.
The specific connection medium among the memory 101, the communication module 103 and the processor 102 is not limited in the embodiments of the present application. In the embodiment of the present application, the memory 101 and the processor 102 are connected by the bus 104 in fig. 10, the bus 104 is represented by a thick line in fig. 10, and the connection manner between other components is merely illustrative and is not limited thereto. The bus 104 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 10, but this is not intended to represent only one bus or type of bus.
According to an aspect of the application, a computer program product or computer program is provided, comprising computer instructions, the computer instructions being stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the program upgrading method in the above-described embodiment. The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application.
Claims (10)
1. A program upgrade method, comprising:
updating version file partitions and partition tables contained in a flash memory according to an upgrading data packet in response to a received program upgrading instruction input by a user;
dividing the user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table;
integrating the data of the target user data area and the data of each backup user data area into a spliced file;
writing the spliced file into the target user data area and each backup user data area respectively; and the backup user data area is used for enabling the program to be started normally when the data of the target user data area are abnormal.
2. The method of claim 1, wherein the partitioning the user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table comprises:
and adjusting the storage address of the user data area according to the user data area parameters in the updated partition table so as to divide the user data area of the flash memory into a target user data area and at least one backup user data area.
3. The method of claim 1, wherein the integrating the data of the target user data area and the data of each backup user data area into a spliced file comprises:
and reading data from the target user data area and each backup user data area according to the sequence of the storage addresses, and integrating the data into a spliced file based on the reading sequence.
4. The method according to any one of claims 1 to 3, wherein said writing said mosaic file into said target user data area and each of said backup user data areas respectively comprises:
if the data in the target user data area and the data in the backup user data area are different, the data in the target user data area and the data in the backup user data area are erased respectively, and the splicing file is written into the target user data area and the backup user data area respectively.
5. The method of claim 4, further comprising, prior to said determining that the data in the target user data area and the backup user data area are different:
mounting the data of the target user data area into a preset first directory, and mounting the data of each backup user data area into a corresponding second directory respectively;
judging whether the data in the target user data area and the backup user data area are the same or not by the following modes:
for any one second directory, detecting whether the data of the first directory and the second directory are the same, and if so, determining that the data in the target user data area and the backup user data area corresponding to the second directory are the same;
the erasing and writing the data of the target user data area and the backup user data area into the splicing file respectively comprises:
and respectively erasing the data mounted by the first directory and each second directory, and writing the data mounted by a third directory, wherein the third directory is a directory mounted with the spliced file.
6. A program upgrading apparatus, comprising:
the program upgrading module is used for responding to a received program upgrading instruction input by a user and updating version file partitions and partition tables contained in the flash memory according to an upgrading data packet;
the data partition module is used for dividing the user data area of the flash memory into a target user data area and at least one backup user data area according to the updated partition table;
the data splicing module is used for integrating the data of the target user data area and the data of each backup user data area into a spliced file;
the data backup module is used for respectively writing the spliced files into the target user data area and each backup user data area; and the backup user data area is used for enabling the program to be started normally when the data of the target user data area are abnormal.
7. The apparatus of claim 6, wherein the data partitioning module is specifically configured to:
and adjusting the storage address of the user data area according to the user data area parameters in the updated partition table so as to divide the user data area of the flash memory into a target user data area and at least one backup user data area.
8. The apparatus of claim 6, wherein the data splicing module is specifically configured to:
and reading data from the target user data area and each backup user data area according to the sequence of the storage addresses, and integrating the data into a spliced file based on the reading sequence.
9. A computer-readable storage medium having a computer program stored therein, the computer program characterized by: the computer program, when executed by a processor, implements the method of any of claims 1-5.
10. An electronic device comprising a flash memory and a processor, the flash memory having stored thereon a computer program operable on the processor, the computer program, when executed by the processor, implementing the method of any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110604261.4A CN113495746B (en) | 2021-05-31 | 2021-05-31 | Program upgrading method, device, medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110604261.4A CN113495746B (en) | 2021-05-31 | 2021-05-31 | Program upgrading method, device, medium and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113495746A true CN113495746A (en) | 2021-10-12 |
CN113495746B CN113495746B (en) | 2024-02-02 |
Family
ID=77997251
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110604261.4A Active CN113495746B (en) | 2021-05-31 | 2021-05-31 | Program upgrading method, device, medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113495746B (en) |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060015698A1 (en) * | 2004-05-11 | 2006-01-19 | Samsung Electronics Co., Ltd. | Method and apparatus for data backup |
CN103176824A (en) * | 2013-03-15 | 2013-06-26 | 青岛海信移动通信技术股份有限公司 | System upgrade method and system upgrade device |
CN103500128A (en) * | 2013-09-30 | 2014-01-08 | 上海斐讯数据通信技术有限公司 | NVRAM data backup method |
WO2014161339A1 (en) * | 2013-08-12 | 2014-10-09 | 中兴通讯股份有限公司 | Firmware upgrade method and device |
EP3046026A1 (en) * | 2013-09-13 | 2016-07-20 | Huizhou TCL Mobile Communication Co., Ltd. | Software upgrade method and system for mobile terminal |
CN107656745A (en) * | 2017-08-28 | 2018-02-02 | 深圳市金立通信设备有限公司 | A kind of data processing method, terminal and computer-readable medium |
CN109002317A (en) * | 2018-06-27 | 2018-12-14 | 上海有个机器人有限公司 | A kind of PCBA firmware upgrade method and system, PCBA |
US20190347164A1 (en) * | 2018-05-09 | 2019-11-14 | Microsoft Technology Licensing, Llc | Fault tolerant device upgrade |
CN111142907A (en) * | 2019-12-25 | 2020-05-12 | 声耕智能科技(西安)研究院有限公司 | Partition upgrading method for off-line keyword recognition system |
CN111913835A (en) * | 2020-07-30 | 2020-11-10 | 深圳忆联信息系统有限公司 | Data multi-backup storage method and device based on cross mapping, computer equipment and storage medium |
CN112328287A (en) * | 2020-11-24 | 2021-02-05 | 杭州海康威视数字技术股份有限公司 | Embedded equipment system updating method, device, equipment and storage medium |
CN112788118A (en) * | 2020-12-30 | 2021-05-11 | 宁波奥克斯电气股份有限公司 | Wi-Fi module, intelligent home equipment and intelligent home system |
-
2021
- 2021-05-31 CN CN202110604261.4A patent/CN113495746B/en active Active
Patent Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060015698A1 (en) * | 2004-05-11 | 2006-01-19 | Samsung Electronics Co., Ltd. | Method and apparatus for data backup |
CN103176824A (en) * | 2013-03-15 | 2013-06-26 | 青岛海信移动通信技术股份有限公司 | System upgrade method and system upgrade device |
CN106293848A (en) * | 2013-03-15 | 2017-01-04 | 青岛海信移动通信技术股份有限公司 | A kind of method and device of system upgrade |
WO2014161339A1 (en) * | 2013-08-12 | 2014-10-09 | 中兴通讯股份有限公司 | Firmware upgrade method and device |
EP3046026A1 (en) * | 2013-09-13 | 2016-07-20 | Huizhou TCL Mobile Communication Co., Ltd. | Software upgrade method and system for mobile terminal |
CN103500128A (en) * | 2013-09-30 | 2014-01-08 | 上海斐讯数据通信技术有限公司 | NVRAM data backup method |
CN107656745A (en) * | 2017-08-28 | 2018-02-02 | 深圳市金立通信设备有限公司 | A kind of data processing method, terminal and computer-readable medium |
US20190347164A1 (en) * | 2018-05-09 | 2019-11-14 | Microsoft Technology Licensing, Llc | Fault tolerant device upgrade |
CN109002317A (en) * | 2018-06-27 | 2018-12-14 | 上海有个机器人有限公司 | A kind of PCBA firmware upgrade method and system, PCBA |
CN111142907A (en) * | 2019-12-25 | 2020-05-12 | 声耕智能科技(西安)研究院有限公司 | Partition upgrading method for off-line keyword recognition system |
CN111913835A (en) * | 2020-07-30 | 2020-11-10 | 深圳忆联信息系统有限公司 | Data multi-backup storage method and device based on cross mapping, computer equipment and storage medium |
CN112328287A (en) * | 2020-11-24 | 2021-02-05 | 杭州海康威视数字技术股份有限公司 | Embedded equipment system updating method, device, equipment and storage medium |
CN112788118A (en) * | 2020-12-30 | 2021-05-11 | 宁波奥克斯电气股份有限公司 | Wi-Fi module, intelligent home equipment and intelligent home system |
Non-Patent Citations (8)
Title |
---|
CHENGF223: "一种简单的nor flash 备份恢复机制", pages 1 - 4, Retrieved from the Internet <URL:《https://blog.csdn.net/chengf223/article/details/83902279》> * |
KUN-RU WU: "Publisher: IEEE Cite This PDF", 《IEEE JOURNAL ON SELECTED AREAS IN COMMUNICATIONS ( VOLUME: 36, ISSUE: 3, MARCH 2018)》, pages 411 * |
佚名: "Technical Tip: How to upgrade the FortiGate firmware", pages 1 - 5, Retrieved from the Internet <URL:《 https://community.fortinet.com/t5/FortiGate/Technical-Tip-How-to-upgrade-the-FortiGate-firmware/ta-p/194980 Below is a snapshot of the Web page as it appeared on 2023/12/15 (the last time our crawler visited it). This is the version of the page that was used for ranking your search results. The page may have changed since we last cached it. To see what might have changed (without the highlights), go to the current page. Bing is not responsible for the content of this page. Fortinet Community Help Sign In》> * |
周成冲: "智能卡操作系统及其bootloader的研究与实现", 《中国优秀硕士学位论文全文数据库 (信息科技辑)》, pages 135 - 242 * |
曹玉保: "基于双备份的兆易创新GD32程序升级方案研究", 《中国集成公路》, pages 1 - 4 * |
王丛华: "网络电视差分升级系统的设计与实现", 《万方》, pages 1 - 67 * |
良好的行为成为习惯: "单片机BootLoader的通用实现方式(备份升级,永不挂机)", pages 1 - 3, Retrieved from the Internet <URL:《https://blog.csdn.net/dsp1406790497/article/details/107126716》> * |
阳辉: "分区隐藏与数据恢复技术", 《西部经济管理论坛 》, pages 53 - 56 * |
Also Published As
Publication number | Publication date |
---|---|
CN113495746B (en) | 2024-02-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107870968B (en) | Performing real-time updates to a file system volume | |
US7996720B2 (en) | Apparatus and method of mirroring firmware and data of embedded system | |
US9301164B2 (en) | Method, system, and terminal for performing system update between mobile communication terminals | |
JP4825433B2 (en) | Computing device with relatively limited storage space and operating system / file system thereof | |
US20120096252A1 (en) | Preparing and preserving a system configuration during a hot upgrade | |
US11640244B2 (en) | Intelligent block deallocation verification | |
US20140082346A1 (en) | Method and System for Managing Basic Input/Output System (BIOS) Configuration Data of BIOS | |
WO2017050064A1 (en) | Memory management method and device for shared memory database | |
US11861349B2 (en) | Modular firmware updates in an information handling system | |
CN104866324A (en) | Method for constructing portable operating system and portable memorizer | |
US9235426B2 (en) | Multicore processor system, computer product, and notification method for updating operating system | |
CN104081376A (en) | Maintaining system firmware images remotely using a distribute file system protocol | |
US20230273799A1 (en) | Storage system with boot volume rollback points | |
CN114443081A (en) | Terminal upgrading method and terminal | |
JP2016533588A (en) | Storage processing method, apparatus and terminal | |
CN111399936A (en) | BMC customization method, system, equipment and readable storage medium | |
KR20170037017A (en) | Memory Upgrade System And Method | |
US11226755B1 (en) | Core dump in a storage device | |
US9298602B2 (en) | Nonvolatile random access memory use | |
CN113495746B (en) | Program upgrading method, device, medium and electronic equipment | |
US7234039B1 (en) | Method, system, and apparatus for determining the physical memory address of an allocated and locked memory buffer | |
CN114020308A (en) | Camera equipment upgrading method, device, equipment and medium | |
US20170242605A1 (en) | Guid partition table based hidden data store system | |
US10831656B2 (en) | System and method to improve input output command latency by dynamic size logical to physical caching | |
EP2613254A2 (en) | Apparatus and method for partitioning memory area for application preloading in a wireless terminal |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |