• Home
Name Date Size #Lines LOC

..--

test/07-Sep-2024-19,89613,846

BUILD.gnD07-Sep-20242.7 KiB8175

LICENSED07-Sep-202417.6 KiB341281

OAT.xmlD07-Sep-20243.9 KiB6711

README.mdD07-Sep-20244.6 KiB9967

README_zh.mdD07-Sep-20244.3 KiB9967

build_kernel.shD07-Sep-20241.6 KiB4922

bundle.jsonD07-Sep-2024905 4039

check_build.shD07-Sep-20241.1 KiB4324

kernel.mkD07-Sep-20245.4 KiB11687

kernel_build.pyD07-Sep-202412.9 KiB386309

kernel_module_build.shD07-Sep-20242.1 KiB6842

README.md

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│   ├── common_patch
32│   │		└── hdf.patch		# linux-4.19 HDF patches
33│   └── hispark_taurus_patch
34│   		└── hispark_taurus.patch	# linux-4.19 Hi3516D V300 SOC patches
35└── linux-5.10
36    ├── common_patch
37    │		└── hdf.patch		# linux-5.10 HDF patches
38    └── hispark_taurus_patch
39    │		└── hispark_taurus.patch	# linux-5.10 Hi3516D V300 SOC patches
40    └── rk3568_patch
41    		├── kernel.patch		# linux-5.10 rk3568 SOC patches
42    		└── hdf.patch		# linux-5.10 rk3568 customized HDF patches
43```
44
45## Usage<a name="section1393789267"></a>
46
471. Apply HDF patches.
48
49	Apply the HDF kernel patches matching your kernel version. For details, see the method in **kernel.mk** in the **kernel/linux/build** repository.
50
51	```
52	$(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME)
53	```
54
552. Apply the chip driver patches.
56
57	The following uses Hi3516D V300 as an example.
58
59	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.
60
61	```
62	DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch
63	DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch
64	```
65
663. Modify the **config** file to build.
67
68	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.
69
70	```
71	KERNEL_CONFIG_PATH := $(OHOS_BUILD_HOME)/kernel/linux/config/${KERNEL_VERSION}
72	DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig
73	```
74
75	> **Note**:
76	>
77	>In the OpenHarmony project build process, patches are installed after **kernel/linux/linux-5.10** is copied. Before using the version-level build command of OpenHarmony, ensure that the **kernel/linux/linux-5.10** source code is available.
78	>
79	>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.
80
81
82## Build<a name="section19369206113115"></a>
83
84The following uses the Hi3516D V300 development board and Ubuntu x86 server as an example.
85
86Perform a full build for the project to generate the **uImage** kernel image.
87
88```
89./build.sh --product-name Hi3516DV300              # Build the Hi3516D V300 image.
90    --build-target build_kernel                    # Build the uImage kernel image of Hi3516D V300.
91    --gn-args linux_kernel_version=\"linux-5.10\"  # Build the specified kernel version.
92```
93
94## Repositories Involved<a name="section27639463106"></a>
95
96[<u>kernel\_linux\_patches</u>](https://gitee.com/openharmony/kernel_linux_patches)
97
98[<u>kernel\_linux\_config</u>](https://gitee.com/openharmony/kernel_linux_config)
99

README_zh.md

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