Software function tailoring method, apparatus and device

By analyzing the software code repository of the baseboard management controller, identifying code units and their relationships, constructing a code knowledge graph, generating and verifying the trimming scheme, the problem of inaccurate trimming range in the software function trimming of the baseboard management controller was solved, and the accuracy and reliability of the trimming results were achieved.

CN123030185APending Publication Date: 2026-11-03DAWNING INFORMATION IND (BEIJING) CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611391203.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-08
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

During the process of trimming existing baseboard management controller software functions, it is difficult to accurately determine the trimming range, which may result in the trimmed firmware containing unnecessary content or affecting the normal operation of the expected management functions.

Method used

By analyzing the software code repository of the baseboard management controller, code units and their relationships are identified, a code knowledge graph is constructed, target code units, dependent code units and candidate pruning code units are determined, a code pruning scheme is generated, and the scheme is verified and adjusted to meet preset conditions after pruning.

Benefits of technology

It improves the accuracy of determining the range of functions to be retained and the range that can be trimmed, reduces the impact of trimming operations on the target functions, and ensures the consistency and reliability of the trimming results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123030185A_ABST
    Figure CN123030185A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a software function tailoring method, device and equipment. The method comprises: parsing a software code repository of a baseboard management controller to obtain a plurality of code units and an association relationship between the plurality of code units; determining a target code unit and a dependent code unit associated with the target code unit from the plurality of code units according to a software function tailoring requirement and the association relationship, and determining a code unit other than the target code unit and the dependent code unit as a candidate tailoring code unit; analyzing an influence of tailoring the candidate tailoring code unit on the target code unit and the dependent code unit according to the association relationship, and generating a code tailoring scheme according to an influence result; tailoring and verifying the software code of the baseboard management controller according to the code tailoring scheme, and adjusting the code tailoring scheme according to the association relationship when the software code after tailoring does not satisfy a preset verification condition. The code tailoring range accuracy of the baseboard management controller software is improved.
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 method, apparatus, and device for software function trimming. Background Technology

[0002] The Baseboard Management Controller (BMC) is a dedicated control component in a server responsible for hardware status monitoring, remote management, and power control. Its firmware configuration affects the server's management capabilities, resource consumption, and deployment adaptability. As servers are applied to various scenarios such as edge computing and data centers, different hardware platforms have varying requirements for management functions, firmware size, and operating resources. Therefore, customizing the BMC software according to actual application needs has become a common requirement in server product adaptation and firmware maintenance.

[0003] In existing technologies, when customizing the functionality of a baseboard management controller software, developers typically review the software engineering directory structure, source files, component descriptions, and configuration content based on product requirements, development documents, and existing experience. They then select the software content to be retained or removed, and create a customized version by deleting relevant files, disabling build options, modifying the service list, or adjusting the installation configuration. After modification, the customized version is rebuilt and tested. If build errors, service startup failures, or expected functional abnormalities occur, the relevant content is restored or the configuration is modified based on the build logs and test results until a working firmware is obtained.

[0004] When software is large-scale and has multiple layers, the implementation of the same management function may be distributed across different program files, configuration contents, and service components. The coordination between these parts may also change with software versions and hardware platforms. Using this approach, developers find it difficult to fully assess the actual impact of each software element on the intended function before implementing modifications, affecting the accurate division of content to be retained and content that can be removed. Therefore, in the process of functional trimming of existing baseboard management controller software, there is a problem of accurately determining the scope of software code trimming. Summary of the Invention

[0005] This application provides a software function trimming method, apparatus, and device to solve the problem of low accuracy in determining the trimming range during the function trimming of existing baseboard management controller software.

[0006] In a first aspect, embodiments of this application provide a software function trimming method, including:

[0007] In response to the software function trimming requirements, the software code repository of the baseboard management controller is analyzed to obtain multiple code units and the relationships between them;

[0008] Based on the software function trimming requirements and relationships, target code units and dependent code units associated with target code units are identified from multiple code units, and code units other than target code units and dependent code units are identified as candidate trimming code units.

[0009] Based on the relationships, analyze the impact of pruning candidate pruning code units on target code units and dependent code units, and generate code pruning schemes based on the impact results;

[0010] The software code of the baseboard management controller is trimmed and verified according to the code trimming scheme. If the trimmed software code does not meet the preset verification conditions, the code trimming scheme is adjusted according to the correlation.

[0011] By analyzing the software code repository of the baseboard management controller, code units and their relationships are obtained. Based on the software function trimming requirements, code units that need to be retained and candidate trimming code units are divided. A code trimming scheme is generated based on the impact of candidate trimming code units on the implementation process of the target function. At the same time, the trimmed software code is verified, and the code trimming scheme is adjusted when the preset verification conditions are not met, thereby correcting the trimming results. This improves the accuracy of determining the scope of function retention and the scope of trimming, and reduces the possibility that the trimming operation will affect the normal implementation of the target function.

[0012] In one possible implementation, the relationships include calling relationships, dependency relationships, and communication relationships; parsing the software code repository of the baseboard management controller yields multiple code units and the relationships between these code units, including:

[0013] The code files in the software code repository are scanned, and lexical and syntactic analysis is performed on the code files to obtain code structure information;

[0014] Identify code units in the software code repository based on code structure information. Code units include at least one of functions, data structures, interfaces, and code blocks.

[0015] Static analysis is performed on code units based on code structure information to extract call relationships and dependencies between code units. Communication relationships are also extracted based on the interface definition, service configuration, and message sending and receiving code of the inter-process message bus corresponding to the code unit.

[0016] By performing lexical, syntactic, and static analysis on code files in the software code repository, and combining the interface definition, service configuration, and message sending and receiving code of the inter-process message bus to extract communication relationships, the calling relationships, dependencies, and communication relationships between code units are identified from the aspects of code structure, static references, and inter-process communication. This improves the completeness of relationship identification and provides a more accurate data foundation for subsequently determining target code units, dependent code units, and candidate trimmed code units.

[0017] In one possible implementation, based on software function tailoring requirements and relationships, the target code unit and its dependent code units are determined from multiple code units, including:

[0018] By treating code units as nodes and connecting call relationships, dependencies, and communication relationships between nodes, a code knowledge graph is constructed.

[0019] Match the software function trimming requirements with the functions represented by code units in the code knowledge graph to determine the target code unit, and then determine the function represented by the target code unit as the target function;

[0020] Based on the code knowledge graph, starting from the target code unit, the search proceeds along the calling relationships, dependencies, and communication relationships required to achieve the target function, and the code units that the target code unit directly or indirectly depends on are identified as dependent code units.

[0021] By constructing a code knowledge graph with code units as nodes and connection relationships between nodes such as calling relationships, dependency relationships, and communication relationships, a structured representation of scattered code units and their relationships can be achieved. By matching software function tailoring requirements with the functions represented by code units, and searching for directly or indirectly dependent code units along the relationships required to achieve the target function, the target function location results are mapped to the corresponding code implementation and its necessary dependencies. This improves the accuracy of identifying target code units and dependent code units and helps maintain the integrity of the target function implementation chain.

[0022] In one possible implementation, based on the correlation, the impact of pruning candidate pruning code units on the target code unit and dependent code units is analyzed, and a code pruning scheme is generated based on the impact results, including:

[0023] Based on the code knowledge graph, the nodes corresponding to the candidate pruning code units and their connection relationships are simulated for deletion to determine the association between the affected code units and the interruption, and the scope of the association impact is obtained.

[0024] Based on the scope of the associated impact, determine whether pruning the candidate pruning code unit will interrupt the association between the target code unit and the dependent code unit to achieve the target function;

[0025] Candidate trimming code units that cause the association to break are removed from the candidate trimming code units. The remaining candidate trimming code units are determined as the actual trimming code units, and a code trimming scheme is generated based on the actual trimming code units.

[0026] By simulating the deletion of nodes and their connections corresponding to candidate pruning code units in the code knowledge graph, the scope of influence of the corresponding candidate pruning code units can be determined before the actual pruning is performed, and it can be determined whether they will interrupt the association relationships required to achieve the target function. By excluding candidate pruning code units that will cause the association relationships to be interrupted, the remaining candidate pruning code units are determined as the actual pruning code units, reducing the impact on the target function due to the pruning of necessary code content, and improving the accuracy and reliability of the code pruning scheme.

