running custom commands during sysupgrade -

Alberto Bursi bobafetthotmail at gmail.com
Sun Nov 22 12:23:27 EST 2020



On 22/11/20 18:07, Hannu Nyman wrote:
> 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"
> 
> 

would it make sense to propose/accept this change in master?
I don't see any drawback to just have this as the default

-Alberto



More information about the openwrt-devel mailing list