Hardware initialization method of switch, switch and storage medium

By acquiring multiple scheme images locally on the switch and using the bootloader to identify the hardware identity, the system accurately loads and matches the driver segment, thus solving the stability problem caused by software and hardware mismatch during switch initialization and improving the startup reliability and maintenance convenience of the switch.

CN121541892APending Publication Date: 2026-02-17深圳市三旺通信股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511499388.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-20
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

During switch initialization, the single-image-to-single-hardware solution results in low stability and is prone to initialization failure or system crash due to software and hardware incompatibility.

Method used

By acquiring image software containing multiple schemes locally on the switch, the bootloader reads the hardware feature registers to identify the current hardware identity, and accurately finds and loads the matching driver segment from the image to achieve hardware initialization.

Benefits of technology

It improves the reliability of switch startup and production flexibility, reduces the risk of initialization failure and system crash, and enhances the convenience of later maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121541892A_ABST
    Figure CN121541892A_ABST
Patent Text Reader

Abstract

The invention discloses a hardware initialization method of a switch, the switch and a storage medium, and belongs to the technical field of data processing. The method comprises the steps that pre-burnt mirror image software is obtained from a local nonvolatile memory of a switch, the mirror image software comprises scheme description segments and drive program segments corresponding to at least two hardware schemes, at least one hardware feature register of the switch is read according to a preset communication protocol by running a bootstrap program in the mirror image software, and the scheme description segments and the drive program segments correspond to the at least two hardware schemes. The method comprises the steps of obtaining a hardware feature value, searching a first hardware scheme matched with the hardware feature value in a scheme description section of mirror image software according to the hardware feature value, and loading a corresponding drive program section into a memory according to the first hardware scheme and executing the corresponding drive program section so as to complete switch hardware initialization. According to the method, multiple hardware schemes are integrated in single mirror image software, and intelligent matching is performed based on the hardware characteristic values, so that the problem of system faults caused by mismatching of software and hardware in the switch initialization stage is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a hardware initialization method for a switch, a switch, and a storage medium. Background Technology

[0002] In the production and maintenance of switches, the switch initialization is usually completed by customizing and burning a dedicated software image for a specific hardware solution.

[0003] In related technologies, each hardware solution requires the compilation of a corresponding independent software image file. During production or firmware upgrades, this specific image is burned into the switch's non-volatile memory. After the switch powers on, its bootloader directly loads and runs the drivers contained in this image, thereby completing the initialization.

[0004] However, the flashing of image software in related technologies is usually done in a "single image corresponding to a single hardware solution" mode. In this case, if the flashed software image does not match the actual hardware solution of the switch, the bootloader will still load the wrong driver, which can easily lead to driver initialization failure, abnormal system function, or even switch crash, reducing the stability of the switch.

[0005] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention

[0006] The main purpose of this application is to provide a hardware initialization method for a switch, a switch, and a storage medium, aiming to solve the technical problem of low stability in the initialization process of a switch.

[0007] To achieve the above objectives, this application provides a hardware initialization method for a switch, the method comprising the following steps: The pre-programmed image software is retrieved from the switch's local non-volatile memory. The image software contains at least two hardware scheme description segments and driver segments. By running the bootloader in the image software, at least one hardware feature register of the switch is read according to the preset communication protocol to obtain hardware feature values; Based on the hardware feature value, a first hardware solution matching the hardware feature value is searched in the solution description section of the image software. According to the first hardware solution, the corresponding driver segment is loaded into memory and executed to complete the switch hardware initialization.

[0008] In one embodiment, after the step of loading the corresponding driver segment into memory and executing it according to the first hardware solution to complete the switch hardware initialization, the method further includes: If the hardware replacement process of the switch is triggered, read the target hardware characteristic value in the target hardware register; Based on the target hardware feature values, a corresponding second hardware solution is determined in the image software; The second hardware solution is compared with the first hardware solution. If the comparison result is inconsistent, the hardware solution loaded on the switch is updated to the second hardware solution.

[0009] In one embodiment, before the step of reading the target hardware feature value in the target hardware register if the hardware replacement process of the switch is triggered, the method further includes: The hardware detector reads the current hardware characteristic value of the hardware status register at preset time intervals. The current hardware characteristic value is compared with the hardware characteristic value. If the comparison result is inconsistent, it is determined that a hardware replacement has occurred. This triggers the hardware replacement process of the switch.

