
1 Yocto原理Yocto 编译完整流程1. 环境准备宿主机要求Ubuntu 20.04/22.04推荐至少 50GB 空闲磁盘16GB 内存。安装依赖sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential \ chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils \ iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ xterm python3-subunit mesa-common-dev zstd liblz4-tool file locales2. 获取 Yocto 源码# 克隆 pokyYocto 参考发行版选一个 LTS 分支比如 kirkstone / scarthgap git clone git://git.yoctoproject.org/poky cd poky git checkout scarthgap # 或你需要的版本分支如果需要额外的 layer比如 meta-openembedded、芯片厂商 BSP layer在 poky 同级目录克隆git clone git://git.openembedded.org/meta-openembedded git clone 你的芯片厂商BSP层仓库 # 如 meta-qcom、meta-ti、meta-raspberrypi3. 初始化构建环境source oe-init-build-env build # build 是构建目录名可自定义执行后自动进入build/目录并生成conf/local.conf和conf/bblayers.conf。4. 配置构建参数编辑conf/local.conf关键项# 目标机器架构由 BSP layer 提供比如 qcom-arm64、raspberrypi4-64 MACHINE ? qemuarm64 # 并行编译加速按 CPU 核心数设置 BB_NUMBER_THREADS ? 8 PARALLEL_MAKE ? -j 8 # 下载目录和缓存目录可选复用加速 DL_DIR ? ${TOPDIR}/downloads SSTATE_DIR ? ${TOPDIR}/sstate-cache # 启用源码包和调试包可选 EXTRA_IMAGE_FEATURES ? debug-tweaks tools-sdk编辑conf/bblayers.conf把需要的 layer 加进去BBLAYERS ? \ /path/to/poky/meta \ /path/to/poky/meta-poky \ /path/to/poky/meta-yocto-bsp \ /path/to/meta-openembedded/meta-oe \ /path/to/meta-openembedded/meta-python \ /path/to/meta-your-bsp \ 5. 选择镜像并编译Yocto 提供几种标准镜像也可以自定义镜像名说明core-image-minimal最小可启动系统仅内核基础 shellcore-image-base基础系统含常用命令行工具core-image-sato带 GUI 桌面的镜像core-image-westonWayland 桌面镜像自定义镜像在自己的 layer 里写.bb文件执行编译bitbake core-image-minimal首次编译会下载所有源码并全量编译耗时 1-3 小时取决于机器和镜像大小。后续有 sstate 缓存增量编译几分钟到几十分钟。6. 编译产出物编译完成后镜像在build/tmp/deploy/images/MACHINE/典型文件文件用途*.wic或*.wic.bz2完整 SD 卡/EMMC 烧录镜像Image/zImage内核镜像*.dtb设备树二进制modules-*.tgz内核模块包*.rootfs.tar.bz2rootfs 压缩包烧录到 SD 卡bzcat core-image-minimal-MACHINE.wic.bz2 | sudo dd of/dev/sdX bs4M statusprogress7. 常用 bitbake 命令命令作用bitbake recipe编译单个软件包bitbake -c cleansstate recipe清理某包的编译状态强制重编bitbake -c menuconfig virtual/kernel内核菜单配置bitbake -e recipe | grep VAR查看变量最终值调试配置bitbake-layers show-layers列出当前生效的 layerbitbake -g image生成依赖关系图关键注意点版本对齐poky 和所有第三方 layer 必须是同一个 Yocto 版本分支比如都是 scarthgap混分支大概率编译失败。MACHINE 必须匹配 BSP layerqemuarm64是 poky 自带的虚拟机目标真机要换成 BSP layer 提供的机器名。首次编译慢是正常的sstate 缓存会让后续编译快很多建议把DL_DIR和SSTATE_DIR设到固定路径复用。网络问题源码从各地下载国内建议配置镜像源或提前下载好downloads/目录。核心就是layerLayer 到底是什么一个 layer 本质上就是一个包含特定结构目录的文件夹里面放着表格内容说明conf/layer.conflayer 声明文件定义名字、优先级、依赖recipes-*/软件包配方.bb文件描述怎么下载、编译、安装某个软件classes/.bbclass类文件封装通用构建逻辑如 autotools、cmake、kernelrecipes-bsp/BSP 相关内核、u-boot、设备树recipes-core/images/自定义镜像配方licenses/许可证文件2 练习计划分4个阶段我使用的WSL 环境情况如下项目状态说明Ubuntu 24.04 (x86_64)✅可正常跑 Yocto交叉编译 aarch64 没问题CPU 12 核✅足够磁盘 935G 空闲✅很充足内存 7.4G⚠️Yocto 官方建议 16G编译时务必限制并行度否则会 OOM计划主要使用树莓派 5来学习它是完整 Linux 单板机ARM64是 Yocto 的标准练习对象能从 bootloader、内核一路编到 rootfs生成完整系统镜像刷 SD 卡启动。学 Yocto 的核心概念bitbake、layer、recipe、machine、distro全靠它。Phase 0 — 准备环境约 1 小时在 WSL 里装依赖sudo apt update sudo apt install -y gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool file locales sudo locale-gen en_US.UTF-8Phase 1 — 跑通最小系统验证工具链1~2 小时用qemux86-64目标快速验证整个链路这是最快的闭环体验mkdir -p ~/yocto cd ~/yocto git clone -b scarthgap git://git.yoctoproject.org/poky cd poky source oe-init-build-env build-qemu # 编辑 conf/local.conf追加 # BB_NUMBER_THREADS 4 # PARALLEL_MAKE -j4 MACHINEqemux86-64 bitbake core-image-minimal runqemu产出在 QEMU 里跑起一个微型 Linux。这一步成功 环境完全 OK。Phase 2 — 为Pi5构建真实镜像核心练习这是真正学会 Yocto的阶段cd ~/yocto git clone -b scarthgap git://git.yoctoproject.org/meta-raspberrypi git clone -b scarthgap git://git.openembedded.org/meta-openembedded cd poky source oe-init-build-env build-rpi5 bitbake-layers add-layer ../meta-openembedded/meta-oe bitbake-layers add-layer ../meta-openembedded/meta-python bitbake-layers add-layer ../meta-openembedded/meta-networking bitbake-layers add-layer ../meta-openembedded/meta-multimedia bitbake-layers add-layer ../meta-raspberrypi # 编辑 conf/local.confMACHINE raspberrypi5 bitbake core-image-base产出tmp/deploy/images/raspberrypi5/下的 SD 卡镜像拷回 Windows 用树莓派 Imager / balenaEtcher 烧录插进 Pi 5 就能启动编译的系统。Phase 3 — 自定义真正理解 Yocto 的地方写自己的 layer 自定义 recipe把 hello 程序编进镜像改内核配置 / 设备树 overlay加分项之前正好有rpi_rdma项目dmatest / hello_dma_pipe可以把它们做成内核模块 recipe 打镜像直接跑在 Pi 5 上——学以致用Phase 4 — SDK 交叉编译bitbake -c populate_sdk生成 aarch64 交叉编译 SDK在 WSL 里编好程序拷到 Pi 5 跑。WSL上编译的特别提醒重要构建目录放 WSL 原生文件系统~/yocto别放/mnt/c—— 跨文件系统 I/O 会慢到怀疑人生内存只有 7.4G → 务必设BB_NUMBER_THREADS 4和PARALLEL_MAKE -j4必要时再加 swap2~4G国内下载 Yocto 源可能很慢可配代理保留build-*/sstate-cache可让二次构建快数倍烧录流程WSL 里生成镜像 → Windows 里用烧录工具写 SD 卡3 环境搭建搭建结果项目状态系统依赖✅ Ubuntu 24.04 全部安装含 24.04 更名后的libegl1/mesa-common-dev等locale✅en_US.UTF-8已生成poky(scarthgap)✅ 已克隆分支scarthgaplocal.conf✅ 已针对 7.4G 内存优化BitBake✅ 2.8.13 个 layer 加载正常变量解析✅MACHINEqemux86-64、BB_NUMBER_THREADS4、PARALLEL_MAKE-j4全部生效目录布局WSL 原生文件系统/root避开 /mnt/c 的跨盘慢 I/O~/yocto/ ├── poky/ # 发行版源码 │ ├── build/ # 构建目录已初始化 │ │ └── conf/local.conf # 已优化 │ ├── meta/ # 核心层 │ ├── meta-poky/ # 发行版层 │ └── meta-yocto-bsp/ # BSP 层 ├── downloads/ # 源码缓存自动创建 └── sstate-cache/ # 编译缓存可大幅加速二次构建使用方法每次进 WSL 后先激活环境交互 shell建议在 WSL 终端里手动执行cd ~/yocto/poky source oe-init-build-env buildQEMU 快速验证整条链路bitbake core-image-minimal # 首次约 30-60 分钟下载编译 runqemu # 启动 QEMU 虚拟 Linux关键提醒内存只有 7.4G→ 已强制-j4如仍 OOM 可降到-j2或加 4G swapsudo fallocate -l 4G /swapfile保留sstate-cache→ 换镜像目标、改配置后二次构建会快很多构建目录已在/rootWSL 原生盘千万别挪到/mnt/c首次bitbake会大量下载源码国内网络慢可配镜像源DL_DIR里已有本地缓存路径已完成的 5 项操作均已验证成功① 安装系统依赖包通过apt-get install装齐 Yocto 所需的编译/下载工具已核实关键包版本gawk 5.2.1 · git 2.43.0 · chrpath 0.16 · socat 1.8 · cpio 2.15 · zstd 1.5.5 · file 5.45另装 python3 / python3-pexpect / xz-utils / texinfo / diffstat / unzip / locales 等期间遇到两个包在 Ubuntu 24.04 更名/移除libegl1-mesa→libegl1、pylint3被移除已改用正确包名补装成功。② 生成 UTF-8 localesudo locale-gen en_US.UTF-8已确认en_US.utf8存在于系统。Yocto 编译强制要求 UTF-8 locale不做后面会报错。③ 克隆 Yocto 发行版源码 pokyscarthgap 分支git clone --single-branch --branch scarthgap https://git.yoctoproject.org/poky已确认分支为scarthgapYocto 5.0 LTS当前主流稳定版。这是整个 Yocto 的核心仓库内含 bitbake、OpenEmbedded 核心层等。④ 初始化 build 构建目录并优化配置执行source oe-init-build-env build生成conf/local.conf和conf/bblayers.conf。随后针对7.4G 内存在 local.conf 追加/调整MACHINE ?? qemux86-64— 默认目标机先用 QEMU 虚拟机练手不碰真机BB_NUMBER_THREADS 4— 限制并行度防 OOMPARALLEL_MAKE -j4— 限制 make 并行度DL_DIR /root/yocto/downloads— 源码缓存目录SSTATE_DIR /root/yocto/sstate-cache— 编译缓存目录期间两次修正第一次脚本转义失败导致 MACHINE 重复写入 8 次、并行度没生效后用脚本从 sample 重新生成干净的 local.conf 再追加最终核实无误第 39/289/290/293/294/297 行配置正确。执行source oe-init-build-env build-qemu时脚本会自动生成build/conf/bblayers.conf内容是这样tomTom-LAPTOP:~/yocto/poky$ cat ./build/conf/bblayers.conf # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf # changes incompatibly POKY_BBLAYERS_CONF_VERSION 2 BBPATH ${TOPDIR} BBFILES ? BBLAYERS ? \ /home/tom/yocto/poky/meta \ /home/tom/yocto/poky/meta-poky \ /home/tom/yocto/poky/meta-yocto-bsp \ 可以看到里面有3个layer。Layer作用metaOE-Core 核心层所有基础软件包、构建类、架构支持meta-pokyPoky 参考发行版策略定义默认镜像、distro 配置meta-yocto-bspYocto 官方 BSP 层qemux86-64这个 MACHINE 的定义就在这里面⑤ 验证环境可正常解析bitbake --version→ BitBake Build Tool Core version 2.8.1bitbake-layers show-layers→ 3 个默认 layercore/yocto/yoctobsp正常加载bitbake -e→ 确认 5 个配置变量全部被 bitbake 正确解析生效4 最小验证系统当前环境状态~/yocto/ ├── poky/ # scarthgap 源码完整克隆 │ └── build/conf/ # 已初始化并优化好的配置 ├── downloads/ # 未创建首次编译生成 └── sstate-cache/ # 未创建首次编译生成然后可以开始跑bitbake core-image-minimal验证整条链路。结果如下整个耗时非常长我是通宵开了第二天早上来检查。tomTom-LAPTOP:~$ cd ~/yocto/poky tomTom-LAPTOP:~/yocto/poky$ source oe-init-build-env build This is the default build configuration for the Poky reference distribution. ### Shell environment set up for builds. ### You can now run bitbake target Common targets are: core-image-minimal core-image-full-cmdline core-image-sato core-image-weston meta-toolchain meta-ide-support You can also run generated qemu images with a command like runqemu qemux86-64. Other commonly useful commands are: - devtool and recipetool handle common recipe tasks - bitbake-layers handles common layer tasks - oe-pkgdata-util handles common target package tasks tomTom-LAPTOP:~/yocto/poky/build$ bitbake core-image-minimal WARNING: You are running bitbake under WSLv2, this works properly but you should optimize your VHDX file eventually to avoid running out o f storage space Loading cache: 100% | | ETA: --:--:-- Loaded 0 entries from dependency cache. Parsing recipes: 100% |####################################################################################################| Time: 0:00:38 Parsing of 920 .bb files complete (0 cached, 920 parsed). 1878 targets, 47 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Build Configuration: BB_VERSION 2.8.1 BUILD_SYS x86_64-linux NATIVELSBSTRING ubuntu-24.04 TARGET_SYS x86_64-poky-linux MACHINE qemux86-64 DISTRO poky DISTRO_VERSION 5.0.19 TUNE_FEATURES m64 core2 TARGET_FPU meta meta-poky meta-yocto-bsp scarthgap:1ba3cd7c884dc6c3d78c6bedc15e081f5000c8c9 NOTE: Fetching uninative binary shim http://downloads.yoctoproject.org/releases/uninative/5.1/x86_64-nativesdk-libc-5.1.tar.xz;sha256sum2 b63a078c26535e0786e87f81ae69509df30f4dce40693004c527bd5e4ab2b85 (will check PREMIRRORS first) Sstate summary: Wanted 1864 Local 0 Mirrors 0 Missed 1864 Current 0 (0% match, 0% complete)###################### | ETA: 0:00:00 Initialising tasks: 100% |#################################################################################################| Time: 0:00:04 NOTE: Executing Tasks WARNING: patch-native-2.7.6-r0 do_fetch: Failed to fetch URL https://ftpmirror.gnu.org/gnu/patch/patch-2.7.6.tar.gz, attempting MIRRORS if available WARNING: xz-native-5.4.7-r0 do_fetch: Failed to fetch URL https://github.com/tukaani-project/xz/releases/download/v5.4.7/xz-5.4.7.tar.gz, attempting MIRRORS if available WARNING: gmp-native-6.3.0-r0 do_fetch: Failed to fetch URL https://gmplib.org/download/gmp/gmp-6.3.0.tar.bz2, attempting MIRRORS if availa ble WARNING: ncurses-native-6.4-r0 do_fetch: Failed to fetch URL git://github.com/ThomasDickey/ncurses-snapshots.git;protocolhttps;branchmas ter, attempting MIRRORS if available WARNING: bzip2-native-1.0.8-r0 do_fetch: Failed to fetch URL git://sourceware.org/git/bzip2-tests.git;namebzip2-tests;branchmaster;proto colhttps, attempting MIRRORS if available WARNING: libunistring-native-1.2-r0 do_fetch: Failed to fetch URL https://ftpmirror.gnu.org/gnu/libunistring/libunistring-1.2.tar.gz, atte mpting MIRRORS if available WARNING: libtasn1-native-4.20.0-r0 do_fetch: Failed to fetch URL https://ftpmirror.gnu.org/gnu/libtasn1/libtasn1-4.20.0.tar.gz, attempting MIRRORS if available WARNING: rpm-native-1_4.19.1.1-r0 do_fetch: Failed to fetch URL git://github.com/rpm-software-management/rpm;branchrpm-4.19.x;protocolht tps, attempting MIRRORS if available WARNING: file-native-5.45-r0 do_fetch: Failed to fetch URL git://github.com/file/file.git;branchmaster;protocolhttps, attempting MIRRORS if available WARNING: readline-native-8.2-r0 do_fetch: Failed to fetch URL https://ftpmirror.gnu.org/gnu/readline/readline-8.2.tar.gz;namearchive, att empting MIRRORS if available WARNING: libbsd-native-0.12.1-r0 do_fetch: Failed to fetch URL https://libbsd.freedesktop.org/releases/libbsd-0.12.1.tar.xz, attempting MIRRO RS if available WARNING: util-macros-native-1_1.20.0-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/util/util-macros-1.20.0.tar.gz, attempting MIRRORS if available WARNING: xorgproto-native-2023.2-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/proto/xorgproto-2023.2.tar.xz, attem pting MIRRORS if available WARNING: qemu-native-8.2.7-r0 do_fetch: Failed to fetch URL https://download.qemu.org/qemu-8.2.7.tar.xz, attempting MIRRORS if available WARNING: libxdmcp-native-1_1.1.4-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libXdmcp-1.1.4.tar.xz, attemptin g MIRRORS if available WARNING: libpthread-stubs-native-0.5-r0 do_fetch: Failed to fetch URL http://xcb.freedesktop.org/dist/libpthread-stubs-0.5.tar.xz, attempting MIRRORS if available WARNING: xcb-proto-native-1.16.0-r0 do_fetch: Failed to fetch URL https://xorg.freedesktop.org/archive/individual/proto/xcb-proto-1.16.0.tar. xz, attempting MIRRORS if available WARNING: libxau-native-1_1.0.11-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libXau-1.0.11.tar.xz, attempting MIRRORS if available WARNING: xtrans-native-1_1.5.0-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/xtrans-1.5.0.tar.xz, attempting MI RRORS if available WARNING: libxcb-native-1.16-r0 do_fetch: Failed to fetch URL http://xcb.freedesktop.org/dist/libxcb-1.16.tar.xz, attempting MIRRORS if availa ble WARNING: libx11-native-1_1.8.9-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libX11-1.8.9.tar.xz, attempting MI RRORS if available WARNING: libsolv-native-0.7.28-r0 do_fetch: Failed to fetch URL git://github.com/openSUSE/libsolv.git;branchmaster;protocolhttps, attemptin g MIRRORS if available WARNING: libxext-native-1_1.3.6-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libXext-1.3.6.tar.xz, attempting MIRRORS if available WARNING: libxrender-native-1_0.9.11-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libXrender-0.9.11.tar.xz, att empting MIRRORS if available WARNING: libxfixes-native-1_6.0.1-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libXfixes-6.0.1.tar.xz, attempt ing MIRRORS if available WARNING: libpciaccess-native-0.18-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libpciaccess-0.18.tar.xz, attem pting MIRRORS if available WARNING: libxrandr-native-1_1.5.4-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libXrandr-1.5.4.tar.xz, attempt ing MIRRORS if available WARNING: libdrm-native-2.4.120-r0 do_fetch: Failed to fetch URL http://dri.freedesktop.org/libdrm/libdrm-2.4.120.tar.xz, attempting MIRRORS i f available WARNING: xrandr-native-1_1.5.2-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/app/xrandr-1.5.2.tar.xz, attempting MI RRORS if available WARNING: libxxf86vm-native-1_1.1.5-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libXxf86vm-1.1.5.tar.xz, attem pting MIRRORS if available WARNING: libxdamage-native-1_1.1.6-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libXdamage-1.1.6.tar.xz, attem pting MIRRORS if available WARNING: makedepend-native-1_1.0.9-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/util/makedepend-1.0.9.tar.gz, atte mpting MIRRORS if available WARNING: libxshmfence-native-1.3.2-r0 do_fetch: Failed to fetch URL https://www.x.org/releases//individual/lib/libxshmfence-1.3.2.tar.xz, att empting MIRRORS if available WARNING: mesa-native-2_24.0.7-r0 do_fetch: Failed to fetch URL https://mesa.freedesktop.org/archive/mesa-24.0.7.tar.xz, attempting MIRRORS if available WARNING: pixman-native-1_0.42.2-r0 do_fetch: Failed to fetch URL https://www.cairographics.org/releases/pixman-0.42.2.tar.gz, attempting MIRR ORS if available NOTE: Tasks Summary: Attempted 4090 tasks of which 0 didnt need to be rerun and all succeeded. Summary: There were 36 WARNING messages.运行命令如下cd ~/yocto/poky source oe-init-build-env build runqemu qemux86-64 slirp nographic5 常见的换源问题换源在 Yocto 里有 4 层机制从我们刚才用过的 PREMIRRORS 到最实用的人工放包。下面按实用性从高到低讲。先理解 Yocto 的下载机制这是换源的基础Yocto 的 fetch下载流程是这样的recipe 里的 SRC_URI原始地址 ↓ 下载失败 PREMIRRORS首选镜像→ 失败 ↓ MIRRORS后备镜像→ 失败 ↓ 报错 Failed to fetch URL: xxx所有下载的文件都统一存到DL_DIR你的是/home/tom/yocto/downloads下载成功的文件会有一个.done标记文件。bitbake 看到.done就不再下载。方法一PREMIRRORS首选镜像刚用过这就是我们在local.conf里配的东西。作用下载任何 URL 时先尝试走镜像PREMIRRORS:prepend \ git://.*/.* http://mirrors.ustc.edu.cn/yocto/git/ \n \ https://.*/.* http://mirrors.ustc.edu.cn/yocto/sources/ \n \ http://.*/.* http://mirrors.ustc.edu.cn/yocto/sources/ \n语法规则原始URL模式 镜像URL \n.*是通配。换源 把镜像 URL 换成别的清华/阿里/公司内网镜像。方法二手动下载 放 DL_DIR最实用、最常用这是解决某个包下载失败最靠谱的方法尤其高通源码经常在境外服务器。原理bitbake 报Failed to fetch URL: https://xxx/abc.tar.gz用浏览器/迅雷/公司代理把这个文件手动下载下来改名为 bitbake 期望的文件名通常是 URL 的最后一段如abc.tar.gz放进DL_DIR重跑bitbake注意两个命名细节git 类源码文件名带前缀如git2_github.com.xxx.git.tar.gz下载完要建一个空的.done文件或 bitbake 自动识别否则它不认重跑后 bitbake 发现文件已在 DL_DIR直接跳过下载。方法三MIRRORS后备镜像和 PREMIRRORS 语法一样但优先级低只在原始地址和 PREMIRRORS 都失败后才用。适合配公司内网的全量备份镜像MIRRORS:prepend \ https://.*/.* http://192.168.x.x/yocto/sources/ \n \ git://.*/.* http://192.168.x.x/yocto/git/ \n方法四批量预下载 断点续传bitbake -c fetchall 目标— 先批量下载所有源码再编译高通用这个先下完断了再续bitbake 下载本身支持断点续传失败重跑会接着下已下好的不重下高通项目的特殊情况高通 BSP如 LE.UM、THINFROG换源时有 3 个与众不同的点源码大量来自 code.qualcomm.com— 需要高通账号授权公共镜像根本下不到所以换源更多是手动下载 → 放 DL_DIR或把 SRC_URI 改成公司内网 git 服务器很多公司会镜像高通源码改 recipe 的 SRC_URI 换源最彻底# 比如某个 recipe 里 SRC_URI git://code.qualcomm.com/xxx;protocolhttps # 改成内网镜像 SRC_URI git://git.company.com/mirror/xxx;protocolhttps经常用mirror.qualcomm.com或公司私服配置 PREMIRRORS 指向内网因为高通源码国外服务器慢且不稳。可直接套用的操作清单场景 A某个包下载失败最常见1. 看报错里的 URL → 手动下载 → 改名 → 放 DL_DIR → 重跑场景 B整体慢/失败多整体换源改 local.conf 里的 PREMIRRORS换成更快的镜像或公司内网镜像场景 C高通授权源码改 recipe 的 SRC_URI 指向公司内网 git 服务器或用 PREMIRRORS 指内网镜像小结方法适用场景操作位置PREMIRRORS整体加速/换源local.confMIRRORS兜底/公司镜像local.conf手动放 DL_DIR单个包下载失败~/yocto/downloads改 SRC_URI授权源码/内网源recipe 文件fetchall批量预下载命令行