> 文档中心 > openharmony标准系统移植之添加产品编译

openharmony标准系统移植之添加产品编译

首先我这里下载的是源码文件包的形式,如下图,我们使用 命令 tar xvf code-v3.1-Release.tar.gz进行解压文件。解压完成后如下图,多了code-v3.1-Release文件夹,
openharmony标准系统移植之添加产品编译
然后需要构建我们自己的git配置,首先删除.repo/文件夹,然后修改drivers/adapter/.gitignore,这里把linux全屏蔽了,不然后期修改了文件,无法找到对应的改动。
首先安装下ruby工具,执行如下命令即可 sudo apt-get install ruby,不装可能会报错

FAILED: gen/isa/isa.yaml[OHOS ERROR] /usr/bin/env ../../ark/runtime_core/isa/combine.rb -d ../../ark/runtime_core/isa/isa.yaml,../../ark/js_runtime/ecmascript/ecma_isa.yaml -o gen/isa/isa.yaml[OHOS ERROR] /usr/bin/env: ‘ruby’: No such file or directory

具体报错信息如下。

[OHOS INFO] [277/33818] ACTION //ark/runtime_core/isa:isa_combine(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [278/33818] STAMP obj/base/miscservices/screenlock/etc/init/screenlockservice.cfg__notice.stamp[OHOS INFO] [279/33818] STAMP obj/applications/standard/hap/calc_demo_hap.stamp[OHOS INFO] [280/33818] ACTION //base/account/os_account/interfaces/kits/napi/osaccount:osaccount__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [281/33818] ACTION //applications/standard/hap:ecg_demo_hap__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [282/33818] ACTION //applications/standard/hap:filepicker_hap__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [283/33818] ACTION //applications/standard/hap:flashlight_demo_hap__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [284/33818] ACTION //applications/standard/hap:airquality_demo_hap__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [285/33818] ACTION //base/telephony/state_registry/sa_profile:state_registry_sa_profile(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [286/33818] ACTION //applications/standard/hap:dynamic.wav__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [287/33818] ACTION //ark/js_runtime:libark_jsruntime__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [288/33818] ACTION //base/miscservices/screenlock/services:screenlock_server__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [289/33818] ACTION //ark/js_runtime/ecmascript/js_vm:ark_js_vm__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [290/33818] ACTION //base/miscservices/screenlock/interfaces/kits/napi:screenlock__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [291/33818] ACTION //developtools/profiler/device/plugins/sample_plugin:sampleplugin__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [292/33818] ACTION //ark/runtime_core/dprof:libdprof__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [293/33818] ACTION //base/powermgr/thermal_manager/application/init:thermal_protector.cfg__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS INFO] [294/33818] ACTION //ark/js_runtime/ecmascript/tooling:libark_ecma_debugger__notice(//build/toolchain/ohos:ohos_clang_arm)[OHOS ERROR] [277/33818] ACTION //ark/runtime_core/isa:isa_combine(//build/toolchain/ohos:ohos_clang_arm)[OHOS ERROR] FAILED: gen/isa/isa.yaml[OHOS ERROR] /usr/bin/env ../../ark/runtime_core/isa/combine.rb -d ../../ark/runtime_core/isa/isa.yaml,../../ark/js_runtime/ecmascript/ecma_isa.yaml -o gen/isa/isa.yaml[OHOS ERROR] /usr/bin/env: ‘ruby’: No such file or directory[OHOS ERROR] Please check build log in /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/hi3516dv300/build.log=====build  error=====

然后先编译下官方已经有的产品,确保环境没有问题。 可以使用sudo apt-get install ccache命令安装 ccache,这样编译会快一点。执行如下命令即可 ./build.sh --product-name Hi3516DV300,等待编译完成,我这边等待了有几十来分钟才编译好吧,编译结果如下,说明我们的环境已经没有问题了,可以开始进行我们的移植 工作了。

在这里插入图片描述
首先在源码目录productdefine/common/products下,增加我们产品定义的json文件,我这里直接复制使用Hi3516DV300.json作为我们的模板修改下使用。使用命令cp Hi3516DV300.json zxyNandst.json即可得到我们的产品定义,打开文件,修改如下