[0027] In one possible implementation, the preset verification conditions include successful compilation of the software code, completeness of the relationships required to achieve the target function, and normal operation of the target function.

[0028] The software code of the baseboard management controller is trimmed and verified according to the code trimming scheme. If the trimmed software code does not meet the preset verification conditions, the code trimming scheme is adjusted according to the correlation relationship, including:

[0029] Based on the version control mechanism, a pruning branch is created from the target code branch of the software code repository, and the code pruning scheme is executed in the pruning branch;

[0030] The firmware compilation engine is called to compile the trimmed software code, and the compilation result is obtained. When the compilation result indicates that the compilation is successful, the firmware image of the baseboard management controller is generated. The target functions in the firmware image are verified to obtain the functional verification result.

[0031] Based on the relationships, the integrity of the calling relationships, dependency relationships, and communication relationships required to achieve the target function is verified, and the integrity verification results are obtained.

[0032] When the compilation result, integrity verification result, or functional verification result does not meet the corresponding preset verification conditions, the code unit associated with the exception is determined according to the association relationship, and the code trimming scheme is adjusted according to the code unit associated with the exception.

[0033] By creating pruning branches and executing code pruning schemes based on version control mechanisms, the pruning operation is isolated from the target code branch. By compiling the pruned software code, verifying the integrity of associations, and validating the target functions, the pruning results can be examined in terms of compileability, association integrity, and functional usability. When the corresponding results do not meet the preset verification conditions, the code pruning scheme is adjusted according to the abnormally associated code units, forming a closed loop of pruning, verification, and adjustment, thereby improving the usability of the pruned software code and its firmware image and the consistency of the pruning results.

[0034] In one possible implementation, the method further includes:

[0035] When the trimmed software code meets the preset verification conditions, a trimming template is generated based on the corresponding hardware platform information, application scenario information, software code version information, code trimming scheme and dependency verification standards.

[0036] When a new software feature trimming requirement is received, if a trimming template matching the new software feature trimming requirement is found, the new software code repository is parsed to obtain the new code unit and the relationship between the new code unit.

[0037] The trimming template is adapted to the new software function trimming requirements, new code units, and relationships to obtain a new code trimming scheme;

[0038] The software code in the new software code repository is trimmed and verified according to the new code trimming scheme.

[0039] By combining code trimming schemes that meet preset verification conditions with hardware platform information, application scenario information, software code version information, and dependency verification standards to generate trimming templates, verified trimming content can be saved. When a new software function trimming requirement is received, by matching the trimming template and adapting the trimming template according to the new code unit and its relationship, a code trimming scheme suitable for the new software code repository can be obtained. This enables the reuse of existing trimming results under different requirements or software code versions, reduces redundant analysis work, and improves the processing efficiency and consistency of software function trimming.

[0040] Secondly, embodiments of this application provide a software function trimming device, comprising:

[0041] The parsing module is used to parse the software code repository of the baseboard management controller in response to software function trimming requirements, and obtain multiple code units and the relationships between the multiple code units;

[0042] The filtering module is used to determine the target code unit and the dependent code units associated with the target code unit from multiple code units based on the software function tailoring requirements and relationships, and to determine the code units other than the target code unit and dependent code units as candidate tailoring code units.

[0043] The analysis module is used to analyze the impact of candidate pruning code units on target code units and dependent code units based on the relationship, and generate code pruning schemes based on the impact results;

[0044] The trimming module is used to trim and verify the software code of the baseboard management controller according to the code trimming scheme, and adjust the code trimming scheme according to the correlation when the trimmed software code does not meet the preset verification conditions.

[0045] Thirdly, embodiments of this application provide a software function trimming device, including:

[0046] At least one processor; and

[0047] A memory that is communicatively connected to at least one processor; wherein,

[0048] The memory stores instructions that can be executed by at least one processor, such that the at least one processor is able to perform the method shown in any of the first aspects.

[0049] Fourthly, embodiments of this application provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the method shown in any of the first aspects.

[0050] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the method shown in any of the first aspects.

[0051] The software function trimming method, apparatus, and device provided in this application, in response to software function trimming requirements, parse the software code repository of the baseboard management controller to obtain multiple code units and the relationships between them. Based on the software function trimming requirements and these relationships, target code units, dependent code units, and candidate trimming code units are determined. This allows the relationship between code units to be used as the basis for defining the trimming scope, reducing omissions or deviations that occur when manually reviewing software content and improving the accuracy of determining the function retention and trimming scope. By analyzing the impact of candidate trimming code units on target and dependent code units based on the relationships, and generating a code trimming scheme accordingly, it is possible to determine whether candidate trimming code units will affect the implementation of the target function before actual trimming, reducing the possibility of including necessary code content in the trimming scope or retaining unnecessary code content. By trimming and verifying the software code according to the code trimming scheme, and adjusting the code trimming scheme based on the relationships when the trimmed software code does not meet preset verification conditions, the function retention and trimming scope can be further corrected based on the verification results, improving the accuracy and reliability of the baseboard management controller software function trimming results. Attached Figure Description

[0052] 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.

[0053] Figure 1 A schematic diagram illustrating the application scenarios provided in the embodiments of this application;

[0054] Figure 2 A flowchart illustrating a software function trimming method provided in an embodiment of this application;

[0055] Figure 3 A schematic diagram of the method for generating and reusing cropping templates provided in an embodiment of this application;

[0056] Figure 4 This is a schematic diagram of the structure of the software function trimming device provided in the embodiments of this application;

[0057] Figure 5 This is a schematic diagram of the structure of the software function trimming device provided in the embodiments of this application.

[0058] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0059] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0060] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0061] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.

[0062] To facilitate understanding, the following will be combined with... Figure 1 The application scenarios applicable to the embodiments of this application will be described.

[0063] Figure 1 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application. Please refer to [link / reference]. Figure 1 This application scenario includes server 101 and client 102. Server 101 is equipped with a code repository analysis platform and firmware compilation engine, and stores or has access to the software code repository of the baseboard management controller. Client 102 can be a terminal used by developers to receive software feature customization requirements and display code customization schemes and verification results.

[0064] In practical applications, client 102 can send software function trimming requests to server 101. Upon receiving the request, server 101 parses the software code repository of the baseboard management controller, determines the code content to be retained and the code content to be trimmed, and generates a code trimming plan based on the relationships between the relevant code content. Server 101 trims and verifies the software code of the baseboard management controller according to the code trimming plan, and adjusts the code trimming plan if the trimmed software code does not meet preset verification conditions. Server 101 can also send at least one of the code trimming plan, trimming results, and verification results to client 102 for developers to view.

[0065] In the field of server hardware management, the baseboard management controller (BMC) undertakes management functions such as hardware status monitoring, remote maintenance, power control, logging, and fault handling. The BMC firmware can be developed based on open-source software frameworks and consists of multiple functional components, hardware drivers, and management services, and is widely used in hardware platforms such as data center servers and edge computing nodes. The functional composition and resource consumption of the BMC firmware affect the server's management capabilities and deployment adaptability.

[0066] In practical applications, different hardware platforms and application scenarios have different requirements for the software functions, firmware size, operating resources, and hardware adaptability of the baseboard management controller. For example, edge computing scenarios typically focus more on firmware size and resource consumption, while data center scenarios may require retaining relatively complete monitoring and remote management functions. Therefore, it is necessary to customize the baseboard management controller software according to the hardware platform and application scenario.

[0067] In existing technologies, when customizing the functionality of a baseboard management controller software, developers typically review the software engineering directory structure, source files, functional specifications, and configuration content based on product requirements, development documents, and existing experience. They determine which software content needs to be retained or removed, and then create a customized version by deleting relevant files, disabling build options, modifying the service list, or adjusting the installation configuration. After modification, the customized version is rebuilt and tested. If build errors, service startup failures, or expected functional abnormalities occur, the relevant content is restored or the configuration is modified based on the build logs and test results.

[0068] As the scale of the baseboard management controller software increases, the implementation of the same management function may be distributed across different source files, configuration contents, and service components. The coordination between these parts may also change with software versions and hardware platforms. When using the above approach, developers may find it difficult to fully determine the actual role of each software component in the expected function before implementing modifications. They may remove software components necessary to achieve the expected function, or they may retain unnecessary software components that can be removed.

[0069] Therefore, in the process of trimming the functions of existing baseboard management controller software, there is a problem that the accuracy of determining the scope of functions to be retained and the scope to be trimmed is low. This may result in the trimmed firmware still containing a lot of unnecessary content, or affecting the normal operation of the expected management functions.

