You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Yocto编译Lichee Pi镜像时U-Boot 2020.01编译失败求助

解决u-boot-1_2020.01-r0编译时yylloc重复定义的问题
  • 先排查主机flex版本:这个冲突是新版本flex(2.6.x及以上)的特性导致的,新版flex生成的lexer代码会自动定义yylloc,而旧版u-boot的dtc模块手动声明了该符号,引发重复定义。执行flex --version确认版本,如果是2.6+,按以下方法处理:

  • 方法一:降级flex到2.5.x版本

    • 以Debian/Ubuntu系统为例:
      sudo apt remove flex
      sudo apt install flex=2.5.35-10ubuntu1
      
  • 方法二:给u-boot打补丁修复符号冲突

    1. 在你的Yocto自定义层中创建recipes-bsp/u-boot/u-boot_2020.01.bbappend文件
    2. 制作补丁文件0001-fix-yylloc-duplicate-definition.patch,内容示例:
      diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
      index xxxxxxx..yyyyyyy 100644
      --- a/scripts/dtc/dtc-parser.y
      +++ b/scripts/dtc/dtc-parser.y
      @@ -17,7 +17,7 @@
       #include "dtc-parser.tab.h"
       #include "data.h"
      
      -YYLTYPE yylloc;
      +static YYLTYPE yylloc;
      
       void yyerror(const char *fmt, ...)
       {
      
    3. 在bbappend文件中添加补丁引用:
      SRC_URI += "file://0001-fix-yylloc-duplicate-definition.patch"
      
  • 方法三:临时指定旧版flex路径(不全局修改)

    • 下载编译旧版flex到本地目录,构建前临时替换PATH:
      export PATH=/your/local/flex-2.5.35/bin:$PATH
      bitbake u-boot
      
  • 清理缓存重新构建
    执行以下命令清理u-boot的编译状态后重新编译:

    bitbake -c cleansstate u-boot
    bitbake core-image-base
    

内容的提问来源于stack exchange,提问作者Ali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 09:20:33