[0010] In one embodiment, the step of searching for a first hardware solution matching the hardware feature value in the solution description segment of the image software includes: The parsing scheme description section contains a mapping table between feature values ​​and the hardware scheme; By traversing the feature values ​​in the mapping table, the read hardware feature value is compared with the feature value in the mapping table; If a matching feature value exists, the hardware scheme corresponding to the feature value is selected as the first hardware scheme, and the hardware scheme identifier corresponding to the hardware scheme is returned. If no perfectly matching feature value exists, a match failure signal is returned.

[0011] In one embodiment, after the step of returning a matching failure signal if no perfectly matching feature value exists, the method further includes: Calculate the similarity between the read hardware feature value and each feature value in the mapping table; The hardware solution corresponding to the feature value with the highest similarity is selected as the candidate solution; Output the hardware scheme identifier and / or scheme prompt information corresponding to the candidate scheme; If a solution confirmation message is received, the candidate solution is selected as the first hardware solution, and the driver segment of the first hardware solution is loaded.

[0012] In one embodiment, after the step of returning a matching failure signal if no perfectly matching feature value exists, the method further includes: If no first hardware solution matches the hardware feature value, a default driver segment is loaded in the image software, wherein the default driver segment is a compatible program segment that is common to different hardware. Based on the compatible program segment, the hardware feature value is sent to the solution server, and the response data packet fed back by the solution server is received. The target image software in the response data packet is burned into the non-volatile memory on the local side of the switch, and the target driver segment of the target image software is loaded.

[0013] In one embodiment, before the step of loading the corresponding driver segment into memory and executing it according to the first hardware solution to complete the switch hardware initialization, the method further includes: Calculate the amount of memory data in the driver segment, request memory space corresponding to the amount of memory data, and copy the driver segment from the non-volatile memory to the memory space; Based on a preset verification value algorithm, the driver segment loaded into the memory space is subjected to verification value calculation, and the calculation result is compared with the pre-stored target verification value. If the comparison results are consistent, the step of loading the corresponding driver segment into memory and executing it according to the first hardware solution is performed; If the comparison results are inconsistent, the driver segment in the image software will be reread, or an error report indicating that the driver was not loaded will be output.

[0014] In one embodiment, the step of obtaining hardware feature values ​​by running the bootloader in the image software and reading at least one hardware feature register of the switch according to a preset communication protocol further includes: The target feature values ​​of at least two hardware feature registers in the switch are read using the preset communication protocol. Based on preset feature value concatenation rules and / or the hardware type corresponding to the target feature value, the target feature value is concatenated to obtain the hardware feature value.

[0015] In addition, to achieve the above objectives, this application also provides a switch, the switch comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the hardware initialization method of the switch as described above.

[0016] In addition, to achieve the above objectives, this application also provides a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the hardware initialization method for the switch as described above.

[0017] One or more technical solutions proposed in this application have at least the following technical effects: This application acquires an image containing multiple hardware schemes from the local machine, and the bootloader reads the hardware feature registers to identify the current hardware identity. Then, it accurately locates and loads the correct driver segment that perfectly matches the hardware from the image to perform initialization. This integrates driver resources for multiple hardware schemes within a single image software, and solves the system failure problem caused by software-hardware incompatibility during the initialization phase by intelligently matching and loading based on hardware feature values. This allows the switch to automatically adapt to the correct driver without prior knowledge of its specific hardware configuration, effectively avoiding initialization failures or system crashes caused by loading incorrect drivers. This significantly improves the reliability of switch startup, production flexibility, and ease of subsequent maintenance. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating the first embodiment of the hardware initialization method for the switch in this application; Figure 2 This is a flowchart illustrating the second embodiment of the hardware initialization method for the switch in this application; Figure 3 This is a flowchart illustrating the third embodiment of the hardware initialization method for the switch in this application; Figure 4 This is a schematic diagram of the structure of the switch in the hardware operating environment involved in the embodiments of this application.

[0021] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0022] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0023] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.

[0024] The main solution of this application embodiment is as follows: obtain the pre-burned image software from the non-volatile memory of the switch. The image software contains at least two hardware scheme description segments and driver segments. By running the boot program in the image software, at least one hardware feature register of the switch is read according to the preset communication protocol to obtain the hardware feature value. According to the hardware feature value, the first hardware scheme that matches the hardware feature value is found in the scheme description segment of the image software. According to the first hardware scheme, the corresponding driver segment is loaded into memory and executed to complete the switch hardware initialization.

