OpenBMC firmware batch upgrading method based on Golang
Through the OpenBMC firmware batch upgrade method based on Golang, the problem of low batch upgrade efficiency of computer BMC firmware batch upgrade is solved, and synchronous upgrades are achieved in multiple platforms and environments, reducing labor costs and improving efficiency.
Patent Information
- Application Number
- CN202510187710.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-05-23
AI Technical Summary
It is difficult for the prior art to efficiently upgrade the BMC firmware of computers in batches, especially under different platforms and environments.
Using the Golang-based OpenBMC firmware batch upgrade method, the firmware image file is uploaded using SFTP through the Golang program, the phosphor-version-software-manager is used for decompression and verification, the busctl command is constructed and executed remotely to achieve firmware upgrade.
The BMC firmware synchronous update and upgrade of multiple computers under different platforms and operating system environments has been achieved, which has significantly reduced labor costs and improved work efficiency.
Smart Images

Figure CN120029644A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer BMC firmware upgrade, and in particular relates to a method for batch upgrading OpenBMC firmware based on Golang. Background Art
[0002] OpenBMC is an open source firmware solution for baseboard management controllers (BMC). It aims to provide a customizable BMC firmware for various hardware platforms. With the participation of more hardware manufacturers and developers, OpenBMC is expected to become a standard choice in the field of BMC firmware. OpenBMC provides a web service, which consists of the backend project bmcweb and the front-end project webui-vue. It provides rich functions in the web page, such as remote console access, firmware upgrade, hardware monitoring and management, power management, event log and alarm functions. In the secondary development based on OpenBMC, it is often necessary to update and upgrade the BMC firmware. Although the firmware can be upgraded by uploading the firmware file on the web page, this method is undoubtedly time-consuming and labor-intensive for the BMC firmware upgrade of batch computers.
[0003] Based on the above problems encountered in actual development, the present invention proposes a method for batch upgrading of OpenBMC firmware based on Golang, which can be used for batch and fast OpenBMC firmware upgrading on different platforms and in different environments. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] The technical problem to be solved by the present invention is how to provide a method for batch upgrading of OpenBMC firmware based on Golang, so as to solve the problem of efficiently batch upgrading the BMC firmware of computers.
[0006] (II) Technical solution
[0007] In order to solve the above technical problems, the present invention proposes a method for batch upgrading OpenBMC firmware based on Golang, which comprises the following steps:
[0008] Step 1: Basic environment preparation
[0009] Prepare a computer for executing the tool software, ensure that it can communicate with the BMC to be updated and upgraded, and copy the BMC firmware image file to be upgraded to the same directory as the tool software;
[0010] Step 2: Get the IP address
[0011] Obtain the IP address of the BMC that needs to upgrade the firmware by reading the ip.txt file or command line parameters;
[0012] Step 3: Traverse all IP addresses
[0013] When traversing the IP addresses of all BMCs, check whether the IP network is unobstructed by pinging; if the IP network is normal, execute the following steps 4 to 7 in the coroutine to achieve the purpose of parallel upgrading of multiple BMCs.
[0014] Step 4: Upload the firmware image file
[0015] The Golang program uses the "github.com / pkg / sftp" library to upload files to the BMC's / tmp / images directory through sftp. This directory is a directory specified by OpenBMC. At the same time, this directory is monitored and controlled by the BMC process / usr / bin / phosphor-version-software-manager.
[0016] Step 5: Get the directory name after decompressing the image
[0017] After the file is uploaded, phosphor-version-software-manager will decompress the firmware image file, verify it, and rename the decompressed directory to the version ID generated by the BMC firmware image file. After waiting for a certain period of time, the "ls / tmp / images" command is remotely executed using the "golang.org / x / crypto / ssh" library to obtain the version ID.
[0018] Step 6: Construct busctl command
[0019] Construct busctl command to activate DBus command of firmware upgrade in OpenBMC-based system, so as to automatically perform flash erase firmware upgrade operation at next reboot;
[0020] Step 7: Execute the busctl restart command
[0021] By using the "golang.org / x / crypto / ssh" library, remotely execute the complete busctl command in step 6, and then execute the / sbin / reboot restart command.
[0022] (III) Beneficial effects
[0023] The present invention proposes a method for batch upgrading OpenBMC firmware based on Golang. The present invention proposes a method for batch upgrading OpenBMC firmware based on Golang, and uses the Golang language to complete software development, supports the execution of tool software in various architecture processors and operating system environments, supports the synchronous updating and upgrading of BMC firmware of several computers, can greatly reduce labor costs, and improve work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 This is a flowchart of the BMC firmware upgrade software program of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0026] The present invention proposes a method for batch upgrading of OpenBMC firmware based on Golang, and develops a tool software by this method to realize batch upgrading of OpenBMC firmware of several computers. The software obtains the IP address of the BMC to be upgraded by reading files or command line parameters, and then uploads the firmware image file to the BMC through sftp, waits for the firmware image file to be uploaded, obtains the directory name after the firmware image file is decompressed, as the version ID, and then splices the version ID into the busctl command, executes the busctl command and the reboot command to restart the BMC through remote ssh, and the BMC can enter the erasing and checking flash stage. After the flash is written, the BMC will be automatically restarted, and after waiting for the BMC to start normally, the BMC firmware upgrade is successful.
[0027] The present invention supports various computer BMC firmware upgrades based on OpenBMC, supports the execution of tool software in various architecture processors and operating system environments, and can greatly improve the efficiency of batch updating and upgrading of BMC firmware.
[0028] The present invention provides a method for batch upgrading OpenBMC firmware based on Golang, the method comprising the following steps:
[0029] Step 1: Basic environment preparation
[0030] The present invention is only for firmware upgrades compiled during secondary development based on OpenBMC. Therefore, it is necessary to first pull the source code of OpenBMC or other manufacturers' open source versions based on OpenBMC, compile it successfully once according to the official document, write the BMC firmware image file (usually a .tar file) generated after compilation into flash through a burner, and run it successfully. For all subsequent firmware upgrades, the burner can no longer be used, and only the tool software produced by the method of the present invention can be used.
[0031] Prepare a computer for executing the tool software to ensure that it can be interconnected with the BMC that needs to be updated and upgraded. Copy the BMC firmware image file to be upgraded to the same directory as the tool software. Since the Golang program can be cross-compiled into executable programs for different platforms, the tool software of the present invention supports computers with various common architectures and operating systems when executed.
[0032] Step 2: Get the IP address
[0033] The present invention obtains the IP address of the BMC that needs to upgrade the firmware by reading the ip.txt file or the command line parameter. The above two methods are supported to be used simultaneously. When ip.txt does not exist or is empty, and there is no IP address in the command line parameter, the tool software terminates execution.
[0034] Step 3: Traverse all IP addresses
[0035] When traversing all BMC IP addresses, first check whether the IP is connected to the network. If the IP cannot be pinged, try pinging it several times and then ignore the BMC of the IP. If the IP network is normal, execute the following steps 4 to 7 in the coroutine to achieve the purpose of parallel upgrade of multiple BMCs.
[0036] Generally, when there are fewer IPs, run as many coroutines as there are normal IPs. If there are too many IPs, you can design a task scheduling strategy. Here we only introduce the basic process and will not go into details on how to optimize it.
[0037] Step 4: Upload the firmware image file
[0038] The Golang program uses the "github.com / pkg / sftp" library to upload files to the BMC's / tmp / images directory through sftp. This directory is a directory specified by OpenBMC. At the same time, this directory is monitored and controlled by the BMC process / usr / bin / phosphor-version-software-manager. If the files uploaded to this directory are abnormal, they will be automatically deleted by phosphor-version-software-manager.
[0039] Step 5: Get the directory name after decompressing the image
[0040] After the file is uploaded, phosphor-version-software-manager will decompress the firmware image file, read the values of the purpose, version, MachineName, ExtendedVersion and other fields in the MANIFEST file after decompression for verification, and after verification, rename the decompressed directory name to the version ID generated by the BMC firmware image file, such as c6dfee37. The version ID is a hash value composed of 8 hexadecimal digits, which is generated by hashing the version string contained in the image using the SHA-512 hash algorithm and taking the first 8 characters.
[0041] Therefore, after the tool software uploads the firmware image file, set it to wait for 5 seconds, during which time phosphor-version-software-manager performs the above-mentioned decompression, verification, renaming, etc. After 5 seconds, use the "golang.org / x / crypto / ssh" library to remotely execute the "ls / tmp / images" command to obtain the version ID.
[0042] Step 6: Construct busctl command
[0043] The busctl command is constructed to activate the DBus command for firmware upgrade in the OpenBMC-based system, so that the firmware upgrade operations such as flash erase and write can be automatically performed at the next restart. The complete busctl command for firmware upgrade is as follows:
[0044] busctl set-propertyxyz.openbmc_project.Software.BMC.Updater\
[0045] / xyz / openbmc_project / software / version_id\
[0046] xyz.openbmc_project.Software.ActivationRequestedActivation s\
[0047] xyz.openbmc_project.Software.Activation.RequestedActivations.Active
[0048] Here is a detailed explanation of this command:
[0049] busctl: This is a DBus tool for sending messages on the system bus. It can be used to query and set properties, call methods, etc.
[0050] ·set-property: This is a subcommand of busctl and is used to set the property value of a D-Bus object.
[0051] xyz.openbmc_project.Software.BMC.Updater: This is the name of the D-Bus service that issues update requests. xyz.openbmc_project is the namespace of the OpenBMC project, and Software.BMC.Updater indicates that this is a service for BMC firmware updates.
[0052] / xyz / openbmc_project / software / version_id: This is the path to the D-Bus object that points to the specific firmware upgrade object. Replace the version_id in the path with the actual 8-bit hash value obtained in step 5, such as c6dfee37.
[0053] xyz.openbmc_project.Software.Activation: This is the name of the D-Bus interface that defines operations related to firmware activation.
[0054] RequestedActivation: This is a property in the interface used to request firmware activation.
[0055] s: This is the type of the attribute value, representing a string.
[0056] xyz.openbmc_project.Software.Activation.RequestedActivations.Active: This is the new value to be set. It is an object path pointing to the specific object of the activation firmware upgrade. This path indicates that the requested activation operation is for the currently active firmware upgrade.
[0057] Step 7: Execute the busctl restart command
[0058] By using the "golang.org / x / crypto / ssh" library, remotely execute the complete busctl command in step 6, and then execute the / sbin / reboot restart command. At this time, through the serial port connected to the BMC, you can see that the BMC has started flash erasing, verification and other operations, and wait for the erasing to complete and automatically restart the BMC.
[0059] Through the above seven steps, an OpenBMC firmware upgrade can be completed. The above description is only the most basic OpenBMC firmware upgrade process, such as all BMCs are configured with the same user name and password, etc. In practice, it can be improved according to different usage scenarios.
[0060] The present invention proposes a method for batch upgrading of OpenBMC firmware based on Golang, and completes software development using the Golang language, supports the execution of tool software in various architecture processors and operating system environments, supports the synchronous updating and upgrading of BMC firmware of several computers, can greatly reduce labor costs, and improve work efficiency.
[0061] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for batch upgrading OpenBMC firmware based on Golang, characterized in that: The method comprises the following steps: Step 1: Basic environment preparation Prepare a computer for executing the tool software, ensure that it can communicate with the BMC to be updated and upgraded, and copy the BMC firmware image file to be upgraded to the same directory as the tool software; Step 2: Get the IP address Obtain the IP address of the BMC that needs to upgrade the firmware by reading the ip.txt file or command line parameters; Step 3: Traverse all IP addresses When traversing the IP addresses of all BMCs, check whether the IP network is unobstructed by pinging; if the IP network is normal, execute the following steps 4 to 7 in the coroutine to achieve the purpose of parallel upgrading of multiple BMCs. Step 4: Upload the firmware image file The Golang program uses the "github.com / pkg / sftp" library to upload files to the BMC's / tmp / images directory through sftp. This directory is a directory specified by OpenBMC. At the same time, this directory is monitored and controlled by the BMC process / usr / bin / phosphor-version-software-manager. If the files uploaded to this directory are abnormal, they will be automatically deleted by phosphor-version-software-manager. Step 5: Get the directory name after decompressing the image After the file is uploaded, phosphor-version-software-manager will decompress the firmware image file, verify it, and rename the decompressed directory to the version ID generated by the BMC firmware image file. After waiting for a certain period of time, the "ls / tmp / images" command is remotely executed using the "golang.org / x / crypto / ssh" library to obtain the version ID. Step 6: Construct busctl command Construct busctl command to activate DBus command of firmware upgrade in OpenBMC-based system, so as to automatically perform flash erase firmware upgrade operation at next reboot; Step 7: Execute the busctl restart command By using the "golang.org / x / crypto / ssh" library, remotely execute the complete busctl command in step 6, and then execute the / sbin / reboot restart command.
2. The method for batch upgrading OpenBMC firmware based on Golang as claimed in claim 1, characterized in that: Before step 1, the process also includes: pulling the source code of OpenBMC or other open source versions based on OpenBMC from other manufacturers, successfully compiling it once according to the official documentation, writing the BMC firmware image file generated after the compilation into the flash through a burner, and running it successfully; for all subsequent firmware upgrades, the burner is no longer used, only the tool software is used.
3. The method for batch upgrading OpenBMC firmware based on Golang as claimed in claim 1, characterized in that: In step 2, when ip.txt does not exist or is empty, and there is no IP address in the command line parameters, the tool software terminates execution.
4. The method for batch upgrading OpenBMC firmware based on Golang as claimed in claim 1, characterized in that: In the step 3, if the IP cannot be pinged, the BMC of the IP is ignored after trying to ping several times; if the IP network is normal, the following steps 4 to 7 are executed in the coroutine to achieve the purpose of parallel upgrading of multiple BMCs.
5. The method for batch upgrading OpenBMC firmware based on Golang as claimed in claim 1, characterized in that: In step 3, when there are fewer IPs, run as many coroutines as there are normal IPs; if there are too many IPs, design a task scheduling strategy.
6. The method for batch upgrading OpenBMC firmware based on Golang as claimed in claim 1, characterized in that: In step 4, if the file uploaded to the directory is abnormal, it will be automatically deleted by phosphor-version-software-manager.
7. The method for batch upgrading OpenBMC firmware based on Golang as claimed in claim 1, characterized in that: In the step 5, after decompression, the values of the purpose, version, MachineName, and ExtendedVersion fields in the MANIFEST file are read for verification. After the verification is completed, the name of the decompressed directory is renamed to the version ID generated by the BMC firmware image file. The version ID is a hash value composed of 8 hexadecimal digits, which is generated by performing a hash calculation on the version string contained in the image through the SHA-512 hash algorithm and taking the first 8 characters.
8. The method for batch upgrading OpenBMC firmware based on Golang as claimed in claim 1, characterized in that: In step 5, a waiting time of 5 seconds is set, during which phosphor-version-software-manager is allowed to perform the above-mentioned decompression, verification, and renaming operations; after 5 seconds, the "ls / tmp / images" command is remotely executed by using the "golang.org / x / crypto / ssh" library to obtain the version ID.
9. The method for batch upgrading OpenBMC firmware based on Golang as claimed in claim 1, characterized in that: In the step 7, the serial port connected to the BMC is used to see that the BMC has started the flash erase and verification operation, and the BMC is automatically restarted after the erase is completed.
10. The method for batch upgrading OpenBMC firmware based on Golang as described in claims 1-9, characterized in that: This method obtains the IP address of the BMC whose firmware is to be upgraded by reading files or command line parameters, and then uploads the firmware image file to the BMC through sftp. After the firmware image file is uploaded, the directory name after the firmware image file is decompressed is obtained as the version ID, and then the version ID is spliced into the busctl command. The busctl command and the reboot command for restarting the BMC are respectively executed through remote ssh, and the BMC can enter the stage of erasing and verifying the flash. After the flash is written, the BMC will automatically restart. After waiting for the BMC to start normally, the BMC firmware upgrade is successful.