#!/usr/bin/expect -f # baps_install_firmware.tcl - Expect script to install BAPS firmware on IP04 # # assumes /etc/minirc.dfl on RS232 machine has 115200 as default baud rate set send_slow {1 0.2} set timeout -1 # connect to machine with RS232 port spawn bash expect "$ " send "killall -9 minicom\r" expect "$ " send "minicom\r" expect "on special keys" # get u-boot prompt expect "Hit any key to stop autoboot" send "\r" expect "ip04>" # flash new kernel send -s "set autostart\r" expect "ip04>" send -s "set serverip 192.168.1.2\r" expect "ip04>" send -s "tftp 0x1000000 uImage_r2.ip08\r" expect "ip04>" send -s "nand erase clean\r" expect "ip04>" send -s "nand erase\r" expect "ip04>" send -s "nand write 0x1000000 0x0 0x300000\r" expect "ip04>" # set bootargs for /dev/mtdblock0 set timeout 5 send -s "print bootargs\r" set ethaddr1 " " expect -re "(ethaddr=..:..:..:..:..:..)" set ethaddr $expect_out(1,string) expect -re "(ethaddr1=..:..:..:..:..:..)" { set ethaddr1 $expect_out(1,string) } expect "ip04>" send -s "set bootargs root=/dev/mtdblock0 rw $ethaddr $ethaddr1\r" expect "ip04>" set timeout -1 # save and reboot into uClinux send -s "set autostart yes\r" expect "ip04>" send -s "save\r" expect "ip04>" send -s "reset\r" expect "root:~> " # set up yaffs, reboot back into u-boot send -s "copy_rootfs.sh\r" expect "root:~> " send -s "reboot\r" # set yaffs as root fs, reboot into uClinux expect "Hit any key to stop autoboot" send "\r" expect "ip04>" send -s "set bootargs root=/dev/mtdblock2 rw $ethaddr $ethaddr1\r" expect "ip04>" send -s "save\r" expect "ip04>" send -s "reset\r" expect "root:~> " # install baseline BAPS packages send -s "ipkg update\r" expect "root:~> " send -s "ipkg install network-static zaptel-sport native-sounds asterisk\r" expect "root:~> " send -s "ipkg install mini-asterisk-gui\r" expect "root:~> " send -s "ipkg install commis\r" expect "root:~> " # set IP to 192.168.1.30 send "sed -i \"s/IPADDRESS=.*/IPADDRESS=\\\"192.168.1.30\\\"/g\" /etc/init.d/network-static\r" expect "root:~> " send "sed -i \"s/GATEWAY=.*/GATEWAY=\\\"192.168.1.22\\\"/g\" /etc/init.d/network-static\r" expect "root:~> " send "sed -i \"s/DNS=.*/DNS=\\\"192.168.1.22\\\"/g\" /etc/init.d/network-static\r" expect "root:~> " puts "\r\rNOW REMOVE RS232 CABLE AND POWER CYCLE" close