[0025] In existing technologies, each hardware solution requires a corresponding independent software image file to be compiled. During production or firmware upgrades, this specific image is burned into the switch's non-volatile memory. After the switch powers on, its bootloader directly loads and runs the drivers contained in this image, thus completing initialization. However, the burning of image software is typically a "single image corresponding to a single hardware solution" model. In this case, if the burned software image does not match the actual hardware solution of the switch, the bootloader will still load the wrong driver, which can easily lead to driver initialization failure, abnormal system functions, or even switch crashes, reducing the stability of the switch.

[0026] This application achieves initialization by acquiring a multi-scheme image from the local machine, having the bootloader read hardware feature registers to identify the current hardware identity, and then accurately finding and loading the correct driver segment that perfectly matches the image. This integrates driver resources for multiple hardware schemes within a single image software, and intelligently matches and loads drivers based on hardware feature values. This solves the system failure problem caused by software-hardware incompatibility during the initialization phase, allowing the switch to automatically adapt to the correct driver without prior knowledge of its specific hardware configuration. This effectively avoids initialization failures or system crashes caused by loading incorrect drivers, significantly improving the reliability of switch startup, production flexibility, and ease of later maintenance.

[0027] To better understand the above technical solutions, exemplary embodiments of this application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of this application are shown in the drawings, it should be understood that this application can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of this application and to fully convey the scope of this application to those skilled in the art.

[0028] It should be noted that the executing entity in this embodiment can be the main control program of a switch, or a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device capable of implementing the above functions, or a hardware initialization device for a switch, etc. This embodiment does not specifically limit it. The following uses the main control program of a switch as an example to describe this embodiment and the following embodiments.

[0029] Based on this, embodiments of this application provide a hardware initialization method for a switch, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the hardware initialization method for the switch in this application.

[0030] In this embodiment, the hardware initialization method of the switch includes steps S10 to S40: Step S10: Obtain the pre-programmed image software from the switch's local non-volatile memory. The image software includes a scheme description segment and a driver segment corresponding to at least two hardware schemes. In this embodiment, non-volatile memory is a storage medium that retains data even after power failure. It is characterized by random access capability and fast read / write speeds, making it suitable for storing boot code. The image software is a single binary file generated from program files for multiple hardware solutions using a specific packaging tool. It contains complete system boot code and driver resources for multiple hardware solutions.

[0031] Specifically, after power-on, the system-on-chip of the switch reads the initial code from the boot read-only memory (ROM) at a fixed address. This initial code initializes the basic memory controller and storage interface, accesses a specific partition of the non-volatile memory through the SDH Physical Interface (SPI) or Secure Digital Input and Output (SDIO) interface, reads the header information of the image file, verifies the digital signature and CRC check value of the image file to ensure integrity, and finally loads the main content of the image file into the internal cache for subsequent processing.

[0032] For example, if the main control program uses a xxxxx series switching chip, its non-volatile memory is SPINOR Flash, and the image file is stored in the address range of 0x00000000 to 0x00FxxxFF in the Flash. The file header contains the magic number 0xxx52564C to identify the image format. The technical effect of this step is to provide a complete and reliable multi-scheme resource foundation for subsequent hardware identification, ensuring resource availability during the initialization process.

[0033] Step S20: By running the boot program in the image software, at least one hardware feature register of the switch is read according to the preset communication protocol to obtain hardware feature values; In this embodiment, the bootloader is a piece of low-level executable code stored at the beginning of the image file, responsible for the initial setup of the hardware environment and the driving of basic peripherals. Hardware feature registers are specific storage units integrated into hardware components, used to store the hardware's identity and configuration parameters. The register addresses and reading methods of different manufacturers typically follow industry standards.

[0034] Specifically, the main control program first initializes the system clock and memory management unit through the bootloader. Then, it configures the timing parameters of the bus controller according to the preset communication protocol. Next, it sends a read command to the specified address of the target hardware characteristic register, waits for the hardware component to return response data, and finally parses and converts the read raw data to obtain standardized hardware characteristic values. For example, to read a chip's register, it needs to access the register identified by the address through the interface. The value of this register, 0xxx625xxA, indicates a specific version and model. This achieves unique identification of the hardware and provides accurate data input for scheme matching.

