summaryrefslogtreecommitdiff
path: root/tool/download.tcl
blob: 45bf5f0d9dc3f71a72c3f00c0201586508330a6c (plain) (blame)
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
#!/usr/bin/env expect

set timeout 3600

set core 0
set wordsperline 1

if {$::argc > 1} {
    set core [lindex $::argv 0]
    set wordsperline [lindex $::argv 1]
} elseif {$::argc > 0} {
    set core [lindex $::argv 0]
}

spawn tool/connect

set atline "\$ @[format %x [expr $core * 32768 / $wordsperline]]"
send "$atline\n"
expect -ex "$atline\r\n"

while {[gets stdin line] >= 0} {
    send "$line\n"
    expect -ex "$line\r\n"
}

# It's likely we ended with a very large zero-memory operation. We want to see
# two command bytes echoed back to us in order to guarantee that the zero
# operation has completely flushed to memory.
# Note that this forces the last line of memory to be zero.
set atline "@[format %x [expr ($core * 32768 + 32767) / $wordsperline]]"
send "$atline =0 $atline ?"
expect -ex "$atline =0 $atline ?0000\r\n"

send "\n~."
wait