Method and device for converting Kconfig into ARXML and storage medium
By parsing Kconfig files and AUTOSAR standardization, converting them into ARXML files, the problem of manual Kconfig configuration conversion is solved, and the problem of time-consuming and labor-intensive and easy introduction of errors is realized, and seamless conversion and efficient migration from Kconfig to ARXML is achieved.
Patent Information
- Application Number
- CN202510058615.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-05-30
AI Technical Summary
In the automotive electronics field, especially in the AUTOSAR architecture, developers need to manually perform a lot of Kconfig configuration conversion work to meet more complex and strict configuration needs, which is not only time-consuming and labor-intensive, but also prone to error introduction.
Provide a method of Kconfig to ARXML. By parsing the Kconfig file, the initial json object is obtained; standardize the json object based on AUTOSAR to obtain the standard json object; convert the standard json object into XML object; and generate the target ARXML file based on the XML object, realizing seamless conversion from Kconfig configuration to ARXML configuration.
The conversion process from Kconfig to ARXML is automated, which improves conversion efficiency and reduces the error risk of manual conversion, providing an effective solution for the migration of OS kernel configuration to AUTOSAR OS configuration.
Smart Images

Figure CN120068805A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automotive electronic file format conversion processing, and particularly relates to a method, device and storage medium for converting Kconfig to ARXML. Background Art
[0002] With the rapid development of automotive electronic technology, the complexity and diversity of automotive software systems are increasing day by day, and the requirements for software configuration management are becoming more and more strict. Traditional configuration methods, such as directly editing configuration files, are not only inefficient but also error-prone, and it is difficult to meet the high reliability and high safety requirements of modern automotive electronic systems. Therefore, it is particularly important to develop an efficient, accurate and easy-to-use configuration system.
[0003] Kconfig (Kernel Configuration) is a configuration system for configuring OS kernel options. With its hierarchical menu structure and simple Menuconfig menu-driven interface, it provides developers with an intuitive and convenient configuration method. Through Kconfig, developers can easily select, configure and compile various functions and options of the kernel without directly editing the configuration file. This configuration method greatly improves development efficiency and reduces the risk of configuration errors.
[0004] However, in the field of automotive electronics, especially in automotive software systems that follow the AUTOSAR architecture (Automotive Open System Architecture), the configuration requirements are more complex and strict. ARXML (AUTOSAR XML), as an XML-based description language, is widely used to describe various elements in automotive software systems, including software components, interfaces, data types and configuration parameters, etc. ARXML not only provides rich description capabilities but also ensures the consistency and reusability of software configurations, and is an indispensable part of the AUTOSAR architecture.
[0005] Although Kconfig and ARXML have achieved remarkable results in their respective fields, there is an obvious gap between the two.
[0006] The current technology mainly conducts batch regression testing based on Kconfig, without converting Kconfig into a file in another format. For example, CN115794656A discloses an incremental automatic batch regression testing method based on the Kconfig automatic configuration system. When developers migrate the Kconfig-based OS configuration to the AUTOSAR architecture, they often need to manually perform a large amount of configuration conversion work, which is not only time-consuming and laborious but also prone to errors. Therefore, how to achieve seamless conversion between Kconfig configuration and ARXML configuration has become an urgent problem to be solved. Summary of the Invention
[0007] In view of the above problems, the present invention provides a method, device, and storage medium for converting Kconfig to ARXML, which can achieve seamless conversion from Kconfig configuration to ARXML configuration.
[0008] A method for converting Kconfig to ARXML provided by the present invention includes: Parsing the Kconfig file to obtain an initial json object; Standardizing the initial json object based on AUTOSAR to obtain a standard json object; Converting the standard json object into an XML object; Generating a target ARXML file according to the XML object.
[0009] As a further improvement of the present invention, the parsing the Kconfig file to obtain an initial json object includes: Optimizing esp-idf-kconfig; Based on the optimized esp-idf-kconfig, parsing the Kconfig file; Capturing the output stream after parsing the Kconfig file to obtain an initial json object.
[0010] As a further improvement of the present invention, the parsing the Kconfig file based on the optimized esp-idf-kconfig includes parsing the configuration data of default and select in the Kconfig file.
[0011] As a further improvement of the present invention, the capturing the output stream after parsing the Kconfig file to obtain an initial json object includes capturing the output stream after parsing the Kconfig file, parsing the output stream into a string, and then converting the string into json format to obtain the initial json object.
[0012] As a further improvement of the present invention, standardizing the initial json object based on AUTOSAR to obtain a standard json object includes parsing the initial json object according to the standard tags and formats of AUTOSAR to obtain a standard json object.
[0013] As a further improvement of the present invention, parsing the initial json object according to the standard tags and formats of AUTOSAR to obtain a standard json object includes traversing the initial json object. If the sub-object is an array of menu type data, continue to traverse the sub-object; otherwise, parse according to the standard tags and formats of AUTOSAR to obtain a standard json object.
[0014] As a further improvement of the present invention, generating a target ARXML file according to the XML object includes serializing the XML object into a string and writing the XML string into the ARXML file to generate a target ARXML file.
[0015] An apparatus provided by the present invention includes a memory, a processor, and a computer program stored on the memory. The processor executes the computer program to implement the steps of the above method for converting Kconfig to ARXML.
[0016] A computer-readable storage medium provided by the present invention has a computer program stored thereon. When the computer program is executed by a processor, the steps of the above method for converting Kconfig to ARXML are implemented.
[0017] By providing a method, apparatus, and storage medium for converting Kconfig to ARXML, the present invention first parses a Kconfig file to obtain an initial json object; standardizes the initial json object based on AUTOSAR to obtain a standard json object; converts the standard json object into an XML object; and generates a target ARXML file according to the XML object, automating the process of converting Kconfig to ARXML, improving the conversion efficiency, solving the problems existing in manual conversion, and providing a solution for migrating the OS kernel configuration to the AUTOSAR OS configuration. Description of the Drawings
[0018] Figure 1 It is a schematic flowchart of the method for converting Kconfig to ARXML according to an embodiment of the present invention.
[0019] Figure 2 It is a specific schematic flowchart of the method for converting Kconfig to ARXML according to an embodiment of the present invention.
[0020] Figure 3It is the configuration interface of RT-Thread Menuconfig in the method of converting Kconfig to ARXML according to the embodiments of the present invention.
[0021] Figure 4 It is another configuration interface of RT-Thread Menuconfig in the method of converting Kconfig to ARXML according to the embodiments of the present invention.
[0022] Figure 5 It is the configuration interface of AUTOSAR OS ARXML in the method of converting Kconfig to ARXML according to the embodiments of the present invention. Detailed implementation manners
[0023] The following combines specific embodiments and appendices Figures 1-5 to make a detailed description of the invention, so that those skilled in the art can more fully understand the purpose, features and effects of the present invention.
[0024] Unless otherwise defined, all technical and scientific terms used in the present invention have the same meaning as commonly understood by those skilled in the art to which the present invention belongs. When the definition of a term in the present invention conflicts with the meaning commonly understood by those skilled in the art, the definition described in the present invention shall prevail.
[0025] The present invention provides a method, device and storage medium for converting Kconfig to ARXML, realizing seamless migration from Kconfig configuration to ARXML configuration.
[0026] Embodiment 1 As a specific embodiment of the present invention, this embodiment provides a method for converting Kconfig to ARXML. Refer to Figure 1 、 Figure 2 , and the specific steps are as follows: S100. Parse the Kconfig file to obtain an initial json object; S200. Standardize the initial json object based on AUTOSAR to obtain a standard json object; S300. Convert the standard json object into an XML object; S400. Generate a target ARXML file according to the XML object.
[0027] The method for converting Kconfig to ARXML provided by the present invention first parses the Kconfig file to obtain an initial json object, and then converts it into a standard json object that conforms to AUTOSAR according to the requirements of AUTOSAR. Then, the standard json object is converted into an available standard ARXML file, realizing the automatic conversion of Kconfig into a standard ARXML configuration file under the basis of the AUTOSAR standard.
[0028] Embodiment 2 As a specific embodiment of the present invention, this embodiment provides a method for converting Kconfig to ARXML, and the specific steps are as follows: S100. Parse the Kconfig file to obtain an initial json object In this embodiment, a parsing tool is used to parse the Kconfig file to obtain the initial josn object. Preferably, the esp-idf-kconfig parsing tool is used. esp-idf-kconfig is an open-source Kconfig parsing tool that can parse the Kconfig file and convert it into data in Json format.
[0029] The traditional esp-idf-kconfig parsing tool fails to parse the configuration data including default and select in Kconfig. Therefore, in this embodiment, esp-idf-kconfig is first optimized, and the optimized esp-idf-kconfig parsing tool is used to realize the parsing of the configuration data including default and select.
[0030] Specifically, in one example, it includes: S101. Optimize esp-idf-kconfig In S101, esp-idf-kconfig is optimized, and the optimized esp-idf-kconfig is packaged into an executable file and named. As Figure 2 shown, the optimized esp-idf-kconfig can be packaged into an executable file k2j.exe. By modifying the source code, the optimized esp-idf-kconfig can realize the parsing of the default and select configuration data in Kconfig.
[0031] S102. Based on the optimized esp-idf-kconfig, parse the Kconfig file Obtain the Kconfig file under the root directory and execute the parsing command for the Kconfig file. As Figure 2As shown, obtain the Kconfig file in the bsp root directory, and execute the command `k2j --kconfig Kconfig` in the code to parse the Kconfig file.
[0032] S103. Capture the output stream after parsing the Kconfig file to obtain the initial json object Capture the output stream after executing the parsing command for the Kconfig file in S102, read the corresponding hexadecimal data and decryption algorithm to parse the output stream into a string, and then convert the string into json format to obtain the initial json object. As Figure 2 shown, obtain the configuration items configs.
[0033] Based on esp-idf-kconfig, implement the parsing of configurations including default, select, and depedents of Kconfig, and convert the final parsing result into json format data. By parsing the Kconfig file and processing the output stream after parsing, all configurations are combined into an initial json object.
[0034] Json (JavaScript Object Notation) is a lightweight data interchange format. It is based on a subset of ECMAScript (the js specification formulated by the European Computer Manufacturers Association), and uses a text format that is completely independent of the language to store and represent data. The Json format is concise and easy to read and write by humans, and is also easy to parse and generate by machines. In the conversion process of this embodiment, json is used as an intermediate representation layer to facilitate data conversion between different formats. By first parsing the Kconfig file into a json object, it is easier to process and convert the data according to AUTOSAR requirements later, standardize the data, and then convert the processed data into an ARXML file. Using the json format as the intermediate representation layer can improve the conversion efficiency.
[0035] If an exception occurs when capturing the output stream after executing the parsing command for the Kconfig file in S102, prompt the reason for the failure and end.
[0036] S200. Standardize the initial json object based on AUTOSAR to obtain the standard json object In this embodiment, the initial json object obtained after parsing the Kconfig file does not meet the AUTOSAR (ARXML) requirements. Therefore, it is necessary to standardize the initial json object and convert it into a standard json object that meets AUTOSAR requirements.
[0037] Specifically, the initial json object is parsed according to the standard tags and formats of AUTOSAR to obtain a json object that conforms to the Autosar standard.
[0038] First, traverse the initial json object obtained in S100. If the sub-object is an array data of menu type, continue to traverse the sub-object; otherwise, parse it in combination with the AUTOSAR standard to obtain a json object that conforms to the AUTOSAR standard. As Figure 2 shown, through parsing based on the AUTOSAR standard, the configuration item configs is converted into a json object auto_configs that conforms to the AUTOSAR standard.
[0039] By interpreting the official standard document of AUTOSAR, the initial json object is converted into a Json object that conforms to the standard according to the standard tags and formats.
[0040] S300: Convert the standard json object into an XML object Since ARXML is an XML-based description language, it is necessary to convert the standard json object into an object in XML format. Specifically, a conversion algorithm in python is used to convert the standard json object into an XML object.
[0041] The conversion algorithm is an existing algorithm in python and can be directly used or called during conversion.
[0042] The standard json object is obtained according to the AUTOSAR standard, so the converted XML object also meets the requirements of the AUTOSAR standard, that is, it meets the requirements of ARXML.
[0043] S400: Generate a target ARXML file according to the XML object The XML object is serialized into a string, and the XML string is written into the ARXML file, thereby obtaining a standard ARXML configuration file.
[0044] In this embodiment, the standard json object is converted into data in XML format through a conversion algorithm, serialized into a string, and then input into the final ARXML file to complete the conversion from Kconfig to ARXML. Due to the simplicity and easy parsing of the json format, the conversion tool can process data faster and generate the required ARXML file.
[0045] Refer to Figures 3-5, the configuration interfaces of RT-Thread Menuconfig and the AUTOSAR OS ARXML configuration interface converted by this method are given respectively.
[0046] The Menuconfig configuration interface of RT-Thread uses Kconfig as the configuration system. After being converted by the method adopted in the present invention, seamless migration to the ARXML configuration of AUTOSAR OS is achieved.
[0047] Furthermore, after completing the conversion from Kconfig to ARXML, the ARXML file can be verified to improve the quality of the ARXML file and better facilitate subsequent use.
[0048] Based on the ARXML specification, the optimized esp-idf-kconfig is used for compliant parsing, and the existing OS configuration is directly converted into the AUTOSAR OS standard configuration format with one key, achieving the effect of a set of configurations being compatible with both Menuconfig configuration and AUTOSAR OS configuration.
[0049] The method for converting Kconfig to ARXML provided by the present invention realizes the conversion of the Kconfig configuration file format. By parsing Kconfig into an initial json, then converting it into a standard json conforming to the ARXML format, and finally serializing it into ARXML. The method automates the process of converting Kconfig to ARXML, improves the conversion efficiency, solves the problems existing in manual conversion, and provides a solution for the migration of the OS kernel configuration to AUTOSAR OS configuration.
[0050] Example Three As a specific embodiment of the present invention, this embodiment provides a device, including a memory, a processor, and a computer program stored on the memory. The processor executes the computer program to implement the steps of the method for converting Kconfig to ARXML in Example One and Example Two.
[0051] Example Four As a specific embodiment of the present invention, this embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for converting Kconfig to ARXML in Example One and Example Two are implemented.
[0052] Through a method, device, and storage medium for converting Kconfig to ARXML of the present invention, Kconfig can be automatically converted into a standard ARXML configuration file based on the AUTOSAR standard.
[0053] The above are only the preferred embodiments of the present invention, and are not any other form of limitation to the present invention. Any modification or equivalent change made according to the technical essence of the present invention still belongs to the scope protected by the present invention.
Claims
1. A method for converting Kconfig to ARXML, characterized in that: The method comprises: Parse the Kconfig file to get the initial json object; Based on AUTOSAR standardization, the initial json object is obtained to obtain a standard json object; Convert the standard JSON object into an XML object; Generate a target ARXML file according to the XML object.
2. The method for converting Kconfig to ARXML according to claim 1, characterized in that: The Kconfig file is parsed to obtain the initial json object including: Optimize esp-idf-kconfig; Based on the optimized esp-idf-kconfig, parsing the Kconfig file; Capture the parsed output stream of the Kconfig file to obtain the initial json object.
3. The method of converting Kconfig to ARXML according to claim 2, characterized in that: The parsing of the Kconfig file based on the optimized esp-idf-kconfig includes parsing the default and select configuration data of the Kconfig file.
4. The method of converting Kconfig to ARXML according to claim 2, characterized in that: The capturing of the output stream after the Kconfig file is parsed to obtain the initial json object includes capturing the output stream after the Kconfig file is parsed, parsing the output stream into a string, and then converting the string into a json format to obtain the initial json object.
5. The method of converting Kconfig to ARXML according to claim 1, characterized in that: The step of standardizing the initial json object based on AUTOSAR to obtain the standard json object includes parsing the initial json object according to the standard tag and format of AUTOSAR to obtain the standard json object.
6. The method of converting Kconfig to ARXML according to claim 5, characterized in that: The initial json object is parsed according to the standard tag and format of AUTOSAR to obtain the standard json object, including traversing the initial json object, and if the sub-object is array data of a menu type, continuing to traverse the sub-object, otherwise parsing according to the standard tag and format of AUTOSAR to obtain the standard json object.
7. The method of converting Kconfig to ARXML according to claim 1, characterized in that: Generating a target ARXML file according to the XML object includes serializing the XML object into a character string, and writing the XML character string into the ARXML file to generate the target ARXML file.
8. A device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Incremental automatic batch regression test method based on Kconfig automatic configuration system
CN115794656A