Method, medium and equipment for upgrading Linux system to swan-gap system
By copying the Linux root file system to the Hongmeng system and modifying the file structure using shell scripts, the Linux system's library package version compatibility and permissions in the Hongmeng system are solved, and the seamless compatibility and operation of the original Linux application is achieved, reducing development Workload and backward compatibility, suitable for iteration and functional iteration of older versions of applications.
Patent Information
- Application Number
- CN202411325013.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-23
- Publication Date
- 2024-12-27
AI Technical Summary
When upgrading to Hongmeng system, Linux system faces problems with incompatibility of library package versions, restricted Docker support, restricted permissions and 32-bit application operation, resulting in large development workload and risk of failure, and the existing migration methods are not controlled for a long time. Sex and backward compatibility.
By copying all directory files of the Linux root file system to the Hongmeng root file system, creating shell scripts to modify the file structure, and using symbolic links and directory mounts to achieve seamless translation of the application, solving the compatibility and permissions of the library package version, At the same time, a 32-bit library directory and dynamic link library symbolic links are established under the Hongmeng system to ensure the normal operation of the original Linux application.
It realizes seamless compatible operation of the original Linux application in the Hongmeng system, reduces development workload, avoids compatibility problems caused by compiling third-party software, and has the advantages of rapid porting, full benefit of the old and backward compatibility, and supports Iteration and feature iteration of old versions of applications.
Smart Images

