Method and device for transplanting open source gap system by linux kernel

By obtaining and compiling the adaptation layer code, the long development time and high maintenance costs of board manufacturers when adapting to the OpenHarmony system are solved, and unified support for Linux, Android and OpenHarmony systems is achieved, reducing labor costs and development cycles.

CN119292666AActive Publication Date: 2025-01-10HONGHU WANLIAN (JIANGSU) TECH DEV CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411452849.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-01-10
Estimated Expiration
2044-10-17

AI Technical Summary

Technical Problem

Board manufacturers need to re-adapt the board driver when adapting to the OpenHarmony system, resulting in long development time and high maintenance costs, and the existing drivers cannot be reused directly, which increases technical threshold and economic costs.

Method used

By obtaining the adapter layer code built based on the kernel characteristics of the open source Hongmeng system framework, kernel code is hongmeng in the target board's linux kernel, kernel image files are generated, and adapter layer code and open source Hongmeng system target are compiled using the target compilation tool. code to obtain the target image file, thereby starting the open source Hongmeng system of the target board.

Benefits of technology

It realizes the drivers adapted to the Linux and Android systems of the board manufacturers, which reduces the technical threshold and economic costs of OpenHarmony, shortens the development cycle, increases the enthusiasm of board manufacturers, and paves the way for the promotion of OpenHarmony. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292666A_ABST
    Figure CN119292666A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for transplanting an open source gap system by a linux kernel. The invention discloses a method for transplanting an open source gap system by a linux kernel. The method comprises the following steps: acquiring an adaptation layer code constructed based on kernel characteristics of an open source gap system framework; performing kernel code swerving on the linux kernel of the target board card to obtain a kernel mirror image file; and based on the kernel compiling related parameters and the target compiling tool, compiling the adaptation layer code and the open source gap system target code to obtain a target mirror image file, and starting the open source gap system of the target board card according to the kernel mirror image file and the target mirror image file. According to the technical scheme, linux, android and OpenHarmony systems can be supported at the same time through a set of kernel codes, the labor cost is greatly reduced, and the development period is shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of board development technology, and in particular to a method and device for transplanting a Linux kernel into an open source Hongmeng system. Background Art

[0002] Currently, all board hardware manufacturers have their own Linux kernels that adapt to Linux and Android systems, but the versions are usually very different from the Linux kernels provided by the OpenHarmony community and cannot support the features of the OpenHarmony system. For hardware manufacturers to run the OpenHarmony system, they usually need to re-adapt the board drivers to the Linux kernel of the OpenHarmony community. The work of re-adapting the board drivers is repetitive and the workload is large. The development workload increases by weeks or even months. In the future, it will be necessary to maintain an additional set of Linux kernel codes adapted to OpenHarmony for a long time, and the development manpower, development costs and development cycles will all double.

[0003] In the existing southbound adaptation process of OpenHarmony, the existing Linux and Android driver adaptation work of the board manufacturers cannot be directly reused. All hardware adaptation is done on the OpenHarmony community Linux kernel version, which is a repetitive development work that is time-consuming and labor-intensive. This makes the technical threshold and economic cost of OpenHarmony relatively high, and to some extent hinders the formation of the OpenHarmony ecosystem. Summary of the invention

[0004] The present invention provides a method and device for porting the Linux kernel to the open source Hongmeng system, so as to solve the problems of long development time and high maintenance cost for board manufacturers to adapt to the OpenHarmony system.

[0005] According to one aspect of the present invention, a method for porting an open source Hongmeng system to a Linux kernel is provided, comprising:

[0006] Obtain the adaptation layer code built based on the kernel features of the open source Hongmeng system framework;

[0007] Perform Hongmeng-based kernel code on the Linux kernel of the target board to obtain the kernel image file, and compile the adaptation layer code and the open source Hongmeng system target code based on the kernel compilation associated parameters and the target compilation tool to obtain the target image file;

[0008] According to the kernel image file and the target image file, start the open source Hongmeng system of the target board.

