OpenHarmony 4.0 Beta2编译到最后一步了出错

OpenHarmony 4.0 Beta2编译到最后一步了出错 [OHOS INFO] [50690/50701] ACTION //build/ohos/images:phone_system_image(//build/toolchain/ohos:ohos_clang_arm)

[OHOS ERROR] [50683/50701] 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-variant root --build-image-tools-path clang_x64/thirdparty/e2fsprogs clang_x64/thirdparty/f2fs-tools …/…/third_party/e2fsprogs/prebuilt/host/bin …/…/build/ohos/images/mkimage

[OHOS ERROR] pid 1095807 ret 1

[OHOS ERROR] Make cpio image!

[OHOS ERROR] Traceback (most recent call last):

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/…/…/build/ohos/images/mkimage/mkcpioimage.py”, line 140, in <module>

[OHOS ERROR] main(sys.argv[1:])

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/…/…/build/ohos/images/mkimage/mkcpioimage.py”, line 135, in main

[OHOS ERROR] build_run_cpio(args)

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/…/…/build/ohos/images/mkimage/mkcpioimage.py”, line 74, in build_run_cpio

[OHOS ERROR] res = run_cmd(ramdisk_cmd, dir_list)

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/…/…/build/ohos/images/mkimage/mkcpioimage.py”, line 37, in run_cmd

[OHOS ERROR] res = subprocess.Popen(cmd, stdout=subprocess.PIPE,

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/prebuilts/python/linux-x86/current/lib/python3.10/subprocess.py”, line 966, in init

[OHOS ERROR] self._execute_child(args, executable, preexec_fn, close_fds,

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/prebuilts/python/linux-x86/current/lib/python3.10/subprocess.py”, line 1842, in _execute_child

[OHOS ERROR] raise child_exception_type(errno_num, err_msg, err_filename)

[OHOS ERROR] FileNotFoundError: [Errno 2] No such file or directory: ‘cpio’

[OHOS ERROR]

[OHOS ERROR] MkImages failed errno: 1

[OHOS ERROR] [50684/50701] ACTION //build/ohos/images:phone_updater_ramdisk_image(//build/toolchain/ohos:ohos_clang_arm)

[OHOS ERROR] FAILED: updater_ramdisk.img

[OHOS ERROR] /usr/bin/env …/…/build/ohos/images/build_image.py --depfile gen/build/ohos/images/phone_updater_ramdisk_image.d --image-name updater_ramdisk --input-path packages/phone/updater --image-config-file …/…/build/ohos/images/mkimage/updater_ramdisk_image_conf.txt --device-image-config-file packages/imagesconf/updater_ramdisk_image_conf.txt --output-image updater_ramdisk.img --target-cpu arm --build-variant root --build-image-tools-path clang_x64/thirdparty/e2fsprogs clang_x64/thirdparty/f2fs-tools …/…/third_party/e2fsprogs/prebuilt/host/bin …/…/build/ohos/images/mkimage

[OHOS ERROR] pid 1095805 ret 1

[OHOS ERROR] Make cpio image!

[OHOS ERROR] Traceback (most recent call last):

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/…/…/build/ohos/images/mkimage/mkcpioimage.py”, line 140, in <module>

[OHOS ERROR] main(sys.argv[1:])

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/…/…/build/ohos/images/mkimage/mkcpioimage.py”, line 135, in main

[OHOS ERROR] build_run_cpio(args)

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/…/…/build/ohos/images/mkimage/mkcpioimage.py”, line 74, in build_run_cpio

[OHOS ERROR] res = run_cmd(ramdisk_cmd, dir_list)

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/…/…/build/ohos/images/mkimage/mkcpioimage.py”, line 37, in run_cmd

[OHOS ERROR] res = subprocess.Popen(cmd, stdout=subprocess.PIPE,

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/prebuilts/python/linux-x86/current/lib/python3.10/subprocess.py”, line 966, in init

[OHOS ERROR] self._execute_child(args, executable, preexec_fn, close_fds,

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/prebuilts/python/linux-x86/current/lib/python3.10/subprocess.py”, line 1842, in _execute_child

[OHOS ERROR] raise child_exception_type(errno_num, err_msg, err_filename)

[OHOS ERROR] FileNotFoundError: [Errno 2] No such file or directory: ‘cpio’

[OHOS ERROR]

[OHOS ERROR] MkImages failed errno: 1

[OHOS ERROR] Traceback (most recent call last):

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/services/ninja.py”, line 49, in _execute_ninja_cmd

[OHOS ERROR] SystemUtil.exec_command(

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/util/system_util.py”, line 63, in exec_command

[OHOS ERROR] raise OHOSException(

[OHOS ERROR] exceptions.ohos_exception.OHOSException: Please check build log in /home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/build.log

[OHOS ERROR]

[OHOS ERROR] During handling of the above exception, another exception occurred:

[OHOS ERROR]

[OHOS ERROR] Traceback (most recent call last):

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/containers/status.py”, line 47, in wrapper

[OHOS ERROR] return func(*args, **kwargs)

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/modules/ohos_build_module.py”, line 67, in run

[OHOS ERROR] raise exception

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/modules/ohos_build_module.py”, line 65, in run

[OHOS ERROR] super().run()

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/modules/interface/build_module_interface.py”, line 72, in run

[OHOS ERROR] raise exception

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/modules/interface/build_module_interface.py”, line 70, in run

[OHOS ERROR] self._target_compilation()

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/modules/ohos_build_module.py”, line 103, in _target_compilation

[OHOS ERROR] self.target_compiler.run()

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/services/ninja.py”, line 38, in run

[OHOS ERROR] self._execute_ninja_cmd()

[OHOS ERROR] File “/home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/build/hb/services/ninja.py”, line 52, in _execute_ninja_cmd

[OHOS ERROR] raise OHOSException(‘ninja phase failed’, ‘4000’)

[OHOS ERROR] exceptions.ohos_exception.OHOSException: ninja phase failed

[OHOS ERROR]

[OHOS ERROR] Code: 4000

[OHOS ERROR]

[OHOS ERROR] Reason: ninja phase failed

[OHOS ERROR]

[OHOS ERROR] Solution: Please check the compile log at out/{compiling product}/build.log, If you could analyze build logs.

[OHOS ERROR] Or you can try the following steps to solve this problem:

[OHOS ERROR] 1. cd to OHOS root path

[OHOS ERROR] 2. run ‘hb clean --all’ or ‘rm -rf out build/resources/args/*.json’.

[OHOS ERROR] 3. repo sync

[OHOS ERROR] 4. repo forall -c ‘git lfs pull’

[OHOS ERROR] 5. bash build/prebuilts_download.sh

[OHOS ERROR] 6. rebuild your product or component

[OHOS ERROR]

[OHOS ERROR] If you still cannot solve this problem, you could post this problem on:

[OHOS ERROR] https://gitee.com/openharmony/build/issues

[OHOS ERROR]

  • [[ 255 -ne 0 ]]

  • echo ‘rk3568 build failed!’

rk3568 build failed!

  • exit 1

ubuntu@b4e7f8d0ab32:~/rk3568-OpenHarmony-4.0-Beta2$


5 回复

根据您提供的错误日志,问题很明确:编译过程中缺少cpio工具。错误信息显示:

FileNotFoundError: [Errno 2] No such file or directory: 'cpio'

这是OpenHarmony编译ramdisk镜像时必需的工具。以下是完整的解决方案:

1. 安装缺失的cpio工具

sudo apt-get update
sudo apt-get install cpio

2. 安装OpenHarmony 4.0编译所需的完整依赖包

为了确保编译环境完整,建议安装所有必需的依赖:

sudo apt-get install -y git git-lfs python3 python3-pip python3-dev binutils binutils-dev gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig libtinfo5 libtinfo-dev genext2fs device-tree-compiler mtools u-boot-tools libssl-dev mtd-utils

3. 清理并重新编译

安装完依赖后,按照官方建议的步骤清理并重新编译:

# 进入OpenHarmony源码根目录
cd ~/rk3568-OpenHarmony-4.0-Beta2

# 清理编译环境
hb clean --all
# 或者
rm -rf out build/resources/args/*.json

# 重新同步代码
repo sync

# 拉取LFS文件
repo forall -c 'git lfs pull'

# 下载预编译工具
bash build/prebuilts_download.sh

# 重新编译
./build.sh -p rk3568

4. 验证cpio是否安装成功

安装完成后,可以验证cpio是否可用:

which cpio
cpio --version

补充说明

  1. Ubuntu版本要求:OpenHarmony 4.0推荐使用Ubuntu 20.04或22.04,如果您使用的是其他版本,可能需要调整依赖包。

  2. WSL2用户注意:如果您在Windows WSL2中编译,请确保WSL2已正确配置,并且有足够的内存(建议16GB以上)和磁盘空间(100GB以上)。

  3. 环境变量:确保Python环境正确配置,建议使用Python 3.8或3.9版本。

  4. 编译耗时:首次全量编译可能需要1-2小时,取决于您的硬件配置。

如果按照以上步骤操作后仍然遇到问题,建议查看详细的编译日志:

cat /home/ubuntu/rk3568-OpenHarmony-4.0-Beta2/out/rk3568/build.log

并将具体的错误信息提交到OpenHarmony官方issue页面:https://gitee.com/openharmony/build/issues


Linux里的cpio这个工具没找到。

sudo apt install cpio

还有问题,可以再排查,全点的log。

cke_154.png

FileNotFoundError: [Errno 2] No such file or directory: ‘cpio’

安装一下 cpio 后试试

OpenHarmony 4.0 Beta2编译最后一步出错通常由链接阶段符号缺失、依赖库版本不匹配或工具链(如gn/ninja)与源码版本不一致引起。请检查报错日志中的具体错误类型,并确认预置的编译环境(如Python、Clang、LLVM)与官方要求完全对应。

系统缺少 cpio 工具,导致打包 ramdisk 镜像失败。执行以下命令安装即可:

sudo apt-get install cpio

安装后重新编译。

回到顶部