Jetson Nano(arm64)部署Fuchsia时报错无法执行Ninja如何解决
问题背景
我想要在arm64架构的Jetson Nano设备上通过qemu和kvm模拟运行谷歌Fuchsia操作系统,参考官方指南执行操作后遇到Ninja执行错误无法解决,操作日志如下:
操作日志
/opt# python --version Python 3.8.11 /opt# curl -sO https://storage.googleapis.com/fuchsia-ffx/ffx-linux-x64 && chmod +x ffx-linux-x64 && ./ffx-linux-x64 platform preflight bash: ./ffx-linux-x64: cannot execute binary file: Exec format error /opt# curl -s "https://fuchsia.googlesource.com/fuchsia/+/HEAD/scripts/bootstrap?format=TEXT" | base64 --decode | bash WARNING: Jiri doesn't support timely updates for arch 'aarch64'. This or future binaries of Jiri might be out of date. cipd bootstrapped to path:"/opt/fuchsia/.jiri_root/bin/cipd" Please add /opt/fuchsia/.jiri_root/bin to your PATH WARN: Please opt in or out of analytics collection. You will receive this warning until an option is selected. To check what data we collect run: jiri init -show-analytics-data To opt-in run: jiri init -analytics-opt=true "/opt/fuchsia" To opt-out run: jiri init -analytics-opt=false "/opt/fuchsia" Updating all projects WARN: Some packages are skipped by cipd due to lack of access, you might want to run "/opt/fuchsia/.jiri_root/bin/cipd auth-login" and try again Done creating a Platform Source Tree at "/opt/fuchsia". Recommended: export PATH="/opt/fuchsia/.jiri_root/bin:$PATH" /opt# nano ~/.bash_profile export PATH=/opt/fuchsia/.jiri_root/bin:$PATH source /opt/fuchsia/scripts/fx-env.sh /opt# source ~/.bash_profile /opt# jiri help Command jiri is a multi-purpose tool for multi-repo development. Usage: jiri [flags] <command> /opt/fuchsia# fx help usage: fx [--dir BUILD_DIR] [-d DEVICE_NAME] [-i] [-x] COMMAND [...] Run Fuchsia development commands. Must be run from a directory that is contained in a Platform Source Tree. /opt/fuchsia# fx set core.qemu-arm64 WARNING: Please opt in or out of fx metrics collection. You will receive this warning until an option is selected. To check what data we collect, run `fx metrics` To opt in or out, run `fx metrics <enable|disable>` /opt/fuchsia/tools/devshell/go: line 21: /opt/fuchsia/prebuilt/third_party/go/linux-arm64/bin/go: cannot execute binary file: Exec format error /opt/fuchsia/tools/devshell/go: line 21: /opt/fuchsia/prebuilt/third_party/go/linux-arm64/bin/go: Success ERROR: Failed to build fx set. ERROR: Please file a bug using `fx report-bug set` with the full error copy-pasted. ERROR: Rerun your command using the uncompiled version: ERROR: fx --enable=legacy_set set core.qemu-arm64 /opt/fuchsia# fx --enable=legacy_set set core.qemu-arm64 WARNING: Please opt in or out of fx metrics collection. You will receive this warning until an option is selected. To check what data we collect, run fx metrics To opt in or out, run `fx metrics <enable|disable>`
最终报错:ERROR Could not execute Ninja. I was trying to execute "/opt/fuchsia/prebuilt/third_party/ninja/linux-arm64/ninja"
解决方案
所有报错的核心原因是Fuchsia官方提供的linux-arm64标签的预构建工具链二进制实际为x86_64架构,无法在arm64架构的Jetson Nano上直接运行,按以下步骤修复:
- 第一步:替换错误的预构建二进制
- 先验证文件架构确认问题,执行:
file /opt/fuchsia/prebuilt/third_party/ninja/linux-arm64/ninja
如果返回结果包含x86-64,即可确认是架构错配问题。 - 安装arm64架构的对应系统工具:
sudo apt update sudo apt install -y ninja-build golang-go
- 替换预构建目录下的错误文件:
# 替换ninja二进制 sudo cp /usr/bin/ninja /opt/fuchsia/prebuilt/third_party/ninja/linux-arm64/ninja # 替换go工具链 sudo rm -rf /opt/fuchsia/prebuilt/third_party/go/linux-arm64/* sudo cp -r /usr/lib/go-*/* /opt/fuchsia/prebuilt/third_party/go/linux-arm64/
- 第二步:调整编译配置
- 先关闭不必要的提示,执行:
jiri init -analytics-opt=false /opt/fuchsia - 执行cipd登录补全缺失的依赖包,按照提示完成账号验证即可:
/opt/fuchsia/.jiri_root/bin/cipd auth-login - 重新执行fx set命令,强制指定主机侧工具链为arm64架构:
fx --enable=legacy_set set core.qemu-arm64 --args="host_toolchain=\"//build/toolchain/linux:clang_arm64\""
- 第三步:配置swap避免编译内存不足
Jetson Nano默认内存仅4GB,远低于Fuchsia编译的最低内存要求,需提前开启swap分区:
sudo fallocate -l 8G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile # 配置开机自动挂载swap echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
执行完以上步骤后即可正常继续后续的Fuchsia编译流程。
内容的提问来源于stack exchange,提问作者john_connor
相关产品推荐
相关产品推荐