[0009] According to another aspect of the present invention, a device for porting a Linux kernel to an open source Hongmeng system is provided, comprising:

[0010] The adaptation layer code acquisition module is used to obtain the adaptation layer code built based on the kernel features of the open source Hongmeng system framework;

[0011] The compilation module is used to perform Hongmeng-based kernel code on the Linux kernel of the target board to obtain the kernel image file, and compile the adaptation layer code and the open source Hongmeng system target code based on the kernel compilation associated parameters and the target compilation tool to obtain the target image file;

[0012] The system startup module is used to start the open source Hongmeng system of the target board according to the kernel image file and the target image file.

[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0014] at least one processor; and

[0015] a memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method of porting the Linux kernel to the open source Hongmeng system as described in any embodiment of the present invention.

[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method of porting the Linux kernel to an open source Hongmeng system as described in any embodiment of the present invention when executed.

[0018] The technical solution of the embodiment of the present invention obtains the adaptation layer code built based on the kernel characteristics of the open source Hongmeng system framework, thereby performing Hongmengization on the kernel code of the target board's Linux kernel to obtain a kernel image file, and based on the kernel compilation associated parameters and the target compilation tool, compiles the adaptation layer code and the open source Hongmeng system target code to obtain a target image file, and then starts the open source Hongmeng system of the target board according to the kernel image file and the target image file. Based on this solution, the Linux kernel adapted to the driver under the Linux and Android systems of the board manufacturer can be directly reused, and the OpenHarmony support and kernel image compilation of the Linux kernel can be completed in one click through the target compilation tool, without debugging the hardware driver, reducing the technical threshold and economic cost of adapting to OpenHarmony, improving the enthusiasm of board manufacturers, paving the way for the promotion of OpenHarmony in various industries, and solving the problem of long development time and high maintenance cost of board manufacturers adapting to the OpenHarmony system. It can support Linux, Android and OpenHarmony systems at the same time through a set of kernel codes, greatly reducing labor costs and shortening the development cycle.

[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 A flowchart of a method for transplanting an open source Hongmeng system to a Linux kernel provided in the first embodiment of the present invention;

[0022] Figure 2 A flowchart of a method for transplanting an open source Hongmeng system to a Linux kernel provided in the second embodiment of the present invention;

[0023] Figure 3 A schematic diagram of the original system architecture of OpenHarmony provided in the second embodiment of the present invention;

[0024] Figure 4 A schematic diagram of a decoupled open source Hongmeng system framework provided in Embodiment 2 of the present invention;

[0025] Figure 5 A schematic diagram of the structure of a device for transplanting the open source Hongmeng system to the Linux kernel provided in the third embodiment of the present invention;

[0026] Figure 6 A schematic diagram of the structure of an electronic device that can be used to implement an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0028] It should be noted that the term "target" and the like in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] Embodiment 1

[0030] Figure 1 This is a flowchart of a method for transplanting the Linux kernel to an open source Hongmeng system provided in the first embodiment of the present invention. This embodiment can be applied to the situation of promoting and popularizing the open source Hongmeng system. The method can be performed by a device for transplanting the Linux kernel to an open source Hongmeng system. The device for transplanting the Linux kernel to an open source Hongmeng system can be implemented in the form of hardware and / or software. The device for transplanting the Linux kernel to an open source Hongmeng system can be configured in an electronic device. Figure 1 As shown, the method includes:

[0031] Step 110: Obtain the adaptation layer code built based on the kernel features of the open source Hongmeng system framework.

[0032] The adaptation layer code can be a script pre-configured by the user based on the kernel features of the open source Hongmeng system, which is used to generate an image file corresponding to the kernel features. The kernel features can be the features that distinguish the kernel under the open source Hongmeng system framework from the kernel under other systems (Linux and Android). The kernel features can be specifically reflected in the functional components unique to the kernel of the open source Hongmeng system.