{  "product_name": "Hi3516DV300", //这里修改为我们对应的文件名, zxyNandst  "product_company": "hisilicon", //修改为对应的产品,xingyunnand  "product_device": "hi3516dv300", // 使用 xingyunelec  "version": "2.0",  "type": "standard",  "product_build_path": "device/board/hisilicon/hispark_taurus/linux", //这里使用device/xingyunelec/xingyunnand/sdk_linux

所以修改后我们的这部分内容如下

{  "product_name": "zxyNandst",  "product_company": "xingyunelec",  "product_device": "xingyunnand",  "version": "2.0",  "type": "standard",  "product_build_path": "device/xingyunelec/xingyunnand/sdk_linux",  "parts":{

然后把图片中这行删除,这个是与海思相关的文件,我们不需要,所以删除即可。
在这里插入图片描述
然后我们使用如下命令尝试编译下 ./build.sh --product-name zxyNandst –ccache,很明显报错

++++++++++++++++++++++++++++++++++++++++2022-04-24 10:01:06--product-name zxyNandst –ccache[OHOS ERROR] /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/productdefine/common/device/xingyunnand.json not found=====build  error=====

我们还没有定义我们soc的相关信息,所以我们需要添加上去,同样的使用cp hi3516dv300.json xingyunnand.json得到我们的soc相关配置信息文件

{    "device_name": "hi3516dv300", //同文件名,xingyunnand.json    "device_company": "hisilicon", //device目录下的xingyunelec    "target_os": "ohos",    "target_cpu": "arm",    "kernel_version": "",    "device_build_path": "device/board/hisilicon/hispark_taurus/linux", //修改成自己对应即可    "enable_ramdisk": true}

修改成我们对应的相关配置信息,

{    "device_name": "xingyunnand",    "device_company": "xingyunelec",    "target_os": "ohos",    "target_cpu": "arm",    "kernel_version": "",    "device_build_path": "device/xingyunelec/xingyunnand/sdk_linux",    "enable_ramdisk": true}

然后使用 ./build.sh --product-name zxyNandst –ccache 再次编译试试,还是报错了,报错信息如下。

ERROR at //drivers/peripheral/audio/audio.gni:11:5: Unable to load "/home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/vendor/xingyunelec/zxyNandst/hals/audio/product.gni".[OHOS INFO]     import("//vendor/${product_company}/${product_name}/hals/audio/product.gni")[OHOS INFO]     ^--------------------------------------------------------------------------[OHOS INFO] See //drivers/peripheral/bluetooth/audio/BUILD.gn:16:1: whence it was imported.[OHOS INFO] import("//drivers/peripheral/audio/audio.gni")[OHOS INFO] ^--------------------------------------------[OHOS INFO] See //build/ohos/ohos_part.gni:25:16: which caused the file to be included.[OHOS INFO]     _deps += [ get_label_info(module_label, "label_with_toolchain") ]

可以看到,报错信息为没有 vendor/xingyunelec/zxyNandst/hals/audio/product.gni文件,所以我们需要提供这个文件,首先进入源码目录下的 vendor目录,然后使用命令 mkdir xingyunelec/zxyNandst/hals/audio/ -p创建目录,然后使用命令cp hisilicon/hispark_taurus_linux/hals/audio/product.gni xingyunelec/zxyNandst/hals/audio/,把海思的先作为我们的使用,目前不太清楚这个文件的具体作用,只是为了解决编译问题。然后再次进行编译。

 ERROR at //drivers/peripheral/camera/hal/camera.gni:30:5: Unable to load "/home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/device/xingyunelec/xingyunnand/camera/product.gni".[OHOS INFO]     import("//device/${product_company}/${device_name}/camera/product.gni")[OHOS INFO]     ^---------------------------------------------------------------------[OHOS INFO] See //drivers/peripheral/camera/hal/BUILD.gn:14:1: whence it was imported.[OHOS INFO] import("camera.gni")[OHOS INFO] ^------------------[OHOS INFO] See //build/ohos/ohos_part.gni:25:16: which caused the file to be included.[OHOS INFO]     _deps += [ get_label_info(module_label, "label_with_toolchain") ][OHOS INFO]  ^--------------------------------------------------

可以看到还是报错,没有device/xingyunelec/xingyunnand/camera/product.gni文件,照例,我们还是给它提供此文件。首先需要创建我们的camera目录,然后使用命令cp soc/hisilicon/common/hal/media/camera/hi3516dv300/linux_standard/camera/* xingyunelec/xingyunnand/camera/ -r把海思目录先拷贝进去,再次编译。

ERROR at //drivers/peripheral/display/hal/BUILD.gn:69:16: Unable to load "/home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/device/xingyunelec/hardware/display/BUILD.gn".[OHOS INFO]deps = [ "//device/${device_hal}/display:display_device" ][OHOS INFO]  ^----------------------------------------------[OHOS INFO] file: /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/xingyunnand/.ninja_log not exists[OHOS INFO] parse file fail[OHOS ERROR] Please check build log in /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/xingyunnand/build.log

那么自然我们需要添加目录device/xingyunelec/hardware,然后把display放进去即可,这里可以参考使用rk的。然后再次编译,可以发现,现在其实就是一个缺啥补啥的过程,先把编译框架搭起来,后面再去细节上的修改对应东西。

 is_mmi_have_libinput = true[OHOS INFO] is_mmi_have_hdf = false[OHOS INFO] is_mmi_have_debug = false[OHOS INFO] ERROR at //foundation/graphic/standard/graphic_config.gni:27:13: Unable to load "/home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/device/hisilicon/hardware/gpu/BUILD.gn".[OHOS INFO]   libgl = [ "//device/hisilicon/hardware/gpu:gpu_libs" ][OHOS INFO]      ^-----------------------------------------[OHOS INFO] file: /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/xingyunnand/.ninja_log not exists[OHOS INFO] parse file fail[OHOS ERROR] Please check build log in /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/xingyunnand/build.log=====build  error=====

依然报错,不要怕,报错是很正常的事情,现在我们查看foundation/graphic/standard/graphic_config.gni文件,可以看到是关于GPU的,我们先仿照不使用gpu的添加看看情况。

diff --git a/foundation/graphic/standard/graphic_config.gni b/foundation/graphic/standard/graphic_config.gniindex 1e4f66c17e..939ebd26db 100644--- a/foundation/graphic/standard/graphic_config.gni+++ b/foundation/graphic/standard/graphic_config.gni@@ -21,6 +21,10 @@ if ("${product_name}" == "watchos" || "${product_name}" == "Hi3516DV300" ||   gpu_defines = [ "ACE_ENABLE_GL" ]   ace_enable_gpu = true   libgl = [ "//device/hihope/hardware/gpu:mali-bifrost-g52-g2p0-ohos" ]+} else if ( "${product_name}" == "zxyNandst" ) {+  gpu_defines = [ "ACE_DISABLE_GL" ]+  ace_enable_gpu = false+  libgl = [] } else {   gpu_defines = [ "ACE_ENABLE_GL" ]   ace_enable_gpu = true

修改补丁如上,然后再次编译,还是报错,修改此处为自己目录即可。
openharmony标准系统移植之添加产品编译
接着再次编译,报错信息如下

[OHOS INFO] WARNING at the command-line "--args":1:225: Build argument has no effect.[OHOS INFO] product_path="/home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/productdefine/common/products" product_name="zxyNandst" device_name="xingyunnand" target_cpu="arm" target_os="ohos" is_standard_system=true device_path="device/xingyunelec/xingyunnand/sdk_linux" ohos_kernel_type="linux" common_feature_verify=true ohos_build_type="debug" ohos_build_time="1650749448763" ohos_build_datetime="2022-04-24 13:30:48"[OHOS INFO] ^-----------------------------------------[OHOS INFO] Did you mean "device_name"?[OHOS INFO][OHOS INFO] The variable "device_path" was set as a build argument[OHOS INFO] but never appeared in a declare_args() block in any buildfile.[OHOS INFO][OHOS INFO] To view all possible args, run "gn args --list "[OHOS INFO][OHOS INFO] The build continued as if that argument was unspecified.[OHOS INFO][OHOS INFO] Done. Made 14487 targets from 2504 files in 80340ms[OHOS ERROR] ninja: error: '../../vendor/xingyunelec/zxyNandst/hdf_config/uhdf/camera/hdi_impl/camera_host_config.hcs', needed by 'gen/device/xingyunelec/xingyunnand/camera/hdi_impl/camera_host_config.hcb', missing and no known rule to make it[OHOS INFO] file: /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/xingyunnand/.ninja_log not exists[OHOS INFO] parse file fail[OHOS ERROR] Please check build log in /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/xingyunnand/build.log=====build  error=====

可以看出,是没有hcs文件导致的,首先vendor/xingyunelec/zxyNandst目录下创建hdf_config目录,然后在hdf_config下创建目录 mkdir uhdf/camera/hdi_impl -p,把其他地方有的camera_host_config.hcs文件复制到刚才创建的目录即可,完整路径vendor/xingyunelec/zxyNandst/hdf_config/uhdf/camera/hdi_impl/camera_host_config.hcs,接着添加
vendor/xingyunelec/zxyNandst/hdf_config/uhdf/camera/pipeline_core/config.hcs文件、vendor/xingyunelec/zxyNandst/hdf_config/uhdf/camera/pipeline_core/params.hcs文件、vendor/xingyunelec/zxyNandst/hdf_config/uhdf/camera/pipeline_core/ipp_algo_config.hcs文件,再创建目录 vendor/xingyunelec/zxyNandst/hdf_config/uhdf/camera/driver,然后添加如下文件
vendor/xingyunelec/zxyNandst/hdf_config/uhdf/camera/driver/mpp_config.hcs,接着添加
vendor/xingyunelec/zxyNandst/hdf_config/uhdf/hdf.hcs,vendor/xingyunelec/zxyNandst/hdf_config/uhdf/device_info.hcs,注意修改hdf.hcs文件内容,不需要包含其他文件,像我这里就只包含了一个。

#include "device_info.hcs"root {    module = "default";}

然后再次执行 ./build.sh --product-name zxyNandst –ccache命令进行编译操作,

[OHOS ERROR] [9232/33223] ACTION //kernel/linux/build:build_kernel(//build/toolchain/ohos:ohos_clang_arm)[OHOS ERROR] FAILED: packages/phone/images/uImage[OHOS ERROR] /usr/bin/env ../../kernel/linux/build/build_kernel.sh ../../kernel/linux/build /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/KERNEL_OBJ /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/xingyunnand/packages/phone/images standard arm vendor/xingyunelec/zxyNandst xingyunnand linux-5.10[OHOS ERROR] build_kernel[OHOS ERROR] ~/openHarmony/source/code-v3.1-Release/OpenHarmony/kernel/linux/build ~/openHarmony/source/code-v3.1-Release/OpenHarmony/out/xingyunnand[OHOS ERROR] echo "build kernel..."[OHOS ERROR] build kernel...[OHOS ERROR] rm -rf /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/KERNEL_OBJ/kernel/src_tmp/linux-5.10;mkdir -p /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/KERNEL_OBJ/kernel/src_tmp/linux-5.10;cp -arfL /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/kernel/linux/linux-5.10/* /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/KERNEL_OBJ/kernel/src_tmp/linux-5.10/[OHOS ERROR] /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/drivers/adapter/khdf/linux/patch_hdf.sh /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/KERNEL_OBJ/kernel/src_tmp/linux-5.10 /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/kernel/linux/patches/linux-5.10/xingyunnand_patch/hdf.patch[OHOS ERROR] /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/drivers/adapter/khdf/linux/patch_hdf.sh: line 55: /home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/kernel/linux/patches/linux-5.10/xingyunnand_patch/hdf.patch: No such file or directory[OHOS ERROR] kernel.mk:64: recipe for target '/home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/KERNEL_OBJ/kernel/src_tmp/linux-5.10/arch/arm/boot/uImage' failed[OHOS ERROR] make: *** [/home/d1/openHarmony/source/code-v3.1-Release/OpenHarmony/out/KERNEL_OBJ/kernel/src_tmp/linux-5.10/arch/arm/boot/uImage] Error 1[OHOS INFO] c targets overlap rate statistics

可以看到是在编译内核的时候报错的,这时候我们就需要去适配内核编译了。可以说明的是,至少没有之前那种文件缺失编译的情况了。接下来我们开始添加我们产品的内核到编译框架中去了。首先修改
build/ohos/kernel/kernel.gni文件,修改点如下,这样就能编译我们自己的内核版本了。

diff --git a/build/ohos/kernel/kernel.gni b/build/ohos/kernel/kernel.gniindex d585469b4e..019c74745a 100644--- a/build/ohos/kernel/kernel.gni+++ b/build/ohos/kernel/kernel.gni@@ -11,5 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. declare_args() {-    linux_kernel_version = "linux-5.10"+    linux_kernel_version = "linux-5.4" }

接着添加 kernel/linux/config/linux-5.4/目录,具体需要添加的文件路径以及名称为
kernel/linux/config/linux-5.4/arch/arm/configs/xingyunnand_standard_defconfig
其中 xingyunnand_standard_defconfig可以是 KaTeX parse error: Expected group after '_' at position 14: (DEVICE_NAME)_̲(BUILD_TYPE)_defconfig组成,
然后添加文件
kernel/linux/patches/linux-5.4/xingyunnand_patch/hdf.patch和kernel/linux/patches/linux-5.4/xingyunnand_patch/xingyunnand.patch两个文件,具体为什么添加这两个文件可以参考kernel/linux/build/kernel.mk文件,或者在编译的时候也会提示需要什么文件。然后把自己的内核源文件拷贝到kernel/linux/目录下,像我这里就是 kernel/linux/linux-5.4 目录,然后开始编译,编译结果如下图,可以看到其实uImage已经成功了,是在执行cp的时候出错了。
openharmony标准系统移植之添加产品编译
在 kernel/linux/build/build_kernel.sh文件中,有执行这个拷贝,目前不知道这是什么文件,我们暂时不用
在这里插入图片描述
直接注释掉,然后再次进行编译。
在这里插入图片描述
然后内核就编译好了,但是报错问题还是有,如下错误。

OHOS ERROR] [3027/24068] CC obj/drivers/peripheral/usb/hal/service/src/usbd/usbd_port.o[OHOS ERROR] FAILED: obj/drivers/peripheral/usb/hal/service/src/usbd/usbd_port.o[OHOS ERROR] ../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang -MMD -MF obj/drivers/peripheral/usb/hal/service/src/usbd/usbd_port.o.d -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -D_GNU_SOURCE -DHAVE_SYS_UIO_H -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD -D__GNU_SOURCE=1 -DCHROMIUM_CXX_TWEAK_INLINES -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D__OHOS_USER__ -D__OHOS_STANDARD_SYS__ -Iobj/third_party/musl/usr/include/arm-linux-ohos -I../../prebuilts/clang/ohos/linux-x86_64/llvm/include/c++/v1 -Ioverride/third_party -I../.. -Igen -I../../drivers/peripheral/usb/hal/service/include -I../../drivers/peripheral/usb/hal/client/include -I../../drivers/peripheral/usb/ddk/common/include -I../../drivers/peripheral/usb/ddk/host/include -I../../drivers/peripheral/usb/interfaces/ddk/common -I../../drivers/peripheral/usb/interfaces/ddk/host -I../../drivers/peripheral/usb/interfaces/ddk/device -I../../drivers/peripheral/usb/gadget/function/include -I../../drivers/framework/model/usb/include -I../../device/soc/xingyunelec/common/hal/usb/xingyunnand/include -I../../utils/native/base/include -I../../drivers/framework/core/manager/include -I../../drivers/framework/core/host/include -I../../drivers/framework/core/shared/include -I../../drivers/adapter/uhdf2/include/host -I../../drivers/adapter/uhdf2/shared/include -I../../drivers/adapter/uhdf2/manager/include -I../../drivers/adapter/uhdf2/host/include -I../../utils/native/base/include -I../../drivers/framework/include -I../../drivers/framework/include/osal -I../../drivers/framework/include/utils -I../../drivers/framework/utils/include -I../../drivers/framework/core/adapter/syscall/include -I../../drivers/framework/core/adapter/vnode/include -I../../drivers/framework/core/shared/include -I../../drivers/framework/include/core -I../../drivers/adapter/uhdf2/shared/include -I../../drivers/adapter/uhdf2/ipc/include -I../../utils/native/base/include -I../../drivers/framework/include -I../../drivers/framework/include/core -I../../drivers/framework/include/osal -I../../drivers/framework/include/utils -I../../drivers/framework/utils/include -I../../drivers/framework/core/adapter/syscall/include -I../../drivers/framework/core/adapter/vnode/include -I../../drivers/framework/core/shared/include -I../../drivers/framework/include/core -I../../drivers/adapter/uhdf2/osal/include -I../../drivers/adapter/uhdf2/utils/include -I../../utils/native/base/include -I../../drivers/framework/utils/include -I../../drivers/framework/core/shared/include -I../../drivers/adapter/uhdf2/ipc/include -I../../drivers/adapter/uhdf2/hdi/include -I../../drivers/adapter/uhdf2/include/hdi -I../../drivers/adapter/uhdf2/include/hdi/base -I../../drivers/adapter/uhdf2/shared/include -I../../base/hiviewdfx/hilog/interfaces/native/innerkits/include -I../../base/startup/syspara_lite/interfaces/innerkits/native/syspara/include -I../../base/startup/syspara_lite/adapter/native/syspara/include -I../../utils/native/base/include -I../../developtools/liblog -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector-strong -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -ffunction-sections -fno-short-enums --target=arm-linux-ohos -march=armv7-a -mfloat-abi=softfp -mtune=generic-armv7-a -mfpu=neon -mthumb -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-error=c99-designator -Wno-error=anon-enum-enum-conversion -Wno-error=implicit-fallthrough -Wno-error=sizeof-array-div -Wno-error=reorder-init-list -Wno-error=range-loop-construct -Wno-error=deprecated-copy -Wno-error=implicit-int-float-conversion -Wno-error=inconsistent-dllimport -Wno-error=unknown-warning-option -Wno-error=abstract-final-class -Wno-error=sign-compare -Wno-error=int-in-bool-context -Wno-error=xor-used-as-pow -Wno-error=return-stack-address -Wno-error=dangling-gsl -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-user-defined-warnings -Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch -O2 -fno-ident -fdata-sections -ffunction-sections -fomit-frame-pointer -gdwarf-3 -g2 -ggnu-pubnames -fno-common -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare --sysroot=obj/third_party/musl -c ../../drivers/peripheral/usb/hal/service/src/usbd_port.c -o obj/drivers/peripheral/usb/hal/service/src/usbd/usbd_port.o[OHOS ERROR] ../../drivers/peripheral/usb/hal/service/src/usbd_port.c:26:10: fatal error: 'default_config.h' file not found

报错信息如上,提示没有default_config.h文件,那么我们需要添加这个文件了。
查看 drivers/peripheral/usb/hal/service/BUILD.gn文件,那么我们仿照着添加我们自己的即可。
在这里插入图片描述
添加好的文件修改补丁如下,

diff --git a/drivers/peripheral/usb/hal/service/BUILD.gn b/drivers/peripheral/usb/hal/service/BUILD.gnindex ee087180c6..ef7dfc80b7 100644--- a/drivers/peripheral/usb/hal/service/BUILD.gn+++ b/drivers/peripheral/usb/hal/service/BUILD.gn@@ -25,6 +25,8 @@ config("usbd_public_config") {     default_config_path = "//device/$device_company/$device_name/usb/include"   } else if (device_company == "openharmony") {     default_config_path = "//device/hihope/rk3568/usb/include"+  } else if ( device_company == "xingyunelec" ) {+    default_config_path = "//device/$device_company/$device_name/usb/include"   }   include_dirs = [

所以我们需要添加 device/xingyunelec/xingyunnand/usb/include/default_config.h文件,接着修改
drivers/peripheral/usb/gadget/function/master/BUILD.gn文件,

diff --git a/drivers/peripheral/usb/gadget/function/master/BUILD.gn b/drivers/peripheral/usb/gadget/function/master/BUILD.gnindex 64347a82f9..ed8f81a770 100644--- a/drivers/peripheral/usb/gadget/function/master/BUILD.gn+++ b/drivers/peripheral/usb/gadget/function/master/BUILD.gn@@ -25,6 +25,8 @@ ohos_shared_library("libusbfn_master") {     default_config_path = "//device/$device_company/$device_name/usb/include"   } else if (device_company == "openharmony") {     default_config_path = "//device/hihope/rk3568/usb/include"+  }  else if ( device_company == "xingyunelec" ) {+    default_config_path = "//device/$device_company/$device_name/usb/include"   }   include_dirs = [

然后接着编译,只能说问题点是真的多,但是没办法,只能硬着头皮根据报错修改了。

[OHOS ERROR] ../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang -MMD -MF obj/device/xingyunelec/hardware/display/src/display_gfx/display_gfx/display_gfx.o.d -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -D_GNU_SOURCE -DHAVE_SYS_UIO_H -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD -D__GNU_SOURCE=1 -DCHROMIUM_CXX_TWEAK_INLINES -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -I../../device/xingyunelec/hardware/display/include -I../../drivers/peripheral/display/interfaces/include -I../../drivers/peripheral/base -I../../drivers/framework/include/utils -I../../drivers/adapter/uhdf2/adapter/osal/include -I../../utils/native/base/include -I../../foundation/graphic/standard/utils/include -I../../device/soc/allwinner/hardware/rga/include -I../../base/hiviewdfx/interfaces/innerkits/libhilog/include -Iobj/third_party/musl/usr/include/arm-linux-ohos -I../../prebuilts/clang/ohos/linux-x86_64/llvm/include/c++/v1 -Ioverride/third_party -I../.. -Igen -I../../utils/native/base/include -I../../developtools/liblog -I../../base/hiviewdfx/hilog/interfaces/native/innerkits/include -Wno-macro-redefined -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector-strong -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -ffunction-sections -fno-short-enums --target=arm-linux-ohos -march=armv7-a -mfloat-abi=softfp -mtune=generic-armv7-a -mfpu=neon -mthumb -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-error=c99-designator -Wno-error=anon-enum-enum-conversion -Wno-error=implicit-fallthrough -Wno-error=sizeof-array-div -Wno-error=reorder-init-list -Wno-error=range-loop-construct -Wno-error=deprecated-copy -Wno-error=implicit-int-float-conversion -Wno-error=inconsistent-dllimport -Wno-error=unknown-warning-option -Wno-error=abstract-final-class -Wno-error=sign-compare -Wno-error=int-in-bool-context -Wno-error=xor-used-as-pow -Wno-error=return-stack-address -Wno-error=dangling-gsl -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-user-defined-warnings -Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch -O2 -fno-ident -fdata-sections -ffunction-sections -fomit-frame-pointer -gdwarf-3 -g2 -ggnu-pubnames -fno-common -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare --sysroot=obj/third_party/musl -c ../../device/xingyunelec/hardware/display/src/display_gfx/display_gfx.c -o obj/device/xingyunelec/hardware/display/src/display_gfx/display_gfx/display_gfx.o[OHOS ERROR] ../../device/xingyunelec/hardware/display/src/display_gfx/display_gfx.c:18:10: fatal error: 'im2d.h' file not found[OHOS ERROR] #include "im2d.h"[OHOS ERROR]   ^~~~~~~~[OHOS ERROR] 1 error generated.

很显然,找不到im2d.h文件,但是其实我们device下已经有了,那只能去看编译情况了,是不是找不到路径造成的。通过查看device/xingyunelec/hardware/display/BUILD.gn文件发现如下情况,果然,没有包含到我们的文件路径,需要替换掉这个路径。
在这里插入图片描述
替换后的结果,替换成我们自己的路径即可。
在这里插入图片描述
开始编译,报错,

OHOS ERROR] FAILED: obj/drivers/peripheral/usb/gadget/function/ecm/libusbfn_cdcecm/cdcecm.o[OHOS ERROR] ../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang -MMD -MF obj/drivers/peripheral/usb/gadget/function/ecm/libusbfn_cdcecm/cdcecm.o.d -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -D_GNU_SOURCE -DHAVE_SYS_UIO_H -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD -D__GNU_SOURCE=1 -DCHROMIUM_CXX_TWEAK_INLINES -D__MUSL__ -D_LIBCPP_HAS_MUSL_LIBC -D__BUILD_LINUX_WITH_CLANG -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D__OHOS_USER__ -D__OHOS_STANDARD_SYS__ -I../../drivers/peripheral/usb/interfaces/ddk/device -I../../drivers/peripheral/usb/interfaces/ddk/common -I../../drivers/peripheral/usb/gadget/function/include -I../../device/soc/xingyunelec/common/hal/usb/xingyunnand/include -Iobj/third_party/musl/usr/include/arm-linux-ohos -I../../prebuilts/clang/ohos/linux-x86_64/llvm/include/c++/v1 -Ioverride/third_party -I../.. -Igen -I../../utils/native/base/include -I../../drivers/framework/core/manager/include -I../../drivers/framework/core/host/include -I../../drivers/framework/core/shared/include -I../../drivers/adapter/uhdf2/include/host -I../../drivers/adapter/uhdf2/shared/include -I../../drivers/adapter/uhdf2/manager/include -I../../drivers/adapter/uhdf2/host/include -I../../utils/native/base/include -I../../drivers/framework/include -I../../drivers/framework/include/osal -I../../drivers/framework/include/utils -I../../drivers/framework/utils/include -I../../drivers/framework/core/adapter/syscall/include -I../../drivers/framework/core/adapter/vnode/include -I../../drivers/framework/core/shared/include -I../../drivers/framework/include/core -I../../drivers/adapter/uhdf2/shared/include -I../../drivers/adapter/uhdf2/ipc/include -I../../utils/native/base/include -I../../drivers/framework/include -I../../drivers/framework/include/core -I../../drivers/framework/include/osal -I../../drivers/framework/include/utils -I../../drivers/framework/utils/include -I../../drivers/framework/core/adapter/syscall/include -I../../drivers/framework/core/adapter/vnode/include -I../../drivers/framework/core/shared/include -I../../drivers/framework/include/core -I../../drivers/adapter/uhdf2/osal/include -I../../drivers/adapter/uhdf2/utils/include -I../../base/hiviewdfx/hilog/interfaces/native/innerkits/include -I../../utils/native/base/include -I../../developtools/liblog -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector-strong -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -ffunction-sections -fno-short-enums --target=arm-linux-ohos -march=armv7-a -mfloat-abi=softfp -mtune=generic-armv7-a -mfpu=neon -mthumb -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-error=c99-designator -Wno-error=anon-enum-enum-conversion -Wno-error=implicit-fallthrough -Wno-error=sizeof-array-div -Wno-error=reorder-init-list -Wno-error=range-loop-construct -Wno-error=deprecated-copy -Wno-error=implicit-int-float-conversion -Wno-error=inconsistent-dllimport -Wno-error=unknown-warning-option -Wno-error=abstract-final-class -Wno-error=sign-compare -Wno-error=int-in-bool-context -Wno-error=xor-used-as-pow -Wno-error=return-stack-address -Wno-error=dangling-gsl -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-user-defined-warnings -Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch -O2 -fno-ident -fdata-sections -ffunction-sections -fomit-frame-pointer -gdwarf-3 -g2 -ggnu-pubnames -fno-common -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare --sysroot=obj/third_party/musl -c ../../drivers/peripheral/usb/gadget/function/ecm/cdcecm.c -o obj/drivers/peripheral/usb/gadget/function/ecm/libusbfn_cdcecm/cdcecm.o[OHOS ERROR] ../../drivers/peripheral/usb/gadget/function/ecm/cdcecm.c:28:10: fatal error: 'default_config.h' file not found

修改如下。

diff --git a/drivers/peripheral/usb/gadget/function/acm/BUILD.gn b/drivers/peripheral/usb/gadget/function/acm/BUILD.gnindex 6f259592a4..a40224364c 100644--- a/drivers/peripheral/usb/gadget/function/acm/BUILD.gn+++ b/drivers/peripheral/usb/gadget/function/acm/BUILD.gn@@ -25,6 +25,8 @@ ohos_shared_library("libusbfn_cdcacm") {     default_config_path = "//device/$device_company/$device_name/usb/include"   } else if (device_company == "openharmony") {     default_config_path = "//device/hihope/rk3568/usb/include"+  } else if ( device_company == "xingyunelec" ) {+    default_config_path = "//device/$device_company/$device_name/usb/include"   }   include_dirs = [

报错

../../drivers/peripheral/usb/gadget/function/ecm/cdcecm.c:28:10: fatal error: 'default_config.h' file not found

修改

diff --git a/drivers/peripheral/usb/gadget/function/ecm/BUILD.gn b/drivers/peripheral/usb/gadget/function/ecm/BUILD.gnindex 9ab3d42aeb..ec43872029 100644--- a/drivers/peripheral/usb/gadget/function/ecm/BUILD.gn+++ b/drivers/peripheral/usb/gadget/function/ecm/BUILD.gn@@ -25,6 +25,8 @@ ohos_shared_library("libusbfn_cdcecm") {     default_config_path = "//device/$device_company/$device_name/usb/include"   } else if (device_company == "openharmony") {     default_config_path = "//device/hihope/rk3568/usb/include"+  } else if ( device_company == "xingyunelec" ) {+    default_config_path = "//device/$device_company/$device_name/usb/include"   }   include_dirs = [

到最后编译报错

[OHOS ERROR] [33212/33223] ACTION //build/ohos/images:phone_ramdisk_image(//build/toolchain/ohos:ohos_clang_arm)[OHOS ERROR] FAILED: ramdisk.img[OHOS ERROR] /usr/bin/env ../../build/ohos/images/build_image.py --depfile gen/build/ohos/images/phone_ramdisk_image.d --image-name ramdisk --input-path packages/phone/ramdisk --image-config-file ../../build/ohos/images/mkimage/ramdisk_image_conf.txt --device-image-config-file packages/imagesconf/ramdisk_image_conf.txt --output-image ramdisk.img --target-cpu arm --build-image-tools-path clang_x64/distributeddatamgr/e2fsprogs clang_x64/filemanagement/storage_service ../../third_party/e2fsprogs/prebuilt/host/bin ../../build/ohos/images/mkimage[OHOS ERROR] pid  31255  ret  1[OHOS ERROR]  Make cpio image![OHOS ERROR] Error: source file does not exist! path: ./fstab.required[OHOS ERROR][OHOS ERROR] MkImages failed errno: 1

可以看出是编译ramdisk出错,如果我们不需要这个,只需修改productdefine/common/device/xingyunnand.json文件里面的如下图所示,修改为false即可。
在这里插入图片描述

ZDfans