Disclosure of Invention
The invention aims to provide an eeprom version updating method and device, which realize updating of an eeprom version under the condition that the eeprom has no version number, and increase the expandability of NTB equipment.
In order to achieve the above object, an embodiment of the present invention provides an eeprom version updating method, including:
after the storage software is started, receiving an update request sent by an eeprom node;
reading the current content of the eeprom node, and generating a current bin file according to the current content;
acquiring a standard bin file from NTB equipment corresponding to the eeprom node;
comparing whether the current bin file is consistent with the standard bin file;
and if not, reading the standard file content corresponding to the standard bin file, and replacing the current content with the standard file content.
Wherein, before comparing whether the current bin file is consistent with the standard bin file, the method further comprises:
and carrying out byte alignment operation on the standard bin file.
Before reading the current content of the eeprom node, the method further comprises the following steps:
and judging whether the eeprom node is available according to the product specification of the NTB equipment corresponding to the eeprom node, and if so, executing a step of reading the current content of the eeprom node.
Reading standard file content corresponding to the standard bin file, and replacing the current content with the standard file content includes:
s1: reading the offset value and the data value of a target data item from the standard file content corresponding to the standard bin file;
s2: searching a corresponding data item in the current content according to the offset value;
s3: replacing the data value of the data item with the data value of the target data item;
s4: and judging whether the standard bin file is read completely, if not, taking the next item of the target data item as the target data item, and entering S1.
After receiving the update request sent by the eeprom node, the method further includes:
judging whether to execute the updating request or not by using a first-come-first-served strategy according to the node id and the request time in the updating request;
if yes, executing a step of reading the current content of the eeprom node;
and if not, returning an disapproval instruction to the eeprom node so that the eeprom node sends an updating request to the processor again after waiting for the preset time.
In order to achieve the above object, an embodiment of the present invention provides an eeprom version updating apparatus, including:
the receiving module is used for receiving an updating request sent by an eeprom node after the storage software is started;
the reading module is used for reading the current content of the eeprom node and generating a current bin file according to the current content;
an obtaining module, configured to obtain a standard bin file from an NTB device corresponding to the eeprom node;
the comparison module is used for comparing whether the current bin file is consistent with the standard bin file or not, and if not, the updating module is triggered;
and the updating module is used for reading the standard file content corresponding to the standard bin file and replacing the current content with the standard file content when the current bin file is inconsistent with the standard bin file.
Wherein, still include:
and the alignment module is used for carrying out byte alignment operation on the standard bin file.
Wherein, still include:
and the judging module is used for judging whether the eeprom node is available according to the product specification of the NTB equipment corresponding to the eeprom node, and if so, triggering the reading module.
Wherein, the update module specifically includes:
a reading unit, configured to read an offset value and a data value of a target data item from standard file content corresponding to the standard bin file;
the searching unit is used for searching the corresponding data item in the current content according to the offset value;
a replacement unit configured to replace the data value of the data item with the data value of the target data item;
and the judging unit is used for judging whether the reading of the standard bin file is finished, if not, taking the next item of the target data item as the target data item, and triggering the reading unit. Wherein, still include:
and the arbitration module is used for judging whether the update request is executed or not by utilizing a first-come-first-served strategy according to the node id and the request time in the update request, if so, the reading module is triggered, and if not, an disapproval instruction is returned to the eeprom node, so that the eeprom node can send the update request to the processor again after waiting for the preset time.
According to the scheme, the method for updating the eeprom version provided by the embodiment of the invention comprises the following steps: after the storage software is started, receiving an update request sent by an eeprom node; reading the current content of the eeprom node, and generating a current bin file according to the current content; acquiring a standard bin file from NTB equipment corresponding to the eeprom node; comparing whether the current bin file is consistent with the standard bin file; and if not, reading the standard file content corresponding to the standard bin file, and replacing the current content with the standard file content.
Therefore, the method for updating the eeprom version provided by the embodiment of the invention receives the update request sent by the eeprom node after the storage software is started, updates the current content of the eeprom node by using the standard bin file in the NTB device corresponding to the eeprom node, realizes the management of the eeprom version under the condition that the eeprom has no version number, and increases the expandability of the NTB device. The invention also discloses an eeprom version updating device which can achieve the technical effects.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention discloses an eeprom version updating method, which realizes updating of an eeprom version under the condition that the eeprom has no version number, and increases the expandability of NTB equipment.
Referring to fig. 1, a flowchart of an eeprom version updating method disclosed in the embodiment of the present invention is shown in fig. 1, and includes:
s101: after the storage software is started, receiving an update request sent by an eeprom node;
after the stored software is started each time, the processor receives an update request sent by an eeprom node, wherein the update request at least comprises a vendor id and a device id of an NTB (network node B) device corresponding to the eeprom node, so that the processor queries the NTB device corresponding to the eeprom node.
S102: reading the current content of the eeprom node, and generating a current bin file according to the current content;
in specific implementation, the processor reads the current content of the eeprom node through registers such as 0x260 and 0x264, and generates a current bin file under the tmp directory to prepare for subsequent comparison operation.
S103: acquiring a standard bin file from NTB equipment corresponding to the eeprom node;
in specific implementation, the processor queries the NTB device corresponding to the eeprom node through the vendor id and the device id in the update request, and acquires a standard bin file compatible with the NTB device from the NTB device to prepare for subsequent comparison operation.
S104: and comparing whether the current bin file is consistent with the standard bin file, if not, entering S105, and if so, ending the process.
And performing binary comparison on the current bin file and the standard bin file through a diff tool of linux, judging whether the current content of the eeprom node is compatible with the NTB equipment, if the current bin file is consistent with the content of the standard bin file, the current content of the eeprom node is compatible with the NTB equipment, ending the process, if the current bin file is inconsistent with the content of the standard bin file, updating the current content, and entering the next step.
S105: and reading the standard file content corresponding to the standard bin file, and replacing the current content with the standard file content.
And when the contents of the current bin file and the standard bin file are inconsistent, reading the standard file content corresponding to the standard bin file, and writing the standard file content into the eeprom node to replace the current content of the eeprom node.
According to the method for updating the eeprom version, after the storage software is started, the updating request sent by the eeprom node is received, the current content of the eeprom node is updated by using the standard bin file in the NTB equipment corresponding to the eeprom node, the management of the eeprom version is realized under the condition that the eeprom has no version number, and the expandability is increased for the NTB equipment.
The embodiment of the invention discloses an eeprom version updating method, and compared with the previous embodiment, the technical scheme is further explained and optimized in the embodiment. Specifically, the method comprises the following steps:
referring to fig. 2, a flowchart of another eeprom version updating method provided in the embodiment of the present invention is shown in fig. 2, and includes:
s201: after the storage software is started, receiving an update request sent by an eeprom node;
s221: judging whether the eeprom node is available according to the product specification of the NTB equipment corresponding to the eeprom node, if so, entering S222, and if not, ending the process;
before the whole updating process, according to the product specification of plx, whether the eprom node is available or not is judged by reading the state of the 0x260 register, if so, the updating process is started, and if not, the process is directly ended.
S222: reading the current content of the eeprom node, and generating a current bin file according to the current content;
s203: acquiring a standard bin file from NTB equipment corresponding to the eeprom node, and performing byte alignment operation on the standard bin file;
in the specific implementation, since the production process of the standard bin file is diversified, in order to ensure that the contents of the standard bin file are all valid, the byte alignment operation needs to be performed on the standard bin file. For example, a 6 byte alignment operation may be performed on a standard bin file.
S204: and comparing whether the current bin file is consistent with the standard bin file, if not, entering S205, and if so, ending the process.
S205: and reading the standard file content corresponding to the standard bin file, and replacing the current content with the standard file content.
On the basis of the foregoing embodiment, as a preferred implementation, reading the standard file content corresponding to the standard bin file, and replacing the current content with the standard file content includes:
s1: reading the offset value and the data value of a target data item from the standard file content corresponding to the standard bin file;
s2: searching a corresponding data item in the current content according to the offset value;
s3: replacing the data value of the data item with the data value of the target data item;
s4: and judging whether the standard bin file is read completely, if not, taking the next item of the target data item as the target data item, and entering S1.
In a specific implementation, the processor may read standard file contents corresponding to a standard bin file item by item, find a corresponding data item in current contents according to an offset value of a target data item, and replace a data value of the data item with a data value of the target data item until the current contents are all replaced with the standard file contents.
In the above example, 2 bytes may be read first, where the 2 bytes are offset values, then the next 4 bytes are read, where the 4 bytes are data values, the corresponding data item in the current content is found through the 0x260 register, an update instruction is sent to the eprom node, the data value of the data item is replaced with the data value of the target data item through the 0x264 register, and the above steps are repeated until the current content is completely replaced with the standard file content.
The method for updating the eeprom version disclosed by the embodiment of the invention can be used for the storage equipment of the double control node, and the temporary unavailability of the storage equipment caused by updating the eeprom node is avoided in order to ensure the reliability and the availability of the storage equipment. Specifically, the method comprises the following steps:
referring to fig. 3, a flowchart of another method for updating an eprom version provided in an embodiment of the present invention is shown in fig. 3, and includes:
s311: after the storage software is started, receiving an update request sent by an eeprom node;
s312: judging whether the updating request is executed or not by utilizing a first-come-first-serve strategy according to the node id and the request time in the updating request, if so, entering S321, and if not, returning an disapproval instruction to the eeprom node so that the eeprom node sends the updating request to the processor again after waiting for a preset time;
in a specific implementation, in order to avoid the temporary unavailability of a storage device caused when an eeprom node is updated, before the eeprom node is updated, whether to execute the update request needs to be judged by using a first-come-first-served policy according to the request time in the update request. It should be noted that the request time used by the two nodes may be provided by the same clock, or may be provided by a synchronous clock, and is not limited in particular herein. And when the updating request is executed, the next step is carried out, and when the updating request is not executed, an disapproval instruction is returned to the eeprom node, so that the eeprom node can send the updating request to the processor again after waiting for the preset time.
S321: judging whether the eeprom node is available according to the product specification of the NTB equipment corresponding to the eeprom node, if so, entering S322, and if not, ending the process;
s322: reading the current content of the eeprom node, and generating a current bin file according to the current content;
s303: acquiring a standard bin file from NTB equipment corresponding to the eeprom node, and performing byte alignment operation on the standard bin file;
s304: comparing whether the current bin file is consistent with the standard bin file, if not, entering S305, and if so, ending the process;
s305: and reading the standard file content corresponding to the standard bin file, and replacing the current content with the standard file content.
The eeprom version updating device provided by the embodiment of the present invention is introduced below, and the eeprom version updating device described below and the eeprom version updating method described above may refer to each other.
Referring to fig. 4, a structural diagram of an eeprom version updating apparatus according to an embodiment of the present invention is shown in fig. 4, and includes:
the receiving module 401 is configured to receive an update request sent by an eprom node after the storage software is started;
a reading module 402, configured to read current content of the eeprom node, and generate a current bin file according to the current content;
an obtaining module 403, configured to obtain a standard bin file from an NTB device corresponding to the eeprom node;
a comparison module 404, configured to compare whether the current bin file is consistent with the standard bin file, and if not, trigger the update module;
an updating module 405, configured to, when the current bin file is inconsistent with the standard bin file, read a standard file content corresponding to the standard bin file, and replace the current content with the standard file content.
According to the method for updating the eeprom version, after the storage software is started, the updating request sent by the eeprom node is received, the current content of the eeprom node is updated by using the standard bin file in the NTB equipment corresponding to the eeprom node, the management of the eeprom version is realized under the condition that the eeprom has no version number, and the expandability is increased for the NTB equipment.
In addition to the above embodiments, as a preferred embodiment, the method further includes:
and the alignment module is used for carrying out byte alignment operation on the standard bin file.
In addition to the above embodiments, as a preferred embodiment, the method further includes:
and the judging module is used for judging whether the eeprom node is available according to the product specification of the NTB equipment corresponding to the eeprom node, and if so, triggering the reading module.
On the basis of the foregoing embodiment, as a preferred implementation, the update module specifically includes:
a reading unit, configured to read an offset value and a data value of a target data item from standard file content corresponding to the standard bin file;
the searching unit is used for searching the corresponding data item in the current content according to the offset value;
a replacement unit configured to replace the data value of the data item with the data value of the target data item;
and the judging unit is used for judging whether the reading of the standard bin file is finished, if not, taking the next item of the target data item as the target data item, and triggering the reading unit.
The embodiment of the invention discloses an eeprom version updating device, and compared with the previous embodiment, the technical scheme is further explained and optimized in the embodiment. Specifically, the method comprises the following steps:
referring to fig. 5, a structure diagram of another eeprom version updating apparatus according to an embodiment of the present invention is shown in fig. 5, and includes:
a receiving module 501, configured to receive an update request sent by an eeprom node after the storage software is started;
the arbitration module 502 is configured to determine whether to execute the update request according to the node id and the request time in the update request by using a first-come-first-served policy, if so, trigger the reading module, and if not, return an disapproval instruction to the eprom node, so that the eprom node waits for a preset time and then sends the update request to the processor again;
a reading module 503, configured to read current content of the eeprom node, and generate a current bin file according to the current content;
an obtaining module 504, configured to obtain a standard bin file from an NTB device corresponding to the eeprom node;
a comparison module 505, configured to compare whether the current bin file is consistent with the standard bin file, and if not, trigger the update module;
an updating module 506, configured to, when the current bin file is inconsistent with the standard bin file, read a standard file content corresponding to the standard bin file, and replace the current content with the standard file content.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.