[0035] As an optional implementation, the main control program attempts to read multiple backup hardware feature registers in sequence, and uses the first successfully read and valid feature value as the hardware feature value. If all backup registers fail to be read, the driver segment corresponding to the default hardware scheme is loaded.

[0036] As another optional implementation, the main control program can also read the target feature values ​​of at least two hardware feature registers in the switch through a preset communication protocol, and based on the preset feature value splicing rules and / or the hardware type corresponding to the target feature value, splice the target feature values ​​to obtain the hardware feature values.

[0037] Step S30: Based on the hardware feature value, find the first hardware solution that matches the hardware feature value in the solution description section of the image software; In this embodiment, the scheme description segment is a special data structure segment in the image file, which contains a mapping table between hardware feature values ​​and drivers, as well as metadata information for each scheme. The lookup and matching process refers to quickly locating the scheme record corresponding to the current hardware feature value in the mapping table using a specific algorithm. Specifically, the main control program parses the mapping table between feature values ​​and hardware schemes in the scheme description segment, and compares the read hardware feature value with the feature values ​​in the mapping table by traversing the table. If a matching feature value exists, the hardware scheme corresponding to that feature value is selected as the first hardware scheme, and the hardware scheme identifier is returned. If no completely matching feature value exists, a matching failure signal is returned.

[0038] Specifically, the main control program parses the file format of the scheme description segment, extracts the starting address and number of entries of the mapping table, and then uses a binary search or hash search algorithm to traverse all entries. It compares the read hardware feature values ​​with the feature values ​​stored in the table bit by bit. When a completely matching entry is found, the scheme offset address of that entry is recorded. Finally, the corresponding hardware scheme identifier is extracted from the scheme description segment based on the scheme offset address. For example, the mapping table is stored using an ordered array structure, with each entry containing a 4-byte feature value and a 4-byte scheme address.

[0039] Optionally, if the switch master control program determines that no perfectly matching feature value exists, or receives a returned matching failure signal, it calculates the similarity between the read hardware feature value and each feature value in the mapping table, and selects the hardware scheme corresponding to the feature value with the highest similarity as a candidate scheme. The hardware scheme identifier and / or scheme prompt information corresponding to the candidate scheme are output to be displayed to the user. If a scheme confirmation message is received, the candidate scheme is selected as the first hardware scheme, and the driver segment of the first hardware scheme is loaded.

[0040] Optionally, if the switch's main control program determines that no first hardware solution matches the hardware characteristic values, a default driver segment is loaded into the image software. This default driver segment is a universally compatible program segment across different hardware, containing only driver instructions for implementing basic communication functions, enabling the switch's main control program to communicate with the solution server. Based on the compatible program segment, the hardware characteristic values ​​are sent to the solution server, and a response data packet is received from the solution server. The target image software in this response data packet is burned into the switch's local non-volatile memory, and the target driver segment of the target image software is loaded.

[0041] Step S40: According to the first hardware solution, load the corresponding driver segment into memory and execute it to complete the switch hardware initialization.

[0042] In this embodiment, the driver segment is a binary data block in the image file containing all the driver code for a specific hardware solution, including low-level register configuration code and mid-level interface functions. The main control program transfers the driver segment from the storage medium to memory and jumps to the entry point for execution to perform hardware initialization.

[0043] Specifically, the main control program requests contiguous physical memory space through the memory management unit based on the driver segment size and memory requirements recorded in the scheme description segment. Then, it uses the Data Access Management (DMA) controller or memory copy instructions to copy the driver segment from non-volatile memory to the allocated memory area. Next, it relocates and resolves the driver code loaded into memory. Finally, after setting the stack pointer and exception vector table, it jumps to the driver initialization function entry point.

[0044] For example, after loading the driver segment to address 0x800xxx00, the system jumps to the init_module function at address 0x800xxx10 to begin hardware initialization. Through the correct loading and running of the hardware driver, the complete functional initialization of the switch is achieved.

[0045] This application embodiment obtains an image containing multiple hardware schemes from the local machine, and the bootloader reads the hardware feature registers to identify the current hardware identity. Then, it accurately finds and loads the correct driver segment that perfectly matches the hardware from the image to perform initialization. This integrates driver resources for multiple hardware schemes within a single image software, and solves the system failure problem caused by software-hardware incompatibility during the initialization phase by intelligently matching and loading based on hardware feature values. This allows the switch to automatically adapt to the correct driver without prior knowledge of its specific hardware configuration, effectively avoiding initialization failures or system crashes caused by loading incorrect drivers. This significantly improves the reliability of switch startup, production flexibility, and ease of subsequent maintenance.

