@@ -15,7 +15,4 @@ The LTS version provides long-term kernel maintenance \(in fixing bugs and secur
## OpenHarmony Kernel Version Selection<a name="section2716416191715"></a>
You can select an appropriate LTS kernel version as the Linux kernel for OpenHarmony. Currently, LTS version 4.19 is used on most devices. LTS versions 4.4 to 4.14 are old and do not support new features. Additionally, these versions will no longer be maintained in 2023 as planned. In this regard, they can be adopted only by the systems for short-term use but are not suitable for the systems of the first release. The more up-to-date LTS version 5.4 has not been widely used in released products. In comparison, version 4.19 is more well-recognized and can shorten the kernel adaptation period. New versions will be released continuously.
In OpenHarmony, the Linux kernel is recommended for devices whose memory is greater than or equal to 128 MB.
Select an appropriate LTS kernel version as the Linux kernel for OpenHarmony. Currently, Linux-4.19 and Linux-5.10 are supported.
# Guidelines for Using Patches on OpenHarmony Development Boards<a name="EN-US_TOPIC_0000001081980461"></a>
# Applying Patches on OpenHarmony Development Boards<a name="EN-US_TOPIC_0000001081980461"></a>
The patch files are stored in the **kernel/linux/patches/linux-4.19** source code path of the project. You can obtain the driver patch of a specific chip architecture from this directory.
1. Apply HDF patches.
To use the patch of a specific chip platform driver, you need to merge the required kernel patch into the kernel code.
Apply the HDF kernel patches matching your kernel version. For details, see the method in **kernel.mk** in the **kernel/linux/build** repository.
Merge the corresponding patches for different chip platforms.
2. Apply the chip driver patches.
The following uses Hi3516D V300 as an example:
The following uses Hi3516D V300 as an example.
Place the patches for the chip component in the corresponding path based on the path and naming rules for the patches of the chip component in **kernel.mk** in the **kernel/linux/build** repository.
>Because patches are applied after the code environment of **kernel/linux-4.19** is copied during compilation and building of the OpenHarmony project, you must retain the original code environment of **kernel/linux-4.19** before running the OpenHarmony version-level build command.
Place the **config** file for the chip component in the corresponding path based on the path and naming rules of the chip component in **kernel.mk** in the **kernel/linux/build** repository.
>In the OpenHarmony project build process, patches are installed after **kernel/linux/linux-\*\.\*** is copied. Before using the version-level build command of OpenHarmony, ensure that the **kernel/linux/linux-\*\.\*** source code is available.
>
>The kernel built is generated in the **kernel** directory under the **out** directory. Modify the **config** file based on the kernel built, and copy the generated **.config** file to the corresponding path in the **config** repository. Then, the configuration takes effect.
OpenHarmony provides LiteOS and Linux for different levels of systems. LiteOS applies to mini and small systems. Linux applies to small and standard systems.
OpenHarmony LiteOS is a real-time OS kernel developed for IoT devices. It boasts lightweight features as the real-time operating system (RTOS) and is easy-to-use like Linux.
LiteOS provides basic kernel functions, such as process and thread scheduling, memory management, inter-process communication (IPC), and timer management.
The LiteOS source code is stored in **kernel\\_liteos\\_a** and **kernel\\_liteos\\_m** repositories. The **kernel\\_liteos\\_a** repository stores kernel code for small and standard systems. The **kernel\\_liteos\\_m** repository stores kernel code for mini systems. This document describes the **kernel\\_liteos\\_a** repository. Figure 1 shows the architecture of OpenHarmony LiteOS-A.
Evolved from the open-source Linux kernel LTS 4.19.y and 5.10.y, the OpenHarmony Linux kernel has incorporated CVE patches and OpenHarmony features as the OpenHarmony common kernel baseline. Vendors can complete the kernel adaptation by applying the driver patches for boards.
For more information about Linux LTS 4.19.y, visit the [official kernel website](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/log/?h=linux-4.19.y).
For more information about Linux LTS 5.10.y, visit the [official kernel website] (https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/log/?h=linux-5.10.y).
During the build process, you can merge the driver code based on the chip platform and build the kernel image. All patches are licensed under GNU General Public License (GPL) 2.0.
By default, the Hi3518E V300 uses the JFFS2 file system, and Hi3516D V300 uses the FAT file system. Adaptation must be performed if you want to use other file systems.
## Usage<a name="section1393789267"></a>
### LiteOS<a name="section118811457303"></a>
For details, see "Usage" in LiteOS-A Kernel [README](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README.md) and LiteOS-M Kernel [README](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README.md).
### Linux<a name="section1352114469620"></a>
1. Apply HDF patches.
Apply the HDF kernel patches matching your kernel version. For details, see the method in **kernel.mk** in the **kernel/linux/build** repository.
Place the patches for the chip component in the corresponding path based on the path and naming rules for the patches of the chip component in **kernel.mk** in the **kernel/linux/build** repository.
Place the **config** file for the chip component in the corresponding path based on the path and naming rules of the chip component in **kernel.mk** in the **kernel/linux/build** repository.
>In the OpenHarmony project build process, patches are installed after **kernel/linux/linux-\*\.\*** is copied. Before using the version-level build command of OpenHarmony, ensure that the **kernel/linux/linux-\*\.\*** source code is available.
>
>The kernel built is generated in the **kernel** directory under the **out** directory. Modify the **config** file based on the kernel built, and copy the generated **.config** file to the corresponding path in the **config** repository. Then, the configuration takes effect.
## Build<a name="section19369206113115"></a>
The following uses the Hi3516D V300 development board and Ubuntu x86 server as an example.
Perform a full build for the project to generate the **uImage** kernel image.
```
./build.sh --product-name Hi3516DV300 # Build the Hi3516D V300 image.
--build-target build_kernel # Build the uImage kernel image of Hi3516D V300.
--gn-args linux_kernel_version=\"linux-5.10\" # Build the specified kernel version.