Error: file not found: arch/arm/boot/compressed/piggy.lzo

本文介绍了解决在ARM交叉编译过程中遇到的piggy.lzo文件未找到错误的方法,通过使用sudo apt-get install lzop命令成功安装了所需的lzop工具,从而修复了编译错误。
$make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all

...
   Error: file not found: arch/arm/boot/compressed/piggy.lzo
...


 安装:

$sudo apt-get install lzop

 

 

你遇到的这个错误: ``` "mkimage" command not found - U-Boot images will not be built arch/arm/boot/Makefile:90: recipe for target 'arch/arm/boot/uImage' failed make-4.1[2]: *** [arch/arm/boot/uImage] Error 1 make[1]: *** [uImage] Error 2 arch/arm/Makefile:332: recipe for target 'uImage' failed make[1]: Leaving directory '/home/user/NT98331_SDK/software/board/na51103_linux_sdk/BSP/linux-kernel' linux: Build finish Makefile:648: include/config/auto.conf: No such file or directory Makefile:701: include/config/auto.conf.cmd: No such file or directory In file included from ./include/linux/kernel.h:14, from ./include/linux/list.h:9, from ./include/linux/module.h:12, from net/core/skbuff.c:37: ``` 这是一个典型的 **嵌入式 Linux 内核编译失败问题**,我们来一步步分析并解决。 --- ## ✅ 错误分解 + 解决方案 ### ❌ 错误 1:`"mkimage" command not found` 这是最核心的问题! > `mkimage` 是 U-Boot 提供的一个工具(全称:`uboot-mkimage` 或 `u-boot-tools` 包的一部分),用于生成 `uImage` 格式的内核镜像。 #### 🔧 原因: 你的系统没有安装 `u-boot-tools`,所以无法找到 `mkimage` 命令。 #### ✅ 解决方法(Ubuntu/Debian 系统): ```bash sudo apt update sudo apt install u-boot-tools -y ``` > 安装后会提供 `/usr/bin/mkimage` 或现代版本中叫 `mkimage` 的符号链接。 📌 注意:某些新版本 U-Boot 已将 `mkimage` 改名为 `fit_image` 或集成到 `mkenvimage` 中,但大多数 SDK 仍使用旧名。可以通过以下命令确认是否安装成功: ```bash which mkimage # 或者 which mkimage || which uboot-mkimage ``` 如果提示找不到,说明没装对。 --- ### ❌ 错误 2:`recipe for target 'uImage' failed` 这是因为 Makefile 尝试构建 `uImage` 镜像时调用了 `mkimage`,但由于上面的原因命令不存在,导致失败。 #### ✅ 解决方法: 安装完 `u-boot-tools` 后重新编译即可。 --- ### ❌ 错误 3:`include/config/auto.conf: No such file or directory` 这表示 **内核配置未生成**。 也就是说你在执行 `make uImage` 之前,**没有先执行内核配置命令**(如 `make menuconfig`、`make xxx_defconfig`)。 #### ✅ 正确流程应该是: ```bash cd /home/user/NT98331_SDK/software/board/na51103_linux_sdk/BSP/linux-kernel make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- na51103_defconfig # 替换为实际 defconfig 名字 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage -j$(nproc) ``` ⚠️ 关键点: - 必须先运行 `defconfig` 来生成 `.config` 文件 → 进而生成 `include/config/auto.conf` - 否则直接 `make uImage` 会报路径缺失错误 🔍 如何知道用哪个 `_defconfig`? 查看目录: ```bash ls arch/arm/configs/ | grep -i na51103 # 输出可能是: # na51103_defconfig ``` 然后使用它: ```bash make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- na51103_defconfig ``` --- ### ❌ 错误 4:头文件报错(kernel.h, list.h 等) ``` In file included from ./include/linux/kernel.h:14, from ./include/linux/list.h:9, ... ``` 这类错误通常是 **前面配置失败导致的连锁反应** —— 因为 `.config` 没生成,编译器不知道如何包含头文件。 ✅ 只要你先正确执行了 `make xxx_defconfig`,这个问题就会自动消失。 --- ## ✅ 总结:完整修复步骤 ```bash # Step 1: 安装 mkimage 工具 sudo apt update sudo apt install u-boot-tools -y # Step 2: 进入内核源码目录 cd /home/user/NT98331_SDK/software/board/na51103_linux_sdk/BSP/linux-kernel # Step 3: 设置交叉编译工具链(根据实际情况调整) export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabi- # Step 4: 加载默认配置(请确认准确的 defconfig 名称) make na51103_defconfig # 如果不行,尝试: # make menuconfig # 手动保存一个 .config # Step 5: 编译 uImage make uImage -j$(nproc) ``` ✅ 成功后你会在 `arch/arm/boot/` 目录下看到生成的 `uImage` 文件。 --- ## ✅ 补充建议 ### 🛠️ 如果你不想生成 uImage? 有些项目允许只生成普通的压缩内核镜像(如 `zImage`),可以修改 Makefile 注释掉 `mkimage` 调用,或者改用: ```bash make zImage ``` 但通常 Bootloader(U-Boot)需要 `uImage` 格式才能启动,所以推荐保留。 --- ### 💡 查看当前是否已安装 mkimage ```bash dpkg -l | grep u-boot-tools # 或 which mkimage ``` 如果没有,重装: ```bash sudo apt install --reinstall u-boot-tools ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值