[0046] Based on the same inventive concept, this application also provides a second embodiment, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the hardware initialization method for the switch in this application.

[0047] In this embodiment, the hardware initialization method of the switch includes steps S51 to S53: Step S51: If the hardware replacement process of the switch is triggered, read the target hardware feature value in the target hardware register; In this embodiment, the switch can use a hardware detector to read the current hardware characteristic value of the hardware status register at preset time intervals and compare the current hardware characteristic value with the original hardware characteristic value. If the comparison result is inconsistent, it is determined that a hardware replacement has occurred, triggering the switch's hardware replacement process.

[0048] Step S52: Based on the target hardware feature values, determine the corresponding second hardware solution in the image software; Step S53: Compare the second hardware solution with the first hardware solution. If the comparison result is inconsistent, update the hardware solution loaded on the switch to the second hardware solution.

[0049] In this embodiment, the second hardware solution refers to the driver solution in the image software that matches the newly replaced hardware. The determination process requires full use of the multi-solution resource library integrated in the image software.

[0050] Specifically, the main control program first accesses the image software header in non-volatile memory, locates the starting address of the scheme description segment, parses the feature values ​​in the scheme description segment and the hardware scheme mapping table data structure, and uses a hash lookup algorithm to quickly compare the read target hardware feature values ​​with all feature values ​​in the mapping table. When a match is found, it records the storage offset address of the scheme in the image and the scheme identifier, and simultaneously obtains the driver size and memory requirement information of the scheme. If no perfect match is found, a similarity matching algorithm is started to select the closest candidate scheme or load a general compatible driver.

[0051] Furthermore, the main control program compares the scheme identifiers of the first hardware scheme and the second hardware scheme to see if they are completely identical. If they are different, it further compares the driver version numbers and hardware dependency characteristics of the two schemes. After the comparison results are different and it is confirmed that an update is needed, the main control program first saves the current hardware running state and data cache, unloads the driver of the currently running first hardware scheme, releases the memory resources and hardware interrupts it occupies, then loads the corresponding driver segment from the image into memory according to the information of the second hardware scheme, initializes the new hardware and restores the running state, and finally updates the system hardware configuration record.

[0052] This application enhances the dynamic response and processing capabilities for runtime hardware replacements, enabling the switch to automatically identify hardware changes and load the correct drivers without manual intervention. This significantly improves system reliability and maintainability, and reduces system downtime caused by hardware replacements.

[0053] Since the system described in Embodiment 2 of this application is a system used to implement the method of Embodiment 1 of this application, those skilled in the art can understand the specific structure and variations of the system based on the method described in Embodiment 1 of this application, and therefore will not be described again here. All systems used in the method of Embodiment 1 of this application fall within the scope of protection of this application.

[0054] Based on the same inventive concept, this application also provides a third embodiment, referring to... Figure 3 , Figure 3 This is a flowchart illustrating the third embodiment of the hardware initialization method for the switch in this application.

[0055] In this embodiment, the hardware initialization method of the switch includes steps S41 to S44: Step S41: Calculate the amount of memory data in the driver segment, request memory space corresponding to the amount of memory data, and copy the driver segment from the non-volatile memory to the memory space; In this embodiment, the memory data volume refers to the number of bytes occupied by the binary image of the driver segment. This information is usually stored in the metadata structure related to the corresponding scheme in the scheme description segment of the image file. The switch parses the scheme description segment by the bootloader to obtain the size information and suggested load address of the driver segment corresponding to the first hardware scheme. Then, it calls the address allocation function of the memory management module to request a contiguous memory space of appropriate size and address alignment. After successful allocation, the direct memory access controller initiates the data transfer operation from non-volatile memory to the target memory. The DMA controller efficiently completes the data transfer without consuming CPU resources. After the data transfer is completed, a transfer completion interrupt is triggered to notify the CPU for subsequent processing.

[0056] Step S42: Based on a preset check value algorithm, calculate the check value of the driver segment loaded into the memory space, and compare the calculation result with the pre-stored target check value; Step S43: If the comparison results are consistent, execute the step of loading the corresponding driver segment into memory and executing it according to the first hardware solution; Step S44: If the comparison results are inconsistent, then reread the driver segment in the image software, or output an error report of driver loading error.