[0033] In an embodiment of the present invention, a user can abstract a custom adaptation layer between the open source Hongmeng system and the kernel based on the kernel characteristics of the open source Hongmeng system framework, and the developer can pre-configure the adaptation layer code of the adaptation layer to provide it to the board manufacturer, so that the board manufacturer's Linux kernel can quickly port the open source Hongmeng system.

[0034] Step 120: Perform Hongmeng-based kernel code on the Linux kernel of the target board to obtain a kernel image file, and compile the adaptation layer code and the open source Hongmeng system target code based on the kernel compilation-related parameters and the target compilation tool to obtain a target image file.

[0035] Among them, the target board can be a board that currently needs to adapt the kernel to the open source Hongmeng system. The kernel compilation associated parameters can be the parameters required for kernel compilation. The target compilation tool can be a compilation tool under a pre-set kernel-devel environment. The open source Hongmeng system target code can be the system code optimized by the open source Hongmeng, which is used to generate an image file of the open source Hongmeng system. The target image file can be an image file obtained by compiling the adaptation layer code and the open source Hongmeng system target code.

[0036] In an embodiment of the present invention, after the Linux kernel of the target board is initialized, the kernel code is HarmonyOS-ized to generate a kernel image file, that is, the kernel code is converted into the file format of the open source HarmonyOS system, and then the kernel compilation associated parameters are used to configure the parameters of the compilation environment, and the target compilation tool is used to compile the adaptation layer code and the open source HarmonyOS system target code in the compilation environment to obtain the target image file.

[0037] For example, the image file compiled from the adaptation layer code can be released together with the image file compiled from the open source Hongmeng system target code. OpenHarmony will no longer require the kernel itself to support open source Hongmeng characteristics, and the open source Hongmeng system will have more extensive support for different Linux versions.

[0038] Step 130: Start the open source Hongmeng system of the target board according to the kernel image file and the target image file.

[0039] In an embodiment of the present invention, the kernel image file and the target image file can be burned to the target board to start the open source Hongmeng system of the target board.

[0040] The technical solution of the embodiment of the present invention obtains the adaptation layer code built based on the kernel characteristics of the open source Hongmeng system framework, thereby performing Hongmengization on the kernel code of the target board's Linux kernel to obtain a kernel image file, and based on the kernel compilation associated parameters and the target compilation tool, compiles the adaptation layer code and the open source Hongmeng system target code to obtain a target image file, and then starts the open source Hongmeng system of the target board according to the kernel image file and the target image file. Based on this solution, the Linux kernel adapted to the driver under the Linux and Android systems of the board manufacturer can be directly reused, and the OpenHarmony support and kernel image compilation of the Linux kernel can be completed in one click through the target compilation tool, without debugging the hardware driver, reducing the technical threshold and economic cost of adapting to OpenHarmony, improving the enthusiasm of board manufacturers, paving the way for the promotion of OpenHarmony in various industries, and solving the problem of long development time and high maintenance cost of board manufacturers adapting to the OpenHarmony system. It can support Linux, Android and OpenHarmony systems at the same time through a set of kernel codes, greatly reducing labor costs and shortening the development cycle.

[0041] Embodiment 2

[0042] Figure 2 The flowchart of a method for transplanting the Linux kernel to the open source Hongmeng system provided in the second embodiment of the present invention is specific based on the above embodiment, and provides a specific optional implementation method for obtaining the adaptation layer code built based on the kernel characteristics of the open source Hongmeng system framework. Figure 2 As shown, the method includes:

[0043] Step 210: Determine the abstract adaptation layer in the open source Hongmeng system framework.

[0044] Among them, the abstract adaptation layer can be a hierarchical structure abstracted between the open source Hongmeng system and the kernel.

[0045] In an embodiment of the present invention, in order to separate the functions supporting OpenHarmony from the kernel and dynamically load them during the OpenHarmony startup process instead of loading them in the kernel, functional separation can be performed based on the kernel characteristics of the OpenHarmony system framework, that is, the functional components unique to the open source Hongmeng system kernel are determined and abstracted into an abstract adaptation layer in the open source Hongmeng system framework.

