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