[0057] In this embodiment, the main control program verifies the integrity of the driver segment during storage and loading to prevent system initialization failure or operational anomalies due to data corruption. The checksum algorithm is used to map data of arbitrary length to a fixed-length digest value; for example, a cyclic redundancy check algorithm or a hash algorithm is used. The pre-stored checksum is a baseline value calculated and stored in the checksum field during the image creation stage.

[0058] Specifically, the switch's bootloader reads the pre-stored checksum from the scheme description segment, selects the same checksum algorithm as when the image was created, such as the CRC32 algorithm, performs polynomial division calculations byte by byte on the driver segment just loaded into memory, generates a checksum value of the current driver content, compares the calculated real-time checksum with the pre-stored baseline checksum bit by bit, and generates a comparison result flag.

[0059] Upon receiving a successful verification signal, the CPU's program counter is set to point to the entry address of the driver's initialization function, and the runtime stack pointer and exception vector table are configured. The process then jumps to the driver code to begin hardware initialization. This involves configuring the various hardware registers, establishing interrupt handlers, and registering the switch interface, thus completing the initialization and commissioning of the entire hardware unit.

[0060] Alternatively, when a checksum mismatch is detected, the main control program will record an error log including the expected checksum, the actual checksum, and the failure timestamp. It will then attempt to reload the driver segment from non-volatile memory into another memory region and perform the checksum calculation again. If the number of retries exceeds the threshold and still fails, it will be considered a permanent error. A detailed error report, including the driver name, version, and checksum information, will be output via the serial port or network interface. At the same time, it will attempt to load a simplified safe mode driver or enter recovery mode to await external intervention.

[0061] The integrity verification process effectively prevents driver code errors caused by storage media damage, data transmission errors, etc., through a verification mechanism. It ensures that only verified and complete driver code can be executed, greatly improving the reliability and security of system startup and avoiding the risk of system instability or hardware damage due to driver corruption.

[0062] Since the system described in Embodiment 3 of this application is a system used to implement the method of Embodiment 1 of this application, those skilled in the art can understand the specific structure and variations of the system based on the method described in Embodiment 1 of this application, and therefore will not be described again here. All systems used in the method of Embodiment 1 of this application fall within the scope of protection of this application.

[0063] This application provides a switch, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the hardware initialization method of the switch in the first embodiment described above.

[0064] The following is for reference. Figure 4The diagram shows a structural schematic of a switch suitable for implementing embodiments of this application. Figure 4 The hardware initialization of the switch shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0065] like Figure 4 As shown, the hardware initialization of the switch can include a processing device 1001 (e.g., a core processor, graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The random access memory 1004 also stores various programs and data required for switch operation. The processing device 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tape, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the switch to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows switches with various systems, it should be understood that implementation or having all of the systems shown is not required. More or fewer systems may be implemented alternatively.

[0066] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0067] The switch provided in this application, employing the hardware initialization method of the switch in the above embodiments, can solve the technical problem of low stability in the switch initialization process. Compared with the prior art, the beneficial effects of the switch provided in this application are the same as those of the hardware initialization method of the switch provided in the above embodiments, and other technical features of this switch are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.

[0068] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0069] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0070] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the hardware initialization method of the switch in the above embodiments.

[0071] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, radio frequency (RF), etc., or any suitable combination thereof.

[0072] The aforementioned computer-readable storage medium may be included in the switch; or it may exist independently and not be assembled into the switch.

[0073] The aforementioned computer-readable storage medium carries one or more programs. When the aforementioned one or more programs are executed by the switch, the switch causes the switch to: retrieve pre-programmed image software from its local non-volatile memory. The image software contains scheme description segments and driver segments corresponding to at least two hardware schemes. By running the boot program in the image software, the switch reads at least one hardware feature register according to a preset communication protocol to obtain hardware feature values. Based on the hardware feature values, the switch searches for a first hardware scheme that matches the hardware feature values ​​in the scheme description segments of the image software. Based on the first hardware scheme, the switch loads the corresponding driver segment into memory and executes it to complete the switch hardware initialization.

[0074] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0075] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0076] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0077] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the hardware initialization method of the aforementioned switch, thereby solving the technical problem of low stability in the switch initialization process. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the hardware initialization method of the switch provided in the above embodiments, and will not be repeated here.

