Repository navigation
Expand file tree
/
Copy path_kcboot_expect
More file actions
executable file
·90 lines (67 loc) · 1.55 KB
/
Copy path_kcboot_expect
File metadata and controls
executable file
·90 lines (67 loc) · 1.55 KB
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
#!/usr/bin/expect
if { $::argc != 4 && $::argc != 2 } {
puts "usage: _kcbot_expect ASTRIS SERIALPORT \[ KERNELCACHE LOCATION \] \n"
exit 1
}
set astris [lindex $::argv 0]
set port [lindex $::argv 1]
set kernelcache ""
set location ""
if { $::argc == 4 } {
set kernelcache [lindex $::argv 2]
set location [lindex $::argv 3]
}
puts ""
puts " ******************* KCBOOT ***********************"
puts ""
puts "kernelcache = $kernelcache"
puts "astris = $astris"
puts "serialport = $port"
puts "location = $location"
proc abort {} {
puts "EEEEK"
exit 1
}
set timeout 1
set baud 115200
set fd [open $port w+]
fconfigure $fd -mode "$baud,n,8,1"
set spawned [spawn -open $fd]
puts ""
puts " ******************** REBOOTING **********************"
puts ""
system "astrisctl --probe $astris reset"
puts ""
puts " ******************** LOOKING FOR IBOOT **********************"
puts ""
set timeout 10
expect "Hit enter to break into the command prompt"
send "\n\n\n"
expect "Entering recovery mode"
if { [ string length $kernelcache ] == 0 } {
exit 0
}
puts ""
puts " ******************** LOADING KERNEL **********************"
puts ""
spawn usbterm -locationid $location
set timeout 10
send "\nhelp\n"
expect {
"command list:" {}
timeout { abort }
}
send "usb get $kernelcache\n"
expect {
"GET complete" {}
timeout { abort }
}
puts ""
puts " ******************** BOOTING **********************"
puts ""
send "bootx\n"
expect {
"Loading kernel cache at" {}
"booting kernel at" {}
timeout { abort }
}