[0046] Step 220: Obtain the adaptation layer code associated with the kernel characteristics in the abstract adaptation layer.

[0047] In the embodiment of the present invention, the adaptation layer code related to the kernel characteristics written by the developer based on the abstract adaptation layer can be obtained.

[0048] Step 230: Perform Hongmeng-based kernel code on the Linux kernel of the target board to obtain a kernel image file, and compile the adaptation layer code and the open source Hongmeng system target code based on the kernel compilation-related parameters and the target compilation tool to obtain a target image file.

[0049] In an optional embodiment of the present invention, before compiling the adaptation layer code and the open source Hongmeng system target code based on the kernel compilation associated parameters and the target compilation tool to obtain the target image file, it can also include: obtaining kernel compilation associated parameters adapted to the Linux kernel compilation of the target board; and constructing a target compilation tool adapted to the Linux kernel compilation environment according to the kernel compilation associated parameters.

[0050] Specifically, since the customized parameters used in kernel compilation of different platforms and manufacturers are different, it is necessary to formulate kernel compilation associated parameters that are compatible with the Linux kernel compilation of the target board, and then determine the compilation environment required for kernel compilation based on the kernel compilation associated parameters, so as to build a target compilation tool that is compatible with the Linux kernel compilation environment according to the determined compilation environment.

[0051] In an optional embodiment of the present invention, kernel compilation associated parameters may include kernel image size, instruction framework, Linux device tree associated directory, image file package name, image output directory and kernel compilation options.

[0052] Among them, the kernel image size can be the kernel image size. Exemplarily, the instruction framework can include but is not limited to arm64. The linux device tree associated directory can be a directory associated with the linux device tree. The linux device tree associated directory can include a linux device tree entry directory and a linux device tree file directory. The image file package name is the name of the kernel image package file. The image output directory can be used to represent the export directory of the image file. The kernel compilation option can be used to allow the kernel to automatically load some modules.

[0053] Optionally, kernel compilation-related parameters may also include image block size, defconfig (load default parameters) file name, debug uart (universal asynchronous receiver / transmitter) port register address, and whether to package a ramdisk (virtual memory disk) in the kernel.

[0054] Step 240: Start the open source Hongmeng system of the target board according to the kernel image file and the target image file.

[0055] In an optional embodiment of the present invention, while starting the open source Hongmeng system of the target board according to the kernel image file and the target image file, it can also include: loading the kernel dynamic module of the abstract adaptation layer, calling the exported kernel symbol table when the kernel dynamic module is loaded, and calling the reverse registration target interface of the abstract adaptation layer to perform function registration.

[0056] The kernel dynamic module may be a kernel module in the abstract adaptation layer, that is, a ko (kernel object, kernel module) component in the abstract adaptation layer. The kernel symbol table may be a definition symbol required for loading the kernel dynamic module during the boot process of the operating system, and may be exported by the abstract adaptation layer. The reverse registration target interface may be an interface for calling back the corresponding function of the kernel dynamic module.

[0057] Specifically, while starting the open source Hongmeng system of the target board according to the kernel image file and the target image file, the kernel dynamic module of the abstract adaptation layer can be dynamically loaded, and the exported kernel symbol table can be called when the kernel dynamic module is loaded to solve the problem of undefined symbols when loading the kernel dynamic module during the startup of the open source Hongmeng system. The reverse registration target interface of the abstract adaptation layer can also be called to register its own functions, so that the Linux kernel can call the kernel dynamic module through the reverse registration target interface.

[0058] In an optional embodiment of the present invention, before calling the reverse registration target interface of the abstract adaptation layer to perform function registration, it may also include: determining a kernel dynamic module associated with the kernel characteristic; and creating a reverse registration target interface matching the kernel characteristic based on the kernel dynamic module.

