| 1 | # $Id$
|
|---|
| 2 | #
|
|---|
| 3 | # tftp flash script for wireless routers
|
|---|
| 4 | #
|
|---|
| 5 | # Copyright (c) 2006, 2007 by Thorsten Glaser <tg@mirbsd.de>
|
|---|
| 6 | # Copyright (C) 2006 by Waldemar Brodkorb <wbx@freewrt.org>
|
|---|
| 7 | # Copyright (C) 2004 by Oleg I. Vdovikin <oleg@cs.msu.su>
|
|---|
| 8 | #
|
|---|
| 9 | # This program is free software; you can redistribute it and/or modify
|
|---|
| 10 | # it under the terms of the GNU General Public License as published by
|
|---|
| 11 | # the Free Software Foundation; either version 2 of the License, or
|
|---|
| 12 | # (at your option) any later version.
|
|---|
| 13 | #
|
|---|
| 14 | # This program is distributed in the hope that it will be useful,
|
|---|
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 17 | # General Public License for more details.
|
|---|
| 18 | #
|
|---|
| 19 | # You should have received a copy of the GNU General Public License
|
|---|
| 20 | # along with this program; if not, write to the Free Software
|
|---|
| 21 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 22 |
|
|---|
| 23 | usage() {
|
|---|
| 24 | cat <<EOF
|
|---|
| 25 | Usage: $0 firmware.bin [address]
|
|---|
| 26 |
|
|---|
| 27 | The following models are supported:
|
|---|
| 28 | asus-wl500g - Asus WL500g
|
|---|
| 29 | asus-wl500g-deluxe - Asus WL500g Deluxe
|
|---|
| 30 | asus-wl500g-premium - Asus WL500g Premium
|
|---|
| 31 | linksys - All Linksys models
|
|---|
| 32 |
|
|---|
| 33 | IMPORTANT:
|
|---|
| 34 | Notes for Linksys routers:
|
|---|
| 35 | be sure you have set boot_wait to yes. Power on your router
|
|---|
| 36 | after executing this script.
|
|---|
| 37 |
|
|---|
| 38 | Notes for Asus routers:
|
|---|
| 39 | be sure POWER led is flashing (if this is not the case,
|
|---|
| 40 | power off the device, then hold the reset button pushed
|
|---|
| 41 | while powering it on again).
|
|---|
| 42 |
|
|---|
| 43 | 1) connect your PC to the LAN port
|
|---|
| 44 | 2) be sure your link is up and has an address in the
|
|---|
| 45 | range 192.168.1.0/24 but other than 192.168.1.1,
|
|---|
| 46 | or specify an IP address where to flash to
|
|---|
| 47 |
|
|---|
| 48 | EOF
|
|---|
| 49 | exit 1
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | # find an available tftp client
|
|---|
| 53 | tftp=
|
|---|
| 54 | for t in tftp atftp; do
|
|---|
| 55 | if which $t >/dev/null 2>&1; then
|
|---|
| 56 | tftp=$t
|
|---|
| 57 | break
|
|---|
| 58 | fi
|
|---|
| 59 | done
|
|---|
| 60 | if [ -z "$tftp" ]; then
|
|---|
| 61 | echo "no tftp client found! make sure, tftp is in your path"
|
|---|
| 62 | tftp=tftp
|
|---|
| 63 | fi
|
|---|
| 64 |
|
|---|
| 65 | file=${1-/nonexistant}
|
|---|
| 66 | ip=${2-192.168.1.1}
|
|---|
| 67 |
|
|---|
| 68 | test -s "$file" || usage
|
|---|
| 69 |
|
|---|
| 70 | cd "$(dirname "$file")"
|
|---|
| 71 | file=$(basename "$file")
|
|---|
| 72 |
|
|---|
| 73 | case $file in
|
|---|
| 74 | *\ *)
|
|---|
| 75 | echo Spaces in filenames are not supported.
|
|---|
| 76 | exit 1
|
|---|
| 77 | ;;
|
|---|
| 78 | *-asus-wl500g-deluxe-*.bin | *-asus-wl500g-premium-*.bin)
|
|---|
| 79 | echo Flashing $ip using "$file"...
|
|---|
| 80 | printf "rexmt 1\ntrace\nbinary\nput $file\nquit\n" | $tftp $ip
|
|---|
| 81 | echo Please wait 3 minutes and then remove the power.
|
|---|
| 82 | echo This device does not reboot automatically after flashing.
|
|---|
| 83 | ;;
|
|---|
| 84 | *-asus-wl500g-*.bin)
|
|---|
| 85 | echo Confirming IP address setting...
|
|---|
| 86 | printf "get ASUSSPACELINK\x01\x01\xa8\xc0 /dev/null\nquit\n" | $tftp $ip
|
|---|
| 87 | echo Flashing $ip using "$file"...
|
|---|
| 88 | printf "binary\nput $file ASUSSPACELINK\nquit\n" | $tftp $ip
|
|---|
| 89 | echo Please wait until leds stops flashing. Device will automatically reboot.
|
|---|
| 90 | ;;
|
|---|
| 91 | *-linksys-*.bin)
|
|---|
| 92 | echo Flashing $ip using "$file"...
|
|---|
| 93 | printf "rexmt 1\ntrace\nbinary\nput $file\nquit\n" | $tftp $ip
|
|---|
| 94 | echo Unit will automatically reboot within 3-5 minutes. Do not power off.
|
|---|
| 95 | ;;
|
|---|
| 96 | *)
|
|---|
| 97 | echo Unsupported model "'$file'"
|
|---|
| 98 | usage
|
|---|
| 99 | ;;
|
|---|
| 100 | esac
|
|---|
| 101 | echo After that you can login via: ssh admin@$ip
|
|---|
| 102 | echo Default password, unless changed in menuconfig, is: FreeWRT
|
|---|