running custom commands during sysupgrade -

Hannu Nyman hannu.nyman at iki.fi
Sun Nov 22 12:07:05 EST 2020


Adrian Schmutzler wrote at Fri Oct 16 19:15:38 EDT 2020:

 > Fortunately, and I don't fully understand why, we were able to drive this 
to effectively zero by simply running
 > echo 3 > /proc/sys/vm/drop_caches
 > directly before sysupgrade. Out of a few hundred upgrades since then, I 
haven't had a single soft-brick. I do occasionally have the situation that 
the device reboots into the old firmware again (i.e. upgrade failed in an 
early stage), but for some reason the soft-bricks were completely gone.

I have stumbled into similar "boot to the old firmware" symptom with my old 
WNDR3700v2 with 64 MB RAM.
I have not been able to reproduce the problem in WNDR3800 that has 128 MB RAM 
but it otherwise identical, (and has serial cable connected).

Sysupgrade in WNDR3700v2 used to regularly
* fail, if sysupgrade was run after the router had been running a few days
* succeed with the same image, when sysupgrade was re-run right after the 
first failure (and automatic reboot)

To avoid failure I have patched the sysupgrade script components itself, and 
I have not seen the problem any more. Patched files are 
/lib/upgrade/common.sh and /lib/upgrade/stage2

I am not sure if those insertion locations are quite optimal, but so far the 
approach has worked


--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -297,6 +297,7 @@ indicate_upgrade() {
  # $(2): (optional) pipe command to extract firmware, e.g. dd bs=n skip=m
  default_do_upgrade() {
      sync
+    echo 3 > /proc/sys/vm/drop_caches
      if [ -n "$UPGRADE_BACKUP" ]; then
          get_image "$1" "$2" | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j 
"$UPGRADE_BACKUP" write - "${PART_NAME:-image}"
      else
--- a/package/base-files/files/lib/upgrade/stage2
+++ b/package/base-files/files/lib/upgrade/stage2
@@ -123,6 +123,7 @@ kill_remaining KILL 1

  sleep 1

+echo 3 > /proc/sys/vm/drop_caches

  if [ -n "$IMAGE" ] && type 'platform_pre_upgrade' >/dev/null 2>/dev/null; then
      platform_pre_upgrade "$IMAGE"




More information about the openwrt-devel mailing list