赞
踩
博主编译的hi3516小型系统,代码版本为3.2release
内核配置文件是kernel.mk文件,它在根目录下kernel/linux/build目录中
$(DEFCONFIG_FILE): $(hide) echo ">>>>>> ___________________________ $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig" $(hide) echo ">>>>>> ___________________________ $(DEVICE_PATCH_FILE)" $(KERNEL_IMAGE_FILE): $(hide) echo "build kernel..." ifeq ($(DEVICE_NAME), hispark_phoenix) $(hide) rm -rf $(KERNEL_SRC_TMP_PATH);mkdir -p $(KERNEL_SRC_TMP_PATH);cp -arfP $(KERNEL_SRC_PATH)/* $(KERNEL_SRC_TMP_PATH)/ $(hide) cd $(KERNEL_SRC_TMP_PATH)/drivers && rm -rf common && ln -s $(SDK_SOURCE_DIR)/common/drv ./common && cd - $(hide) cd $(KERNEL_SRC_TMP_PATH)/drivers && rm -rf msp && ln -s $(SDK_SOURCE_DIR)/msp/drv ./msp && cd - else $(hide) rm -rf $(KERNEL_SRC_TMP_PATH);mkdir -p $(KERNEL_SRC_TMP_PATH);cp -arfL $(KERNEL_SRC_PATH)/* $(KERNEL_SRC_TMP_PATH)/ endif $(hide) $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME) ifeq ($(PRODUCT_PATH), vendor/hisilicon/watchos) $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(PRODUCT_PATCH_FILE) else $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(DEVICE_PATCH_FILE) endif ifneq ($(findstring $(BUILD_TYPE), small),) $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(SMALL_PATCH_FILE) endif
kernel.mk这个文件里面包含了你要编译的产品的干净的linux内核源码目录和打完补丁之后的内核源码目录。而且还有你编译的产品的参考config文件(DEFCONFIG_FILE)、补丁文件(DEVICE_PATCH_FILE)等,假如说不知道自己编译的产品的补丁包的位置在哪,可以在这个文件里面按照博主的方法将补丁包文件名和位置打印出来就行。因为在鸿蒙中所有的产品用的都是一套内核源码,编译不同的产品只需要将对于的各个补丁包按照规则打进去就可以了。博主之前只搞过海思的纯linux系统,对linux系统没有研究的这么多,对于这个打linux补丁的操作也是看了半天才明白一些。
博主编译的是hi3516小型系统,从打印可以看出来用的是hispark_taurus_small_defconfig这个config配置文件以及hispark_taurus.patch这个补丁包,如果你想看其他的信息,可以按照这个方法将信息打印出来,之后再对kernel做相应的更改即可。加上打印会报错,但是会把信心打印出来,看完之后再将打印注释掉即可,这个问题我并没有深究。
- [OHOS ERROR] [205/4604] ACTION //kernel/linux/build:linux_kernel(//build/lite/toolchain:linux_x86_64_ohos_clang)
- [OHOS ERROR] FAILED: obj/kernel/linux/build/linux_kernel_build_ext_components.txt
- [OHOS ERROR] /3.2.release/prebuilts/python/linux-x86/3.9.2/bin/python3 ../../../build/lite/build_ext_components.py --path=../../../kernel/linux/build --command=./kernel_module_build.sh\ /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux\ small\ arm\ vendor/hisilicon/hispark_taurus_linux\ hispark_taurus\ linux-5.10 --target_dir=/3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/obj/kernel/linux/build/build.log --out_dir=/3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/error.log
- [OHOS ERROR] echo ">>>>>> ___________________________ hispark_taurus_small_defconfig"
- [OHOS ERROR] >>>>>> ___________________________ hispark_taurus_small_defconfig
- [OHOS ERROR] echo ">>>>>> ___________________________ /3.2.release/kernel/linux/patches/linux-5.10/hispark_taurus_patch/hispark_taurus.patch"
- [OHOS ERROR] >>>>>> ___________________________ /3.2.release/kernel/linux/patches/linux-5.10/hispark_taurus_patch/hispark_taurus.patch
官方目录说明
- kernel/linux/patches
- ├── linux-4.19 # linux-4.19 相关patch
- │ ├── common_patch
- │ │ └── hdf.patch # linux-4.19 HDF patches
- │ └── hi3516dv300_patch
- │ └── hi3516dv300.patch # linux-4.19 Hi3516D V300 SOC patches
- └── linux-5.10
- ├── common_patch
- │ └── hdf.patch # linux-5.10 HDF patches
- └── hi3516dv300_patch
- │ └── hi3516dv300.patch # linux-5.10 Hi3516D V300 SOC patches
- └── rkrk3568_patch
- ├── kernel.patch # linux-5.10 rk3568 SOC patches
- └── hdf.patch # linux-5.10 rk3568 定制 HDF patches
根据上面的分析我编译的产品的补丁包是在这kernel/linux/patches/linux-5.10/hispark_taurus_patch/hispark_taurus.patch,那我们就打开补丁包看一下
- diff --git a/arch/arm/boot/dts/hi3516dv300-demb.dts b/arch/arm/boot/dts/hi3516dv300-demb.dts
- new file mode 100644
- index 000000000..bbe67651e
- --- /dev/null
- +++ b/arch/arm/boot/dts/hi3516dv300-demb.dts
- @@ -0,0 +1,270 @@
- +/*
- + * Copyright (c) 2013-2014 Linaro Ltd.
- + * Copyright (c) 2015-2017 HiSilicon Technologies Co., Ltd.
- + *
- + * This program is free software; you can redistribute it and/or modify it
- + * under the terms of the GNU General Public License as published by the
- + * Free Software Foundation; either version 2 of the License, or (at your
- + * option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + *
- + */
- +
- +/dts-v1/;
- +#include "hi3516dv300.dtsi"
- +#include "autoconf.h"
- +
- +/ {
- + model = "Hisilicon HI3516DV300 DEMO Board";
- + compatible = "hisilicon,hi3516dv300";
- +
- + memory {
- + device_type = "memory";
- + reg = <0x82000000 0x20000000>;
- + };
- + firmware {
- + android {
- + compatible = "android,firmware";
- + fstab {
- + compatible = "android,fstab";
- + // delete for system as root
- + /*system {
- + compatible = "android,system";
- + dev = "/dev/block/platform/soc/f9830000.himciv200.MMC/by-name/system";
- + type = "ext4";
- + mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
- + fsmgr_flags = "wait";
- + };*/
- + vendor {
- + compatible = "android,vendor";
从代码中可以看出来,最上面是用diff制作补丁的规则,下面就是补丁文件的内容了,从完整的hispark_taurus.patch来看整个补丁文件会将makefile、kconfig、.c、.h等一些hi3516平台的适配好的补丁打包进kernel。假如我们想修改内核的设备树、内核的源代码都可以在里面找到相应的代码做修改即可。
注意在修改添加代码的时候要按照diff制作补丁的规则将@@ -0,0 +1,270 @@中行数按照你所添加的行数依次累加上去即可。
生成的设备树dtb文件及生成过程在out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/OBJ/linux-5.10/arch/arm/boot/dts目录
下
- -rw-r--r-- 1 root root 16775 1月 24 22:12 hi3516dv300-demb.dtb
- -rw-r--r-- 1 root root 2480 1月 24 22:12 .hi3516dv300-demb.dtb.cmd
- -rw-r--r-- 1 root root 88 1月 24 22:12 .hi3516dv300-demb.dtb.d.dtc.tmp
- -rw-r--r-- 1 root root 536 1月 24 22:12 .hi3516dv300-demb.dtb.d.pre.tmp
- -rw-r--r-- 1 root root 24575 1月 24 22:12 .hi3516dv300-demb.dtb.dts.tmp
- cmd_arch/arm/boot/dts/hi3516dv300-demb.dtb := mkdir -p arch/arm/boot/dts/; gcc -E -Wp,-MMD,arch/arm/boot/dts/.hi3516dv300-demb.dtb.d.pre.tmp -nostdinc -I/3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/scripts/dtc/include-prefixes -I./include/generated -I/3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/include/dt-bindings -undef -D__DTS__ -x assembler-with-cpp -o arch/arm/boot/dts/.hi3516dv300-demb.dtb.dts.tmp /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/arch/arm/boot/dts/hi3516dv300-demb.dts ; ./scripts/dtc/dtc -O dtb -o arch/arm/boot/dts/hi3516dv300-demb.dtb -b 0 -i/3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/arch/arm/boot/dts/ -i/3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/scripts/dtc/include-prefixes -i./include/generated -i/3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/include/dt-bindings -Wno-interrupt_provider -Wno-unit_address_vs_reg -Wno-unit_address_format -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-simple_bus_reg -Wno-unique_unit_address -Wno-pci_device_reg -d arch/arm/boot/dts/.hi3516dv300-demb.dtb.d.dtc.tmp arch/arm/boot/dts/.hi3516dv300-demb.dtb.dts.tmp ; cat arch/arm/boot/dts/.hi3516dv300-demb.dtb.d.pre.tmp arch/arm/boot/dts/.hi3516dv300-demb.dtb.d.dtc.tmp > arch/arm/boot/dts/.hi3516dv300-demb.dtb.d
-
- source_arch/arm/boot/dts/hi3516dv300-demb.dtb := /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/arch/arm/boot/dts/hi3516dv300-demb.dts
-
- deps_arch/arm/boot/dts/hi3516dv300-demb.dtb := \
- $(wildcard include/config/arch/hisi/bvt/amp.h) \
- $(wildcard include/config/mtd.h) \
- $(wildcard include/config/hiedmacv310.h) \
- /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/arch/arm/boot/dts/hi3516dv300.dtsi \
- $(wildcard include/config/hiedmac.h) \
- $(wildcard include/config/usb/drd0/in/host.h) \
- $(wildcard include/config/usb/drd0/in/device.h) \
- /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/arch/arm/boot/dts/skeleton.dtsi \
- /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/include/dt-bindings/clock/hi3516dv300-clock.h \
-
- arch/arm/boot/dts/hi3516dv300-demb.dtb: $(deps_arch/arm/boot/dts/hi3516dv300-demb.dtb)
-
- $(deps_arch/arm/boot/dts/hi3516dv300-demb.dtb):
在.hi3516dv300-demb.dtb.cmd文件中可以看到dtb文件的生成过程,其中生成原料hi3516dv300-demb.dts、hi3516dv300.dtsi、skeleton.dtsi等包括头文件都可以在hispark_taurus.patch补丁包文件里面找到。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。