我为自定义 iMX8M 板制作了自己的内核包,它通过了 lintian,没有警告或错误。
包树的前三层是:
/tmp/my-kernel_5.10.9-2lEIW6BD_arm64
|-- DEBIAN
| |-- control
| `-- preinst
|-- boot
| |-- Image
| `-- dtbs
| `-- imx8mq-smarc.dtb
|-- lib
| `-- modules
`-- usr
`-- share
`-- doc
preinst 确保 /boot 已安装:
fadedbee@box ~ $ sudo cat /tmp/my-kernel_5.10.9-2lEIW6BD_arm64/DEBIAN/preinst
#!/bin/bash
set -e
if grep -qs '/dev/mmcblk1p1 /boot' /proc/mounts; then
echo "/boot is mounted."
else
echo "/boot is not yet mounted, mounting..."
mount /dev/mmcblk1p1 /boot
fi
exit 0
如果尚未安装,它会安装 /boot,并依赖 dpkg 将所有文件放置到位。
目前它失败了。
root@arm:~# dpkg -i /tmp/my-kernel_5.10.9-2lEIW6BD_arm64.deb
(Reading database ... 45956 files and directories currently installed.)
Preparing to unpack .../my-kernel_5.10.9-2lEIW6BD_arm64.deb ...
/boot is not yet mounted, mounting...
Unpacking my-kernel (5.10.9) ...
dpkg: error processing archive /tmp/my-kernel_5.10.9-2lEIW6BD_arm64.deb (--install):
unable to make backup link of './boot/Image' before installing new version: Operation not permitted
Errors were encountered while processing:
/tmp/my-kernel_5.10.9-2lEIW6BD_arm64.deb
/boot/Image 上的权限符合预期:
root@arm:~# ls -lsa /boot/Image
28680 -rwxr-xr-x 1 root root 29366784 Mar 25 11:48 /boot/Image
/boot 分区是 vfat 并挂载 R/W:
root@arm:~# mount | grep boot
/dev/mmcblk1p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
为什么此操作可能会失败?
有解决方法吗?
更新:我已经检查了“正常”debian 内核包中的内容。它还依赖于正常行为在 /boot 中安装内核映像。
root@debian:/tmp/tmp# tree -L 3
.
├── boot
│ ├── config-6.1.0-18-amd64
│ ├── System.map-6.1.0-18-amd64
│ └── vmlinuz-6.1.0-18-amd64
├── lib
│ └── modules
│ └── 6.1.0-18-amd64
└── usr
└── share
├── bug
├── doc
└── lintian
10 directories, 3 files
答案1
我需要解决两个问题才能完成这项工作。
- 我修改了磁盘映像构建系统以创建 ext4 /boot,而不是供应商提供的 vfat /boot。这允许 dpkg 建立符号链接和硬链接。不幸的是,这导致 u-boot 无法加载 uEnv.txt、内核映像和设备树 blob。我能够使用 u-boot 监视器列出 /boot 上的文件,所以我困惑了一两个小时,直到我执行了“print env”并注意到编译后的文件中有一些“loadfat”调用在环境中。
u-boot$ ext4ls mmc 1:1
<DIR> 1024 .
<DIR> 1024 ..
<DIR> 12288 lost+found
<DIR> 1024 dtbs
29366784 Image
1163 uEnv.txt
u-boot$ printenv
...
loadaddr=0x40480000
loadbootenv=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} uEnv.txt
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} /dtbs/${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
...
- 为了解决这个问题,我首先确认我可以手动修复环境并从 ext4 启动。然后我找到了正确的源文件并编辑了u-boot的smarcimx8mq.h:
fadedbee@box ~/my_build/src/uboot $ git diff
diff --git a/include/configs/smarcimx8mq.h b/include/configs/smarcimx8mq.h
index 7eb93677cd..43ce2636eb 100644
--- a/include/configs/smarcimx8mq.h
+++ b/include/configs/smarcimx8mq.h
@@ -101,8 +101,8 @@
"mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \
"usbroot=/dev/sda2 rootwait ro\0" \
"mmcrootfstype=ext4 rootwait\0" \
- "loadbootenv=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} uEnv.txt\0" \
+ "loadbootenv=ext4load mmc ${mmcdev}:${mmcpart} ${loadaddr} uEnv.txt\0" \
"loadusbbootenv=fatload usb 0:1 ${loadaddr} uEnv.txt\0" \
"mmcautodetect=yes\0" \
"importbootenv=echo Importing environment from mmc (uEnv.txt)...; " \
"env import -t $loadaddr $filesize\0" \
@@ -112,13 +112,13 @@
"rootfstype=${mmcrootfstype} root=${mmcroot}\0 " \
"usbargs=setenv bootargs ${jh_clk} console=${console} ${optargs} " \
"rootfsusbtype=${usbrootfstype} root=${usbroot}\0 " \
- "loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
+ "loadbootscript=ext4load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
"bootscript=echo Running bootscript from mmc ...; " \
"source\0" \
- "loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
+ "loadimage=ext4load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
"loadm4bin=load mmc ${mmcdev}:${mmcpart} ${m4_addr_tmp} ${m4_bin}\0" \
"loadusbimage=fatload usb 0:1 ${loadaddr} ${image}\0" \
- "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} /dtbs/${fdt_file}\0" \
+ "loadfdt=ext4load mmc ${mmcdev}:${mmcpart} ${fdt_addr} /dtbs/${fdt_file}\0" \
"loadusbfdt=fatload usb 0:1 ${fdt_addr} /dtbs/${fdt_file}\0" \
"cpm4mem=cp.b ${m4_addr_tmp} ${m4_addr} 20000\0" \
"mmcboot=echo Booting from mmc ...; " \
并重新编译u-boot。