Background
When the embedded network device needs firmware update, the conventional operation is to upgrade the firmware through the WEB page of the device or to upgrade the firmware through the SSH login re-order line. However, under some abnormal conditions, such as WEB program abnormality or SSH failure to log in, or even firmware damage in FLASH failure to start, the conventional upgrading method is no longer applicable.
Generally speaking, Boot loaders in FLASH can work normally because of the write protection measures. Some advanced point systems can be started from other storage media (such as a U disk and an SD card) and then upgrade firmware by switching BOOT mode selection of a CPU (central processing unit), or upgrade firmware by other storage media under a BOOT loader, but the premise is that equipment needs to support a BOOT mode selection switch and a corresponding storage media interface. Many low-cost embedded network devices do not support or expose such BOOT mode selection, or support such external interfaces, or even have no outgoing console, such as IPC, wireless router, CPE, and some industrial gateway devices. The existing related repairing and brushing methods comprise the following steps:
1. programming FLASH on board programmers is supported, and the programmer interface is not usually exposed to the chassis.
2. When the programming of FLASH in a board programmer is not supported, the FLASH needs to be welded, and the off-line programmer is used for programming and then re-mounting.
The two firmware upgrading methods are time-consuming and labor-consuming, and operation can be performed without disassembling the shell.
Disclosure of Invention
The invention mainly aims to provide a method for upgrading firmware of an embedded network device without detaching a cover, which can upgrade the firmware only through a network port under the condition that a Boot loader works normally without detaching a shell.
Meanwhile, the invention also discloses a system for implementing the method.
According to a first aspect of the present invention, there is provided a method for upgrading firmware of an embedded network device without detaching a set cover, the method comprising the steps of:
step 1: starting a Boot loader, and entering a flashing mode;
step 2: acquiring network flashing agent firmware through a network card, wherein the network flashing agent firmware is prestored in a first peripheral server;
and step 3: storing the network flashing agent firmware into a memory and operating to obtain a network flashing agent system operating in the memory;
and 4, step 4: running a flashing script on the network flashing agent system, wherein the flashing script is obtained from a second peripheral server;
and 5: acquiring system firmware from a second peripheral server through a network card;
step 6: writing the system firmware into the formatted flash memory, automatically resetting the network flashing agent system after the firmware writing is finished, and running the system firmware in the flash memory to finish upgrading.
In the method for upgrading the firmware of the non-dismantling cover of the embedded network device, the step 1 specifically comprises:
and starting the Boot loader, and entering a flashing mode or normally starting a system of the embedded network equipment according to the user operation.
In the method for upgrading the firmware of the embedded network device without detaching the cover, the first server is a TFTP server, and the second server is an FTP server;
and starting the FTP client in the network flashing proxy system, and acquiring a flashing script and system firmware from the FTP server through the FTP client.
In the method for upgrading firmware of an embedded network device without detaching a set cover, the step 5 further includes: formatting and partitioning the flash memory according to the partition information; in the step 6, the system firmware is written into the designated partition;
and the partition information is recorded in the flashing script.
In the method for upgrading the firmware of the non-dismantling cover of the embedded network device, the network card initialization operation is further performed after the steps 1 and 4 are performed.
Meanwhile, the invention also discloses a system for upgrading the firmware of the embedded network equipment without detaching the machine cover, which comprises a first server and a second server, wherein the first server stores the network machine-refreshing agent firmware, and the second server stores the system firmware;
when the embedded network equipment needs to be upgraded, the network flashing agent firmware and the flashing script are obtained from the first server based on any one of the methods, and when the flashing script is run, the system firmware is obtained from the second server and is adopted to upgrade the firmware.
In the above system for upgrading the firmware without detaching the embedded network device, the first server is a TFTP server, and the second server is an FTP server.
One of the above technical solutions of the present invention has at least one of the following advantages or beneficial effects:
in the invention, the network flashing agent firmware is obtained and stored in the memory, the flashing script can be obtained by running the firmware, the system firmware can be obtained by running the flashing script, the network flashing agent system is automatically reset after the firmware is written in the flash memory, and the system firmware in the flash memory is run to realize the upgrading of the system firmware.
The method only needs the normal network card and can start the Boot loader.
The method and the system can be implemented under abnormal conditions such as damaged system firmware, abnormal WEB program or incapability of logging in by SSH, and can realize the purpose of upgrading the system firmware without detaching the machine.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention.
Example 1
Referring to fig. 1, a method for upgrading firmware of an embedded network device without detaching a set cover, the embedded network device having a network card and running a linux system, the method comprising the steps of:
step 1: starting a Boot loader, and entering a flashing mode;
in the last 20 years, embedded systems have used rom (eprom) as their storage device, however in recent years, Flash memory has fully replaced the status of rom (eprom) in embedded systems, and is used for storing Boot loaders and operating systems or program codes, or directly as hard disk.
The Boot loader needs to be started before the linux system, generally, the damage probability of system firmware is far greater than that of the Boot loader, and therefore the method is provided on the premise that the Boot loader can operate.
After Boot loader is started, if a user presses a certain key for a long time, such as a start key for 3s, the mode is started, and if the user does not do any operation, the linux system is operated and started normally.
Step 2: initializing a network card, and acquiring network flashing agent firmware through the network card, wherein the network flashing agent firmware is prestored in a first peripheral server; the first server is preferably a TFTP server that communicates with the device based on the simple file transfer protocol.
In this embodiment, the reason why the first server is preferably a TFTP server is that: FTP servers require TCP, while TFTP requires UDP. UDP is simple and easy to implement, whereas TCP is implemented in Bootloader in a non-tasking environment with a large workload.
Under a flashing mode, after a network card is initialized, network flashing agent firmware is obtained from a first server and written to a specified address of a memory;
bootloaders of different CPUs (different manufacturers or different CPU architectures) are generally not completely uniform. The specific address written on the memory after the first server acquires the network flashing agent firmware is specified in the Bootloader of the specific hardware platform. That is, at this stage, after the Bootloader enters the flush mode, the Bootloader knows which name of the flush agent firmware it needs to obtain from the TFTP server, and also knows which address of the memory the obtained flush agent firmware exists at. Generally, the version and the name of the flashing agent firmware are matched with the name and the model of the internet of things device, and the name and the model of the internet of things device are transmitted before the flashing agent firmware is acquired from the first server to search for the matched firmware.
And step 3: storing the network flashing agent firmware into a memory and operating the network flashing agent firmware; after the network flashing agent firmware is run, a network flashing agent system is run in the memory, and the agent system has necessary tools for running corresponding scripts and writing necessary information and tools of the firmware into the flash.
The machine-refreshing agent firmware is only required to be acquired by the bootloader and stored in the memory, and is guided to run by the bootloader.
And 4, step 4: running a flashing script on a network flashing agent system, initializing a network card, establishing an FTP client, and establishing a communication connection based on a file transfer protocol between the FTP client and a second server;
the system refreshing script is generated after the network refreshing agent firmware is started, and the memory address of the system firmware is recorded in the network refreshing script;
and 5: acquiring system firmware from a second peripheral server through a network card;
after the network flashing agent system starts to operate, the network flashing agent system downloads the flashing script from the second server, and the flashing script sysupdate.
The premise of programming the corresponding partition is to format and partition the flash memory, the formatting and the partitioning are performed according to the partition information, and the partition information is stored in a memory of the internet of things device and cannot be lost in the flashing process.
The partition information is used to format and partition the flash memory.
In the invention, the IP address stored in the firmware of the first server, whether the firmware of the first server is the flashing agent firmware, the flashing script or the system firmware, can be written into the memory of the Internet of things equipment in advance and cannot be lost due to the flashing process.
During the continuous updating process, the administrator can correspondingly update the relevant firmware and scripts in the first server and the second server.
How to distinguish the firmware and the script suitable for the device from the scripts and the firmware in the first server and the second server is achieved in many ways, for example, the name of the firmware script corresponds to the name and the model of the device, or a special folder is arranged to store the script and the firmware for a specific device, so that the required firmware and the script can be accurately acquired.
Step 6: writing the system firmware into the formatted flash memory, automatically resetting the network flashing agent system after the firmware writing is finished, and running the system firmware in the flash memory to finish upgrading.
The invention has the advantages that: the method can finish system upgrading only by starting the Boot loader with a normal network card, can be implemented under abnormal conditions such as damaged system firmware, abnormal WEB program or incapability of logging in by SSH and the like, and can realize the purpose of upgrading the system firmware without dismantling the machine.
Example 2
Referring to fig. 2, an embedded network device disassembly-free cover firmware upgrade system includes a first server 1 and a second server 2, wherein the first server stores a network update proxy firmware therein, and the second server stores a system firmware; the embedded network device 3 needs to be able to Boot the Boot loader and needs a network card 4 to be able to access the network.
When the embedded network device needs to perform firmware upgrade, the method according to embodiment 1 is used to obtain a network flush agent firmware from a first server and run a flush script, and when the flush script is run, a system firmware is obtained from a second server and the firmware upgrade is performed by using the system firmware, where the first server is a TFTP server and the second server is an FTP server.
While embodiments of the present invention have been shown and described, it will be understood by those of ordinary skill in the art that: various changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.