Discussion:
Bug#942004: INSTALL: buster-backports linux-image 5.2 fails during installation on QNAP TS-219P II
Add Reply
Robert Schlabbach
2019-10-08 21:50:02 UTC
Reply
Permalink
Package: linux-image-5.2.0-0.bpo.2-marvell
Version: 5.2.9-2~bpo10+1

With Debian Buster installed on my QNAP TS-219P II, "aptitude -t buster-backports" offers an upgrade to linux-image-5.2.0-0.bpo.2-marvell, which fails to install when it comes to flashing the kernel, since the kernel image exceeds the available space on the mtd1 partition (2MB). While this is in fact documented in the changelog for this package:

* [armel/marvell] Increase maximum image size (fixes FTBFS):
- This removes support for QNAP TS-109, TS-119, TS-209, TS-219, TS-409,
and HP Media Vault mv2120
- This may be reverted if we can disable or modularise some features

I would have expected that this upgrade would not be made available on the affected devices instead of "wrecking" the installation.

Moreover, I would actually prefer to have this issue fixed so that my QNAP TS-219P-II may continue to be supported. Aside from reducing the kernel image size, I see at least on my model another possibility:

The QNAP TS219P-II has 16MB of flash in total, which is (AFAIK "soft"-)partitioned as:

mtd0: 0.5 MB U-Boot partition
mtd1: 2 MB Kernel partition (vmlinuz)
mtd2: 9 MB RootFS1 partition (initrd.img)
mtd3: 3 MB RootFS2 partition
mtd4: 0.25MB U-Boot Config partition
mtd5: 1.25MB NAS Config partition

I see two possibilities to get more space for the Kernel:

1. Resize mtd1 and mtd2 to 3 and 8 MB, respectively. All the initrd.img's I've had were less than 7 MB in size, so mtd2 can give up 1 MB without ill effects. This would require changing the device tree which AFAIK defines the partitions and sizes, and the U-Boot Config (which can be modified with fw_setenv) to change the bootcmd from:

bootcmd=uart1 0x68;cp.l 0xf8200000 0x800000 0x80000;cp.l 0xf8400000 0xa00000 0x240000;bootm 0x800000

