[solved] sysupgrade fails with "Could not get image magic"



  • So I was trying to use sysupgrade to upgrade an O2+ to the latest firmware and kept getting "Could not get image magic" and "Image check failed." errors.

    I'd copied the .bin file from my USB to my O2+ root filesystem and ran sysupgrade with the -n parameter like so:

    root@Omega-C0D3:/# cp /tmp/mounts/USB-A1/omega2p-v0.2.0-b183.bin .
    root@Omega-C0D3:/# sysupgrade -n omega2p-v0.2.0-b183.bin
    killall: watchdog: no process killed
    Sending TERM to remaining processes ... onion-helper udhcpc udhcpc dnsmasq mountd ntpd ubusd logd rpcd netifd odhcpd uhttpd device-client avahi-daemon
    Sending KILL to remaining processes ...
    Switching to ramdisk...
    Performing system upgrade...
    Could not get image magic
    Image check failed.
    Upgrade completed
    Rebooting system...
    umount: can't unmount /dev: Resource busy
    [  128.911166] Removing MTD device #6 (rootfs_data) with use count 1
    [  128.947452] reboot: Restarting system
    

    After a fair amount of head scratching and frustration (including comparing md5sums of the source and the destination files), I found that running it directly from the USB drive worked:

    root@Omega-C0D3:/tmp/run/mountd/sda1# sysupgrade -n omega2p-v0.2.0-b183.bin
    killall: watchdog: no process killed
    Sending TERM to remaining processes ... onion-helper udhcpc udhcpc dnsmasq mountd ntpd ubusd logd rpcd netifd odhcpd uhttpd device-client avahi-daemon
    Sending KILL to remaining processes ...
    Switching to ramdisk...
    Performing system upgrade...
    Unlocking firmware ...
    
    Writing from <stdin> to firmware ...
    Upgrade completed
    Rebooting system...
    umount: can't unmount /tmp/run/mountd/sda1: Resource busy
    umount: can't unmount /tmp/run/mountd: Resource busy
    umount: can't u[  484.971767] Removing MTD device #6 (rootfs_data) with use count 1
    nmount /dev: Resource busy
    umount: can't unmount /tmp: Resource busy
    [  485.008580] reboot: Restarting system
    

    Thought I'd put this out there in case anyone else runs into the same problem....

    [edit]
    Ok, so the root of the problem (pun not intended) actually appears to be that you can't run the sysupgrade command if the firmware binary is in your root (/) directory.
    Observe:

    BusyBox v1.26.2 () built-in shell (ash)
    
       ____       _             ____
      / __ \___  (_)__  ___    / __ \__ _  ___ ___ ____ _
     / /_/ / _ \/ / _ \/ _ \  / /_/ /  ' \/ -_) _ `/ _ `/
     \____/_//_/_/\___/_//_/  \____/_/_/_/\__/\_, /\_,_/
     W H A T  W I L L  Y O U  I N V E N T ? /___/
     -----------------------------------------------------
       Ω-ware: 0.1.9 b159
     -----------------------------------------------------
    root@Omega-C0D3:/# cp /tmp/mounts/USB-A1/omega2p-v0.2.0-b183.bin .
    root@Omega-C0D3:/# sync
    root@Omega-C0D3:/# sysupgrade -n omega2p-v0.2.0-b183.bin
    killall: watchdog: no process killed
    Sending TERM to remaining processes ... uhttpd device-client onion-helper udhcpc avahi-daemon dnsmasq udhcpc mountd ntpd ubusd logd rpcd netifd odhcpd
    Sending KILL to remaining processes ...
    Switching to ramdisk...
    Performing system upgrade...
    Could not get image magic
    Image check failed.
    Upgrade completed
    Rebooting system...
    umount: can't unmount /dev: Resource busy
    [  373.914390] Removing MTD device #6 (rootfs_data) with use count 1
    [  373.951674] reboot: Restarting system
    

    But if we move the firmware file from the root (/) directory to root's home directory (/root), hey presto, no problem writing it, as you can see here:

    BusyBox v1.26.2 () built-in shell (ash)
    
       ____       _             ____
      / __ \___  (_)__  ___    / __ \__ _  ___ ___ ____ _
     / /_/ / _ \/ / _ \/ _ \  / /_/ /  ' \/ -_) _ `/ _ `/
     \____/_//_/_/\___/_//_/  \____/_/_/_/\__/\_, /\_,_/
     W H A T  W I L L  Y O U  I N V E N T ? /___/
     -----------------------------------------------------
       Ω-ware: 0.1.9 b159
     -----------------------------------------------------
    root@Omega-C0D3:/# mv omega2p-v0.2.0-b183.bin /root/
    root@Omega-C0D3:/# cd /root
    root@Omega-C0D3:~# sysupgrade -n omega2p-v0.2.0-b183.bin
    killall: watchdog: no process killed
    Sending TERM to remaining processes ... onion-helper udhcpc udhcpc dnsmasq mountd ntpd ubusd logd rpcd netifd odhcpd uhttpd device-client avahi-daemon
    Sending KILL to remaining processes ...
    Switching to ramdisk...
    Performing system upgrade...
    Unlocking firmware ...
    
    Writing from <stdin> to firmware ...
    Upgrade completed
    Rebooting system...
    umount: can't unmount /dev: Resource busy
    [  215.389374] Removing MTD device #6 (rootfs_data) with use count 1
    [  215.425706] reboot: Restarting system
    
    [snip]
    
    BusyBox v1.25.1 () built-in shell (ash)
    
       ____       _             ____
      / __ \___  (_)__  ___    / __ \__ _  ___ ___ ____ _
     / /_/ / _ \/ / _ \/ _ \  / /_/ /  ' \/ -_) _ `/ _ `/
     \____/_//_/_/\___/_//_/  \____/_/_/_/\__/\_, /\_,_/
     W H A T  W I L L  Y O U  I N V E N T ? /___/
     -----------------------------------------------------
       Ω-ware: 0.2.0 b183
     -----------------------------------------------------
    root@Omega-C0D3:/#
    

    Hopefully less head-scratching for someone else (and I've marked the topic title [solved] for anyone finding this from google as a google search didn't have a lot of hits on this one).

    [/edit]



Looks like your connection to Community was lost, please wait while we try to reconnect.