[0070] To address the aforementioned problems, the inventive concept of this application is to parse the software code repository of the baseboard management controller in response to software function trimming requirements, obtaining multiple code units and the relationships between them; based on the software function trimming requirements and relationships, target code units, dependent code units, and candidate trimming code units are determined, providing a corresponding code association basis for determining the scope of function retention and the scope of trimming. On this basis, the impact of trimming candidate trimming code units on target code units and dependent code units is analyzed based on the relationships, and a code trimming scheme is generated based on the impact results; trimming and verification are performed according to the code trimming scheme, and if the trimmed software code does not meet preset verification conditions, the code trimming scheme is adjusted according to the relationships. Thus, by forming an interconnected process of trimming scope determination, trimming impact analysis, and post-trimming verification and adjustment, the accuracy of determining the software code trimming scope is improved, and the possibility of trimming operations affecting the normal implementation of the target function is reduced.

[0071] The method described in this application will now be illustrated through specific embodiments. It should be noted that the following embodiments may exist independently or in combination with each other; identical or similar content will not be repeated in different embodiments.

[0072] Figure 2 This is a flowchart illustrating a software function trimming method provided in an embodiment of this application. Please refer to... Figure 2 The method may include:

[0073] S201, in response to the software function trimming requirements, parses the software code repository of the baseboard management controller to obtain multiple code units and the relationships between them.

[0074] In this embodiment, the baseboard management controller serves as the runtime environment for the software code, and the corresponding software code repository stores code content, resource files, and configuration content related to software operation. The software code repository is the basic object for performing the pruning process, the code unit is the basic granularity for subsequent association analysis and pruning, and the association relationship is used to characterize the connections and dependencies between multiple code units.

[0075] In practice, the system receives software feature trimming requests. These requests indicate the target features to be retained and the non-target features to be removed. These requests can be generated based on at least one of the following: product configuration, platform customization requirements, user-inputted feature retention items, hardware platform information, application scenario information, performance constraints, and hardware adaptation constraints. In response to the software feature trimming requests, the system determines the current software code version to be trimmed from the software code repository and uses the corresponding version of the software code repository as the parsing object.

[0076] Subsequently, the code content in the software code repository, as well as the configuration content related to software compilation and operation, are parsed to identify multiple code units that can serve as the basic granularity for trimming, and the relationships between these code units are extracted. For software code repositories with platform configuration differences, the code content and configuration content that are effective under the current target platform configuration can also be determined by combining the target platform configuration, in order to reduce the impact of ineffective content on the identification of relationships.

[0077] After the above processing, a structured parsing result is obtained, including a list of code units, the identification and location information of each code unit, and the association results between code units. This structured parsing result provides an analytical basis for the subsequent determination of target code units, dependent code units, and candidate trimmed code units. By dividing the software code repository into code units and extracting the association relationships between them, subsequent trimming can use code units and their association results as the basis for identifying trimming boundaries, reducing reliance on manual document-by-document review and improving the completeness of association relationship identification in complex software code repositories.

[0078] S202, based on the software function trimming requirements and relationships, determine the target code unit and the dependent code units associated with the target code unit from multiple code units, and determine the code units other than the target code unit and dependent code units as candidate trimming code units.

[0079] In this embodiment, the target code unit is a code unit determined based on software function tailoring requirements that directly corresponds to the target function to be retained. It can represent the function implementation entry point, external service interface, command processing logic, or hardware access logic of the target function. Dependent code units are code units that are associated with the target code unit and provide support for implementing the target function. Candidate tailored code units are the remaining code units that were not included in the retention scope after the target code unit and dependent code units were identified. They are used as input for subsequent tailoring impact analysis and code tailoring scheme generation.

[0080] In practice, the process begins by extracting the target functionalities to be retained from the software functionality trimming requirements. Based on this information, the code units directly corresponding to the target functionalities are identified from multiple code units, and these identified code units are designated as target code units. Subsequently, based on the relationships between code units, the code units associated with the target code units and required to implement the target functionalities are identified, and these identified code units are designated as dependent code units.

[0081] After identifying the target code unit and its dependent code units, these units are included in the retention scope. A set difference operation is then performed on all code units to identify the remaining units (excluding the target and dependent units) as candidate trimmed code units. Candidate trimmed code units only indicate code units that require trimming impact analysis in subsequent steps; they do not imply that all such units can be directly trimmed. The relationships between each candidate trimmed code unit and the code units within the retention scope, their associated code files, functional modules, and corresponding build targets can also be recorded for use in subsequent trimming impact analysis.

[0082] Based on the above analysis, according to the software function trimming requirements and the relationship between code units, the code units that need to be retained and the code units that need further analysis are divided, clarifying the boundary between the target function implementation scope and the candidate trimming scope. The judgment based on human experience is transformed into a code unit division process that can be repeatedly executed, providing a definite input range for subsequent trimming impact analysis.

[0083] S203, based on the relationship, analyze the impact of the candidate pruning code units on the target code unit and dependent code units, and generate a code pruning scheme based on the impact results.

[0084] In this embodiment, impact analysis is used to determine whether the pruning of candidate pruned code units will adversely affect the target code unit and dependent code units, and whether it will cause the interruption of the association relationships required to achieve the target function. The code pruning scheme is used to characterize the processing results corresponding to each candidate pruned code unit and the adjustment information related to the processing results. In specific implementation, based on the association relationships between code units, an impact assessment is performed on the candidate pruned code units to determine the affected code units and association relationships after pruning the corresponding candidate pruned code units, thus obtaining the scope of the association impact. Based on the scope of the association impact, it is determined whether the association relationships required to achieve the target function remain intact, and the processing method for each candidate pruned code unit is determined accordingly.

[0085] If trimming candidate code units does not interrupt the relationships required to achieve the target function, then the corresponding candidate code units can be determined as the actual trimmed code units. If trimming candidate code units would interrupt the relationships required to achieve the target function, then the corresponding candidate code units would be removed from the candidate trimming range and included in the retention range. If the corresponding impact can be eliminated through corresponding adjustments, then the corresponding adjustments can be recorded. Based on the above impact analysis results, a code trimming scheme is generated to clarify the code units that need to be trimmed, the code units that need to be retained, and the corresponding adjustments. Based on the above analysis, this embodiment identifies the role of candidate code units in the target function implementation process through the relationships between code units, and determines the processing method of the corresponding candidate code units according to the impact results, so that the generated code trimming scheme can maintain the integrity of the target function and its necessary relationships, providing a basis for subsequent trimming processing.

[0086] S204. The software code of the baseboard management controller is trimmed and verified according to the code trimming scheme. If the trimmed software code does not meet the preset verification conditions, the code trimming scheme is adjusted according to the correlation relationship.

[0087] In this embodiment, "tailoring" refers to modifying the code content in the software code repository and the configuration content related to software compilation and operation according to the code tailoring scheme; "verification" refers to checking whether the tailored software code and its build products meet the software function tailoring requirements. Preset verification conditions can be pre-set according to the software function tailoring requirements and the target operating environment to determine whether the tailored software code can be built normally, whether the relationships required to achieve the target function are maintained intact, and whether the target function can run normally. When the software function tailoring requirements include performance constraints, the preset verification conditions may also include corresponding performance constraints.

[0088] In practice, the code and configuration content that needs to be deleted or modified is determined according to the code trimming scheme, and the software code of the baseboard management controller is trimmed accordingly. After trimming, the trimmed software code is built and verified to obtain the corresponding verification results, which are then compared with preset verification conditions. If the trimmed software code meets the preset verification conditions, the current code trimming scheme is deemed suitable for the corresponding software function trimming requirements; if the trimmed software code does not meet the preset verification conditions, the abnormal code units and related relationships that caused the verification failure are identified based on the failed verification results and the relationships between code units, and the code trimming scheme is adjusted accordingly. Adjustment methods may include restoring the code content or code file corresponding to the mistakenly deleted code unit, restoring missing build dependencies, or modifying the configuration content related to the trimming operation.