(the first cp.l copies the kernel image from flash to RAM, the second the initrd image, with the parameters sourceaddr, destaddr, # of 32-bit words to copy)

to:

bootcmd=uart1 0x68;cp.l 0xf8200000 0x800000 0xc0000;cp.l 0xf8500000 0xb00000 0x200000;bootm 0x800000

2. Keep the partitions as they are, but use mtd3 instead of mtd1 for the kernel image. This would require changing the kernel flashing tool and the U-Boot Config to change the bootcmd to:

bootcmd=uart1 0x68;cp.l 0xf8d00000 0x800000 0xc0000;cp.l 0xf8400000 0xb00000 0x240000;bootm 0x800000

Both solutions would provide 3 MB space for the kernel image, which should suffice for some time...
Robert Schlabbach
2019-10-09 12:40:01 UTC
Reply
Permalink
Ok, so I actually took the plunge and tried option 2 above, as follows (it appears the backport-kernel was updated from 5.2.9-2 to 5.2.17-1 overnight):

1. sudo vi /usr/share/flash-kernel/db/all.db
   -> /219 -> line 1447:
   change
      Mtd-Kernel: Kernel
   to
      Mtd-Kernel: RootFS2

2. sudo aptitude -t buster-backports
   -> Upgrade all Upgradable Packages
   -> Kernel is flashed to mtd3:

Processing triggers for flash-kernel (3.99) ...
kirkwood-qnap: machine: QNAP TS219 family
Using DTB: kirkwood-ts219-6282.dtb
Installing /usr/lib/linux-image-5.2.0-0.bpo.3-marvell/kirkwood-ts219-6282.dtb into /boot/dtbs/5.2.0-0.bpo.3-marvell/./kirkwood-ts219-6282.dtb
Taking backup of kirkwood-ts219-6282.dtb.
Installing new kirkwood-ts219-6282.dtb.
flash-kernel: installing version 5.2.0-0.bpo.3-marvell
flash-kernel: appending /usr/lib/linux-image-5.2.0-0.bpo.3-marvell/kirkwood-ts219-6282.dtb to kernel
Generating kernel u-boot image... done.
Flashing kernel (using 2170954/3145728 bytes)... done.
Flashing initramfs (using 6568944/9437184 bytes)... done.
Processing triggers for initramfs-tools (0.133+deb10u1) ...
update-initramfs: Generating /boot/initrd.img-5.2.0-0.bpo.3-marvell
kirkwood-qnap: machine: QNAP TS219 family
Using DTB: kirkwood-ts219-6282.dtb
Installing /usr/lib/linux-image-5.2.0-0.bpo.3-marvell/kirkwood-ts219-6282.dtb into /boot/dtbs/5.2.0-0.bpo.3-marvell/./kirkwood-ts219-6282.dtb
Taking backup of kirkwood-ts219-6282.dtb.
Installing new kirkwood-ts219-6282.dtb.
Installing /usr/lib/linux-image-5.2.0-0.bpo.3-marvell/kirkwood-ts219-6282.dtb into /boot/dtbs/5.2.0-0.bpo.3-marvell/./kirkwood-ts219-6282.dtb
Taking backup of kirkwood-ts219-6282.dtb.
Installing new kirkwood-ts219-6282.dtb.
flash-kernel: installing version 5.2.0-0.bpo.3-marvell
flash-kernel: appending /usr/lib/linux-image-5.2.0-0.bpo.3-marvell/kirkwood-ts219-6282.dtb to kernel
Generating kernel u-boot image... done.
Flashing kernel (using 2170954/3145728 bytes)... done.
Flashing initramfs (using 6568918/9437184 bytes)... done.

3. sudo fw_setenv bootcmd "uart1 0x68;cp.l 0xf8d00000 0x800000 0xc0000;cp.l 0xf8400000 0xb00000 0x240000;bootm 0x800000"
   sudo fw_setenv bootargs "console=ttyS0,115200 root=/dev/ram initrd=0xb00000,0x900000 ramdisk=34816"

4. sudo shutdown -r now

Take a deep breath, and voila, it's ALIVE:

$ cat /proc/version
Linux version 5.2.0-0.bpo.3-marvell (debian-***@lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 Debian 5.2.17-1~bpo10+1 (2019-09-30)

It seems to be working so far, although there is this message during bootup:

[    1.269790] Loading compiled-in X.509 certificates
[    1.326675] ------------[ cut here ]------------
[    1.331358] WARNING: CPU: 0 PID: 1 at crypto/rsa-pkcs1pad.c:539 pkcs1pad_verify+0x38/0x10c
[    1.339661] Modules linked in:
[    1.342733] CPU: 0 PID: 1 Comm: swapper Not tainted 5.2.0-0.bpo.3-marvell #1 Debian 5.2.17-1~bpo10+1
[    1.351912] Hardware name: Marvell Kirkwood (Flattened Device Tree)
[    1.358204] random: fast init done
[    1.361639] [<c0016c0c>] (unwind_backtrace) from [<c0013768>] (show_stack+0x18/0x1c)
[    1.369431] [<c0013768>] (show_stack) from [<c0021bd8>] (__warn+0xe0/0xf8)
[    1.376345] [<c0021bd8>] (__warn) from [<c0021fcc>] (warn_slowpath_null+0x40/0x4c)
[    1.383956] [<c0021fcc>] (warn_slowpath_null) from [<c01f76e4>] (pkcs1pad_verify+0x38/0x10c)
[    1.392444] [<c01f76e4>] (pkcs1pad_verify) from [<c01fd6cc>] (public_key_verify_signature+0x210/0x2d8)
[    1.401809] [<c01fd6cc>] (public_key_verify_signature) from [<c01fedf8>] (x509_check_for_self_signed+0xf0/0x118)
[    1.412035] [<c01fedf8>] (x509_check_for_self_signed) from [<c01fe070>] (x509_cert_parse+0x198/0x1c8)
[    1.421304] [<c01fe070>] (x509_cert_parse) from [<c01fea40>] (x509_key_preparse+0x1c/0x17c)
[    1.429701] [<c01fea40>] (x509_key_preparse) from [<c01fc688>] (asymmetric_key_preparse+0x68/0xc4)
[    1.438712] [<c01fc688>] (asymmetric_key_preparse) from [<c01c876c>] (key_create_or_update+0x144/0x378)
[    1.448156] [<c01c876c>] (key_create_or_update) from [<c0573c04>] (load_system_certificate_list+0xb4/0x11c)
[    1.457954] [<c0573c04>] (load_system_certificate_list) from [<c000ab2c>] (do_one_initcall+0x60/0x19c)
[    1.467309] [<c000ab2c>] (do_one_initcall) from [<c05601a8>] (kernel_init_freeable+0x214/0x264)
[    1.476056] [<c05601a8>] (kernel_init_freeable) from [<c041be00>] (kernel_init+0x10/0xf4)
[    1.484278] [<c041be00>] (kernel_init) from [<c00090e0>] (ret_from_fork+0x14/0x34)
[    1.491884] Exception stack(0xdf4c1fb0 to 0xdf4c1ff8)
[    1.496961] 1fa0:                                     00000000 00000000 00000000 00000000
[    1.505177] 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.513398] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    1.520041] ---[ end trace 947abc38fbcd6ffd ]---
[    1.524687] Problem loading in-kernel X.509 certificate (-22)

But that's probably an issue for another bug report.

Not sure if that's a workable solution for everyone, but at least I'm a happy camper now with the latest Linux kernel.
Please DO NOT block further kernel upgrades from the QNAP TS-219 platform, even if the image size exceeds 2MB. Mine can take it :-)

Best Regards,
-Robert

Loading...