• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Patch<a name="EN-US_TOPIC_0000001078264110"></a>
2
3-   [Introduction](#section11660541593)
4-   [Driver Patches for a Specific Chip Architecture (such as Hi3516D V300)](#section1521510717399)
5-   [Directory Structure](#section21571344112)
6-   [Usage](#section1393789267)
7-   [Build](#section19369206113115)
8-   [Repositories Involved](#section27639463106)
9
10## Introduction<a name="section11660541593"></a>
11
12Evolved 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.
13
14For 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).
15
16For 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).
17
18During 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.
19
20## Driver Patches for a Specific Chip Architecture (such as Hi3516D V300)<a name="section1521510717399"></a>
21
22The vendor provides the driver code of the chip architecture.
23
24**hi3516dv300_small.patch**: supports boot of the kernel of the Arm architecture (such as the DTS) and drivers such as DRM and MMC on Hi3516D V300.
25
26## Directory Structure<a name="section21571344112"></a>
27
28```
29kernel/linux/patches
30├── linux-4.19					# linux-4.19 patches
31│   └── hi3516dv300_patch
32│   		├── hi3516dv300.patch	# linux-4.19 Hi3516D V300 SOC patches
33│   		└── hdf.patch			# linux-4.19 Hi3516D V300 HDF patches
34└── linux-5.10
35    └── hi3516dv300_patch
36    		├── hi3516dv300.patch	# linux-5.10 Hi3516D V300 SOC patches
37    		└── hdf.patch			# linux-5.10 Hi3516D V300 HDF patches
38```
39
40## Usage<a name="section1393789267"></a>
41
421. Apply HDF patches.
43
44	Apply the HDF kernel patches matching your kernel version. For details, see the method in **kernel.mk** in the **kernel/linux/build** repository.
45
46	```
47	$(OHOS_BUILD_HOME)/drivers/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH)     $(HDF_PATCH_FILE)
48	```
49
502. Apply the chip driver patches.
51
52	The following uses Hi3516D V300 as an example.
53
54	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.
55
56	```
57	DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch
58	DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch
59	```
60
613. Modify the **config** file to build.
62
63	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.
64
65	```
66	KERNEL_CONFIG_PATH := $(OHOS_BUILD_HOME)/kernel/linux/config/${KERNEL_VERSION}
67	DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig
68	```
69
70	> **Note**:
71	>
72	>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.
73	>
74	>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.
75
76
77## Build<a name="section19369206113115"></a>
78
79The following uses the Hi3516D V300 development board and Ubuntu x86 server as an example.
80
81Perform a full build for the project to generate the **uImage** kernel image.
82
83```
84./build.sh --product-name Hi3516DV300              # Build the Hi3516D V300 image.
85    --build-target build_kernel                    # Build the uImage kernel image of Hi3516D V300.
86    --gn-args linux_kernel_version=\"linux-5.10\"  # Build the specified kernel version.
87```
88
89## Repositories Involved<a name="section27639463106"></a>
90
91<u>kernel\_linux\_patches</u>
92
93<u>kernel\_linux\_config</u>
94