-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash3610.exo
executable file
·100 lines (65 loc) · 2.36 KB
/
flash3610.exo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/expect
log_file log.log
# Please adapt these variables to match your local environment
#set device "/dev/ttyUSB0"
#set device "/dev/ttyACM1"
set device $::env(DEVICE)
set hostip $::env(HOSTIP)
set apip $::env(APIP)
set baudrate 115200
set timeout 120
send_user "\n======== Please press enter, after stoping the device, and make sure that the seriell connector is connected to the pc\n"
expect_user "\n"
#spawn picocom /dev/ttyUSB0 -b 115200 -g picocom.log
spawn picocom $device -b 115200 -g picocom.log
# script -f log.sc ./x
send_user "\n========= Don't connect the device yet\n"
expect "Terminal ready"
send_user "\n============ Power on/plug in the device.\n"
set timeout 120
send_user "\n============================================================ Waiting to connect...\n\n"
expect timeout abort "Hit any key to stop autoboot:"
send "\r"
sleep 1
send "\r"
expect "Boot->"
send_user "\n============================================================ Applying U-Boot configuration...\n\n"
set send_slow {10 0.000001}
sleep 1
send -s "setenv boot_openwrt 'setenv bootargs; bootm 0xbf080000'\r"
expect "Boot->"
sleep 1
send -s "setenv ramboot_openwrt 'setenv serverip 192.168.1.66; tftpboot 0x80100000 openwrt-ap3610-ramboot.bin; bootm'\r"
expect "Boot->"
sleep 1
send -s "setenv bootcmd \"run boot_openwrt\"\r"
expect "Boot->"
sleep 1
send -s "setenv ipaddr $apip\r"
expect "Boot->"
sleep 1
send -s "saveenv\r"
expect "Boot->"
send_user "\n============================================================ Booting from TFTP server...\n\n"
# Some sort of race condition on AP side.
sleep 10
send_user "\n====sleep\n"
send -s "run ramboot_openwrt\r"
expect "Please press Enter to activate this console."
send_user "\n========================================= Please Wait...\n\n"
send "\r"
expect "root@(none):/#"
sleep 20
send -s "until ping -c1 \"$hostip%br-lan\" >/dev/null 2>&1; do :; done\r"
expect ":/#"
send -s "cd /tmp && wget \"http://\[$hostip%br-lan\]:8000/openwrt-ap3610-sysupgrade.bin\" && sysupgrade -n /tmp/openwrt-ap3610-sysupgrade.bin\r"
set timeout 300
expect "Rebooting system..."
sleep 1
send_user "\n============================================================ Rebooting system...\n\n"
set timeout 60
expect "Please press Enter to activate this console."
send_user "\nFlashing the device has been completed successfully.\n"
# Close the cu session
close
wait