From 23cd9fafa89a8058a88763cc0526a1e85a9f7ebb Mon Sep 17 00:00:00 2001 From: Roger Pueyo Centelles Date: Tue, 31 Aug 2021 16:45:17 +0200 Subject: [PATCH] ath79: mikrotik: use 64 KiB SPI NOR erase sectors MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch removes CONFIG_MTD_SPI_NOR_USE_4K_SECTORS from the default symbols for the ath79/mikrotik target. MikroTik devices hold some of their user-configurable settings in the soft_config partition, which is typically sized 4 KiB, of the SPI NOR flash memory. Previously, in the ar71xx target, it was possible to use 64 KiB erase sectors but also smaller 4 KiB ones when needed. This is no longer the case in ath79 with newer kernels so, to be able to write to these 4 KiB small partitions without erasing 60 KiB around, the CONFIG_MTD_SPI_NOR_USE_4K_SECTORS symbol was added to the defaults. However, this ended up making sysupgrade images which were built with 64 KiB size blocks not to keep settings (e.g., the files under /etc/config/) over the flashing process. Using 4 KiB erase sector size on the sysupgrade images (by setting BLOCKSIZE = 4k) allows keeping settings over a flashing process, but renders the process terribly slow, possibly causing a user to mistakenly force a manual device reboot while the process is still on- going. Instead, ditching the 4 KiB erase sectors for the default 64 KiB erase size provides normal SPI write speed and sysupgrade times, at the expense of not being able to modify the soft_config partition (which is rarely a required thing). An OpenWrt patch for MTD_SPI_NOR_USE_4K_SECTORS_LIMIT may once have allowed to use different per-partition erase sector sizes. Due to changes on recent kernels it now only works on a per-device basis. Also, partial eraseblock write can be performed in ath79 with kernels 5.4 and lower, by copying the blocks from the 64 KiB, erasing the whole sector and restoring those blocks not meant to be modified. A kernel bump had that patch broken for a long time, but got fixed in bf2870c. Note: the settings in the soft_config partition can be reset to their defaults by holding the reset button for 5 seconds (and less than 10 seconds) at device boot. Fixes: FS#3492 (sysupgrade […] loses settings...) Fixes: a66eee63368e (ath79: add mikrotik subtarget) Signed-off-by: Roger Pueyo Centelles (cherry picked from commit 68d91f08edd0efd47841a2e53d3437d570a61612) --- target/linux/ath79/mikrotik/config-default | 1 - 1 file changed, 1 deletion(-) diff --git a/target/linux/ath79/mikrotik/config-default b/target/linux/ath79/mikrotik/config-default index 97dddfb197d..5839b332ecc 100644 --- a/target/linux/ath79/mikrotik/config-default +++ b/target/linux/ath79/mikrotik/config-default @@ -19,7 +19,6 @@ CONFIG_MTD_NAND_RB91X=y CONFIG_MTD_RAW_NAND=y CONFIG_MTD_ROUTERBOOT_PARTS=y CONFIG_MTD_SPI_NAND=y -CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y CONFIG_MTD_SPLIT_MINOR_FW=y CONFIG_MTD_UBI=y CONFIG_MTD_UBI_BLOCK=y -- 2.30.2