[0059] In an embodiment of the present invention, based on the kernel characteristics of the open source Hongmeng system, the functions corresponding to the kernel characteristics of the open source Hongmeng system can be determined, and then the components corresponding to the aforementioned determined functions, namely the kernel dynamic modules, can be screened out in the kernel of the open source Hongmeng system. The abstract adaptation layer further provides a reverse registration interface for the kernel dynamic module, thereby obtaining a reverse registration target interface that matches the kernel characteristics.

[0060] In an optional embodiment of the present invention, the kernel dynamic module may include necessary dynamic loading components and non-essential dynamic loading components; wherein, the necessary dynamic loading components may include system inter-process communication components and permission token management components; the non-essential dynamic loading components may include an exception log collection component, a log buffer management component, a downtime log capture component, a Hongmeng log ring buffer component, an event log buffer management component, a user space process watchdog component, an open source file system for distributed storage and processing, and at least one of a shared file system.

[0061] Among them, the necessary dynamically loaded component may be a key component that needs to be decoupled from the kernel. The non-essential dynamically loaded component may be a component that is selectively decoupled from the kernel. The system inter-process communication component may be a binder module in the kernel of the open source Hongmeng system framework. The permission token management component may be the accesstokenid module in the kernel of the open source Hongmeng system framework, which is responsible for the permission token management of the open source Hongmeng process execution and file access. The exception log collection component may be the blackbox module in the kernel of the open source Hongmeng system framework, which is responsible for the callback of the registered function when an exception occurs, saving the log total and restarting. The log buffer management component may be the hievent module in the kernel of the open source Hongmeng system framework, which is responsible for event log cache management and relies on hisysevent. The downtime log capture component may be the zerohung module in the kernel of the open source Hongmeng system framework, which is responsible for capturing downtime logs. The Hongmeng log ring buffer component may be the hilog module in the kernel of the open source Hongmeng system framework, that is, the Hongmeng log ring buffer. The event log buffer management component may be the hisysevent module in the kernel of the open source Hongmeng system framework, which is responsible for event log buffer management. The user space process watchdog component can be a user space process watchdog module in the kernel of the open source Hongmeng system framework, namely, the Hungtask module. The open source file system for distributed storage and processing is the hmdfs file system in the kernel of the open source Hongmeng system framework. The shared file system can be the sharefs file system in the kernel of the open source Hongmeng system framework.

[0062] Optionally, the non-essential dynamic loading component may also include a ramoops module and / or a pstore module. The ramoops module is used to transfer the log to a memory stick that does not lose power during restart. The pstore module is used to capture kernel crash logs.

[0063] Exemplarily, some reverse registration interfaces in the reverse registration target interface matching the kernel characteristics are as follows:

[0064] int register_blackbox_api(struct blackbox_api*bboxapi);

[0065] void unregister_blackbox_api(void).

[0066] int register_hungtask_api(struct hungtask_api*htapi);

[0067] void unregister_hungtask_api(void).

[0068] int register_zerohung_api(struct zerohung_api*zhapi);

[0069] void unregister_zerohung_api(void).

[0070] int register_pstore_api(struct pstore_api*papi);

[0071] void unregister_pstore_api(void).

[0072] The OpenHarmony community Linux kernel and the OpenHarmony system architecture are as follows Figure 3 As shown in FIG. 1 , the kernel dynamic modules that support OpenHarmony in the Linux kernel include the binder module, hisysevent module, hungtask module, hievent module, accesstokenid module, hilog module, zerohung module, sharefs module, hmdfs module, blackbox module, ramoops module and pstore module, which invade the core functional logic of the Linux kernel such as scheduling and file system, and separate the functions of the kernel features that support OpenHarmony in the OpenHarmony community kernel, that is, extract these kernel dynamic modules separately as independent components, no longer statically compiled into the kernel, but separated from the kernel and compiled into dynamic modules that can be dynamically loaded and packaged into the open source Hongmeng system image file, and dynamically loaded during the system startup process, so as to achieve the purpose of separating the OpenHarmony related features in the kernel from the kernel and reduce the coupling between OpenHarmony and the kernel. For the system framework of the decoupled open source Hongmeng, see Figure 4 .

