1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

flashing firmware from the command line on toastman

Discussion in 'Tomato Firmware' started by Mangix, Aug 28, 2012.

  1. Mangix

    Mangix Networkin' Nut Member

    on openwrt, the mtd command is used.
    on dd-wrt. the write command is used.

    as both seem to be missing in toastman-mod, what's the procedure if any?
     
  2. ulyan

    ulyan Networkin' Nut Member

    One question, why do you prefer flashing from command line ? Is it more failsafe ?
     
  3. koitsu

    koitsu Network Guru Member

  4. apnar

    apnar Network Guru Member

    This is a script I use to do my firmware updates. It clears nvram and writes a new firmware file (looks for file called /tmp/fw_*.bin). I dove into the GUI source to see how it did it and tried to mimic it the best I could. It works for me but no guarantees, it may turn your router into a flower pot.

    Code:
    #!/bin/sh
    FIRM=/tmp/fw_*.bin
    echo About to clear all settings and write new firmware from file: $FIRM
    echo Hit return to continue or ^C to cancel
    read
    echo
    echo Waiting for services to stop.
    nvram set action_service=upgrade-start
    sleep 1
    kill -s SIGUSR1 1
    while [ "$(nvram get action_service)" ]; do echo -n .; sleep 1; done
    echo
    echo Services stopped.
    echo Clearing all nvram settings
    mtd-erase -d nvram
    echo Writing firmware $FIRM
    nohup mtd-write -i $FIRM -d linux &
    while [ "$(pidof mtd-write)" ]; do echo -n .; sleep 1; done
    echo
    echo Flash finished.  Rebooting...
    sleep 1
    reboot
    
    Couple things to note. I'd origionally tried to use the mtd-write commands directly but was unsuccessful without stopping the services first. Also, for some reason I had to clear nvram then flash the firmware, it didn't seem to erase nvram if I did it after the firmware write even though that's how the GUI does it.

    Happy flashing.
     
  5. Mangix

    Mangix Networkin' Nut Member

    ah so it is possible. thanks a lot for that script.

    It is more failsafe, especially over wi-fi since the firmware gets flashed from the firmware's RAM and the firmware usually gets grabbed with wget. in fact with dd-wrt, flashing new firmware with the command line is the recommended way to do it over wifi. and also on dd-wrt, i do it since there is a bug where the nvram does not get cleared even with the "Reset to Default Settings" option selected. Just a lot easier.

    i'm trying this on a different router actually. but yeah i guess it's a possibility.
     

Share This Page