使用hikey_defconfig编译U-Boot失败,出现汇编器错误求助
Hey there! Let's walk through the most common causes of assembler errors you might hit when building U-Boot for Hikey, along with actionable fixes:
Mismatched or outdated cross-compilation toolchain
Hikey targets the ARM64 architecture, so you need a dedicatedaarch64cross-compiler. Using an x86 toolchain, or a version that's too old/new (e.g., gcc <7 or gcc 12+ with untested changes) can break assembly parsing.- Fix: Install a stable, ARM64-focused toolchain like Linaro's
aarch64-linux-gnu-gcc(versions 8.x–10.x are widely recommended for U-Boot). Set your environment variables correctly:
Verify the toolchain is in yourexport ARCH=arm64 export CROSS_COMPILE=aarch64-linux-gnu-PATHwithwhich aarch64-linux-gnu-gcc.
- Fix: Install a stable, ARM64-focused toolchain like Linaro's
Dirty build tree with leftover artifacts
If you previously compiled U-Boot for another target, residual.ofiles, preprocessed headers, or configuration fragments can conflict with thehikey_defconfigsetup, leading to unexpected assembler errors.- Fix: Wipe the build tree completely before reconfiguring:
make distclean make hikey_defconfig make
- Fix: Wipe the build tree completely before reconfiguring:
Using the wrong assembler (system vs cross-toolchain)
Your host system's defaultas(assembler) doesn't understand ARM64-specific instructions. If yourCROSS_COMPILEvariable isn't set properly, the build might fall back to the host assembler, causing failures.- Fix: Double-check that the build is using the cross-toolchain's assembler. Run
make V=1to see the full command lines—you should seeaarch64-linux-gnu-asinstead of justas.
- Fix: Double-check that the build is using the cross-toolchain's assembler. Run
Incomplete or corrupted source code
Network issues during cloning could leave some assembly files missing or corrupted. Even a single broken line in an.Sfile will trigger an assembler error.- Fix: Check your git repository for issues with:
If files look corrupted, reset the repo withgit status git diffgit checkout .or re-clone it entirely.
- Fix: Check your git repository for issues with:
Incorrect build arguments
Forgetting to specifyARCH=arm64can lead the build system to misdetect the target architecture, trying to compile ARM64 assembly with tools meant for another platform.- Fix: Explicitly define the architecture during both configuration and build:
make ARCH=arm64 hikey_defconfig make ARCH=arm64
- Fix: Explicitly define the architecture during both configuration and build:
If you can share the exact error message (the specific line of assembly that failed, and the error code), we can narrow this down even further. But these steps should cover 90% of the common cases!
内容的提问来源于stack exchange,提问作者InsaneCoder