[0073] In this solution, kernel features that support OpenHarmony are extracted from the OpenHarmony community kernel, compiled and packaged into the image file corresponding to the adaptation layer code (referred to as the adaptation layer image file), and released together with the image file corresponding to the open source Hongmeng system target code (referred to as the open source Hongmeng system image file). OpenHarmony will no longer require the kernel itself to support OpenHarmony features, and OpenHarmony's support for different Linux versions will be more extensive.

[0074] The target compilation tool based on kernel-devel is used to port the original Android and Linux kernels to OpenHarmony as a whole. These kernels have been adapted to the board-level peripheral drivers and will not need to debug the drivers, thereby reducing the manpower investment in OpenHarmony's southbound adaptation.

[0075] The OpenHarmony system supplier provides the board manufacturers with the OpenHarmony system image with the adaptation layer image file and the target compilation tool. The board manufacturer obtains the target compilation tool and Hongmengizes the kernel code of the board. It further adapts the open source Hongmeng characteristics and image compilation with one click based on the target compilation tool, and then burns the compiled image file and starts the open source Hongmeng system. Board manufacturers do not need to do driver adaptation on the kernel version of the OpenHarmony community, but directly compile the kernel version that has been driver adapted on Linux or Android, and use it together with the OpenHarmony system image to start OpenHarmony.

[0076] The kernel features decoupled from the original kernel are compiled into kernel dynamic modules. After the kernel initialization is completed, the OpenHarmony file system is switched, and the kernel dynamic modules supporting OpenHarmony are loaded during the init process, which reduces the coupling between OpenHarmony and the kernel and is more conducive to OpenHarmony supporting different kernel versions.

[0077] In this solution, by separating the logical functions that support OpenHarmony in the kernel, the coupling between OpenHarmony and the kernel is reduced. The separated functions in the kernel are dynamically loaded during the startup of OpenHarmony, and are no longer loaded in the kernel. The target compilation tool is used to achieve the purpose of quickly adapting the kernels of different versions of each manufacturer to OpenHarmony, that is, the Linux kernel that has been adapted to the Linux system and Android system by the board manufacturer is reused to adapt to the OpenHarmony system, reducing the debugging process of adapting drivers on different Linux versions. Board manufacturers only need to maintain a set of kernel code versions that support Linux, Android and OpenHarmony systems at the same time. For board manufacturers, this reduces labor costs and shortens the development cycle (the workload of adapting OpenHarmony, which originally took several weeks to several months, is shortened to a few hours to a few days), promotes the popularization and promotion of OpenHarmony, and plays a key role in forming the OpenHarmony ecosystem.

[0078] The technical solution of the embodiment of the present invention determines the abstract adaptation layer in the open source Hongmeng system framework, thereby compiling and packaging the kernel characteristics in the abstract adaptation layer, generating an adaptation layer code that supports the Hongmeng system, and then Hongmengizing the kernel code in the Linux kernel of the target board to obtain a kernel image file, and compiling the adaptation layer code and the open source Hongmeng system target code based on the kernel compilation associated parameters and the target compilation tool to obtain a target image file, and further starting the open source Hongmeng system of the target board based on the kernel image file and the target image file. Based on this solution, the Linux kernel that has been adapted for the drivers under the Linux and Android systems of the board manufacturer can be directly reused, and the OpenHarmony support and kernel image compilation of the Linux kernel can be completed in one click through the target compilation tool. There is no need to debug the hardware driver, which reduces the technical threshold and economic cost of adapting to OpenHarmony, increases the enthusiasm of board manufacturers, paves the way for the promotion of OpenHarmony in various industries, and solves the problems of long development time and high maintenance cost for board manufacturers to adapt to the OpenHarmony system. Through a set of kernel code, it can support Linux, Android and OpenHarmony systems at the same time, greatly reducing labor costs and shortening the development cycle.

[0079] Embodiment 3

[0080] Figure 5 A schematic diagram of the structure of a device for transplanting the Linux kernel to the open source Hongmeng system provided in the third embodiment of the present invention. Figure 5 As shown, the device comprises:

[0081] The adaptation layer code acquisition module 310 is used to obtain the adaptation layer code built based on the kernel characteristics of the open source Hongmeng system framework;

[0082] The compilation module 320 is used to perform Hongmeng-based kernel code on the Linux kernel of the target board to obtain a kernel image file, and compile the adaptation layer code and the open source Hongmeng system target code based on the kernel compilation associated parameters and the target compilation tool to obtain a target image file;

[0083] The system startup module 330 is used to start the open source Hongmeng system of the target board according to the kernel image file and the target image file.

[0084] The technical solution of the embodiment of the present invention obtains the adaptation layer code built based on the kernel characteristics of the open source Hongmeng system framework, thereby performing Hongmengization on the kernel code of the target board's Linux kernel to obtain a kernel image file, and based on the kernel compilation associated parameters and the target compilation tool, compiles the adaptation layer code and the open source Hongmeng system target code to obtain a target image file, and then starts the open source Hongmeng system of the target board according to the kernel image file and the target image file. Based on this solution, the Linux kernel adapted to the driver under the Linux and Android systems of the board manufacturer can be directly reused, and the OpenHarmony support and kernel image compilation of the Linux kernel can be completed in one click through the target compilation tool, without debugging the hardware driver, reducing the technical threshold and economic cost of adapting to OpenHarmony, improving the enthusiasm of board manufacturers, paving the way for the promotion of OpenHarmony in various industries, and solving the problem of long development time and high maintenance cost of board manufacturers adapting to the OpenHarmony system. It can support Linux, Android and OpenHarmony systems at the same time through a set of kernel codes, greatly reducing labor costs and shortening the development cycle.

[0085] Optionally, the adaptation layer code acquisition module 310 is specifically used to determine the abstract adaptation layer in the open source Hongmeng system framework; compile and package the kernel features in the abstract adaptation layer to generate the adaptation layer code that supports the Hongmeng system.

[0086] Optionally, the device for porting the Linux kernel to the open source Hongmeng system also includes a startup loading and interface acquisition module, which is used to load the kernel dynamic module of the abstract adaptation layer, call the exported kernel symbol table when the kernel dynamic module is loaded, and call the reverse registration target interface of the abstract adaptation layer to perform function registration.

[0087] Optionally, the device for porting the Linux kernel to the open source Hongmeng system also includes obtaining kernel compilation associated parameters that are compatible with the Linux kernel compilation of the target board; and constructing a target compilation tool that is compatible with the Linux kernel compilation environment based on the kernel compilation associated parameters.

[0088] Optionally, the device for porting the Linux kernel to the open source Hongmeng system also includes a reverse registration target interface creation module, which is used to determine a kernel dynamic module associated with the kernel characteristic; based on the kernel dynamic module, a reverse registration target interface matching the kernel characteristic is created.

[0089] Optional, kernel compilation related parameters, including kernel image size, instruction framework, Linux device tree related directory, image file package name, image output directory and kernel compilation options.

[0090] Optionally, the kernel dynamic module includes necessary dynamic loading components and non-essential dynamic loading components; wherein the necessary dynamic loading components include system inter-process communication components and permission token management components; the non-essential dynamic loading components include exception log collection components, log buffer management components, downtime log capture components, Hongmeng log ring buffer components, event log buffer management components, user space process watchdog components, distributed storage and processing of open source file systems and at least one of shared file systems.

[0091] The device for transplanting the Linux kernel to the open source Hongmeng system provided in the embodiment of the present invention can execute the method for transplanting the Linux kernel to the open source Hongmeng system provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.

[0092] Embodiment 4

[0093] Figure 6 A schematic diagram of an electronic device that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0094] like Figure 6 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0095] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0096] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 performs the various methods and processes described above, such as the method of porting the Linux kernel to the open source Hongmeng system.