[0089] The software code is re-trimmed and verified according to the adjusted code trimming scheme. If the trimmed software code still does not meet the preset verification conditions, the code trimming scheme is adjusted again according to the relationship until the trimmed software code meets the preset verification conditions. Based on the above analysis, this embodiment forms a closed loop by combining code trimming, result verification, and relationship backtracking adjustment. This allows the code trimming scheme to be corrected according to the actual verification results, reducing the possibility of accidental deletion or missing dependencies under complex relationships, and obtaining trimming results that meet the software function trimming requirements.

[0090] Based on the above analysis, this application provides a software function trimming method, including: responding to software function trimming requirements, parsing the software code repository of the baseboard management controller to obtain multiple code units and the relationships between them; determining the target code unit and the dependent code units associated with the target code unit from the multiple code units according to the software function trimming requirements and the relationships, and identifying the code units other than the target code unit and the dependent code units as candidate trimming code units; analyzing the impact of the candidate trimming code units on the target code unit and the dependent code units according to the relationships, and generating a code trimming scheme based on the impact results; trimming and verifying the software code of the baseboard management controller according to the code trimming scheme, and adjusting the code trimming scheme according to the relationships when the trimmed software code does not meet the preset verification conditions. By dividing the software code repository into code units, modeling relationships, identifying the retention range, analyzing the impact of candidate trimmed code units, and performing closed-loop verification and adjustment after trimming, the software function trimming process of the baseboard management controller is implemented as a parsable, judgmental, executable, and traceable processing link to adapt to the software code customization requirements under different hardware platforms and application scenarios. This implementation addresses the problem that multi-layered call chains, implicit dependencies, and cross-functional collaboration relationships are difficult to stably cover through manual trimming. It uses association relationships to constrain the boundaries between target code units, dependent code units, and candidate trimming code units, and reverse-corrects the code trimming scheme based on the verification results, so that the final trimmed software code is consistent with the software function trimming requirements.

[0091] In one possible implementation, the relationships include call relationships, dependency relationships, and communication relationships. Parsing the software code repository of the baseboard management controller yields multiple code units and the relationships between them, including: scanning code files in the software code repository and performing lexical and syntactic analysis to obtain code structure information; identifying code units in the software code repository based on the code structure information, where each code unit includes at least one of functions, data structures, interfaces, and code blocks; performing static analysis on the code units based on the code structure information to extract call relationships and dependency relationships between them, and extracting communication relationships based on the interface definition, service configuration, and message sending and receiving code of the inter-process message bus corresponding to each code unit.

[0092] In practical implementation, the code files in the software code repository are first traversed and read, and lexical segmentation and syntax parsing are performed on the file content to obtain code structure information including file paths, symbol tables, abstract syntax trees, and scope information. Then, based on this structure information, function definitions, structure definitions, interface declarations, and code block boundaries are extracted, and code fragments within the same file and across files are mapped to corresponding code units. Static analysis can combine abstract syntax trees, call graphs, and symbolic reference relationships to identify function calls, member accesses, type references, and macro expansion relationships, and form call relationships and dependency relationships accordingly. For communication relationships, the interface definition, service configuration files, and message sending and receiving code of the inter-process message bus are further parsed to identify communication service identifiers, communication interface identifiers, message types, senders, and receivers, and map them to the code units involved in the communication to obtain communication paths and dependencies. Configuration files, service configuration files, build recipes, layer configurations, and other build metadata can also be parsed to establish mapping relationships between code units and code files, configuration files, build recipes, and compilation targets, and to supplement build dependencies that are difficult to identify solely from code files.

[0093] In one implementation, code structure information can be uniformly represented as a structured intermediate representation. This intermediate representation records the start and end positions, parent-child hierarchy, and referenced objects of each code unit, used to extract relationships layer by layer at the file, module, and symbol levels. The interface definition of the inter-process message bus may include the message interface name, message identifier, and callback prototype. Service configuration may include service startup parameters, binding relationships, and subscription relationships. Message sending and receiving code may include publish calls, subscription callbacks, and processing branches. These three elements work together to determine which code unit sends the message, via which bus it is forwarded, and which code unit receives it, thus completing the cross-module communication relationships. In an optional implementation, the inter-process message bus can be a D-Bus inter-process message bus.

[0094] Using the above method, the software code repository can be broken down into computable code units, and three types of relationships—calls, dependencies, and communication—can be established simultaneously, providing complete input for subsequent pruning impact analysis. Since these relationships originate from code file parsing, static semantic analysis, and message bus configuration parsing, omissions caused by manual judgment can be reduced, improving the accuracy of identifying target and dependent code units, and ensuring that the code pruning scheme maintains good stability and consistency even when facing multi-layered call chains and cross-module communication.

[0095] In one possible implementation, based on software function tailoring requirements and relationships, the target code unit and its dependent code units are determined from multiple code units. This includes: constructing a code knowledge graph by treating code units as nodes and using call relationships, dependency relationships, and communication relationships as connections between nodes; matching the software function tailoring requirements with the functions represented by the code units in the code knowledge graph to determine the target code unit, and identifying the function represented by the target code unit as the target function; and based on the code knowledge graph, starting from the target code unit, searching along the call relationships, dependency relationships, and communication relationships required to achieve the target function, and identifying the code units that the target code unit directly or indirectly depends on as dependent code units.

[0096] In practical implementation, the code files in the software code repository are first parsed to extract function calls, header file inclusions, interface references, and message sending / receiving paths, forming a set of code units and their relationships. Then, the functional descriptions, comments, interface names, and calling contexts of each code unit are normalized and written into the code knowledge graph. Nodes in the code knowledge graph can also record at least one of the following: code unit type, code file location, interface information, software code version information, and resource usage information. The connections between nodes can record the corresponding association type and direction. Subsequently, the functional keywords, scenario constraints, or resource constraints in the tailored requirements are matched with the functional representations in the graph to filter out target code units that meet the requirements, and the function undertaken by these target code units is determined as the target function. When expanding the graph along the connections starting from the target code unit, the association paths are identified according to the association type and direction represented by each connection relationship. Directly or indirectly dependent code units that must be retained in the process of achieving the target function, as well as cross-module communication code units, are included in the dependent code unit set.

[0097] In this process, the code knowledge graph provides a unified foundation for relational representation, enabling the location results of the target function to be directly mapped to specific code units, and further tracing out its necessary dependencies to output the target code unit and its corresponding dependent code units. This approach establishes the scope of pruning on structured relationships, maintains the integrity of the corresponding links of the target function, and provides a basis for the subsequent screening of candidate pruning code units and the generation of code pruning schemes.

[0098] In one possible implementation, based on the association relationships, the impact of pruning candidate pruning code units on the target code unit and dependent code units is analyzed, and a code pruning scheme is generated based on the impact results. This includes: simulating the deletion of nodes corresponding to candidate pruning code units and their connection relationships based on the code knowledge graph, determining the affected code units and the interrupted association relationships, and obtaining the association impact range; based on the association impact range, determining whether pruning candidate pruning code units will interrupt the association relationship between the target code unit and dependent code units to achieve the target function; removing candidate pruning code units that cause the association relationship to be interrupted from the candidate pruning code units, determining the remaining candidate pruning code units as actual pruning code units, and generating a code pruning scheme based on the actual pruning code units.

[0099] In practical implementation, the impact simulation is first performed on each candidate pruning code unit based on the code knowledge graph. Alternatively, multiple candidate pruning code units can be simulated according to a preset combination. The resulting call edges, dependency edges, and communication edges that may be broken in the graph after simulated deletion are obtained, and the set of code units affected is recorded. Then, considering the path relationship between the target code unit and its dependent code units in the target function, it is determined whether these interruptions will sever the necessary links for achieving the target function. Candidate pruning code units that would cause the necessary links to become invalid are removed from the candidate set and included in the retention scope; candidate pruning code units that do not cause interruptions are identified as actual pruning code units, and a code pruning scheme is formed accordingly. Furthermore, the mapping relationship between the actual pruning code units and code files, configuration files, and build recipes can be used to determine the code content to be deleted, the code files to be deleted, the configuration parameters to be modified, and the build recipes to be modified. By performing graph-level simulated deletion and association interruption determination on candidate pruning code units, the code pruning scheme can be made to include only code units that do not disrupt the target functional chain, and the pruning results can be directly mapped to the set of executable pruning objects, thereby improving the accuracy and consistency of the code pruning scheme and reducing the reliance on human experience judgment.

