当前位置:   article > 正文

鸿蒙hi3516内核打补丁及设备树_hi3518鸿蒙需要设备树吗?

hi3518鸿蒙需要设备树吗?

博主编译的hi3516小型系统,代码版本为3.2release

1、内核配置文件

内核配置文件是kernel.mk文件,它在根目录下kernel/linux/build目录中

  1. $(DEFCONFIG_FILE):
  2. $(hide) echo ">>>>>> ___________________________ $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig"
  3. $(hide) echo ">>>>>> ___________________________ $(DEVICE_PATCH_FILE)"
  4. $(KERNEL_IMAGE_FILE):
  5. $(hide) echo "build kernel..."
  6. ifeq ($(DEVICE_NAME), hispark_phoenix)
  7. $(hide) rm -rf $(KERNEL_SRC_TMP_PATH);mkdir -p $(KERNEL_SRC_TMP_PATH);cp -arfP $(KERNEL_SRC_PATH)/* $(KERNEL_SRC_TMP_PATH)/
  8. $(hide) cd $(KERNEL_SRC_TMP_PATH)/drivers && rm -rf common && ln -s $(SDK_SOURCE_DIR)/common/drv ./common && cd -
  9. $(hide) cd $(KERNEL_SRC_TMP_PATH)/drivers && rm -rf msp && ln -s $(SDK_SOURCE_DIR)/msp/drv ./msp && cd -
  10. else
  11. $(hide) rm -rf $(KERNEL_SRC_TMP_PATH);mkdir -p $(KERNEL_SRC_TMP_PATH);cp -arfL $(KERNEL_SRC_PATH)/* $(KERNEL_SRC_TMP_PATH)/
  12. endif
  13. $(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)
  14. ifeq ($(PRODUCT_PATH), vendor/hisilicon/watchos)
  15. $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(PRODUCT_PATCH_FILE)
  16. else
  17. $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(DEVICE_PATCH_FILE)
  18. endif
  19. ifneq ($(findstring $(BUILD_TYPE), small),)
  20. $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(SMALL_PATCH_FILE)
  21. endif

kernel.mk这个文件里面包含了你要编译的产品的干净的linux内核源码目录和打完补丁之后的内核源码目录。而且还有你编译的产品的参考config文件(DEFCONFIG_FILE)、补丁文件(DEVICE_PATCH_FILE)等,假如说不知道自己编译的产品的补丁包的位置在哪,可以在这个文件里面按照博主的方法将补丁包文件名和位置打印出来就行。因为在鸿蒙中所有的产品用的都是一套内核源码,编译不同的产品只需要将对于的各个补丁包按照规则打进去就可以了。博主之前只搞过海思的纯linux系统,对linux系统没有研究的这么多,对于这个打linux补丁的操作也是看了半天才明白一些。

博主编译的是hi3516小型系统,从打印可以看出来用的是hispark_taurus_small_defconfig这个config配置文件以及hispark_taurus.patch这个补丁包,如果你想看其他的信息,可以按照这个方法将信息打印出来,之后再对kernel做相应的更改即可。加上打印会报错,但是会把信心打印出来,看完之后再将打印注释掉即可,这个问题我并没有深究。

  1. [OHOS ERROR] [205/4604] ACTION //kernel/linux/build:linux_kernel(//build/lite/toolchain:linux_x86_64_ohos_clang)
  2. [OHOS ERROR] FAILED: obj/kernel/linux/build/linux_kernel_build_ext_components.txt
  3. [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
  4. [OHOS ERROR] echo ">>>>>> ___________________________ hispark_taurus_small_defconfig"
  5. [OHOS ERROR] >>>>>> ___________________________ hispark_taurus_small_defconfig
  6. [OHOS ERROR] echo ">>>>>> ___________________________ /3.2.release/kernel/linux/patches/linux-5.10/hispark_taurus_patch/hispark_taurus.patch"
  7. [OHOS ERROR] >>>>>> ___________________________ /3.2.release/kernel/linux/patches/linux-5.10/hispark_taurus_patch/hispark_taurus.patch

2、内核补丁包

官方目录说明

  1. kernel/linux/patches
  2. ├── linux-4.19 # linux-4.19 相关patch
  3. │   ├── common_patch
  4. │   │ └── hdf.patch # linux-4.19 HDF patches
  5. │   └── hi3516dv300_patch
  6. │   └── hi3516dv300.patch # linux-4.19 Hi3516D V300 SOC patches
  7. └── linux-5.10
  8. ├── common_patch
  9. │ └── hdf.patch # linux-5.10 HDF patches
  10. └── hi3516dv300_patch
  11. │ └── hi3516dv300.patch # linux-5.10 Hi3516D V300 SOC patches
  12. └── rkrk3568_patch
  13. ├── kernel.patch # linux-5.10 rk3568 SOC patches
  14. └── hdf.patch # linux-5.10 rk3568 定制 HDF patches

根据上面的分析我编译的产品的补丁包是在这kernel/linux/patches/linux-5.10/hispark_taurus_patch/hispark_taurus.patch,那我们就打开补丁包看一下

  1. diff --git a/arch/arm/boot/dts/hi3516dv300-demb.dts b/arch/arm/boot/dts/hi3516dv300-demb.dts
  2. new file mode 100644
  3. index 000000000..bbe67651e
  4. --- /dev/null
  5. +++ b/arch/arm/boot/dts/hi3516dv300-demb.dts
  6. @@ -0,0 +1,270 @@
  7. +/*
  8. + * Copyright (c) 2013-2014 Linaro Ltd.
  9. + * Copyright (c) 2015-2017 HiSilicon Technologies Co., Ltd.
  10. + *
  11. + * This program is free software; you can redistribute it and/or modify it
  12. + * under the terms of the GNU General Public License as published by the
  13. + * Free Software Foundation; either version 2 of the License, or (at your
  14. + * option) any later version.
  15. + *
  16. + * This program is distributed in the hope that it will be useful,
  17. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. + * GNU General Public License for more details.
  20. + *
  21. + * You should have received a copy of the GNU General Public License
  22. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. + *
  24. + */
  25. +
  26. +/dts-v1/;
  27. +#include "hi3516dv300.dtsi"
  28. +#include "autoconf.h"
  29. +
  30. +/ {
  31. + model = "Hisilicon HI3516DV300 DEMO Board";
  32. + compatible = "hisilicon,hi3516dv300";
  33. +
  34. + memory {
  35. + device_type = "memory";
  36. + reg = <0x82000000 0x20000000>;
  37. + };
  38. + firmware {
  39. + android {
  40. + compatible = "android,firmware";
  41. + fstab {
  42. + compatible = "android,fstab";
  43. + // delete for system as root
  44. + /*system {
  45. + compatible = "android,system";
  46. + dev = "/dev/block/platform/soc/f9830000.himciv200.MMC/by-name/system";
  47. + type = "ext4";
  48. + mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
  49. + fsmgr_flags = "wait";
  50. + };*/
  51. + vendor {
  52. + compatible = "android,vendor";

从代码中可以看出来,最上面是用diff制作补丁的规则,下面就是补丁文件的内容了,从完整的hispark_taurus.patch来看整个补丁文件会将makefile、kconfig、.c、.h等一些hi3516平台的适配好的补丁打包进kernel。假如我们想修改内核的设备树、内核的源代码都可以在里面找到相应的代码做修改即可。

注意在修改添加代码的时候要按照diff制作补丁的规则将@@ -0,0 +1,270 @@中行数按照你所添加的行数依次累加上去即可。

3、设备树

生成的设备树dtb文件及生成过程在out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/OBJ/linux-5.10/arch/arm/boot/dts目录

  1. -rw-r--r-- 1 root root 16775 124 22:12 hi3516dv300-demb.dtb
  2. -rw-r--r-- 1 root root 2480 124 22:12 .hi3516dv300-demb.dtb.cmd
  3. -rw-r--r-- 1 root root 88 124 22:12 .hi3516dv300-demb.dtb.d.dtc.tmp
  4. -rw-r--r-- 1 root root 536 124 22:12 .hi3516dv300-demb.dtb.d.pre.tmp
  5. -rw-r--r-- 1 root root 24575 124 22:12 .hi3516dv300-demb.dtb.dts.tmp
  1. 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
  2. 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
  3. deps_arch/arm/boot/dts/hi3516dv300-demb.dtb := \
  4. $(wildcard include/config/arch/hisi/bvt/amp.h) \
  5. $(wildcard include/config/mtd.h) \
  6. $(wildcard include/config/hiedmacv310.h) \
  7. /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/arch/arm/boot/dts/hi3516dv300.dtsi \
  8. $(wildcard include/config/hiedmac.h) \
  9. $(wildcard include/config/usb/drd0/in/host.h) \
  10. $(wildcard include/config/usb/drd0/in/device.h) \
  11. /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/arch/arm/boot/dts/skeleton.dtsi \
  12. /3.2.release/out/hispark_taurus/ipcamera_hispark_taurus_linux/kernel/linux-5.10/include/dt-bindings/clock/hi3516dv300-clock.h \
  13. arch/arm/boot/dts/hi3516dv300-demb.dtb: $(deps_arch/arm/boot/dts/hi3516dv300-demb.dtb)
  14. $(deps_arch/arm/boot/dts/hi3516dv300-demb.dtb):

在.hi3516dv300-demb.dtb.cmd文件中可以看到dtb文件的生成过程,其中生成原料hi3516dv300-demb.dts、hi3516dv300.dtsi、skeleton.dtsi等包括头文件都可以在hispark_taurus.patch补丁包文件里面找到。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/331101
推荐阅读
相关标签
  

闽ICP备14008679号