[0097] In some embodiments, the method of porting the Linux kernel to an open source Hongmeng system may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method of porting the Linux kernel to an open source Hongmeng system described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method of porting the Linux kernel to an open source Hongmeng system in any other appropriate manner (e.g., by means of firmware).

[0098] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0099] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0100] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0101] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0102] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0103] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of traditional physical hosts and VPS servers, which are difficult to manage and have weak business scalability.

[0104] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0105] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for transplanting the Linux kernel to the open source Hongmeng system, characterized in that: include: Obtain the adaptation layer code built based on the kernel features of the open source Hongmeng system framework; Perform Hongmeng-based kernel code on the Linux kernel of the target board to obtain a kernel image file, and compile the adaptation layer code and the open source Hongmeng system target code based on kernel compilation associated parameters and target compilation tools to obtain a target image file; According to the kernel image file and the target image file, start the open source Hongmeng system of the target board.

2. The method according to claim 1, characterized in that The obtaining of the adaptation layer code built based on the kernel characteristics of the open source Hongmeng system framework includes: Determine the abstract adaptation layer in the open source Hongmeng system framework; An adaptation layer code associated with a kernel feature in the abstract adaptation layer is obtained.

3. The method according to claim 2, characterized in that While starting the open source Hongmeng system of the target board according to the kernel image file and the target image file, it also includes: The kernel dynamic module of the abstract adaptation layer is loaded, the exported kernel symbol table is called when the kernel dynamic module is loaded, and the reverse registration target interface of the abstract adaptation layer is called to perform function registration.

4. The method according to claim 1, characterized in that Before the adaptation layer code and the open source Hongmeng system target code are compiled based on the kernel compilation associated parameters and the target compilation tool to obtain the target image file, the following step is also included: Obtain kernel compilation associated parameters adapted to the Linux kernel compilation of the target board; According to the kernel compilation associated parameters, a target compilation tool adapted to the Linux kernel compilation environment is constructed.

5. The method according to claim 3, characterized in that: Before calling the reverse registration target interface of the abstract adaptation layer to register the function, the method further includes: determining a kernel dynamic module associated with the kernel characteristic; Based on the kernel dynamic module, a reverse registration target interface matching the kernel characteristics is created.

6. The method according to claim 1, characterized in that The kernel compilation associated parameters include kernel image size, instruction framework, Linux device tree associated directory, image file package name, image output directory and kernel compilation options.

7. The method according to claim 5, characterized in that The kernel dynamic module includes necessary dynamic loading components and non-essential dynamic loading components; wherein, the necessary dynamic loading components include system inter-process communication components and permission token management components; the non-essential dynamic loading components include exception log collection components, log buffer management components, downtime log capture components, Hongmeng log ring buffer components, event log buffer management components, user space process watchdog components, distributed storage and processing of open source file systems and at least one of shared file systems.

8. A device for porting the Linux kernel to the open source Hongmeng system, characterized in that: include: The adaptation layer code acquisition module is used to obtain the adaptation layer code built based on the kernel features of the open source Hongmeng system framework; A compilation module is used to perform Hongmengization of the kernel code in the Linux kernel of the target board to obtain a kernel image file, and based on the kernel compilation associated parameters and the target compilation tool, compile the adaptation layer code and the open source Hongmeng system target code to obtain a target image file; The system startup module is used to start the open source Hongmeng system of the target board according to the kernel image file and the target image file.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method of porting the Linux kernel to the open source Hongmeng system as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method of transplanting the Linux kernel to the open source Hongmeng system as described in any one of claims 1-7 when executed.

Citation Information

Patent Citations

  • Coexistence method of bionic and musl

    CN114860255A

  • Method, device, equipment and medium for enabling swan-gap system to adapt to high-pass chip

    CN116302092A

  • Software system construction method, device and equipment and computer readable storage medium

    CN116541065A

  • AI-EC embedded system based on swan Mongolia distributed SoftBus and construction and deployment method of AI-EC embedded system

    CN116756067A

  • Method, device and equipment for transplanting swan mongolian system and medium

    CN117435247A