Wbm2009v2/ConfigExpectScript
From Hackerspace Brussels
Parent: Wbm2009v2
[edit] serial
This script will reflash a fonera node with a new LZMA compressed kernel and a new JFFS2 rootfs via serial, assuming the device LAN IP is 192.168.1.1 and the TFTP server IP is 192.168.1.42.
Replace DEVICE below with your serial device (e.g. /dev/ttyUSB0 on Linux or /dev/tty.usbserial on MacOS X)
#!/usr/bin/expect -f
spawn cu -l DEVICE -s 9600
#match_max 100000
set timeout 3600
# Look for passwod prompt
expect "enter ^C to abort"
sleep .5
send \003
expect "RedBoot>"
# send blank line (\r) to make sure we get back to gui
send -- "ip_address -h 192.168.1.42 -l 192.168.1.1/24\r"
expect "RedBoot>"
send -- "fis init\r"
expect "(y/n)? "
send -- "y\r"
expect "RedBoot>"
send -- "load -r -b %\{FREEMEMLO\} openwrt-atheros-vmlinux.lzma\r"
expect "RedBoot>"
send -- "fis create -e 0x80041000 -r 0x80041000 vmlinux.bin.l7\r"
expect "RedBoot>"
send -- "load -r -b %\{FREEMEMLO\} openwrt-atheros-root.jffs2-64k\r"
expect "RedBoot>"
send -- "fis create -l 0x006E0000 rootfs\r"
expect "RedBoot>"
send -- "reset\r"
sleep 1
[edit] telnet
This script will reflash a fonera node with a new LZMA compressed kernel and a new JFFS2 rootfs via telnet, assuming the device LAN IP is 192.168.1.1 and the TFTP server IP is 192.168.1.42.
#!/usr/bin/expect --
set target "192.168.1.1"
set port 9000
spawn ping $target
set timeout -1
expect {
-re "time=.*$" close
}
spawn telnet $target $port
expect -re "Escape character is.*$" {
sleep .5
send \003
expect "RedBoot>" {
send "version\r"
}
}
#match_max 100000
set timeout 3600
expect "RedBoot>"
send -- "ip_address -h 192.168.1.42 -l 192.168.1.1\r"
expect "RedBoot>"
send -- "fis init\r"
expect "(y/n)? "
send -- "y\r"
expect "RedBoot>"
send -- "load -r -b %\{FREEMEMLO\} /trunk-r18050/openwrt-atheros-vmlinux.lzma\r"
expect "RedBoot>"
send -- "fis create -e 0x80041000 -r 0x80041000 vmlinux.bin.l7\r"
expect "RedBoot>"
send -- "load -r -b %\{FREEMEMLO\} /trunk-r18050/openwrt-atheros-root.jffs2-64k\r"
expect "RedBoot>"
send -- "fis free\r"
expect "RedBoot>"
send -- "fis create -l 0x6E0000 rootfs\r"
expect "RedBoot>"
send -- "reset\r"
sleep 1
it's a combination of scripts found on: