CN117714281A - Upgrading method and device of switch firmware and related products - Google Patents

Upgrading method and device of switch firmware and related products Download PDF

Info

Publication number
CN117714281A
CN117714281A CN202311740665.1A CN202311740665A CN117714281A CN 117714281 A CN117714281 A CN 117714281A CN 202311740665 A CN202311740665 A CN 202311740665A CN 117714281 A CN117714281 A CN 117714281A
Authority
CN
China
Prior art keywords
image file
switch
firmware
file corresponding
switch firmware
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311740665.1A
Other languages
Chinese (zh)
Inventor
杨成林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Aoxing Technology Co ltd
Original Assignee
Beijing Aoxing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Aoxing Technology Co ltd filed Critical Beijing Aoxing Technology Co ltd
Priority to CN202311740665.1A priority Critical patent/CN117714281A/en
Publication of CN117714281A publication Critical patent/CN117714281A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The application discloses a method and a device for upgrading switch firmware and related products. Comprising the following steps: acquiring an image file corresponding to switch firmware prestored in a storage device; writing the mirror image file corresponding to the switch firmware in the memory partition into a flash partition of the switch to obtain the mirror image file corresponding to the switch firmware written into the flash partition; and replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, thereby finishing the upgrading of the switch firmware. It can be seen that the present application stores the switch firmware to be upgraded in the storage device, and then writes the switch firmware to be upgraded in the storage device into the flash partition of the switch, so as to replace the switch firmware to be upgraded in the flash partition by the switch firmware to be upgraded. Therefore, the storage device is utilized to directly upgrade the switch firmware, and the reliability is improved.

Description

Upgrading method and device of switch firmware and related products
Technical Field
The present invention relates to the field of software upgrading technologies, and in particular, to a method and an apparatus for upgrading firmware of a switch, and related products.
Background
In the related art, the switch firmware is generally updated by means of an application program, such as starting the application program, and when the application program is in a running state, the switch firmware is updated. However, when the application program appears a bug, the upgrade of the switch firmware cannot be realized, and the reliability is poor. Therefore, how to improve reliability is a major concern for those skilled in the art.
Disclosure of Invention
Based on the above problems, the present application provides a method and apparatus for upgrading firmware of a switch, and related products, which aim to improve reliability. The embodiment of the application discloses the following technical scheme:
in a first aspect, the present application discloses a method for upgrading firmware of a switch, including:
acquiring an image file corresponding to switch firmware prestored in a storage device;
copying the mirror image file corresponding to the switch firmware into a memory partition of the switch to obtain the mirror image file corresponding to the switch firmware stored in the memory partition;
writing the image file corresponding to the switch firmware in the memory partition into a flash partition of the switch to obtain the image file corresponding to the switch firmware written into the flash partition;
and replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, thereby finishing the upgrading of the switch firmware.
Optionally, after the copying the image file corresponding to the switch firmware to the memory partition of the switch, obtaining the image file corresponding to the switch firmware stored in the memory partition, the method further includes:
carrying out hash calculation on the image file corresponding to the switch firmware to obtain a first hash value;
and carrying out hash calculation on the mirror image file corresponding to the switch firmware in the memory partition to obtain a second hash value.
Optionally, the writing the image file corresponding to the switch firmware in the memory partition into the flash partition of the switch to obtain the image file corresponding to the switch firmware written into the flash partition includes:
and if the first hash value is the same as the second hash value, performing erasing operation on the mirror image file corresponding to the switch firmware in the memory partition to obtain the mirror image file corresponding to the switch firmware written into the flash partition.
Optionally, after the obtaining the image file corresponding to the switch firmware written in the flash partition, the method further includes:
carrying out hash calculation on the image file corresponding to the switch firmware in the flash partition to obtain a third hash value;
and if the second hash value is the same as the third hash value, executing the step of replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, and finishing the upgrading of the switch firmware.
Optionally, the method further comprises:
and if the second hash value is different from the third hash value, repeating the step of erasing the image file corresponding to the switch firmware in the memory partition within a preset frequency threshold to obtain the image file corresponding to the switch firmware in the flash partition.
Optionally, the obtaining an image file corresponding to the switch firmware stored in advance in the storage device includes:
acquiring switch firmware prestored in a storage device;
and packing and compressing the switch firmware to obtain an image file corresponding to the switch firmware.
Optionally, before replacing the image to-be-updated file corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, the method further includes:
copying the image file to be upgraded corresponding to the switch firmware in the flash partition to the storage device.
In a second aspect, the present application discloses an upgrade apparatus for a switch firmware, including:
the image file acquisition unit is used for acquiring an image file corresponding to the switch firmware stored in the storage device in advance;
the mirror image file copying unit is used for copying the mirror image file corresponding to the switch firmware into a memory partition of the switch to obtain the mirror image file corresponding to the switch firmware stored in the memory partition;
the image file writing unit is used for writing the image file corresponding to the switch firmware in the memory partition into the flash partition of the switch to obtain the image file corresponding to the switch firmware written into the flash partition;
and the image file replacing unit is used for replacing the image file to be updated corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, so that the update of the switch firmware is completed.
Optionally, the upgrading device further includes:
the first hash value obtaining unit is used for carrying out hash calculation on the image file corresponding to the switch firmware to obtain a first hash value;
and the second hash value obtaining unit is used for carrying out hash calculation on the mirror image file corresponding to the switch firmware in the memory partition to obtain a second hash value.
Optionally, the image file writing unit is specifically configured to:
and if the first hash value is the same as the second hash value, performing erasing operation on the mirror image file corresponding to the switch firmware in the memory partition to obtain the mirror image file corresponding to the switch firmware written into the flash partition.
Optionally, the upgrading device further includes:
the third hash value obtaining unit is used for carrying out hash calculation on the image file corresponding to the switch firmware in the flash partition to obtain a third hash value;
and the first hash value judging unit is used for executing the step of replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition if the second hash value is the same as the third hash value, and completing the step of upgrading the switch firmware.
Optionally, the upgrading device further includes:
and the second hash value judging unit is used for repeatedly executing the step of erasing the image file corresponding to the switch firmware in the memory partition within a preset frequency threshold value if the second hash value is different from the third hash value, so as to obtain the image file corresponding to the switch firmware written into the flash partition.
Optionally, the image file obtaining unit is specifically configured to:
acquiring switch firmware prestored in a storage device;
and packing and compressing the switch firmware to obtain an image file corresponding to the switch firmware.
Optionally, the upgrading device further includes:
and the file to be upgraded copying unit is used for copying the image file to be upgraded corresponding to the switch firmware in the flash partition to the storage equipment.
In a third aspect, an embodiment of the present application provides an electronic device, including:
a memory for storing a computer program;
a processor for implementing the steps of the method for upgrading the switch firmware in the first aspect when executing the computer program.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method for upgrading switch firmware in the first aspect.
Compared with the prior art, the application has the following beneficial effects:
firstly, obtaining an image file corresponding to a switch firmware stored in a storage device in advance, after that, copying the image file corresponding to the switch firmware to a memory partition of a switch, obtaining the image file corresponding to the switch firmware stored in the memory partition, writing the image file corresponding to the switch firmware in the memory partition to a flash partition of the switch, obtaining the image file corresponding to the switch firmware written to the flash partition, and finally, replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, thereby completing the upgrade of the switch firmware. It can be seen that, the switch firmware to be upgraded is pre-stored in the storage device, and then the switch firmware to be upgraded in the storage device is written into the flash partition of the switch, so that the switch firmware to be upgraded in the flash partition is replaced by the switch firmware to be upgraded. Therefore, the storage device is utilized to directly upgrade the switch firmware, and the reliability is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive faculty for a person skilled in the art.
Fig. 1 is a flowchart of a method for upgrading firmware of a switch according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of an upgrade apparatus for switch firmware according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the technical solutions in the embodiments of the present application will be made clearly and completely with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments herein without making any inventive effort are intended to fall within the scope of the present application.
It should be noted that, the method, the device and the related products for upgrading the switch firmware provided in the present application are used in the technical field of software upgrading, and the foregoing is merely an example and not limiting the application fields of the method and the device name provided in the present application.
As described above, in the related art, the switch firmware is generally updated by means of an application program, such as starting the application program, and the switch firmware is updated while the application program is in a running state. However, when the application program appears a bug, the upgrade of the switch firmware cannot be realized, and the reliability is poor. Therefore, how to improve reliability is a major concern for those skilled in the art.
In another related technology, it is proposed to upgrade the switch firmware by a network, for example, building a tftp server in a local area network, and connecting a serial port and a network cable, so as to upgrade the switch firmware. However, when the switch firmware is upgraded under the condition of poor network environment, faults are likely to occur, so that the reliability is poor, and the tftp server, the connection serial port and the network cable are built, so that the operation is possibly troublesome, and inconvenience is brought.
The inventor proposes the technical scheme of the application, firstly, the mirror image file corresponding to the switch firmware stored in the storage device is obtained, then the mirror image file corresponding to the switch firmware is copied to the memory partition of the switch, the mirror image file corresponding to the switch firmware stored in the memory partition is obtained, the mirror image file corresponding to the switch firmware in the memory partition is written to the flash partition of the switch, the mirror image file corresponding to the switch firmware written to the flash partition is obtained, finally, the mirror image to be upgraded file corresponding to the switch firmware in the flash partition is replaced by the mirror image file corresponding to the switch firmware in the flash partition, and the upgrading of the switch firmware is completed. It can be seen that, the switch firmware to be upgraded is pre-stored in the storage device, and then the switch firmware to be upgraded in the storage device is written into the flash partition of the switch, so that the switch firmware to be upgraded in the flash partition is replaced by the switch firmware to be upgraded. Therefore, the storage device is utilized to directly upgrade the switch firmware, so that the reliability is improved, and the condition of troublesome operation is reduced.
The method provided by the embodiment of the application can be executed by software on the terminal equipment. The terminal equipment can be, for example, mobile phones, tablet computers, computers and other equipment. The software may be, for example, system software.
Several terms which may be referred to in the embodiments below in this application are explained first.
uboot: uboot is a boot loader that is primarily used in embedded systems and can support a variety of different computer system architectures, including PPC, ARM, AVR, MIPS, x86, 68k, nios, and MicroBlaze.
flash: the nonvolatile random access memory is characterized in that data does not disappear after power failure, so the nonvolatile random access memory can be used as an external memory.
OHCI: open Host Controller Interface, open host controller interface.
MMC: microsoft management console.
FAT: FAT is a universal file system (FAT/exFAT) module for implementing FAT file systems in small embedded systems, which can be embedded in resource-limited microcontrollers such as 8051, pic, avr, arm, z80, rx, etc.
In order to provide a better understanding of the present application, those skilled in the art will now make further details of the present application with reference to the drawings and detailed description.
An upgrade method for switch firmware provided in the present application is described below by using an embodiment.
Referring to fig. 1, the flowchart of a method for upgrading switch firmware according to an embodiment of the present application is shown in fig. 1, where the method includes:
s101: and acquiring an image file corresponding to the switch firmware stored in the storage device in advance.
In this step, the storage device includes devices with portability, such as a usb disk and an SD card, and the image file corresponding to the switch firmware stored in advance is the image file corresponding to the switch firmware to be upgraded. Such as: the mirror image file corresponding to the switch firmware of the high version is stored in the U disk in advance, so that the mirror image file corresponding to the switch firmware of the low version in the switch can be replaced by the mirror image file corresponding to the switch firmware of the high version in the subsequent process.
It should be noted that, the storage device may be inserted into a switch in a uboot environment, where the switch enables a USB OHCI function to support that uboot in the switch may identify the state of the storage device and the storage device, and after identifying the storage device, the MMC driver is migrated so that uboot may initialize the storage device, that is, may operate the storage device, and under the support of the FAT file system, may read a file in the storage device (that is, an image file corresponding to the pre-stored firmware of the switch) in the FAT32 format. The uboot can also detect a flash chip to be used, so that the firmware of the switch is upgraded in a flash partition in the flash chip in a subsequent process.
Further, in the present application, the switch firmware stored in the storage device in advance may be first obtained, and then the switch firmware is packaged and compressed, so as to obtain an image file corresponding to the switch firmware. In some examples, the image file corresponding to the pre-stored switch firmware may be obtained directly from the root directory of the storage device. The image file is a file in a single form, and is convenient to transmit and download.
S102: copying the mirror image file corresponding to the switch firmware into a memory partition of the switch to obtain the mirror image file corresponding to the switch firmware stored in the memory partition.
In this step, the switch includes a memory partition in FAT32 format, and before copying the image file corresponding to the switch firmware into the memory partition of the switch, it may also be determined whether the memory partition in the switch is a memory partition in FAT32 format, and if the memory partition in the switch is a memory partition in FAT32 format, the image file corresponding to the switch firmware is copied into the memory partition of the switch.
It should be noted that, in the present application, after the image file corresponding to the switch firmware is copied to the memory partition of the switch, the image file corresponding to the switch firmware stored in the memory partition is obtained, hash calculation may also be performed on the image file corresponding to the switch firmware, so as to obtain a first hash value; and performing hash calculation on the image file corresponding to the switch firmware in the memory partition to obtain a second hash value.
Further, it may also be determined whether the first hash value and the second hash value are the same, and if the first hash value and the second hash value are the same, step S103 is executed; if the first hash value is different from the second hash value, the file is indicated to have errors in the copying process, and the updating of the switch firmware is stopped at the moment. It should also be noted that the hash value in the present application may be an md5 value.
S103: and writing the image file corresponding to the switch firmware in the memory partition into a flash partition of the switch to obtain the image file corresponding to the switch firmware written into the flash partition.
Specifically, in this step, if the first hash value is the same as the second hash value, the image file corresponding to the switch firmware in the memory partition is subjected to erasing operation, so as to obtain the image file corresponding to the switch firmware written into the flash partition. After the image file corresponding to the switch firmware written into the flash partition is obtained, hash calculation can be performed on the image file corresponding to the switch firmware in the flash partition to obtain a third hash value.
Further, whether the second hash value is the same as the third hash value can be judged, if the second hash value is the same as the third hash value, the step of replacing the image to-be-updated file corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition is executed, and the step of updating the switch firmware is completed; and if the second hash value is different from the third hash value, repeatedly executing the erasing operation on the mirror image file corresponding to the switch firmware in the memory partition to obtain the mirror image file corresponding to the switch firmware in the flash partition, and judging whether the hash values are the same again, and if the number of times of the hash values is different is greater than a preset number of times threshold, indicating that the file is in error in the writing process, and stopping upgrading the switch firmware at the moment.
Such as: when the second hash value is different from the third hash value, the image file corresponding to the switch firmware in the memory partition can be rewritten to obtain the image file corresponding to the switch firmware in the flash partition, which is obtained by the current rewritten operation, and further, the image file corresponding to the switch firmware in the flash partition is subjected to hash calculation to obtain a new hash value. Judging whether the second hash value is the same as the new hash value, if so, executing the step of replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, and finishing the upgrading of the switch firmware; if the second hash value is different from the new hash value, repeating the process until the number of times that the hash values are different is greater than a preset number of times threshold value, and stopping upgrading the switch firmware.
In another implementation manner, since the first hash value and the second hash value are the same, whether the first hash value and the third hash value are the same or not can be further determined, if the first hash value and the third hash value are the same, the step of replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition is performed, and the step of upgrading the switch firmware is completed; and if the first hash value is different from the third hash value, repeatedly executing the erasing operation on the mirror image file corresponding to the switch firmware in the memory partition within the preset times threshold to obtain the mirror image file corresponding to the switch firmware written into the flash partition.
S104: and replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, thereby finishing the upgrading of the switch firmware.
It can be understood that, the image file corresponding to the switch firmware in the flash partition is an image file corresponding to the switch firmware to be upgraded, and when the image file corresponding to the switch firmware to be upgraded is subjected to the copying process and the writing process and the hash value is unchanged, the image file corresponding to the switch firmware to be upgraded can be replaced by the image file corresponding to the switch firmware to be upgraded, so as to complete the upgrade of the switch firmware.
Furthermore, before the image to-be-updated file corresponding to the switch firmware in the flash partition is replaced by the image file corresponding to the switch firmware in the flash partition, the image to-be-updated file corresponding to the switch firmware in the flash partition can be copied to the storage device, so that after the update fails and the file is damaged, the image to-be-updated file corresponding to the switch firmware in the flash partition can be retransmitted to the flash partition, and normal operation of the system is ensured. It should also be noted that, after the switch firmware is upgraded, the switch can be restarted, so that the switch can operate the upgraded switch firmware.
To sum up, in this embodiment, the switch firmware to be upgraded is stored in the storage device in advance, and then the switch firmware to be upgraded in the storage device is written into the flash partition of the switch, so that the switch firmware to be upgraded in the flash partition is replaced by the switch firmware to be upgraded. Therefore, the storage device is utilized to directly upgrade the switch firmware, so that the reliability is improved, and the condition of troublesome operation is reduced.
The following describes an apparatus for upgrading a switch firmware according to an embodiment of the present application, and the apparatus for upgrading a switch firmware described below and the method for upgrading a switch firmware described above may be referred to correspondingly.
Referring to fig. 2, the structure diagram of an upgrade apparatus for switch firmware provided in the embodiment of the present application is shown in fig. 2, where the upgrade apparatus for switch firmware includes:
an image file obtaining unit 201, configured to obtain an image file corresponding to a switch firmware stored in a storage device in advance;
an image file copying unit 202, configured to copy an image file corresponding to the switch firmware to a memory partition of the switch, so as to obtain an image file corresponding to the switch firmware stored in the memory partition;
an image file writing unit 203, configured to write an image file corresponding to the switch firmware in the memory partition into a flash partition of the switch, so as to obtain an image file corresponding to the switch firmware written into the flash partition;
and the image file replacing unit 204 is configured to replace an image file to be upgraded corresponding to the switch firmware in the flash partition with an image file corresponding to the switch firmware in the flash partition, so as to complete the upgrade of the switch firmware.
Optionally, the upgrading device further includes:
the first hash value obtaining unit is used for carrying out hash calculation on the image file corresponding to the switch firmware to obtain a first hash value;
and the second hash value obtaining unit is used for carrying out hash calculation on the mirror image file corresponding to the switch firmware in the memory partition to obtain a second hash value.
Optionally, the image file writing unit 203 is specifically configured to:
and if the first hash value is the same as the second hash value, performing erasing operation on the mirror image file corresponding to the switch firmware in the memory partition to obtain the mirror image file corresponding to the switch firmware written into the flash partition.
Optionally, the upgrading device further includes:
the third hash value obtaining unit is used for carrying out hash calculation on the image file corresponding to the switch firmware in the flash partition to obtain a third hash value;
and the first hash value judging unit is used for executing the step of replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition if the second hash value is the same as the third hash value, and completing the step of upgrading the switch firmware.
Optionally, the upgrading device further includes:
and the second hash value judging unit is used for repeatedly executing the step of erasing the image file corresponding to the switch firmware in the memory partition within a preset frequency threshold value if the second hash value is different from the third hash value, so as to obtain the image file corresponding to the switch firmware written into the flash partition.
Optionally, the image file obtaining unit 201 is specifically configured to:
acquiring switch firmware prestored in a storage device;
and packing and compressing the switch firmware to obtain an image file corresponding to the switch firmware.
Optionally, the upgrading device further includes:
and the file to be upgraded copying unit is used for copying the image file to be upgraded corresponding to the switch firmware in the flash partition to the storage equipment.
The upgrade device for the switch firmware provided in the embodiment of the present application has the same beneficial effects as the upgrade method for the switch firmware provided in the above embodiment, so that the description thereof is omitted.
Electronic device embodiment
Referring to fig. 3, the schematic structural diagram of an electronic device provided in an embodiment of the present application, as shown in fig. 3, includes:
a memory 11 for storing a computer program;
a processor 12, configured to implement the steps of the method for upgrading the switch firmware according to any of the method embodiments described above when executing the computer program.
In this embodiment, the device may be a PC (Personal Computer ), or may be a terminal device such as a smart phone, a tablet computer, a palm computer, or a portable computer.
The device may include a memory 11, a processor 12, and a bus 13. The memory 11 includes at least one type of readable storage medium including flash memory, a hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the device, such as a hard disk of the device. The memory 11 may in other embodiments also be an external storage device of the device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the device. Further, the memory 11 may also include both an internal storage unit of the device and an external storage device. The memory 11 may be used not only for storing application software installed in the device and various types of data, but also for temporarily storing data that has been output or is to be output.
The processor 12 may in some embodiments be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor or other data processing chip for executing program code or processing data stored in the memory 11.
The bus 13 may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus, or an extended industry standard architecture (extended industry standard architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in fig. 3, but not only one bus or one type of bus.
Further, the device may also include a network interface 14, and the network interface 14 may optionally include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), typically used to establish a communication connection between the device and other electronic devices.
Optionally, the device may further comprise a user interface 15, the user interface 15 may comprise a Display (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 15 may further comprise a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like. The display may also be referred to as a display screen or display unit, as appropriate, for displaying information processed in the device and for displaying a visual user interface.
Fig. 3 shows only a device having components 11-15, it will be understood by those skilled in the art that the configuration shown in fig. 3 is not limiting of the device and may include fewer or more components than shown, or may combine certain components, or a different arrangement of components.
Readable storage medium embodiments
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program realizes the steps of the method for upgrading the switch firmware when being executed by a processor. Wherein the storage medium may include: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It should be further noted that, in the embodiments of the present application, the "first" and the "second" in the names of "first" and "second" (where any exists) are only used for name identification, and do not represent the first and second in sequence.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The method, the device and the related products for upgrading the switch firmware provided by the application are described in detail. Specific examples are set forth herein to illustrate the principles and embodiments of the present application, and the description of the examples above is only intended to assist in understanding the methods of the present application and their core ideas. It should be noted that it would be obvious to those skilled in the art that various improvements and modifications can be made to the present application without departing from the principles of the present application, and such improvements and modifications fall within the scope of the claims of the present application.

Claims (10)

1. A method for upgrading firmware of a switch, comprising:
acquiring an image file corresponding to switch firmware prestored in a storage device;
copying the mirror image file corresponding to the switch firmware into a memory partition of the switch to obtain the mirror image file corresponding to the switch firmware stored in the memory partition;
writing the image file corresponding to the switch firmware in the memory partition into a flash partition of the switch to obtain the image file corresponding to the switch firmware written into the flash partition;
and replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, thereby finishing the upgrading of the switch firmware.
2. The upgrade method according to claim 1, wherein after the copying the image file corresponding to the switch firmware to the memory partition of the switch, obtaining the image file corresponding to the switch firmware stored in the memory partition, further comprises:
carrying out hash calculation on the image file corresponding to the switch firmware to obtain a first hash value;
and carrying out hash calculation on the mirror image file corresponding to the switch firmware in the memory partition to obtain a second hash value.
3. The upgrade method according to claim 2, wherein writing the image file corresponding to the switch firmware in the memory partition into the flash partition of the switch to obtain the image file corresponding to the switch firmware written into the flash partition, includes:
and if the first hash value is the same as the second hash value, performing erasing operation on the mirror image file corresponding to the switch firmware in the memory partition to obtain the mirror image file corresponding to the switch firmware written into the flash partition.
4. The upgrade method according to claim 3, further comprising, after the obtaining the image file corresponding to the switch firmware written in the flash partition:
carrying out hash calculation on the image file corresponding to the switch firmware in the flash partition to obtain a third hash value;
and if the second hash value is the same as the third hash value, executing the step of replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, and finishing the upgrading of the switch firmware.
5. The upgrade method of claim 4, further comprising:
and if the second hash value is different from the third hash value, repeating the step of erasing the image file corresponding to the switch firmware in the memory partition within a preset frequency threshold to obtain the image file corresponding to the switch firmware in the flash partition.
6. The upgrade method according to claim 1, wherein the obtaining the image file corresponding to the switch firmware stored in the storage device in advance includes:
acquiring switch firmware prestored in a storage device;
and packing and compressing the switch firmware to obtain an image file corresponding to the switch firmware.
7. The upgrade method according to claim 1, wherein before replacing the image file to be upgraded corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, the upgrade method further comprises:
copying the image file to be upgraded corresponding to the switch firmware in the flash partition to the storage device.
8. An apparatus for upgrading firmware of a switch, comprising:
the image file acquisition unit is used for acquiring an image file corresponding to the switch firmware stored in the storage device in advance;
the mirror image file copying unit is used for copying the mirror image file corresponding to the switch firmware into a memory partition of the switch to obtain the mirror image file corresponding to the switch firmware stored in the memory partition;
the image file writing unit is used for writing the image file corresponding to the switch firmware in the memory partition into the flash partition of the switch to obtain the image file corresponding to the switch firmware written into the flash partition;
and the image file replacing unit is used for replacing the image file to be updated corresponding to the switch firmware in the flash partition with the image file corresponding to the switch firmware in the flash partition, so that the update of the switch firmware is completed.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of a method for upgrading switch firmware according to any of claims 1 to 7 when executing said computer program.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of a method of upgrading a switch firmware according to any of claims 1-7.
CN202311740665.1A 2023-12-18 2023-12-18 Upgrading method and device of switch firmware and related products Pending CN117714281A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311740665.1A CN117714281A (en) 2023-12-18 2023-12-18 Upgrading method and device of switch firmware and related products

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311740665.1A CN117714281A (en) 2023-12-18 2023-12-18 Upgrading method and device of switch firmware and related products

Publications (1)

Publication Number Publication Date
CN117714281A true CN117714281A (en) 2024-03-15

Family

ID=90154968

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311740665.1A Pending CN117714281A (en) 2023-12-18 2023-12-18 Upgrading method and device of switch firmware and related products

Country Status (1)

Country Link
CN (1) CN117714281A (en)

Similar Documents

Publication Publication Date Title
CN109634645B (en) Firmware upgrading method and terminal
US8539471B2 (en) Updating firmware of an electronic device
US9804832B2 (en) Method, apparatus, and communication device for updating firmware
EP2375323A1 (en) Firmware image update and management
US9959125B2 (en) Field update of boot loader using regular device firmware update procedure
US7512777B2 (en) Method and system for maintaining system management BIOS
CN111813428A (en) Method and device for upgrading terminal firmware, electronic equipment and storage medium
CN104123153A (en) Apparatus and method for firmware upgrade using USB
CN107908417B (en) Firmware upgrading method and electronic equipment
CN110851154B (en) Computer-implemented method, system, and medium for updating read-only memory code
CN108694052B (en) Firmware upgrading method, firmware upgrading device and firmware upgrading system
CN115756561A (en) Software upgrading method and device, computer equipment and storage medium
CN111221553A (en) Firmware upgrading method and device
CN108153548A (en) A kind of EMMC firmware upgrade methods and device
CN109522174B (en) Method, device, terminal and storage medium for controlling adb enabling
CN117714281A (en) Upgrading method and device of switch firmware and related products
CN114296764A (en) System upgrading method and device, storage medium and electronic equipment
CN112667444A (en) System upgrading method, storage medium and terminal equipment
CN115185745A (en) Data processing method, system, electronic device and computer readable storage medium
CN113778485A (en) System operation method and device of electronic chip, electronic chip and storage medium
KR101190314B1 (en) System and Method for Updating Firmware Using Smart Phone App.
GB2471480A (en) Preventing boot crashes due to new files
CN112596759A (en) Method, device and system for upgrading MCU software based on TF card
CN113448600A (en) System installation method and device, upper computer and storage medium
CN114138305A (en) Reliable MCU firmware upgrading method

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