Figure CN119201224A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of Linux operating system transplantation, and specifically relates to a method, medium and device for upgrading a Linux system to a Hongmeng system. Background Art
[0002] In the past decade, Linux embedded operating systems have been widely used in fields such as industrial automation, intelligent manufacturing, intelligent transportation, smart homes and consumer electronics. These application fields have built a huge Linux embedded operating system ecosystem. Its powerful ecosystem and open source technology support the operation of hundreds of millions of devices and applications. The open source Hongmeng operating system has been developed in recent years. It is an original distributed operating system for IOT. It emphasizes seamless collaboration between different devices and realizes multi-device integrated operation, data sharing, and business collaboration through a distributed architecture. This has significant advantages for building IoT application scenarios. At the same time, the Hongmeng operating system has greatly improved security and stability compared to the Linux system, which has prompted many domestic industries to upgrade the Linux embedded operating system they are using to the open source Hongmeng system.
[0003] According to the technical guide of Hongmeng official website and existing operating experience, it is not an easy task to transplant Linux operating system applications to Hongmeng operating system. Due to many factors, there are currently two main transplantation methods in the industry. One is to adapt to Hongmeng operating system in the form of third-party software for full compilation, and the other is to use containerized software to encapsulate the original Linux program into a container for operation. These two methods have many technical difficulties in practice, which are mainly manifested in the following points: (1) Incompatible library package versions: Application software needs to rely on a specific version of library files to run normally. If the library version installed in the system is incompatible with the application, it may cause the application to fail to start or an error during operation. The Hongmeng operating system, the current open source Hongmeng official website can download the release version is OpenHarmony-3.2-release and OpenHarmony-4.0-release. Most of the library packages in the system are compatible with versions after 2022. The dependency packages of the original Linux applications before 2021 or even earlier involved in the application scenarios are not supported by the current Hongmeng system version. Since the Hongmeng operating system has only been developed for a few years, its starting point is to adhere to the distinctive personality of independent innovation. The original development path is to create a new IOT technology route, strip off the old code in the continuous development, and achieve true independent control. It is precisely because of this that it has been favored by domestic application manufacturers, but the contradictions are also highlighted. Upgrading the original Linux code to adapt to the Hongmeng dependency package requires a huge development workload, and the most important thing is to bear the risk of failure.
[0004] (2) Docker's concerns: Docker is a virtual environment container that can package the Linux operating environment, applications, and configuration files into this container for operation. The native Hongmeng operating system does not support Docker as a third-party software for compilation, but it has been successfully ported to Hongmeng for operation. At present, it seems that using Docker to port old versions of Linux system applications is one of the better methods. However, in 2022, the Docker official website updated the agreement statement, prohibiting organizations and individuals included in the entity list from using it. This means that the use of Docker software requires long-term strategic considerations, and in the later stage, it is better to use controllable technical means to achieve it, such as using the domestically produced container software isula.
[0005] (3) Troubles with permission restrictions: Hongmeng officially announced that the Hongmeng operating system adopts a microkernel architecture, which is naturally rootless. Fine-grained permission control improves system security from the source, and the mutual isolation of the outer kernel is safer and more efficient. In practice, it is found that if the original Linux application is transplanted to the Hongmeng system, as long as it involves the Hongmeng system-level directory, files and underlying calls, it will be prohibited if it is not configured and compiled through the Hongmeng source code. Even if these applications are compatible and compiled, they basically cannot run.
[0006] (4) Issues with the operation of 32-bit applications and binary applications: Due to historical reasons, the application scenario of the present invention requires porting Linux applications before the release of the open source Hongmeng software to the Hongmeng system for operation, with a time interval of at least 5 years. The original Linux programs are basically 32-bit codes or even only binary files. According to the above points, these discontinued products have to be discarded and redeveloped. This is also one of the reasons why many industry application upgrades have stagnated.
[0007] In summary, lowering the library package version in the Hongmeng system to make it compatible with old versions of applications, or modifying Hongmeng permissions to meet the operating environment of old versions of application software is basically a technical means that violates Hongmeng's constraints and is not desirable. Although dockerization is a common method, with the emergence of Hongmeng 5.0, support for docker is limited, which is bound to bring new problems soon. Summary of the invention
[0008] The purpose of the present invention is to provide a method, medium and device for upgrading a Linux system to a Hongmeng system, aiming to solve the above-mentioned problems.
[0009] The present invention is mainly achieved through the following technical solutions: A method for upgrading a Linux system to a Hongmeng system comprises the following steps: Step S1: Copy all directory files of the Linux root file system to the newly created directory / data / linux-rootfs under the root of the Hongmeng root file system; Step S2: Create a shell script; Step S3: After the Hongmeng operating system is started, modify the root directory and file structure of the Hongmeng root file system through a shell script; Mount the directory under the Linux root file system directory to the corresponding directory under the root of the Hongmeng root file system, link the files under the Linux root file system directory to the corresponding files under the root of the Hongmeng root file system, and create the root file system environment required by the original Linux application based on the Hongmeng root file system to achieve seamless migration and compatible operation of the application.
[0010] In order to better implement the present invention, further, step S3 includes the following steps: Step S31: Use the symbolic link command ln to create symbolic links between the files in the / data / linux-rootfs / etc / *, / data / linux-rootfs / lib / *, and / data / linux-rootfs / lib64 / * directories and the / etc / lib / lib64 / var / run directory under the root of the Hongmeng system. If the file name in the / data / linux-rootfs directory is the same as the file name in the directory corresponding to the root of the Hongmeng system, no link will be made. Step S32: Use the mount-bind command to mount the directories under the / data / linux-rootfs / etc / *, / data / linux-rootfs / lib / *, and / data / linux-rootfs / lib64 / * directories to the / etc / lib / lib64 / var / run directory under the root of the Hongmeng system; if the directory name under the / data / linux-rootfs directory is the same as the directory name under the root of the Hongmeng system, do not mount it, enter the same directory to compare the file names, and only soft link different files; if there is no directory with the same name, create a new / usr directory under the corresponding directory of the Hongmeng system root, and mount the / data / linux-rootfs / usr directory to the / usr directory under the root of the Hongmeng system.
[0011] In order to better implement the present invention, further, in the step S3, a 32-bit library package is deployed in the original Linux root file system, a lib32-bit library directory is established under the lib directory under the Hongmeng root file system, and the lib32 directory under the Linux directory is pointed to by directory mounting.
[0012] In order to better implement the present invention, further, in step S3, after the Hongmeng operating system is started, the Hongmeng root file system is read-only by default, and modification of system directory files is not allowed. The root file system needs to be remounted in writable mode.
[0013] In order to better implement the present invention, further, in the step S3, a dynamic link library so symbolic link of the Linux root file system directory is established under the Hongmeng system library, so that the original Linux application can find the specified so.
[0014] In order to better implement the present invention, further, in step S3, the C library path in the Linux root file system is placed in the specified search path of the Hongmeng system.
[0015] In order to better implement the present invention, further, in step S2, a shell script file is created and copied to the self-starting directory of the root of the Hongmeng root file system.
[0016] In order to better implement the present invention, further, in the step S2, a shell script file for starting the Linux operating environment during the Hongmeng runtime is created, and is not added to the Hongmeng system for compilation; the native image file system.img after the Hongmeng compilation is modified, and the shell script file is copied to the directory specified by system.img through commands in the background as one of the Hongmeng startup scripts, and then system.img and userdata.img are burned into the device together; after the system is started, the Hongmeng operating environment is modified through the shell script to adapt to the running requirements of the original Linux application.
[0017] A computer-readable storage medium stores a computer program, which implements the above method when executed by a processor.
[0018] An electronic device comprises a memory and a processor; the memory stores a computer program; the processor is used to execute the computer program in the memory to implement the above method.
[0019] The beneficial effects of the present invention are as follows: (1) The present invention does not require configuration, deployment and compilation of the Hongmeng operating system source code. It only needs to completely copy all directory files of the Linux root file system (hereinafter referred to as linux-rootfs) to a self-named directory under the root of the Hongmeng root file system (hereinafter referred to as ohos-rootfs), write a shell script file, and copy it to the self-starting directory of the root of ohos-rootfs. After OHOS is started, the script modifies the root directory and file structure of ohos-rootfs, mounts the directories and files under the linux-rootfs directory to the corresponding directories and files under the root of ohos-rootfs, and creates the root file system environment required by the original Linux application based on ohos-rootfs, thereby realizing seamless translation and compatible operation of the application, and has good practicality.
[0020] (2) Secondly, in terms of specific implementation details, the present invention also solves a series of problems such as library package call version compatibility, permission issues, and resource usage, and enables the normal operation of old versions of Linux applications in the new OHOS system, retaining the original Linux applications. At the same time, applications based on Hongmeng characteristics are developed in OHOS, realizing system code iteration.
[0021] (3) The present invention has the advantage of fast transplantation: as long as the application runs normally under the original Linux operating system, it only needs to be copied to ohos-rootfs, and can be run at runtime through file symbolic links and directory mounting. It does not participate in OHOS system configuration and compilation, avoiding the software library package compatibility problems caused by OHOS compiling third-party software.
[0022] (4) The present invention has the advantage of fully reusing the old: the original Linux system application that is lower than the Hongmeng operating system library package requirements can be transplanted to the original Linux system library, and the original Linux library can be run by linking and calling it, without the need for redevelopment and compilation, and fully reusing the old. The present invention is particularly suitable for the transplantation of applications with only binary files.
[0023] (5) The present invention has the advantage of backward compatibility: the cross-compilation tool chain version of the original Linux system is lower than the OHOS version, and the gap between some program code versions is more than 5 years. To ensure that such programs can run compatibly, it is necessary to copy the runtime library and dependent libraries of the old version to the OHOS related directory, and copy what is missing, so as to achieve backward compatibility.
[0024] (6) The present invention has the advantage of continuous iteration: the purpose of upgrading from Linux to OHOS on the technical level is to utilize the IOT functional characteristics of Hongmeng. In the application scenario of the present invention, OHOS has been successfully transplanted into the terminal, and it is still necessary to use the original Linux system application code to retain its original functional characteristics. At the same time, the IOT function is realized by calling the HDF interface of OHOS based on the original Linux application. This does not affect the original business, but realizes new functions on the original basis, thus realizing system iteration. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0026] Embodiment 1: A method for upgrading a Linux system to a Hongmeng system, after upgrading the Linux embedded operating system of the electric energy collection terminal in use to the Hongmeng operating system standard version (hereinafter referred to as OHOS), the application in the original Linux system does not need to be cross-compiled in the Hongmeng operating system source code environment, and only the Linux application binary file needs to be copied to the relevant directory of the Hongmeng operating system, and the dependent library and configuration file are copied and configured, so as to achieve seamless translation and compatible operation of the application. The present invention transforms the files and directories of the OHOS native root file system (hereinafter referred to as ohos-rootfs), and completely copies the directory files of the Linux native root file system (hereinafter referred to as linux-rootfs) to the newly created directory under the root of ohos-rootfs. After OHOS is started, the linux-rootfs directory files are linked and mounted to the corresponding system directories and files under the root of ohos-rootfs through the shell startup script execution.
[0027] The electric energy data acquisition terminal used in the application scenario of the present invention has a hardware environment of Arm64 Cortex-A architecture CPU, 4G memory, 16G external memory, and supports UART / CAN / SPI / PCIE / LVDS / HDMI / I2C / USB and other interfaces. The software environment adopts the open source Hongmeng standard system (hereinafter referred to as OHOS), the version is OpenHarmony-4.0-release, the kernel version is Linux-5.10.184, supports QT5 graphical interface application environment, supports LVDS and HDMI graphical interface and touch function, and supports Wife / BT / 4G / 5G / Audio / Camera and other driving capabilities. The present invention transplants the original 32-bit and 64-bit Linux applications on the old terminal device to the new terminal device system for operation. The original application functions need to continue to be used, and the OHOS-based application functions are iteratively developed. Preferably, the specific implementation method of the transplantation of the present invention mainly includes the following points: (1) Modification of the directory structure of the Hongmeng root file system Copy all directory files of the root file system (hereinafter referred to as linux-rootfs) in the Linux operating system running environment to the / data / linux-rootfs directory under the root of the Hongmeng root file system (hereinafter referred to as ohos-rootfs).
[0028] Use the symbolic link command (ln) and directory mount (mount —bind) command to create symbolic links for the files in directories such as / data / linux-rootfs / etc / *, / data / linux-rootfs / lib / *, and / data / linux-rootfs / lib64 / * to directories such as / etc / lib / lib64 / var / run under the ohos-system system root. If the file name in the / data / linux-rootfs directory is the same as the file name in the directory corresponding to the ohos-system system root, no link will be made.
[0029] Similarly, through the directory mount command, mount the directories under the directories / data / linux-rootfs / etc / *, / data / linux-rootfs / lib / *, and / data / linux-rootfs / lib64 / * to the directories / etc / lib / lib64 / var / run under the ohos-system system root. If the directory name under the / data / linux-rootfs directory is the same as the directory name under the ohos-system system root, it will not be mounted, but it is necessary to enter the same directory to compare the file names and only soft link different files. If there is no directory with the same name, create a new directory under the corresponding directory of the ohos-system system root, mainly create a new / usr directory, and mount the / data / linux-rootfs / usr directory to the / usr directory under the ohos-system system root.
[0030] (2) Write a startup script for the Linux runtime environment when Hongmeng is running. This script needs to be configured and deployed in the Hongmeng startup directory. It does not need to be compiled into the Hongmeng system. It only needs to modify the original image file system.img compiled by Hongmeng, and copy the file to the directory specified by system.img through the background command as one of the Hongmeng startup scripts, and then burn system.img and userdata.img into the device together. After the system starts, the script modifies the Hongmeng runtime environment to adapt to the original Linux application running requirements.
[0031] (5) Compilation library compatibility: OHOS-4.0 uses aarch64-2020. The application scenario of this invention is to port old versions of Linux applications. The highest version of the compilation tool chain is aarch64-2017. (6) Permission modification: After the Hongmeng operating system is started, the Hongmeng root file system is read-only by default. Modification of system directory files is not allowed. The root file system needs to be remounted in writable mode.
[0032] (7) 32-bit library support: The Hongmeng root file system supports 64-bit applications by default, but does not support 32-bit applications. It is necessary to deploy 32-bit library packages in the original Linux root file system, create a lib32-bit library directory in the lib directory under the Hongmeng root file system, and point to the lib32 directory under the Linux directory through directory mounting.
[0033] (8) so library link: It is necessary to create a dynamic link library so symbolic link in the Linux root file system directory under the Hongmeng system library so that the original Linux application can find the specified so.
[0034] (9) glibc library call: The C library version used for application system compilation is different. The C library path in the Linux root file system needs to be placed in the specified search path of the Hongmeng system.
[0035] Runtime environment configuration: The original Linux program needs to generate the runtime environment directory and files in the system directory such as / var / sys. Due to the permission issue, the Hongmeng system does not support unsigned program calls and no directory and files are created. Since one of the technical points of the present invention is to run the original Linux application out of the control of Hongmeng, the Linux runtime environment startup script is used to create it before running.
[0036] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification or equivalent change made to the above embodiment based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for upgrading a Linux system to a Hongmeng system, characterized in that: The following steps are involved: Step S1: Copy all directory files of the Linux root file system to the newly created directory / data / linux-rootfs under the root of the Hongmeng root file system; Step S2: Create a shell script; Step S3: After the Hongmeng operating system is started, modify the root directory and file structure of the Hongmeng root file system through a shell script; Mount the directory under the Linux root file system directory to the corresponding directory under the root of the Hongmeng root file system, link the files under the Linux root file system directory to the corresponding files under the root of the Hongmeng root file system, and create the root file system environment required by the original Linux application based on the Hongmeng root file system to achieve seamless migration and compatible operation of the application.
2. A method for upgrading a Linux system to a Hongmeng system according to claim 1, characterized in that: The step S3 comprises the following steps: Step S31: Use the symbolic link command ln to create symbolic links between the files in the / data / linux-rootfs / etc / *, / data / linux-rootfs / lib / *, and / data / linux-rootfs / lib64 / * directories and the / etc / lib / lib64 / var / run directory under the root of the Hongmeng system; if the file name in the / data / linux-rootfs directory is the same as the file name in the directory corresponding to the root of the Hongmeng system, no link will be made; Step S32: Use the mount-bind command to mount the directories under the / data / linux-rootfs / etc / *, / data / linux-rootfs / lib / *, and / data / linux-rootfs / lib64 / * directories to the / etc / lib / lib64 / var / run directory under the root of the Hongmeng system; if the directory name under the / data / linux-rootfs directory is the same as the directory name under the root of the Hongmeng system, do not mount it, enter the same directory to compare the file names, and only soft link different files; if there is no directory with the same name, create a new / usr directory under the corresponding directory of the Hongmeng system root, and mount the / data / linux-rootfs / usr directory to the / usr directory under the root of the Hongmeng system.
3. A method for upgrading a Linux system to a Hongmeng system according to claim 1 or 2, characterized in that: In step S3, a 32-bit library package is deployed in the original Linux root file system, a lib32-bit library directory is established under the lib directory under the Hongmeng root file system, and the lib32 directory under the Linux directory is pointed to through directory mounting.
4. A method for upgrading a Linux system to a Hongmeng system according to claim 1 or 2, characterized in that: In step S3, after the Hongmeng operating system is started, the Hongmeng root file system is read-only by default, and modification of system directory files is not allowed. The root file system needs to be remounted in writable mode.
5. A method for upgrading a Linux system to a Hongmeng system according to claim 1 or 2, characterized in that: In step S3, a dynamic link library so symbolic link of the Linux root file system directory is established under the Hongmeng system library, so that the original Linux application can find the specified so.
6. A method for upgrading a Linux system to a Hongmeng system according to claim 1 or 2, characterized in that: In step S3, the C library path in the Linux root file system is placed in the specified search path of the Hongmeng system.
7. A method for upgrading a Linux system to a Hongmeng system according to claim 1, characterized in that: In step S2, a shell script file is created and copied to the self-starting directory of the root of the Hongmeng root file system.
8. The method for upgrading a Linux system to a Hongmeng system according to claim 1, characterized in that: In the step S2, a shell script file for starting the Linux runtime environment during the Hongmeng runtime is created, and is not compiled into the Hongmeng system; the native image file system.img after the Hongmeng compilation is modified, and the shell script file is copied to the directory specified by system.img through commands in the background as one of the Hongmeng startup scripts.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method described in any one of claims 1 to 8 is implemented.
10. An electronic device, characterized in that: The invention comprises a memory and a processor; the memory stores a computer program; the processor is used to execute the computer program in the memory to implement the method according to any one of claims 1 to 8.
