• Home
Name Date Size #Lines LOC

..--

linux-4.19/12-May-2024-457,170448,597

linux-5.10/12-May-2024-768,305737,050

.gitattributesD12-May-2024631 1615

LICENSED12-May-202417.6 KiB341281

OAT.xmlD12-May-20243.9 KiB6711

README.mdD12-May-20245.6 KiB11284

README_zh.mdD12-May-20245.3 KiB11384

README.md

1# Patch<a name="EN-US_TOPIC_0000001078264110"></a>
2
3-   [Introduction](#section11660541593)
4-   [Directory Structure](#section21571344112)
5-   [Usage](#section1393789267)
6-   [Build](#section19369206113115)
7-   [Repositories Involved](#section27639463106)
8
9## Introduction<a name="section11660541593"></a>
10
11Evolved 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.
12
13For 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).
14
15For 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).
16
17During 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.
18
19## Directory Structure<a name="section21571344112"></a>
20
21```
22kernel/linux
23├── build
24│	├── BUILD.gn					# GN file of the build framework
25│	├── kernel.mk				# Kernel build file
26│	└── ohos.build				# Kernel build component file
27├── patches
28│	├── linux-4.19				# linux-4.19 patches
29│	│   ├── common_patch
30│	│   │		└── hdf.patch		# linux-4.19 HDF patches
31│	│   └── hi3516dv300_patch
32│	│   		└── hi3516dv300.patch	# linux-4.19 Hi3516D V300 SOC patches
33│	└── linux-5.10
34│	    ├── common_patch
35│	    │		└── hdf.patch		# linux-5.10 HDF patches
36│	    └── hi3516dv300_patch
37│	    │		└── hi3516dv300.patch	# linux-5.10 Hi3516D V300 SOC patches
38│	    └── rkrk3568_patch
39│	    		├── kernel.patch		# linux-5.10 rk3568 SOC patches
40│	    		└── hdf.patch		# linux-5.10 rk3568 customized HDF patches
41└── config
42	├── linux-4.19
43	│   └── arch
44	│       └── arm
45	│           └── configs
46	│               ├── hi3516dv300_small_defconfig       # Small-system defconfig of the open-source Hi3516D V300 development board from HiSilicon
47	│               ├── hi3516dv300_standard_defconfig    # Standard-system defconfig of the open-source Hi3516D V300 development board from HiSilicon
48	│               ├── small_common_defconfig            # Common defconfig of the small-system kernel
49	│               └── standard_common_defconfig         # Common defconfig of the standard-system kernel
50	└── linux-5.10
51	    └── arch
52	        └── arm
53	            └── configs
54	                ├── hi3516dv300_small_defconfig       # Small-system defconfig of the open-source Hi3516D V300 development board from HiSilicon
55	                ├── hi3516dv300_standard_defconfig    # Standard-system defconfig of the open-source Hi3516D V300 development board from HiSilicon
56	                ├── small_common_defconfig            # Common defconfig of the small-system kernel
57	                └── standard_common_defconfig         # Common defconfig of the standard-system kernel
58```
59
60## Usage<a name="section1393789267"></a>
61
621. Apply HDF patches.
63
64	Apply the HDF kernel patches matching your kernel version. For details, see the method in **kernel.mk** in the **kernel/linux/build** repository.
65
66	```
67	$(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME)
68	```
69
702. Apply the chip driver patches.
71
72	The following uses Hi3516D V300 as an example.
73
74	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.
75
76	```
77	DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch
78	DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch
79	```
80
813. Modify the **config** file to build.
82
83	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.
84
85	```
86	KERNEL_CONFIG_PATH := $(OHOS_BUILD_HOME)/kernel/linux/config/${KERNEL_VERSION}
87	DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig
88	```
89
90	> **Note**:
91	>
92	>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.
93	>
94	>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.
95
96
97## Build<a name="section19369206113115"></a>
98
99The following uses the Hi3516D V300 development board and Ubuntu x86 server as an example.
100
101Perform a full build for the project to generate the **uImage** kernel image.
102
103```
104./build.sh --product-name Hi3516DV300              # Build the Hi3516D V300 image.
105    --build-target build_kernel                    # Build the uImage kernel image of Hi3516D V300.
106    --gn-args linux_kernel_version=\"linux-5.10\"  # Build the specified kernel version.
107```
108
109## Repositories Involved<a name="section27639463106"></a>
110
111<u>kernel\_linux\_patches</u>
112

README_zh.md

1# Patch组件<a name="ZH-CN_TOPIC_0000001078264110"></a>
2
3-   [简介](#section11660541593)
4-   [目录](#section21571344112)
5-   [使用说明](#section1393789267)
6-   [构建说明](#section19369206113115)
7-   [相关仓](#section27639463106)
8
9## 简介<a name="section11660541593"></a>
10
11OpenHarmony的Linux内核基于开源Linux内核LTS **4.19.y / 5.10.y** 分支演进,在此基线基础上,回合CVE补丁及OpenHarmony特性,作为OpenHarmony Common Kernel基线。针对不同的芯片,各厂商合入对应的板级驱动补丁,完成对OpenHarmony的基线适配。
12
13Linux社区LTS 4.19.y分支信息请查看[kernel官网](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/log/?h=linux-4.19.y)14
15Linux社区LTS 5.10.y分支信息请查看[kernel官网](https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/log/?h=linux-5.10.y)16
17内核的Patch组成模块,在编译构建流程中,针对具体芯片平台,合入对应的架构驱动代码,进行编译对应的内核镜像。所有补丁来源均遵守GPL-2.0协议。
18
19## 目录<a name="section21571344112"></a>
20
21```
22kernel/linux
23├── build
24│	├── BUILD.gn					# 编译框架GN文件
25│	├── kernel.mk				# 内核编译文件
26│	└── ohos.build				# 内核编译组件文件
27├── patches
28│	├── linux-4.19				# linux-4.19 相关patch
29│	│   ├── common_patch
30│	│   │		└── hdf.patch		# linux-4.19 HDF patches
31│	│   └── hi3516dv300_patch
32│	│   		└── hi3516dv300.patch	# linux-4.19 Hi3516D V300 SOC patches
33│	└── linux-5.10
34│	    ├── common_patch
35│	    │		└── hdf.patch		# linux-5.10 HDF patches
36│	    └── hi3516dv300_patch
37│	    │		└── hi3516dv300.patch	# linux-5.10 Hi3516D V300 SOC patches
38│	    └── rkrk3568_patch
39│	    		├── kernel.patch		# linux-5.10 rk3568 SOC patches
40│	    		└── hdf.patch		# linux-5.10 rk3568 定制 HDF patches
41└── config
42	├── linux-4.19
43	│   └── arch
44	│       └── arm
45	│           └── configs
46	│               ├── hi3516dv300_small_defconfig       # 厂商Hisilicon对应的开源开发板Hi3516dv300小型系统的defconfig
47	│               ├── hi3516dv300_standard_defconfig    # 厂商Hisilicon对应的开源开发板Hi3516dv300标准系统的defconfig
48	│               ├── small_common_defconfig            # 小型系统的内核的common defconfig
49	│               └── standard_common_defconfig         # 标准系统的内核的common defconfig
50	└── linux-5.10
51	    └── arch
52	        └── arm
53	            └── configs
54	                ├── hi3516dv300_small_defconfig       # 厂商Hisilicon对应的开源开发板Hi3516dv300小型系统的defconfig
55	                ├── hi3516dv300_standard_defconfig    # 厂商Hisilicon对应的开源开发板Hi3516dv300标准系统的defconfig
56	                ├── small_common_defconfig            # 小型系统的内核的common defconfig
57	                └── standard_common_defconfig         # 标准系统的内核的common defconfig
58```
59
60## 使用说明<a name="section1393789267"></a>
61
621. 合入HDF补丁
63
64kernel/linux/build仓中,按照kernel.mk中HDF的补丁合入方法,合入不同内核版本对应的HDF内核补丁:
65
66	```
67	$(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME)
68	```
69
702. 合入芯片平台驱动补丁
71
72	以Hi3516DV300为例:
73
74kernel/linux/build仓中,按照kernel.mk中的芯片组件所对应的patch路径规则及命名规则,将对应的芯片组件patch放到对应路径下:
75
76	```
77	DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch
78	DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch
79	```
80
813. 修改自己所需要编译的config
82
83kernel/linux/build仓中,按照kernel.mk中的芯片组件所对应的patch路径规则及命名规则,将对应的芯片组件config放到对应路径下:
84
85	```
86	KERNEL_CONFIG_PATH := $(OHOS_BUILD_HOME)/kernel/linux/config/${KERNEL_VERSION}
87	DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig
88	```
89
90	> **须知:**
91	>
92	>由于OpenHarmony工程的编译构建流程中会拷贝kernel/linux/linux-\*\.\*的代码环境后进行打补丁动作,在使用OpenHarmony的版本级编译命令前,需要kernel/linux/linux-\*\.\*原代码环境。
93	>
94	>根据不同系统工程,编译完成后会在out目录下的kernel目录中生成对应实际编译的内核,基于此目录的内核,进行对应的config修改,将最后生成的\.config文件cp到config仓对应的路径文件里,即可生效。
95
96
97## 构建说明<a name="section19369206113115"></a>
98
99以hi3516dv300开源开发板+ubuntu x86主机开发环境为例
100
101使用工程的全量编译命令,编译生成uImage内核镜像
102
103```
104./build.sh --product-name Hi3516DV300              # 编译hi3516dv300镜像
105    --build-target build_kernel                    # 编译hi3516dv300的uImage内核镜像
106    --gn-args linux_kernel_version=\"linux-5.10\"  # 编译指定内核版本
107```
108
109## 相关仓<a name="section27639463106"></a>
110
111<u>kernel\_linux\_patches</u>
112
113