[0100] Based on the aforementioned embodiments, the preset verification conditions further include successful software code compilation, complete associations required to achieve the target function, and normal operation of the target function. The software code of the baseboard management controller is trimmed and verified according to the code trimming scheme. When the trimmed software code does not meet the preset verification conditions, the code trimming scheme is adjusted according to the associations. This includes: creating a trimming branch from the target code branch of the software code repository based on a version control mechanism, and executing the code trimming scheme in the trimming branch; calling the firmware compilation engine to compile the trimmed software code, obtaining a compilation result, and generating a firmware image of the baseboard management controller when the compilation result indicates successful compilation; performing functional verification on the target function in the firmware image, and obtaining a functional verification result; performing integrity checks on the call relationships, dependency relationships, and communication relationships required to achieve the target function according to the associations, and obtaining an integrity check result; when the compilation result, integrity check result, or functional verification result does not meet the corresponding preset verification conditions, abnormally associated code units are determined according to the associations, and the code trimming scheme is adjusted according to the abnormally associated code units.

[0101] In practice, the version control mechanism employs branch isolation in the software code repository, deriving trimming branches from the target code branch and associating trimming operations with records related to compilation, verification, and rollback to the trimming branch, enabling traceability of the code state corresponding to each adjustment. The firmware compilation engine can call a cross-compiler and linker matching the target architecture of the baseboard management controller to compile and link the code in the trimming branch, generating a firmware image upon successful compilation and linking. In one optional implementation, the firmware compilation engine can be the BitBake compilation engine. Functional verification can be performed by executing target function use cases in a simulation environment or on the target board to test peripheral control, service startup, and message responses. Integrity verification can be based on the relationships represented by the code knowledge graph, comparing the call relationships, dependencies, and communication relationships corresponding to the target function to confirm that relevant code units, interface definitions, and message paths are all preserved.

[0102] When compilation fails, related links are missing, or functionality malfunctions, the abnormal relationships and corresponding abnormal code units are located based on the relationships. These code units are then mapped to deleted and retained records in the trimming operation, thereby correcting the code trimming scheme. This correction can manifest as restoring the code content corresponding to the abnormal code unit, restoring the corresponding build dependencies or service configurations, or supplementing the corresponding configuration modifications. Trimming, compilation, integrity verification, and functional verification are re-executed according to the adjusted code trimming scheme until the trimmed software code meets the preset verification conditions. By linking trimming, compilation, integrity verification, and functional verification, and by backtracking abnormal code units and correcting the code trimming scheme based on relationships when any verification fails, the trimmed baseboard management controller software code can remain compilable, with complete relationships, and capable of normal operation, improving the consistency and maintainability of the trimming results.

[0103] Figure 3 This is a schematic flowchart illustrating the method for generating and reusing cropping templates provided in an embodiment of this application. Please refer to... Figure 3 In addition to the foregoing embodiments, it further includes:

[0104] S301: When the trimmed software code meets the preset verification conditions, a trimming template is generated based on the corresponding hardware platform information, application scenario information, software code version information, code trimming scheme and dependency verification standard.

[0105] S302, when a new software function trimming requirement is received, if a trimming template matching the new software function trimming requirement is found, the new software code repository is parsed to obtain the new code unit and the relationship between the new code units;

[0106] S303, adapt the trimming template according to the new software function trimming requirements, new code units and relationships to obtain a new code trimming scheme;

[0107] S304, trimming and verifying the software code in the new software code repository according to the new code trimming scheme.

[0108] In practical implementation, after the trimmed software code passes compilation, functional and related integrity verification, the current code trimming scheme, along with hardware platform information, application scenario information, software code version information, and dependency verification standards, is written into the trimming template library. A retrieval identifier is configured for each trimming template to facilitate subsequent matching based on the target function, platform type, and version range in the new requirements. Upon receiving a new software function trimming requirement, if a matching trimming template is found, structural parsing is performed on the new software code repository to re-identify code units and their call relationships, dependencies, and communication relationships within the code files. The new requirements, code units, and relationships are then mapped to the trimming rules and verification conditions recorded in the template, generating a new, adapted code trimming scheme. Based on this scheme, trimming, compilation, related verification, and functional verification are performed on the new software code repository. If code unit names, interfaces, or relationships change, the corresponding mappings can be updated based on functional correspondences, interface correspondences, and relationship correspondences.

[0109] This process solidifies validated trimming experience and verification standards into trimming templates. When new requirements arise, these templates are rebuilt and adapted to the new code structure. This ensures that the trimming objects, dependency boundaries, and verification constraints in the new software code repository are compatible with the new software feature trimming requirements and code structure, resulting in a reusable, adapted code trimming solution. Using this implementation method, trimming results can be migrated based on template reuse, reducing the workload of repeatedly analyzing code relationships and maintaining consistency in trimming and verification across different hardware platforms and application scenarios.

[0110] Based on the aforementioned embodiments, the firmware compilation engine is further invoked to compile the trimmed software code, including: detecting the execution status of the code trimming scheme through the code repository analysis platform; generating compilation trigger information when the code trimming scheme is detected to be completed, and sending the compilation trigger information to the firmware compilation engine; and receiving the compilation status and compilation result returned by the firmware compilation engine.

[0111] Upon detection of the code trimming scheme's completion, compilation trigger information is generated and sent to the firmware compilation engine via interface calls, message queues, or task scheduling channels. Based on the version information carried in the trigger information, the corresponding compilation environment is selected. Dependency resolution and target file generation are performed on the trimmed software code, and firmware image building is initiated upon successful compilation and linking. The system receives the returned compilation status and results. The compilation status indicates compilation progress or completion, while the compilation results indicate successful compilation, compilation failure, and the reason for failure. The compilation status can be returned in stages: at the start of the build, during the build, and at the completion of the build. The compilation results may include log summaries, error codes, artifact paths, and image verification information, forming a compilation record corresponding to the software code version.

[0112] By first determining whether the code trimming scheme has truly been completed, and then sending trigger information to the firmware compilation engine, the compilation timing is kept consistent with the trimming state. Based on the returned compilation status and results, the build status of the trimmed code can be recorded and judged, and used as the basis for subsequent verification, rollback, or further trimming, ensuring that the compilation process of the trimmed software code is linked to the software code repository state.

[0113] Based on the foregoing embodiments, the method further includes: recording the deleted code files, modified configuration parameters, operators, operation time, and software code version during the execution of the code trimming scheme, generating trimming operation records; setting version tags for the trimming operation records and the software code corresponding to the trimming operation records, forming a trimming log for tracing the software function trimming process.

[0114] In implementation, the execution results of the code pruning scheme are obtained in the pruning branch, and the deleted file paths, configuration item names, parameter values ​​before and after changes, execution account identifiers, commit timestamps, and version numbers are collected and written to the pruning operation log table. It can also record the deleted code content, modified build recipes, and corresponding rollback information. Subsequently, version tags are generated for the pruning operation records and their corresponding software code based on the commit hash value, branch identifier, or version sequence number, and the version tags are written to the log index field, enabling the pruning log to be retrieved by version, by person, or by time. The version tag can use a single version number or a combination of version number and commit hash value. In practical applications, other implementation methods can also be chosen for this tag, and this application does not limit this.

[0115] By recording the deleted code files, modified configuration parameters, operators, operation times, and software code versions, and further setting version tags for the corresponding software code, a correspondence is established between the trimming records and the code status. The resulting trimming log can completely preserve the feature trimming trajectory and provide a basis for subsequent version backtracking, change source location, and trimming result verification, thereby improving the traceability of the software feature trimming process and the consistency of version management.

[0116] In one possible implementation, calling the firmware compilation engine to compile the trimmed software code also includes: monitoring the compilation status of the firmware compilation engine and obtaining compilation error information when the compilation result indicates a compilation failure; and determining the code unit that caused the compilation failure and the corresponding code file location based on the compilation error information and the correlation.

[0117] In practical implementation, after the trimmed software code is submitted to the firmware compilation engine, it enters the compilation execution state. Compilation status information is obtained through synchronous reception or polling to determine whether the current compilation process is still running, has ended, or has terminated abnormally. When the compilation result indicates a failure, the compilation log, error code, and error text are obtained. The error text may include the file name, line number, column number, and a description of the failure reason. Subsequently, the compilation error information is matched with pre-established associations. Based on the file identifier, function identifier, interface identifier, or macro definition identifier contained in the error text, combined with the static mapping relationship of code units, the corresponding code unit is located, and its line and column positions in the code file are further parsed to obtain the code file location related to the compilation failure. For cases with cross-file references, related code units can also be traced based on call relationships and dependencies to confirm the error location, the actual cause, and its propagation path.

