0

I've made my own kernel package for a custom iMX8M board, which passes lintian without warnings or errors.

The top three layers of the package tree are:

/tmp/my-kernel_5.10.9-2lEIW6BD_arm64 |-- DEBIAN | |-- control | `-- preinst |-- boot | |-- Image | `-- dtbs | `-- imx8mq-smarc.dtb |-- lib | `-- modules `-- usr `-- share `-- doc 

preinst makes sure that /boot is mounted:

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 

It mounts /boot, if not already mounted and relies on the dpkg to put all of the files in place.

It currently fails.

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 

The permissions on /boot/Image are as expected:

root@arm:~# ls -lsa /boot/Image 28680 -rwxr-xr-x 1 root root 29366784 Mar 25 11:48 /boot/Image 

The /boot partition is vfat and mounted 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) 

Why might this operation be failing?

Is there a work-around?


Update: I've checked what's inside a "normal" debian kernel package. It also relies on normal behaviour to install the kernel image in /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
  • 1
    I've been helped to see that "link" is the critical word. FAT filesystems may not support symbolic and/or hard links. I will try using ext2 for boot instead of FAT. Commented Mar 26, 2024 at 11:58

1 Answer 1

0

I needed to fix two problems to make this work.

  1. I amended my disk-image build system to create a ext4 /boot instead of the vendor-provided vfat /boot. This allows dpkg to make symlinks and hardlinks. Unfortunately this led to u-boot failing to load uEnv.txt, the kernel Image and the device-tree blob. I was able to use the u-boot monitor to list the files on /boot, so I was confused for an hour or two, until I did a "print env" and noticed that there were some "loadfat" calls in the compiled-in environment.
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} ... 
  1. To fix that, I first confirmed that I could manually fix the environment and boot from ext4. Then I found the correct source file and edited u-boot's 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 ...; " \ 

and recompiled u-boot.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.