CN114995852A - Device upgrade method, device and computer-readable storage medium - Google Patents
Device upgrade method, device and computer-readable storage medium Download PDFInfo
- Publication number
- CN114995852A CN114995852A CN202210607284.5A CN202210607284A CN114995852A CN 114995852 A CN114995852 A CN 114995852A CN 202210607284 A CN202210607284 A CN 202210607284A CN 114995852 A CN114995852 A CN 114995852A
- Authority
- CN
- China
- Prior art keywords
- upgrade
- image
- mirror image
- upgrading
- crc
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 46
- 230000008569 process Effects 0.000 claims abstract description 16
- 238000004590 computer program Methods 0.000 claims description 24
- 238000012795 verification Methods 0.000 claims description 7
- 238000011084 recovery Methods 0.000 abstract description 9
- 230000005856 abnormality Effects 0.000 abstract description 2
- 230000008447 perception Effects 0.000 abstract 1
- 230000006872 improvement Effects 0.000 description 8
- 238000004891 communication Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 4
- 230000002159 abnormal effect Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 238000012546 transfer Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000009977 dual effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000007787 solid Substances 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
-
- 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/08—Error detection or correction by redundancy in data representation, e.g. by using checking codes
- G06F11/10—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
- G06F11/1004—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
-
- 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/1415—Saving, restoring, recovering or retrying at system level
- G06F11/1433—Saving, restoring, recovering or retrying at system level during software upgrading
-
- 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/1415—Saving, restoring, recovering or retrying at system level
- G06F11/1438—Restarting or rejuvenating
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/61—Installation
- G06F8/63—Image based installation; Cloning; Build to order
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Quality & Reliability (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
本发明公开了一种设备升级方法、设备及计算机可读存储介质,该方法包括:在设备的升级过程中,将升级文件拷贝到升级镜像区域;当检测到所述升级镜像区域内的升级镜像完整时,重启所述设备;在所述设备重启后,将所述升级镜像拷贝到主镜像区域;当检测到所述主镜像区域内的主镜像完整时,再次重启所述设备,以完成设备升级;本发明解决了设备升级过程中遇到突发断电后,再上电无法正常启动问题,实现了在没有人工干预的情况下,自动恢复断电导致的升级启动异常,做到无感知恢复,保证设备的正常使用。
The invention discloses a device upgrade method, device and computer-readable storage medium. The method includes: during the upgrade process of the device, copying the upgrade file to the upgrade mirror area; when detecting the upgrade mirror in the upgrade mirror area When the device is complete, restart the device; after the device is restarted, copy the upgrade image to the main image area; when it is detected that the main image in the main image area is complete, restart the device again to complete the device upgrade; the invention solves the problem that the equipment cannot be started normally after being powered on again after a sudden power failure during the equipment upgrade process, and realizes the automatic recovery of the upgrade startup abnormality caused by the power failure without manual intervention, so as to achieve no perception recovery to ensure the normal use of the device.
Description
技术领域technical field
本发明涉及网络通信技术领域,尤其涉及一种设备升级方法、设备及计算机可读存储介质。The present invention relates to the technical field of network communication, and in particular, to a device upgrading method, device and computer-readable storage medium.
背景技术Background technique
随着计算机技术的不断发展,网络技术的应用范围也越来越广泛,而作为电脑、打印机、服务器及IP电话等基于以太网的设备的核心,对于交换机的转发性能也提出了更高的要求。因而为了完善交换机的性能,相同型号的交换机也衍生出很多的不同版本,在主交换机的应用无法满足应用需求等情况下,需要对交换机的版本进行升级。With the continuous development of computer technology, the application scope of network technology has become more and more extensive, and as the core of Ethernet-based equipment such as computers, printers, servers and IP phones, it also puts forward higher requirements for the forwarding performance of switches . Therefore, in order to improve the performance of the switch, many different versions of the same type of switch are also derived. When the application of the main switch cannot meet the application requirements, etc., the version of the switch needs to be upgraded.
但是,在交换机升级过程中,若遇到突发断电,交换机重新上电后,容易出挂起,无法正常启动场景。为了解决突发断电导致交换机无法正常启动的问题,目前常见的解决方案有二种;第一种是用户通过交换机的串口进入Uboot(通用引导加载程序),然后重新进行升级启动,此时交换机必须提供串口支持,用户需要手动进入Uboot恢复;第二种是交换机实现了双镜像功能,用户通过串口进入Uboot切换备份镜像启动;此时交换机也必须提供串口支持,用户需要手动进入Uboot恢复,切换备份镜像为启动镜像启动,启动后再通过升级恢复主镜像区域。However, during the switch upgrade process, if there is a sudden power failure, after the switch is powered on again, it is easy to hang up and cannot start normally. In order to solve the problem that the switch cannot be started normally due to a sudden power failure, there are two common solutions at present; the first one is that the user enters Uboot (universal boot loader) through the serial port of the switch, and then restarts the upgrade and restart, at this time the switch Serial port support must be provided, and the user needs to manually enter Uboot to restore; the second is that the switch implements the dual mirror function, and the user enters Uboot through the serial port to switch the backup image to start; at this time, the switch must also provide serial port support, and the user needs to manually enter Uboot to restore and switch The backup image is the startup image, and after startup, the primary image area is restored through the upgrade.
对于上述两种方案,在现有技术中,会在Uboot中嵌入一个MiniOS(微型操作系统),当突发断电导致设备无法正常启动时,Uboot就会被引导启动MiniOS,MiniOS会加载一个升级页面,用户可以手动进行重新升级,从而恢复交换机正常启动,然而还是无法做到无感知恢复,需要用户去手动升级恢复。For the above two solutions, in the prior art, a MiniOS (mini operating system) is embedded in Uboot. When a sudden power failure causes the device to fail to start normally, Uboot will be booted to start MiniOS, and MiniOS will load an upgrade page, the user can manually re-upgrade to restore the normal startup of the switch, however, it is still unable to achieve non-aware recovery, and the user needs to manually upgrade and restore.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供一种设备升级方法、设备及计算机可读存储介质,其实现了在没有人工干预的情况下,自动恢复断电导致的升级启动异常,做到无感知恢复,保证设备的正常使用。Embodiments of the present invention provide a device upgrade method, device, and computer-readable storage medium, which realize automatic recovery of upgrade startup abnormality caused by power failure without manual intervention, achieve non-perceptual recovery, and ensure the normal operation of the device. use.
第一方面,本发明实施例提供一种设备升级方法,包括:In a first aspect, an embodiment of the present invention provides a device upgrade method, including:
在设备的升级过程中,将升级文件拷贝到升级镜像区域;During the upgrade process of the device, copy the upgrade file to the upgrade mirror area;
当检测到所述升级镜像区域内的升级镜像完整时,重启所述设备;When it is detected that the upgrade image in the upgrade image area is complete, restart the device;
在所述设备重启后,将所述升级镜像拷贝到主镜像区域;After the device is restarted, copy the upgrade image to the main image area;
当检测到所述主镜像区域内的主镜像完整时,再次重启所述设备,以完成设备升级。When it is detected that the master image in the master image area is complete, the device is restarted again to complete the device upgrade.
作为上述方案的改进,所述当检测到所述升级镜像区域内的升级镜像完整时,重启所述设备,包括:As an improvement of the above solution, when it is detected that the upgrade image in the upgrade image area is complete, restarting the device includes:
对所述升级镜像进行第一校验;performing a first check on the upgrade image;
在通过第一校验时,确定所述升级镜像完整,并置位升级标志位;When passing the first check, it is determined that the upgrade image is complete, and the upgrade flag is set;
在完成所述升级标志位置位后,重启所述设备;After completing the setting of the upgrade flag, restart the device;
在未通过所述第一校验时,确定所述升级镜像不完整,发出升级失败提示。When the first check is not passed, it is determined that the upgrade image is incomplete, and an upgrade failure prompt is issued.
作为上述方案的改进,所述在所述设备重启后,将所述升级镜像拷贝到主镜像区域,包括:As an improvement of the above solution, after the device is restarted, copying the upgrade image to the main image area includes:
在所述设备重启后,读取所述升级标志位,并判断所述升级标志位是否为第一预设值;After the device is restarted, read the upgrade flag, and determine whether the upgrade flag is a first preset value;
当所述升级标志位为所述第一预设值时,将所述升级镜像拷贝到主镜像区域。When the upgrade flag bit is the first preset value, the upgrade image is copied to the main image area.
作为上述方案的改进,所述当检测到所述主镜像区域内的主镜像完时,再次重启所述设备,包括:As an improvement of the above solution, when it is detected that the master image in the master image area is completed, restarting the device again includes:
对所述主镜像进行第二校验;performing a second check on the primary image;
在通过所述第二校验时,确定所述主镜像完整,并复位所述升级标志位;When passing the second check, it is determined that the primary image is complete, and the upgrade flag is reset;
在完成所述升级标志位复位后,重启所述设备;After completing the reset of the upgrade flag bit, restart the device;
在未通过所述第二校验时,确定所述主镜像不完整,继续将所述升级镜像拷贝到主镜像。When the second check is not passed, it is determined that the primary image is incomplete, and the upgrade image continues to be copied to the primary image.
作为上述方案的改进,所述在完成所述升级标志位复位后,重启所述设备之后,还包括:As an improvement of the above solution, after completing the reset of the upgrade flag bit and restarting the device, the method further includes:
读取所述升级标志位,并判断所述升级标志为是否为第二预设值;reading the upgrade flag bit, and judging whether the upgrade flag is a second preset value;
当所述升级标志位为所述第二预设值时,所述设备正常启动;When the upgrade flag is the second preset value, the device starts normally;
当所述升级标志位不为所述第二预设值时,继续将所述升级镜像拷贝到主镜像,直至所述主镜像通过所述第二校验。When the upgrade flag bit is not the second preset value, continue to copy the upgrade image to the primary image until the primary image passes the second check.
作为上述方案的改进,在所述设备的FLASH中配置有所述升级镜像区域、所述主镜像区域、所述升级标志位以及Uboot。As an improvement of the above solution, the upgrade image area, the main image area, the upgrade flag and Uboot are configured in the FLASH of the device.
作为上述方案的改进,所述对所述升级镜像进行第一校验,包括:As an improvement of the above solution, performing the first verification on the upgrade image includes:
计算所述升级镜像的CRC;calculating the CRC of the upgrade image;
当所述升级镜像的CRC与升级文件头部存放的CRC一致时,确定通过所述第一校验;When the CRC of the upgrade image is consistent with the CRC stored in the upgrade file header, it is determined that the first check is passed;
当所述升级镜像的CRC与升级文件头部存放的CRC不一致时,确定未通过所述第一校验。When the CRC of the upgrade image is inconsistent with the CRC stored in the header of the upgrade file, it is determined that the first check is not passed.
作为上述方案的改进,所述对所述主镜像进行第二校验,包括:As an improvement of the above solution, the performing a second check on the primary image includes:
计算所述主镜像的CRC;Calculate the CRC of the primary image;
当所述主镜像的CRC与升级镜像区域的镜像头部存放的CRC一致时,确定通过所述第二校验;When the CRC of the main image is consistent with the CRC stored in the image header of the upgrade image area, it is determined that the second check is passed;
当所述主镜像的CRC与升级镜像区域的镜像头部存放的CRC不一致时,确定未通过所述第二校验。When the CRC of the main image is inconsistent with the CRC stored in the image header of the upgrade image area, it is determined that the second check is not passed.
第二方面,本发明实施例提供了一种设备,包括:In a second aspect, an embodiment of the present invention provides a device, including:
存储器,用于存储计算机程序;memory for storing computer programs;
处理器,用于执行所述计算机程序时实现如第一方面任一项所述的设备升级方法。The processor is configured to implement the device upgrading method according to any one of the first aspect when executing the computer program.
第三方面,本发明实施例提供了一种计算机可读存储介质,所述计算机可读存储介质包括存储的计算机程序,其中,在所述计算机程序运行时控制所述计算机可读存储介质所在设备执行如第一方面任一项所述的设备升级方法。In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program, wherein when the computer program runs, a device where the computer-readable storage medium is located is controlled The device upgrading method according to any one of the first aspect is performed.
相对于现有技术,本发明实施例的有益效果在于:通过在设备的升级过程中,将升级文件拷贝到升级镜像区域;当检测到所述升级镜像区域内的升级镜像完整时,重启所述设备;在所述设备重启后,将所述升级镜像拷贝到主镜像区域;当检测到所述主镜像区域内的主镜像完整时,再次重启所述设备,以完成设备升级。本发明实施例解决了设备(比如交换机)升级过程中遇到突发断电后,再上电无法正常启动问题,实现了在没有人工干预的情况下,自动恢复断电导致的升级启动异常,做到无感知恢复,保证交换机的正常使用。Compared with the prior art, the beneficial effects of the embodiments of the present invention are: during the upgrade process of the device, the upgrade file is copied to the upgrade mirror area; when it is detected that the upgrade mirror in the upgrade mirror area is complete, the device; after the device is restarted, copy the upgrade image to the main image area; when it is detected that the main image in the main image area is complete, restart the device again to complete the device upgrade. The embodiment of the present invention solves the problem that the equipment (such as a switch) cannot be started normally after a sudden power failure during the upgrade process, and realizes that the abnormal upgrade startup caused by the power failure is automatically restored without manual intervention. To achieve non-sensing recovery, to ensure the normal use of the switch.
附图说明Description of drawings
为了更清楚地说明本发明的技术方案,下面将对实施方式中所占据要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions of the present invention more clearly, the accompanying drawings occupied in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention, which are very important in the art. For those of ordinary skill, other drawings can also be obtained from these drawings without any creative effort.
图1是本发明实施例提供的一种设备升级方法的流程图;1 is a flowchart of a device upgrading method provided by an embodiment of the present invention;
图2是本发明实施例提供的设备的FLASH布局示意图;2 is a schematic diagram of a FLASH layout of a device provided by an embodiment of the present invention;
图3是本发明实施例提供的设备升级流程图;3 is a flow chart of equipment upgrade provided by an embodiment of the present invention;
图4是本发明实施例提供的升级镜像的头部结构示意图;4 is a schematic diagram of a header structure of an upgrade image provided by an embodiment of the present invention;
图5是本发明实施例提供的一种设备的示意框图。FIG. 5 is a schematic block diagram of a device provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
实施例一Example 1
请参见图1,其实本发明实施例提供的一种设备升级方法流程图,所述设备升级方法,具体包括:Referring to FIG. 1, in fact, a flowchart of a device upgrading method provided by an embodiment of the present invention, the device upgrading method specifically includes:
S1:在设备的升级过程中,将升级文件拷贝到升级镜像区域;S1: During the upgrade process of the device, copy the upgrade file to the upgrade mirror area;
S2:当检测到所述升级镜像区域内的升级镜像完整时,重启所述设备;S2: when it is detected that the upgrade image in the upgrade image area is complete, restart the device;
S3:在所述设备重启后,将所述升级镜像拷贝到主镜像区域;S3: after the device is restarted, copy the upgrade image to the main image area;
S4:当检测到所述主镜像区域内的主镜像完整时,再次重启所述设备,以完成设备升级。S4: When it is detected that the master image in the master image area is complete, restart the device again to complete the device upgrade.
在本发明实施例中,以交换机为例,对设备升级过程进行说明。In the embodiment of the present invention, a switch is taken as an example to describe a device upgrade process.
其中,在交换机的FLASH中配置有所述升级镜像区域、所述主镜像区域、升级标志位以及Uboot,如图2所示。需要说明的是,所述升级镜像区域、所述主镜像区域在FLASH中的顺序不固定,可以根据需要进行设定。The upgrade mirror area, the main mirror area, the upgrade flag and the Uboot are configured in the FLASH of the switch, as shown in FIG. 2 . It should be noted that the order of the upgrade mirror area and the main mirror area in the FLASH is not fixed, and can be set as required.
示例性的,交换机正常升级可以分为两个阶段,第一个阶段是升级文件传输,在此阶段会将升级文件存放到FLASH的升级镜像区域,待升级文件传输完成后,检测升级镜像的完整性;如果升级镜像完整,则表明升级文件已经全部拷贝到升级镜像中,然后重启交换机;第二阶段是镜像覆盖,重启在Uboot阶段,Uboot会启动拷贝,将升级镜像拷贝到主镜像区域,拷贝完成后,检测主镜像的完整性,如果主镜像完整,则表明升级文件已经全部拷贝到主镜像区域中,然后再次重启交换机,此时交换机可以正常启动,升级完成。交换机在升级过程中,无论在哪一个阶段突发断电,再上电仍然可以正常启动,无需人工干预,实现了自动恢复断电导致的升级启动异常,能做到无感知恢复,保证交换机的正常使用。需要说明的是,升级文件拷贝到升级镜像区域后,升级镜像区域内可生成包括升级文件的升级镜像,同理,将升级进行拷贝到主镜像区域后,主镜像区域可生成包括升级文件的主镜像。Exemplarily, the normal upgrade of the switch can be divided into two stages. The first stage is the upgrade file transfer. In this stage, the upgrade file will be stored in the upgrade image area of FLASH. After the upgrade file transfer is completed, the integrity of the upgrade image is checked. If the upgrade image is complete, it means that all the upgrade files have been copied to the upgrade image, and then restart the switch; the second stage is image overwriting. In the Uboot stage, Uboot will start copying, copy the upgrade image to the main image area, and copy After completion, check the integrity of the master image. If the master image is complete, it means that all the upgrade files have been copied to the master image area, and then restart the switch again. At this time, the switch can be started normally and the upgrade is complete. During the upgrade process of the switch, no matter what stage it is suddenly powered off, it can still be started normally without manual intervention, which realizes the automatic recovery of the abnormal upgrade startup caused by the power failure, and can achieve non-sensing recovery to ensure that the switch is in good condition. Normal use. It should be noted that, after the upgrade files are copied to the upgrade mirror area, the upgrade mirror area including the upgrade files can be generated in the upgrade mirror area. Similarly, after the upgrade is copied to the main mirror area, the main mirror area can generate the main mirror area including the upgrade files. mirror.
在一种可选的实施例中,所述当检测到所述升级镜像区域内的升级镜像完整时,重启所述设备,包括:In an optional embodiment, when it is detected that the upgrade image in the upgrade image area is complete, restarting the device includes:
对所述升级镜像进行第一校验;performing a first check on the upgrade image;
在通过第一校验时,确定所述升级镜像完整,并置位升级标志位;When passing the first check, it is determined that the upgrade image is complete, and the upgrade flag is set;
在完成所述升级标志位置位后,重启所述设备;After completing the setting of the upgrade flag, restart the device;
在未通过所述第一校验时,确定所述升级镜像不完整,发出升级失败提示。When the first check is not passed, it is determined that the upgrade image is incomplete, and an upgrade failure prompt is issued.
在一种可选的实施例中,所述在所述设备重启后,将所述升级镜像拷贝到主镜像区域,包括:In an optional embodiment, after the device is restarted, copying the upgrade image to the main image area includes:
在所述设备重启后,读取所述升级标志位,并判断所述升级标志位是否为第一预设值;After the device is restarted, read the upgrade flag, and determine whether the upgrade flag is a first preset value;
当所述升级标志位为所述第一预设值时,将所述升级镜像拷贝到主镜像。When the upgrade flag bit is the first preset value, the upgrade image is copied to the primary image.
在一种可选的实施例中,所述当检测到所述主镜像区域内的主镜像完整时,再次重启所述设备,包括:In an optional embodiment, when it is detected that the master image in the master image area is complete, restarting the device again includes:
对所述主镜像进行第二校验;performing a second check on the primary image;
在通过所述第二校验时,确定所述主镜像完整,并复位所述升级标志位;When passing the second check, it is determined that the primary image is complete, and the upgrade flag is reset;
在完成所述升级标志位复位后,重启所述设备;After completing the reset of the upgrade flag bit, restart the device;
在未通过所述第二校验时,确定所述主镜像不完整,继续将所述升级镜像拷贝到主镜像。When the second check is not passed, it is determined that the primary image is incomplete, and the upgrade image continues to be copied to the primary image.
在一种可选的实施例中,所述在完成所述升级标志位复位后,重启所述设备之后,还包括:In an optional embodiment, after completing the reset of the upgrade flag bit and restarting the device, the method further includes:
读取所述升级标志位,并判断所述升级标志为是否为第二预设值;reading the upgrade flag bit, and judging whether the upgrade flag is a second preset value;
当所述升级标志位为所述第二预设值时,所述设备正常启动;When the upgrade flag is the second preset value, the device starts normally;
当所述升级标志位不为所述第二预设值时,继续将所述升级镜像拷贝到主镜像,直至所述主镜像通过所述第二校验。When the upgrade flag bit is not the second preset value, continue to copy the upgrade image to the primary image until the primary image passes the second check.
其中,所述第一预设值为1,第二预设值为0。Wherein, the first preset value is 1, and the second preset value is 0.
在一种可选的实施例中,所述对所述升级镜像进行第一校验,包括:In an optional embodiment, the performing the first verification on the upgrade image includes:
计算所述升级镜像的CRC;calculating the CRC of the upgrade image;
示例性,升级文件包含升级文件头部和升级文件主体两部分,所述升级文件头部包括CRC、升级文件主体长度(length)、空白PAD,比如4字节CRC、4字节升级文件主体长度(length)、8字节空白PAD(用于以后扩展)。编译时会通过标准CRC算法计算升级镜像的CRC,再同镜像长度一起填充到升级镜像的头部,然后将升级镜像头部和升级镜像组装为最终提供给用户的升级文件,升级镜像头部包括CRC、升级镜像长度、空白PAD;主镜像同理;文件结构如图4所示。Exemplarily, the upgrade file includes an upgrade file header and an upgrade file body, and the upgrade file header includes a CRC, an upgrade file main body length (length), and a blank PAD, such as a 4-byte CRC and a 4-byte upgrade file main body length. (length), 8-byte blank PAD (for later expansion). When compiling, the CRC of the upgrade image will be calculated by the standard CRC algorithm, and then filled into the header of the upgrade image together with the image length. Then, the upgrade image header and the upgrade image will be assembled into the upgrade file that is finally provided to the user. The upgrade image header includes CRC, upgrade image length, blank PAD; the same is true for the main image; the file structure is shown in Figure 4.
当所述升级镜像区域的CRC与所述升级镜像区域的头部的CRC一致时,确定通过所述第一校验;When the CRC of the upgrade mirror area is consistent with the CRC of the header of the upgrade mirror area, it is determined that the first check is passed;
当所述升级镜像区域的CRC与所述升级镜像区域的头部的CRC不一致时,确定未通过所述第一校验。When the CRC of the upgrade mirror area is inconsistent with the CRC of the header of the upgrade mirror area, it is determined that the first check is not passed.
在一种可选的实施例中,所述对所述主镜像进行第二校验,包括:In an optional embodiment, the performing the second check on the primary image includes:
计算所述主镜像的CRC;Calculate the CRC of the primary image;
当所述主镜像的CRC与升级镜像区域的镜像头部存放的CRC一致时,确定通过所述第二校验;When the CRC of the main image is consistent with the CRC stored in the image header of the upgrade image area, it is determined that the second check is passed;
当所述主镜像的CRC与升级镜像区域的镜像头部存放的CRC不一致时,确定未通过所述第二校验。When the CRC of the main image is inconsistent with the CRC stored in the image header of the upgrade image area, it is determined that the second check is not passed.
具体拷贝时,升级镜像(包含头部)全部拷贝到主镜像区域,拷贝完后校验主镜像区域除去头部算出的CRC和升级镜像区域的镜像头部存放的CRC对比。When copying, the upgrade image (including the header) is copied to the main image area. After copying, the CRC calculated from the main image area except the header is compared with the CRC stored in the image header of the upgrade image area.
下面结合图3对本发明实施例的整个交换机升级流程进行说明。The entire switch upgrade process according to the embodiment of the present invention will be described below with reference to FIG. 3 .
步骤1:开始升级;Step 1: Start the upgrade;
步骤2:将升级文件拷贝到升级镜像区域;Step 2: Copy the upgrade file to the upgrade mirror area;
步骤3:判断升级镜像CRC校验是否通过;若否,则提示用户升级失败;若是,则将升级标志位置1;Step 3: judge whether the upgrade image CRC check is passed; if not, prompt the user that the upgrade fails; if so, set the upgrade flag to 1;
步骤4:重启交换机;Step 4: Restart the switch;
步骤5:判断升级标志位是否为1;若否,则表示无可升级文件,跳转到步骤11,其中,在步骤11中交换机以旧镜像正常启动;若是,跳转到下一步;Step 5: determine whether the upgrade flag is 1; if not, it means that there is no upgrade file, and jump to step 11, where the switch starts normally with the old image in
步骤6:将升级镜像拷贝到主镜像区域;Step 6: Copy the upgrade image to the main image area;
步骤7:判断主镜像CRC校验是否通过;若否,则返回步骤6;若是,跳转到下一步;Step 7: judge whether the main image CRC check is passed; if not, return to step 6; if so, jump to the next step;
步骤8:将升级标志位置0;Step 8: Set the upgrade flag to 0;
步骤9:重启交换机;Step 9: Restart the switch;
步骤10:判断升级标志位是否为0;若否,则跳转到步骤6;若是,则表示无可升级文件,跳转到下一步;Step 10: determine whether the upgrade flag is 0; if not, jump to step 6; if so, it means that there is no upgrade file, and jump to the next step;
步骤11:正常启动交换机。Step 11: Start the switch normally.
在本发明实施例中,在交换机升级过程中,当突发断电出现在文件传输阶段时,由于镜像CRC校验还未进行,升级标志位还是0,所以重新上电后,交换机可以以旧镜像启动;当在重启后镜像覆盖阶段突发断电,由于升级标志位还未置0,重新上电后,又会因为检测到升级标志位为1而重新进行镜像覆盖动作,直到最终镜像覆盖完成,清零升级标志位,从而使得交换机无论在整个升级流程哪一个阶段出现突发断电,都不会导致重新上电后,交换机无法启动的问题;同时整个升级过程无需人工干预,可以自动恢复断电导致的升级启动异常,做到无感知恢复,保证用户的正常使用。In the embodiment of the present invention, during the switch upgrade process, when a sudden power failure occurs in the file transfer stage, since the mirror CRC check has not been performed, the upgrade flag is still 0, so after the switch is powered on again, the switch can use the old Mirror startup; when there is a sudden power failure during the mirror overlay stage after restarting, since the upgrade flag has not been set to 0, after the power is turned on again, the mirror overlay action will be performed again because the upgrade flag is detected to be 1 until the final mirror overlay. After completion, clear the upgrade flag bit, so that no matter at which stage of the whole upgrade process the switch has a sudden power failure, it will not cause the problem that the switch cannot be started after power-on again; at the same time, the entire upgrade process does not require manual intervention, and can Recover the abnormal upgrade startup caused by power failure, achieve non-perceptual recovery, and ensure the normal use of users.
实施例二Embodiment 2
本发明实施例提供了一种设备,包括:An embodiment of the present invention provides a device, including:
存储器,用于存储计算机程序;memory for storing computer programs;
处理器,用于执行所述计算机程序时实现如实施例一任一项所述的设备升级方法。The processor is configured to implement the device upgrading method according to any one of the embodiments when executing the computer program.
所述处理器执行所述计算机程序时实现上述设备升级方法实施例中的步骤,例如图1所示的步骤S1-S4。When the processor executes the computer program, the steps in the above embodiments of the device upgrading method are implemented, for example, steps S1-S4 shown in FIG. 1 .
示例性的,所述设备可以是交换机或其他网关设备。如图5所示,该设备包括:至少一个处理器11,例如CPU,至少一个网络接口14或者其他用户接口13,存储器15,至少一个通信总线12,通信总线12用于实现这些组件之间的连接通信。其中,用户接口13可选的可以包括USB接口以及其他标准接口、有线接口。网络接口14可选的可以包括Wi-Fi接口以及其他无线接口。存储器15可能包含高速RAM存储器,也可能还包括非不稳定的存储器(non-volatilememory),例如至少一个磁盘存储器。存储器15可选的可以包含至少一个位于远离前述处理器11的存储装置。Exemplarily, the device may be a switch or other gateway device. As shown in FIG. 5, the device includes: at least one
在一些实施方式中,存储器15存储了如下的元素,可执行模块或者数据结构,或者他们的子集,或者他们的扩展集:In some embodiments,
操作系统151,包含各种系统程序,用于实现各种基础业务以及处理基于硬件的任务;The
程序152。
具体地,处理器11用于调用存储器15中存储的程序152,执行上述实施例所述的设备升级方法,例如图1所示的步骤S1-S4。Specifically, the
示例性的,所述计算机程序可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器中,并由所述处理器执行,以完成本发明。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序在所述设备中的执行过程。Exemplarily, the computer program may be divided into one or more modules/units, and the one or more modules/units are stored in the memory and executed by the processor to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the apparatus.
所述设备可包括,但不仅限于,处理器、存储器。本领域技术人员可以理解,所述示意图仅仅是交换机的示例,并不构成对交换机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件。The device may include, but is not limited to, a processor, a memory. Those skilled in the art can understand that the schematic diagram is only an example of a switch, and does not constitute a limitation on the switch, and may include more or less components than the one shown, or combine some components, or different components.
所称处理器11可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等,所述处理器11是所述设备的控制中心,利用各种接口和线路连接整个交换机的各个部分。The so-called
所述存储器15可用于存储所述计算机程序和/或模块,所述处理器11通过运行或执行存储在所述存储器内的计算机程序和/或模块,以及调用存储在存储器内的数据,实现所述设备的各种功能。所述存储器15可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据手机的使用所创建的数据(比如音频数据、电话本等)等。此外,存储器15可以包括高速随机存取存储器,还可以包括非易失性存储器,例如硬盘、内存、插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)、至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。The
其中,所述设备集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。Wherein, if the modules/units integrated in the device are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable storage medium. Based on this understanding, the present invention can implement all or part of the processes in the methods of the above embodiments, and can also be completed by instructing relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed by the processor, the steps of the foregoing method embodiments can be implemented. Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form, and the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.
实施例三,本发明实施例提供了一种计算机可读存储介质,所述计算机可读存储介质包括存储的计算机程序,其中,在所述计算机程序运行时控制所述计算机可读存储介质所在设备执行如实施例一任一项所述的设备升级方法。
需说明的是,以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本发明提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。It should be noted that the device embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical unit, that is, it can be located in one place, or it can be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. In addition, in the drawings of the apparatus embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. Those of ordinary skill in the art can understand and implement it without creative effort.
以上所述是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出多台改进和润饰,这些改进和润饰也视为本发明的保护范围。The above are the preferred embodiments of the present invention. It should be pointed out that for those skilled in the art, without departing from the principles of the present invention, many improvements and modifications can be made. It is regarded as the protection scope of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210607284.5A CN114995852A (en) | 2022-05-31 | 2022-05-31 | Device upgrade method, device and computer-readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210607284.5A CN114995852A (en) | 2022-05-31 | 2022-05-31 | Device upgrade method, device and computer-readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114995852A true CN114995852A (en) | 2022-09-02 |
Family
ID=83031966
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210607284.5A Pending CN114995852A (en) | 2022-05-31 | 2022-05-31 | Device upgrade method, device and computer-readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114995852A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116501357A (en) * | 2023-06-28 | 2023-07-28 | 广东高斯宝电气技术有限公司 | Online upgrade method of singlechip |
CN118626119A (en) * | 2024-07-25 | 2024-09-10 | 中星联华科技(北京)有限公司 | System upgrade method and device based on image file |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103488501A (en) * | 2013-09-09 | 2014-01-01 | 青岛海信宽带多媒体技术有限公司 | Optical network terminal equipment and system software upgrade method thereof |
CN108376077A (en) * | 2018-02-11 | 2018-08-07 | 广东美的厨房电器制造有限公司 | The upgrade method and device of control unit |
WO2021115477A1 (en) * | 2019-12-13 | 2021-06-17 | 中兴通讯股份有限公司 | Program upgrade method and apparatus, electronic device and storage medium |
CN113114730A (en) * | 2021-03-22 | 2021-07-13 | 深圳市晨北科技有限公司 | Upgrading method and device, terminal equipment and storage medium |
CN114296757A (en) * | 2021-12-20 | 2022-04-08 | 歌尔科技有限公司 | Software upgrading method and device for wearable equipment, wearable equipment and medium |
-
2022
- 2022-05-31 CN CN202210607284.5A patent/CN114995852A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103488501A (en) * | 2013-09-09 | 2014-01-01 | 青岛海信宽带多媒体技术有限公司 | Optical network terminal equipment and system software upgrade method thereof |
CN108376077A (en) * | 2018-02-11 | 2018-08-07 | 广东美的厨房电器制造有限公司 | The upgrade method and device of control unit |
WO2021115477A1 (en) * | 2019-12-13 | 2021-06-17 | 中兴通讯股份有限公司 | Program upgrade method and apparatus, electronic device and storage medium |
CN113114730A (en) * | 2021-03-22 | 2021-07-13 | 深圳市晨北科技有限公司 | Upgrading method and device, terminal equipment and storage medium |
CN114296757A (en) * | 2021-12-20 | 2022-04-08 | 歌尔科技有限公司 | Software upgrading method and device for wearable equipment, wearable equipment and medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116501357A (en) * | 2023-06-28 | 2023-07-28 | 广东高斯宝电气技术有限公司 | Online upgrade method of singlechip |
CN118626119A (en) * | 2024-07-25 | 2024-09-10 | 中星联华科技(北京)有限公司 | System upgrade method and device based on image file |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110083374B (en) | Upgrade rollback method, system and terminal equipment | |
KR100750132B1 (en) | How to boot, automatically update software and recover from errors, and the system and computer-readable recording media recording the method | |
US8539471B2 (en) | Updating firmware of an electronic device | |
CN102165422B (en) | Firmware update device and method | |
TW202030602A (en) | The method and system of bios recovery and update | |
JPWO2013103023A1 (en) | Information processing apparatus, information processing method, and computer program | |
WO2016206514A1 (en) | Startup processing method and device | |
CN113254048B (en) | Method, device and equipment for updating boot program and computer readable medium | |
TWI764454B (en) | Firmware corruption recovery | |
CN114995852A (en) | Device upgrade method, device and computer-readable storage medium | |
CN116932010B (en) | System firmware upgrading method, device and server | |
CN114265603A (en) | System upgrade method, device and electronic device based on asymmetric partition | |
CN117130672A (en) | Server start flow control method, system, terminal and storage medium | |
CN113867807A (en) | Method, device, equipment and storage medium for shortening power-on time of server | |
CN111090546B (en) | Method, device and equipment for restarting operating system and readable storage medium | |
JP6599725B2 (en) | Information processing apparatus, log management method, and computer program | |
CN113778485A (en) | System operation method, device, electronic chip and storage medium of electronic chip | |
CN110286953B (en) | Method and device for starting embedded system, embedded device and storage medium | |
CN110045971B (en) | System upgrade recovery method and device | |
CN104834574B (en) | A kind of method and device solving system partitioning damage | |
CN116166292A (en) | Software upgrading method and server | |
CN113687851A (en) | Embedded device upgrade method and device | |
US20160004607A1 (en) | Information processing apparatus and information processing method | |
CN112667444A (en) | System upgrading method, storage medium and terminal equipment | |
CN117389598A (en) | Configuration update and hardening methods, devices, electronic equipment and storage media |
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 |