aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorRodrigo Balerdi <lanchon@gmail.com>2022-05-02 05:33:01 -0300
committerDaniel Golle <daniel@makrotopia.org>2022-05-02 12:42:15 +0100
commit7d02fc0951ffcff3ba885374b108d20de92eddbe (patch)
treec6452a34baad115697950dfe6a06a0c9723f3b39 /package/base-files
parent4e8d095013fb822eaa4fd6b4512a434fc17ac901 (diff)
downloadupstream-7d02fc0951ffcff3ba885374b108d20de92eddbe.tar.gz
upstream-7d02fc0951ffcff3ba885374b108d20de92eddbe.tar.bz2
upstream-7d02fc0951ffcff3ba885374b108d20de92eddbe.zip
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>
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/files/lib/upgrade/nand.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh
index 5ecdb0ff23..c9960bf9d4 100644
--- a/package/base-files/files/lib/upgrade/nand.sh
+++ b/package/base-files/files/lib/upgrade/nand.sh
@@ -305,7 +305,11 @@ nand_upgrade_tar() {
local ubi_kernel_length
if [ "$kernel_length" ]; then
if [ "$kernel_mtd" ]; then
- mtd erase "$CI_KERNPART"
+ # On some devices, the raw kernel and ubi partitions overlap.
+ # These devices brick if the kernel partition is erased.
+ # Hence only invalidate kernel for now.
+ dd if=/dev/zero bs=4096 count=1 2>/dev/null | \
+ mtd write - "$CI_KERNPART"
else
ubi_kernel_length="$kernel_length"
fi
@@ -322,7 +326,7 @@ nand_upgrade_tar() {
if [ "$kernel_length" ]; then
if [ "$kernel_mtd" ]; then
tar xf "$tar_file" "$board_dir/kernel" -O | \
- mtd -n write - "$CI_KERNPART"
+ mtd write - "$CI_KERNPART"
else
local kern_ubivol="$( nand_find_volume $ubidev "$CI_KERNPART" )"
tar xf "$tar_file" "$board_dir/kernel" -O | \