Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#3492 - sysupgrade from CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y loses settings where image has BLOCKSIZE:=64k #9125

Closed
openwrt-bot opened this issue Dec 8, 2020 · 4 comments
Labels

Comments

@openwrt-bot
Copy link

openwrt-bot commented Dec 8, 2020

johnth:

Test device: ath79 mikrotik wap-g on snapshot r15165-66d12ce667

Reproduce

  • sysupgrade
  • change settings
  • sysupgrade: settings lost

without CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y

  • settings are found and restored on sysupgrade (after the initial 4K_SECTORS=y to 4K_SECTORS=n upgrade)
  • lose write access for routerboot soft_config (which explicitly requires CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y, as Openwrt partial erase target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch had a merge error which was rendering devices unbootable at the time.)
  • faster sysupgrade erase/write time: 45s -> 26s

#3094 (comment)
#3037 (comment)

target/linux/generic/pending-5.4/470-mtd-spi-nor-support-limiting-4K-sectors-support-base.patch stopped functioning with linux 4.19
Now all partitions have a 4K erase block if CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
This causes mount_root to fail to find upgrade settings where the image is expecting 64K blocksize.

grep --binary-files=text -E 'overlay|upgrade|reboot|mount' ath79_mikrotik_wap-g_sysupgrade_loses_settings [ 8.892059] mount_root: switching to jffs2 overlay [ 8.899647] overlayfs: upper fs does not support tmpfile. Mon Dec 7 13:25:31 UTC 2020 upgrade: Sending TERM to remaining processes ... logd hostapd wpa_supplicant netifd odhcpd ntpd dnsmasq ubusd askfirst urngd Mon Dec 7 13:25:34 UTC 2020 upgrade: Sending KILL to remaining processes ... Mon Dec 7 13:25:35 UTC 2020 upgrade: Switching to ramdisk... Mon Dec 7 13:25:38 UTC 2020 upgrade: Performing system upgrade... Appending jffs2 data from /tmp/sysupgrade.tgz to firmware.. Mon Dec 7 13:26:21 UTC 2020 upgrade: Upgrade completed Mon Dec 7 13:26:22 UTC 2020 upgrade: Rebooting system... umount: can't unmount /dev: Resource busy umount: can't unmount /tmp: Resource busy [ 175.677595] reboot: Restarting system [ 8.611437] mount_root: no usable overlay filesystem found, using tmpfs overlay [ 117.356605] overlayfs: upper fs does not support tmpfile.

./package/base-files/files/lib/preinit/80_mount_root:do_mount_root() {

do_mount_root() { mount_root boot_run_hook preinit_mount_root [ -f /sysupgrade.tgz ] && { echo "- config restore -" cp /etc/passwd /etc/group /etc/shadow /tmp cd / tar xzf /sysupgrade.tgz missing_lines /tmp/passwd /etc/passwd >> /etc/passwd missing_lines /tmp/group /etc/group >> /etc/group missing_lines /tmp/shadow /etc/shadow >> /etc/shadow rm /tmp/passwd /tmp/group /tmp/shadow # Prevent configuration corruption on a power loss sync } }

https://git.openwrt.org/?p=project/fstools.git;a=blob;f=mount_root.c;

61 case FS_NONE:
62 ULOG_WARN("no usable overlay filesystem found, using tmpfs overlay\n");
63 return ramoverlay();

@openwrt-bot
Copy link
Author

openwrt-bot commented May 4, 2021

johnth:

Note that this is still unchanged, so Mikrotik ath79 devices do not restore config in master or 21.02rc1

@openwrt-bot
Copy link
Author

openwrt-bot commented Jul 16, 2021

rogerpueyo:

Hi,

Maybe one of these workarounds could be applied for while/if there is no fix for the 4K blocksize problem:

  • Make soft_config read-only on all the devices, and unset CONFIG_MTD_SPI_NOR_USE_4K_SECTORS
  • Tweak mount_root so that it can find the sysupgrade settings

Each ones comes at a price. With the first one, soft_config will not be modifiable from the userspace. With the second one, writing to SPI will remain very slow although, most likely, this should only be noticeable when sysupgrading, I guess not for single-file editions.

Any ideas on how to implement the second idea, if even possible?

@openwrt-bot
Copy link
Author

openwrt-bot commented Jul 16, 2021

rogerpueyo:

  1. Tweak mount_root so that it can find the sysupgrade settings
    Any ideas on how to implement the second idea, if even possible?

I can answer myself: //using "BLOCKSIZE = 4k" instead of the default 64k when generating the image//. Either on each device entry, or for all the //mikrotik_nor//-type devices. In common-mikrotik.mk:

define Device/mikrotik_nor $(Device/mikrotik) BLOCKSIZE = 4k IMAGE/sysupgrade.bin := append-kernel | kernel2minor -s 1024 -e | \ pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | \ check-size | append-metadata endef

Flashing process is still slow, yes, but settings are now kept over upgrades. I tested it on the wAP AC.

@john: What do you think? Would you like to give it a try? Maybe submit a patch?

@openwrt-bot
Copy link
Author

openwrt-bot commented Nov 3, 2021

rogerpueyo:

@johnth, this should be fixed in snapshots and 21.02.1. Does it work for you? If so, we can close the task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant