base-files: fix sysupgrade for kernel-out-of-UBI
authorRodrigo Balerdi <lanchon@gmail.com>
Mon, 2 May 2022 08:33:01 +0000 (05:33 -0300)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 2 May 2022 11:42:15 +0000 (12:42 +0100)
commit7d02fc0951ffcff3ba885374b108d20de92eddbe
treec6452a34baad115697950dfe6a06a0c9723f3b39
parent4e8d095013fb822eaa4fd6b4512a434fc17ac901
base-files: fix sysupgrade for kernel-out-of-UBI

Commit ecbcc0b59551 bricks devices on which the raw kernel and UBI mtd
partitions overlap.

This is the case of the ZyXEL NR7101 for example. Its OEM bootloader has
no UBI support. OpenWrt splits the stock kernel mtd partition into a raw
kernel part used by the bootloader and a UBI part used to store rootfs
and rootfs_data. Running mtd erase on the complete partition during
sysupgrade erases the UBI part and results in a soft brick.

Arguably the best solution would be to fix the partition layouts so that
kernel and UBI partitions do not overlap, also including a stock_kernel
partition to help reverting to stock firmware. This would have the added
benefit of protecting UBI from kernel images that are excessively large.

Fixes: ecbcc0b59551 ("base-files: safer sysupgrade.tar for kernel-out-of-UBI")
Reported-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
package/base-files/files/lib/upgrade/nand.sh