Skip to content

sysupgrade -n: camera can hang instead of rebooting after the overlay wipe, needing a physical power cycle #2298

Description

@widgetii

sysupgrade -n completes and announces its reboot, but the camera sometimes never comes back — only a physical power cycle recovers it. Seen repeatedly; opening this to pin the mechanism down rather than to report a single event.

Distinct from the page-cache hazard fixed by the ramfs pivot in #2251: that one is about rewriting the rootfs the camera runs from, and it is excluded here — the run below pivoted into RAM successfully (Flashing from RAM (pid 1041)) and never touched mtd3. The only partition written was rootfs_data.

Environment

SoC hi3516ev300 (NOR, 16 MB)
Build master+2f558d4, 2026-08-21, BUILD_PLATFORM=hi3516ev300_lite, OPENIPC_VERSION=2.6.08.21
sysupgrade v1.0.60
Overlay mtd4 "rootfs_data", 008b0000, erasesize 00010000, jffs2 on /dev/mtdblock4 mounted at /overlay

Steps to reproduce

/usr/sbin/sysupgrade -n --web

The WebUI's Reset firmware button runs the same thing, so it reproduces from the browser too. --web is incidental — it only skips the killall -3 majestic in free_resources().

What happens

The run completes normally end to end, erase reaches 100%, and sysupgrade prints its reboot line:

OpenIPC System Updater v1.0.60

Vendor	hisilicon
SoC	hi3516ev300
Model	hi3516ev300
Kernel	22:58:06 2026-08-21
RootFS	master+2f558d4, 2026-08-21

Synchronizing time
Sun Aug 23 06:16:23 UTC 2026

Stop services, sync files, free up memory
Stopping crond: OK
Stopping ntpd: OK
Stopping klogd: OK
Stopping syslogd: OK

Uptime:
 06:16:24 up 22:40,  load average: 0.22, 0.17, 0.10

Memory:
              total        used        free      shared  buff/cache   available
Mem:         120.7M       53.7M       61.8M       20.0K        5.1M       64.5M
Swap:             0           0           0

Processes:
PID   USER     TIME  COMMAND
    1 root      0:01 init
  694 root      0:00 udhcpc -x hostname:hi3516ev300-imx335 -A 0 -T 1 -t 5 -R -b -O search -p /var/run/udhcpc.eth0.pid -i eth0
  705 root      0:00 dropbear -R -B -k -p 22 -K 300
  847 root      1h19 majestic -s
  854 root      0:00 /sbin/getty -L console 0 vt100
 1039 root      0:00 dropbear -R -B -k -p 22 -K 300
 1040 root      0:00 sh -c /usr/sbin/sysupgrade -n --web 2>&1 | cat
 1041 root      0:00 {sysupgrade} /bin/sh /usr/sbin/sysupgrade -n --web
 1042 root      0:00 cat
 1093 root      0:00 ps

Unmounting SD card

Protected: flashing continues even if this terminal disconnects.

Moving the flash phase into RAM
Flashing from RAM (pid 1041)

OverlayFS
Erase overlay partition
Erasing 64 Kibyte @ 8b0000 - 100% complete.Cleanmarker written at 8a0000.

Unconditional reboot

Then nothing. No ICMP, no :80, no :22 for ~45 minutes. A manual power cycle brought it straight back, healthy, with a correctly wiped overlay — so the flash contents were fine and the reset itself did what it was asked. It is the reboot that did not take.

Timing, from the timestamped capture: the whole run is 34 s. The erase is 139 blocks at ~215 ms each (~30 s of the 34), and the last byte received is Unconditional reboot.

What this rules out

  • Not the sysupgrade: flash from a ramfs, so the reboot cannot be eaten by the flash #2251 page-cache hazard. The pivot into RAM succeeded, so reboot was busybox running from tmpfs, not from a rewritten partition. mtd3 was never written.
  • Not a bad erase or a corrupt overlay. After the power cycle the camera booted clean on a freshly populated overlay.
  • Not board-specific to goke. Reported against gk7205v300 in majestic-webui#154 and reproduced here on hi3516ev300 — though on gk7205v300 the same command did reboot normally, so it is intermittent rather than universal.

Leading hypothesis: the overlay is erased while it is still mounted

do_wipe_overlay() erases rootfs_data and nothing unmounts or remounts it first:

do_wipe_overlay() {
	echo_c 33 "\nOverlayFS"
	echo "Erase overlay partition"
	[ "$flash_type" = "nand" ] || jffs2="-j"
	mark_live_flash_dirty
	set_progress flash_eraseall $jffs2 "$(get_device "rootfs_data")"
}

At that point /dev/mtdblock4 is still a live, read-write jffs2, and pivot_root moved it to /mnt rather than releasing it — so after the erase the in-kernel jffs2 state describes a medium that no longer exists. busybox reboot -f calls reboot(RB_AUTOBOOT) straight into kernel_restart(), which runs device_shutdown() before machine_restart(). A jffs2 GC thread or a pending writeback stuck on erased blocks would block exactly there, which fits the symptom: the announcement is printed, nothing further happens, and only cutting power gets the SoC to reset.

That would also explain the intermittency — whether jffs2 has dirty state or GC in flight at erase time depends on what was written to the overlay just before.

Worth considering alongside it:

  • free_resources() stops the watchdog service on boards that have one, so nothing is left armed to rescue a hung reset. If the reboot path can hang at all, disarming the watchdog first removes the one thing that would have papered over it.
  • With --web, majestic is deliberately left running across the erase. Anything of its still open on the overlay disappears mid-erase.

What would settle it

A serial console capture across the next reproduction — that is the only place a hang between Unconditional reboot and machine_restart() is visible. Failing that, echo b > /proc/sysrq-trigger as an alternative reboot primitive would tell us whether the block is in device_shutdown() (sysrq-b skips it) or lower down.

If the hypothesis holds, the fix is presumably to get the overlay out of the way before erasing it — mount -o remount,ro or a real unmount of /mnt/overlay post-pivot — rather than to make the reboot more forceful.

Found while working on majestic-webui#154 (OpenIPC/majestic-webui#154).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions