diff mbox series

ath79: mikrotik: erase firmware on SPI NOR devices before install

Message ID 20200817104413.1798-1-hacks@slashdirt.org
State Accepted
Headers show
Series ath79: mikrotik: erase firmware on SPI NOR devices before install | expand

Commit Message

Thibaut Aug. 17, 2020, 10:44 a.m. UTC
On Mikrotik SPI NOR devices, the firmware partition must be erased when flashing
from stock firmware, otherwise leftover bits (in particular a kernel signature)
can trigger a boot loop.

When booted from initramfs (the only way to install OpenWRT on these devices),
this patch unconditionally erases the firmware partition in the do_upgrade()
stage for all supported SPI NOR devices.

This is forward-ported from ed49d0876 and 20452a8db

Signed-off-by: Thibaut VARĂˆNE <hacks@slashdirt.org>
---
 target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh b/target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh
index d79bd03af5..d7fac35708 100644
--- a/target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh
@@ -38,6 +38,8 @@  platform_do_upgrade() {
 		platform_do_upgrade_mikrotik_nand "$1"
 		;;
 	*)
+		# NOR devices: erase firmware if booted from initramfs
+		[ -z "$(rootfs_type)" ] && mtd erase firmware
 		default_do_upgrade "$1"
 		;;
 	esac