[0118] Using the above method, error messages after compilation failures can be associated with specific code units and their file locations, providing a clear basis for subsequent code trimming or code repair. Because the localization process relies on compilation status monitoring, error message extraction, and correlation mapping, it reduces the need for manual file-by-file checks and enables faster problem localization results when compilation errors occur in the trimmed software code.

[0119] Based on the foregoing embodiments, further functional verification is performed on the target functions in the firmware image, including: verifying at least one of the following functions: hardware status monitoring, remote management, power on / off control, and inter-process message bus communication; furthermore, performance verification can also be performed on at least one of the following: firmware size, memory usage, and processor load of the firmware image.

[0120] In practical verification, the trimmed firmware image can be loaded onto the target hardware platform or simulation environment corresponding to the baseboard management controller. After startup, the test program triggers hardware status reading, remote management command issuance, power-on / off control command execution, or inter-process message bus transmission and reception operations. The availability of the target function is determined based on the return status, log records, and interface responses. For performance verification, the file size of the firmware image can be obtained, and data such as peak resident memory usage and average processor load can be collected during firmware operation. The corresponding data is compared with the performance constraints in the software function trimming requirements to confirm that the trimmed firmware image meets the resource constraints. The test program can be deployed on the management terminal or test host and interact through network interface, serial interface, or inter-process message bus interface. In practical applications, the test program can also choose other implementation forms, which are not limited in this application. By combining functional verification and performance verification, the resource consumption of the trimmed firmware can be simultaneously constrained while confirming that the target function remains available. This ensures that the verification results cover both functional correctness and resource adaptability, and provides a basis for subsequent code trimming adjustments.

[0121] In one possible implementation, the target application scenarios in the software function pruning requirements include edge computing scenarios or data center scenarios; the software function pruning requirements corresponding to edge computing scenarios include low power consumption requirements, fast response requirements, and lightweight operation requirements; the software function pruning requirements corresponding to data center scenarios include stable operation requirements, large-scale monitoring requirements, and centralized management requirements.

[0122] In practical implementation, application scenario information can be written into the requirement description file as the initial parameter for pruning requirements. Application scenario information can directly use the input tags corresponding to edge computing scenarios or data center scenarios; when the target application scenario is not directly recorded, the corresponding scenario can also be determined based on hardware platform information, deployment scale, and operation and maintenance methods. The low-power consumption requirements, fast response requirements, and lightweight operation requirements corresponding to edge computing scenarios can be used to determine the corresponding target functions, performance constraints, and verification conditions; the stable operation requirements, large-scale monitoring requirements, and centralized management requirements corresponding to data center scenarios can be used to determine the corresponding target functions and verification conditions. The corresponding scenario information can participate in code knowledge graph matching, dependent code unit search, and code pruning scheme generation. The specific form can be scenario enumeration values, configuration key-value pairs, or requirement description fields; this application does not limit this. It should be noted that application scenario information is only used as the basis for determining target functions, performance constraints, and verification conditions; whether a code unit can be pruned still needs to be judged in conjunction with the target function and the relationship between code units. This implementation maps different application scenarios to different pruning constraints, enabling subsequent judgments on target code units, dependent code units, and candidate pruned code units to revolve around scenario requirements. For edge computing scenarios, this helps ensure that the pruning results meet the requirements of low power consumption, fast response, and lightweight operation; for data center scenarios, it helps ensure that the pruning results meet the requirements of stable operation, large-scale monitoring, and centralized management, and that the code pruning scheme is consistent with the target deployment environment.

[0123] In one possible implementation, the method further includes: responding to a change in the software code repository from a first software code version to a second software code version, determining newly added, modified, or deleted code files based on version difference information between the first and second software code versions; parsing the newly added or modified code files, comparing the parsing results of the modified code files with the parsing results of the corresponding code files in the first software code version, and combining the parsing results of the newly added code files and the mapping relationship between the deleted code files and code units to determine graph change information, the graph change information including nodes to be added, updated, or deleted and their connection relationships; incrementally updating the code knowledge graph based on the graph change information to obtain an updated code knowledge graph corresponding to the second software code version; and associating the updated code knowledge graph with the version identifier of the second software code version.

[0124] In this embodiment, the first software code version is the code version before the software code repository version change, and the second software code version is the code version after the software code repository version change. Version difference information is used to characterize the file changes between the first and second software code versions, and can be determined based on at least one of commit records, file status information, file content differences, or file identifier changes. The version identifier is used to identify the software code version corresponding to the updated code knowledge graph, and can include at least one of commit hash values, version tags, branch identifiers, or version serial numbers.

[0125] In practice, when new commit records, branch update records, or version tags are detected in the software code repository, the file directories and file states before and after the version change can be obtained. Based on the differences in file paths, file hash values, and file content, the newly added, modified, or deleted code files can be identified. For newly added code files, the code units within them, as well as the call relationships, dependencies, and communication relationships between code units, are identified using the aforementioned code parsing method. For modified code files, the parsing results after modification are compared with the parsing results before modification to determine the newly added, content-changed, or invalid code units and their relationships. For deleted code files, the code units corresponding to the deleted code file and the relationships connected to the corresponding code units are determined based on the mapping relationship between code units and code files.

[0126] In one possible embodiment, if the version change involves the interface definition file, service configuration file, or message sending and receiving code of the inter-process message bus, the changed interface definitions, service configurations, and message processing content can be parsed to determine the communication relationships to be added, updated, or deleted. If the modified code file contains changes in function names, interface names, or code locations, the code units before and after the modification can be matched based on the code unit identifier, interface identifier, and referenced object; for code units for which no corresponding relationship can be established, they can be processed as newly added or deleted code units.

[0127] After confirming the changes to the code knowledge graph, corresponding nodes and their connections are added to the graph based on the code units and relationships to be added. For the changed code units and relationships, the node attributes and their connections are updated. For the deleted code units and relationships, the corresponding nodes and their connections are deleted. During incremental updates, nodes and their connections unaffected by version changes are retained, eliminating the need to re-parse the entire software code repository. After the update, the nodes, connections, and attributes in the code knowledge graph correspond to the second software code version.

[0128] Furthermore, the updated code knowledge graph is associated with the commit hash, version tag, or other version identifier of the second software code version, and the correspondence between the software code version and the code knowledge graph is saved. When performing software feature trimming based on the second software code version, the updated code knowledge graph corresponding to that software code version can be obtained, and the target code unit, dependent code unit, and candidate trimming code unit can be re-determined based on the updated nodes and their connections. If it is necessary to backtrack the previous software feature trimming process, the code knowledge graph of the corresponding version can also be obtained based on the version identifier to determine the code units under the corresponding software code version and their associations.

[0129] By incrementally updating the nodes and their connections in the code knowledge graph affected by version changes based on differences between software code versions, the redundant processing required to re-parse all code files when partial changes occur in the software code repository can be reduced. Furthermore, by associating the updated code knowledge graph with the corresponding software code version identifier, the code units and their relationships used for subsequent pruning can be kept consistent with the software code version to be pruned. This reduces discrepancies in pruning scope judgments caused by inconsistencies between the code knowledge graph and the software code version, and provides a basis for pruning processing and issue backtracking across different software code versions.

[0130] This application takes the firmware trimming of a baseboard management controller deployed on an edge computing node server as an example. The operating environment of the baseboard management controller is limited by resources such as storage space, memory, and processing power. The corresponding software function trimming requirements include low power consumption, lightweight operation, and fast response, and require the firmware size to be controlled within 50MB, while retaining target functions such as hardware status detection, remote management, and remote power on / off control. The software code repository to be trimmed contains approximately 10,000 functional modules, of which about 30% of the functional modules do not need to be retained in the current edge computing scenario, and there are function calls, build dependencies, hardware driver dependencies, and D-Bus communication associations between the functional modules.

[0131] Upon receiving the software feature customization requirements, the software code repository of the baseboard management controller is connected to the Git Nexus code repository analysis platform. Code files, configuration files, service configuration files, and BitBake build recipes are scanned and parsed. Through lexical analysis, syntax analysis, and static analysis of the code files, code units such as functions, data structures, interfaces, and code blocks are identified, and the call relationships and dependencies between these code units are extracted. Combined with the D-Bus interface definition, service configuration, and message sending and receiving code, communication relationships are extracted.

[0132] For example, the analysis results show that the `get_temperature()` function in `sensor_monitor` calls the `process_data()` function, there is a hardware driver dependency between `sensor_monitor` and `gpio-driver`, and `process_data()` sends hardware status information via D-Bus communication. Based on the above call relationships, dependency relationships, and communication relationships, a code knowledge graph is constructed, with each code unit as a node and the corresponding relationships as graph edges. The relevant call chains, dependency chains, and D-Bus communication paths are then displayed through the GitNexus code repository analysis platform.

[0133] The software functionality requirements, including hardware status detection, remote management, and remote power-on / off control, are matched with the functions represented by each code unit in the code knowledge graph. This identifies the functions and interfaces in `sensor_monitor` used for hardware status detection, and the functions and interfaces used for remote management and remote power-on / off control, as target code units. Then, starting from these target code units, a search is performed along the call relationships, dependencies, and communication relationships required to implement the target functionality. Interfaces and processing code for message sending and receiving in `dbus-communication`, and interfaces and processing code for hardware access in `gpio-driver`, are identified as dependent code units. The remaining code units are then identified as candidate code units for tailoring.

[0134] After screening, it was determined that all code units contained in `big_data_analyzer` were unrelated to the target function, and these code units were identified as candidate code units to be pruned. The scope of the impact was obtained by simulating the deletion of the nodes and graph edges corresponding to the candidate code units using a code knowledge graph. Simulation results showed that deleting the corresponding nodes and graph edges would not interrupt the calling relationships, dependencies, or D-Bus communication relationships required for hardware status detection, remote management, and remote power-on / off control. Therefore, the corresponding candidate code units were determined as the actual code units to be pruned, and a code pruning scheme for removing `big_data_analyzer` was generated accordingly.

[0135] Once the code pruning plan is determined, a pruning branch named feature / edge-bmc-trim is created from the target code branch based on the version control mechanism. The code files corresponding to big_data_analyzer are deleted from this pruning branch, and the relevant configuration files and BitBake build recipes are updated. During the pruning process, the deleted code files, modified configuration parameters and build recipes, the operating account, the operation time, and the software code version are recorded to generate a pruning operation record. This record is then associated with the software code version in the pruning branch to form a pruning log.

[0136] After the code trimming scheme is detected and executed, compilation trigger information is generated and sent to the BitBake compilation engine. The BitBake compilation engine is then invoked to compile and link the trimmed software code, and the corresponding compilation status and results are received. During this initial compilation, due to the failure to properly preserve the build dependencies corresponding to gpio-driver when modifying the BitBake build recipe, gpio-driver was not included in the compilation targets, resulting in compilation failure.

[0137] Based on the missing symbols and error file locations in the compilation error message, and combined with the dependency relationship between sensor_monitor and gpio-driver in the code knowledge graph, the code unit related to the compilation failure was determined to belong to gpio-driver, and the corresponding call location and BitBake build recipe were further identified. The code trimming scheme was adjusted based on the location results, the build dependencies corresponding to gpio-driver were restored, and the trimming and compilation were re-executed according to the adjusted code trimming scheme.

[0138] After successful recompilation, a firmware image for the baseboard management controller is generated. The integrity of the call relationships, dependencies, and D-Bus communication relationships required to achieve the target functionality is verified based on the code knowledge graph. Subsequently, hardware status detection verification, remote management verification, remote power-on / off control verification, and D-Bus communication function verification are performed on the firmware image, along with performance verification of the firmware size. If the compilation results, integrity verification results, or function verification results do not meet the corresponding preset verification conditions, abnormal code units are identified based on the relationships, and the code trimming scheme is adjusted until the trimmed software code meets the preset verification conditions.

[0139] In this embodiment, the firmware image obtained after recompilation passes the integrity verification of the association relationship and the verification of each target function. The firmware size is reduced from 120MB before trimming to 48MB, which meets the performance constraint that the firmware size does not exceed 50MB. Thus, a firmware image suitable for the baseboard management controller of edge computing nodes is obtained.

[0140] After the trimmed software code meets the preset verification conditions, a trimming template is generated based on the hardware platform information, edge computing application scenario information, software code version information, code trimming scheme, and dependency verification standards corresponding to this trimming. The trimming template records the target function matching rules, the determination results of the target code unit and dependent code unit, the actual trimmed code unit, related configuration modifications, and dependency verification standards. Among them, the target function matching rules are used to determine the code units corresponding to hardware status detection, remote management, and remote power on / off control, and the dependency verification standards are used to ensure that the corresponding call chain, hardware driver dependencies, and D-Bus communication path remain intact, rather than deciding whether to retain or trim the code unit based solely on its resource consumption value.

[0141] When customizing the firmware for the baseboard management controller for another edge computing node, a trimming template was retrieved based on the new software function trimming requirements. The new software code repository (version v2.0) was parsed to obtain new code units and their relationships. Based on the functions, interface information, and associated paths represented by the code units, the corresponding `lightweight_monitor` in the new version was determined to correspond to the `sensor_monitor` in the original version. Accordingly, the code unit mappings, relationships, and configuration modifications in the trimming template were updated to obtain a code trimming scheme suitable for the new version. After completing trimming, compilation, integrity verification, and functional verification based on the new code trimming scheme, a baseboard management controller firmware image adapted to the new version software code repository was obtained.

[0142] Through the above implementation process, a closed loop is formed by software function trimming requirements, code knowledge graph, trimming impact analysis, compilation and verification results, and the verified trimming template is reused in the new version software code repository. This can reduce firmware size while maintaining the integrity of target functions and necessary dependencies, and at the same time reduce the workload of repeatedly determining code trimming boundaries and dependency verification conditions.

[0143] Figure 4 This is a schematic diagram of the software function trimming device provided in an embodiment of this application. Please refer to... Figure 4 The software function trimming device 40 includes:

[0144] The parsing module 401 is used to parse the software code repository of the baseboard management controller in response to the software function trimming requirements, and obtain multiple code units and the relationship between the multiple code units.

[0145] The filtering module 402 is used to determine the target code unit and the dependent code units associated with the target code unit from multiple code units based on the software function tailoring requirements and relationships, and to determine the code units other than the target code unit and the dependent code units as candidate tailoring code units.

[0146] Analysis module 403 is used to analyze the impact of candidate pruning code units on target code units and dependent code units based on the relationship, and generate a code pruning scheme based on the impact results;

[0147] The trimming module 404 is used to trim and verify the software code of the baseboard management controller according to the code trimming scheme, and adjust the code trimming scheme according to the correlation when the trimmed software code does not meet the preset verification conditions.

[0148] In one possible implementation, the relationships include call relationships, dependency relationships, and communication relationships. The parsing module 401 is specifically used for:

[0149] The code files in the software code repository are scanned, and lexical and syntactic analysis is performed on the code files to obtain code structure information;

[0150] Identify code units in the software code repository based on code structure information. Code units include at least one of functions, data structures, interfaces, and code blocks.

[0151] Static analysis is performed on code units based on code structure information to extract call relationships and dependencies between code units. Communication relationships are also extracted based on the interface definition, service configuration, and message sending and receiving code of the inter-process message bus corresponding to the code unit.

[0152] In one possible implementation, the filtering module 402 is specifically used for:

[0153] By treating code units as nodes and connecting call relationships, dependencies, and communication relationships between nodes, a code knowledge graph is constructed.

[0154] Match the software function trimming requirements with the functions represented by code units in the code knowledge graph to determine the target code unit, and then determine the function represented by the target code unit as the target function;

[0155] Based on the code knowledge graph, starting from the target code unit, the search proceeds along the calling relationships, dependencies, and communication relationships required to achieve the target function, and the code units that the target code unit directly or indirectly depends on are identified as dependent code units.

[0156] In one possible implementation, the analysis module 403 is specifically used for:

[0157] Based on the code knowledge graph, the nodes corresponding to the candidate pruning code units and their connection relationships are simulated for deletion to determine the association between the affected code units and the interruption, and the scope of the association impact is obtained.

[0158] Based on the scope of the associated impact, determine whether pruning the candidate pruning code unit will interrupt the association between the target code unit and the dependent code unit to achieve the target function;

[0159] Candidate trimming code units that cause the association to break are removed from the candidate trimming code units. The remaining candidate trimming code units are determined as the actual trimming code units, and a code trimming scheme is generated based on the actual trimming code units.