[0078] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method of hardware initialization of a switch, the method comprising: The method comprises the following steps: acquiring pre-burned image software from non-volatile memory local to the switch, the image software comprising a scheme description section and a driver section corresponding to at least two hardware schemes; reading at least one hardware feature register of the switch according to a preset communication protocol to obtain a hardware feature value by running a boot program in the image software; finding a first hardware scheme matching the hardware feature value in the scheme description section of the image software according to the hardware feature value; loading the corresponding driver section into memory and executing it according to the first hardware scheme to complete hardware initialization of the switch.

2. The method of claim 1, wherein, After the step of loading the corresponding driver section into memory and executing it according to the first hardware scheme to complete hardware initialization of the switch, the method further comprises: if a hardware replacement process of the switch is triggered, reading a target hardware feature value in a target hardware register; determining a second hardware scheme corresponding to the target hardware feature value in the image software according to the target hardware feature value; comparing the second hardware scheme with the first hardware scheme, and if the comparison result is inconsistent, updating the hardware scheme loaded in the switch to the second hardware scheme.

3. The method of claim 2, wherein, Before the step of reading a target hardware feature value in a target hardware register if a hardware replacement process of the switch is triggered, the method further comprises: reading a current hardware feature value of the hardware state register based on a preset time interval by a hardware detector; comparing the current hardware feature value with the hardware feature value, and determining that hardware replacement has occurred when the comparison result is inconsistent; triggering the hardware replacement process of the switch.

4. The method of claim 1, wherein, The step of finding a first hardware scheme matching the hardware feature value in the scheme description section of the image software according to the hardware feature value comprises: analyzing a mapping table of feature values and hardware schemes in the scheme description section; comparing the read hardware feature value with the feature values in the mapping table by traversing the feature values in the mapping table; if there is a matching feature value, selecting the hardware scheme corresponding to the feature value as the first hardware scheme and returning a hardware scheme identifier corresponding to the hardware scheme; if there is no completely matching feature value, returning a matching failure signal.

5. The method of claim 4, wherein, After the step of returning a matching failure signal if there is no completely matching feature value, the method further comprises: calculating the similarity of the read hardware feature value and each feature value in the mapping table; selecting the hardware scheme corresponding to the feature value with the highest similarity as a candidate scheme; outputting a hardware scheme identifier and / or scheme prompt information corresponding to the candidate scheme; if scheme confirmation information is received, selecting the candidate scheme as the first hardware scheme and loading the driver section of the first hardware scheme.

6. The method of claim 1 or 4, wherein, After the step of returning a matching failure signal if there is no completely matching feature value, the method further comprises: If the first hardware scheme matching the hardware characteristic value does not exist, a default driver segment is loaded in the mirror software, wherein the default driver segment is a compatible program segment common to different hardware; Based on the compatible program segment, the hardware characteristic value is sent to a scheme server, and a response data packet fed back by the scheme server is received; The target mirror software in the response data packet is burned into the non-volatile memory locally of the switch, and a target driver segment of the target mirror software is loaded.

7. The method of claim 1, wherein, Before the step of loading the corresponding driver segment into the memory and executing according to the first hardware scheme to complete the hardware initialization of the switch, the method further comprises: The memory data amount of the driver segment is calculated, and the memory space corresponding to the corresponding memory data amount is applied, and the driver segment is copied from the non-volatile memory to the memory space; Based on a preset check value algorithm, the driver segment loaded into the memory space is subjected to check value calculation, and the calculation result is compared with a pre-stored target check value; If the comparison result is consistent, the step of loading the corresponding driver segment into the memory and executing according to the first hardware scheme is executed; If the comparison result is inconsistent, the driver program segment in the mirror software is re-read, or an error report of the driver program loading error is output.

8. The method of claim 1, wherein, The step of obtaining the hardware characteristic value by running the boot program in the mirror software and reading at least one hardware characteristic register of the switch according to a preset communication protocol further comprises: The target characteristic value of at least two hardware characteristic registers in the switch is read through the preset communication protocol; Based on a preset characteristic value splicing rule and / or the hardware type corresponding to the target characteristic value, the target characteristic value is spliced to obtain the hardware characteristic value.

9. A switch, characterized by The switch comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, and the computer program is configured to implement the steps of the hardware initialization method of the switch according to any one of claims 1 to 8.

10. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the hardware initialization method of the switch according to any one of claims 1 to 8.