[0160] In one possible implementation, the preset verification conditions include successful software code compilation, complete associations required to achieve the target function, and normal operation of the target function. The trimming module 404 is specifically used for:

[0161] Based on the version control mechanism, a pruning branch is created from the target code branch of the software code repository, and the code pruning scheme is executed in the pruning branch;

[0162] The firmware compilation engine is called to compile the trimmed software code, and the compilation result is obtained. When the compilation result indicates that the compilation is successful, the firmware image of the baseboard management controller is generated. The target functions in the firmware image are verified to obtain the functional verification result.

[0163] Based on the relationships, the integrity of the calling relationships, dependency relationships, and communication relationships required to achieve the target function is verified, and the integrity verification results are obtained.

[0164] When the compilation result, integrity verification result, or functional verification result does not meet the corresponding preset verification conditions, the code unit associated with the exception is determined according to the association relationship, and the code trimming scheme is adjusted according to the code unit associated with the exception.

[0165] In one possible implementation, a multiplexing module is also included, for:

[0166] When the trimmed software code meets the preset verification conditions, a trimming template is generated based on the corresponding hardware platform information, application scenario information, software code version information, code trimming scheme and dependency verification standards.

[0167] When a new software feature trimming requirement is received, if a trimming template matching the new software feature trimming requirement is found, the new software code repository is parsed to obtain the new code unit and the relationship between the new code unit.

[0168] The trimming template is adapted to the new software function trimming requirements, new code units, and relationships to obtain a new code trimming scheme;

[0169] The software code in the new software code repository is trimmed and verified according to the new code trimming scheme.

[0170] The software function trimming device 40 provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0171] Figure 5 This is a schematic diagram of the software function trimming device provided in an embodiment of this application. Please refer to... Figure 5 The software function trimming device 50 may include a memory 501 and a processor 502. For example, the memory 501 and the processor 502 are interconnected via a bus 503.

[0172] Memory 501 is used to store program instructions;

[0173] The processor 502 is used to execute the program instructions stored in the memory, so that the software function trimming device 50 performs the method shown in the above method embodiment.

[0174] The software function trimming device 50 provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.

[0175] This application provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above-described method when executed by a processor.

[0176] This application embodiment may also provide a computer program product, including a computer program that, when executed by a processor, can implement the above-described method.

[0177] All or part of the steps in the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a readable memory. When the program is executed, it performs the steps of the above-described method embodiments; and the aforementioned memory (storage medium) includes: read-only memory (ROM), random access memory (RAM), flash memory, hard disk, solid-state drive, magnetic tape, floppy disk, optical disc, and any combination thereof.

[0178] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0179] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0180] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0181] Obviously, those skilled in the art can make various modifications and variations to the embodiments of this application without departing from the spirit and scope of this application. Therefore, if these modifications and variations to the embodiments of this application fall within the scope of the claims of this application and their equivalents, this application also intends to include these modifications and variations.

[0182] In this application, the term "comprising" and its variations can refer to non-limiting inclusion; the term "or" and its variations can refer to "and / or". The terms "first", "second", etc., in this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. In this application, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

Claims

1. A method for trimming software functions, characterized in that, The method includes: In response to the software function trimming requirements, the software code repository of the baseboard management controller is analyzed to obtain multiple code units and the relationships between the multiple code units; Based on the software function trimming requirements and the association relationships, target code units and dependent code units associated with the target code units are determined from the plurality of code units, and code units other than the target code units and the dependent code units are determined as candidate trimming code units; Based on the aforementioned relationship, the impact of pruning the candidate pruning code units on the target code unit and the dependent code units is analyzed, and a code pruning scheme is generated based on the impact results. The software code of the baseboard management controller is trimmed and verified according to the code trimming scheme. If the trimmed software code does not meet the preset verification conditions, the code trimming scheme is adjusted according to the correlation.

2. The method according to claim 1, characterized in that, The relationships include invocation relationships, dependency relationships, and communication relationships; The software code repository of the analytical substrate management controller is used to obtain multiple code units and the relationships between the multiple code units, including: The code files in the software code repository are scanned, and lexical and syntactic analysis is performed on the code files to obtain code structure information; Identify code units in the software code repository based on the code structure information, wherein the code units include at least one of functions, data structures, interfaces, and code blocks; Static analysis is performed on the code units based on the code structure information to extract the calling and dependency relationships between the code units. Furthermore, the communication relationships are extracted based on the interface definition, service configuration, and message sending and receiving code of the inter-process message bus corresponding to the code unit.

3. The method according to claim 2, characterized in that, The step of determining the target code unit and its dependent code units from the plurality of code units based on the software function tailoring requirements and the association relationships includes: By using the code units as nodes and the calling relationships, the dependency relationships, and the communication relationships as the connection relationships between nodes, a code knowledge graph is constructed. The software function trimming requirements are matched with the functions represented by the code units in the code knowledge graph to determine the target code unit, and the function represented by the target code unit is determined as the target function; Based on the code knowledge graph, starting from the target code unit, the search proceeds along the call relationships, dependencies, and communication relationships required to achieve the target function, and the code units that the target code unit directly or indirectly depends on are identified as the dependent code units.

4. The method according to claim 3, characterized in that, Based on the aforementioned relationship, the impact of pruning the candidate pruning code units on the target code unit and the dependent code units is analyzed, and a code pruning scheme is generated based on the impact results, including: Based on the code knowledge graph, the nodes corresponding to the candidate pruning code units and their connection relationships are simulated for deletion to determine the affected code units and the association relationship of the interruption, and the scope of the association impact is obtained. Based on the scope of the association, determine whether pruning the candidate pruning code unit will interrupt the association between the target code unit and the dependent code unit in order to achieve the target function; Candidate trimming code units that cause the association to be interrupted are removed from the candidate trimming code units, the remaining candidate trimming code units are determined as actual trimming code units, and the code trimming scheme is generated based on the actual trimming code units.

5. The method according to claim 3, characterized in that, The preset verification conditions include successful software code compilation, complete associations required to achieve the target function, and normal operation of the target function. The software code of the baseboard management controller is trimmed and verified according to the code trimming scheme. If the trimmed software code does not meet the preset verification conditions, the code trimming scheme is adjusted according to the correlation relationship, including: Based on the version control mechanism, a pruning branch is created from the target code branch of the software code repository, and the code pruning scheme is executed in the pruning branch; The trimmed software code is compiled by calling the firmware compilation engine to obtain the compilation result. When the compilation result indicates successful compilation, the firmware image of the baseboard management controller is generated. The target function in the firmware image is verified to obtain the function verification result. Based on the aforementioned relationships, the integrity of the calling relationships, dependency relationships, and communication relationships required to achieve the target function is verified, and the integrity verification result is obtained. When the compilation result, the integrity verification result, or the functional verification result does not meet the corresponding preset verification conditions, the abnormal associated code unit is determined according to the association relationship, and the code trimming scheme is adjusted according to the abnormal associated code unit.

6. The method according to claim 5, characterized in that, The method further includes: When the trimmed software code meets the preset verification conditions, a trimming template is generated based on the corresponding hardware platform information, application scenario information, software code version information, code trimming scheme and dependency verification standard. When a new software feature trimming requirement is received, if a trimming template matching the new software feature trimming requirement is found, the new software code repository is parsed to obtain the new code unit and the association between the new code units. The trimming template is adapted to the new software function trimming requirements, the new code units, and the relationships to obtain a new code trimming scheme; The software code in the new software code repository is trimmed and verified according to the new code trimming scheme.

7. A software function trimming device, characterized in that, include: The parsing module is used to parse the software code repository of the baseboard management controller in response to software function trimming requirements, and obtain multiple code units and the relationships between the multiple code units; The filtering module is used to determine the target code unit and the dependent code unit associated with the target code unit from the plurality of code units according to the software function trimming requirements and the association relationship, and to determine the code units other than the target code unit and the dependent code units as candidate trimming code units. The analysis module is used to analyze the impact of pruning the candidate pruning code units on the target code unit and the dependent code units based on the correlation relationship, and generate a code pruning scheme based on the impact results; The trimming module is used to trim and verify the software code of the baseboard management controller according to the code trimming scheme, and adjust the code trimming scheme according to the association relationship when the trimmed software code does not meet the preset verification conditions.

8. A software function trimming device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, in, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.