OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [tools/] [bin/] [openmsp430-gdbproxy.tcl] - Blame information for rev 20

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 olivier.gi
#!/usr/bin/tclsh
2
#------------------------------------------------------------------------------
3
# Copyright (C) 2001 Authors
4
#
5
# This source file may be used and distributed without restriction provided
6
# that this copyright statement is not removed from the file and that any
7
# derivative work contains the original copyright notice and the associated
8
# disclaimer.
9
#
10
# This source file is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU Lesser General Public License as published
12
# by the Free Software Foundation; either version 2.1 of the License, or
13
# (at your option) any later version.
14
#
15
# This source is distributed in the hope that it will be useful, but WITHOUT
16
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18
# License for more details.
19
#
20
# You should have received a copy of the GNU Lesser General Public License
21
# along with this source; if not, write to the Free Software Foundation,
22
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
#
24
#------------------------------------------------------------------------------
25
# 
26
# File Name: openmsp430-gdbproxy.tcl
27
# 
28 14 olivier.gi
# Author(s):
29
#             - Olivier Girard,    olgirard@gmail.com
30
#
31 2 olivier.gi
#------------------------------------------------------------------------------
32 14 olivier.gi
# $Rev: 14 $
33
# $LastChangedBy: olivier.girard $
34
# $LastChangedDate: 2009-08-04 22:34:42 +0200 (Tue, 04 Aug 2009) $
35
#------------------------------------------------------------------------------
36 2 olivier.gi
 
37
global serial_baudrate
38
global serial_device
39
global serial_status
40
global hw_break
41
global clients
42
global server
43
global verbose
44
global shell
45
 
46
# Initializations
47
set serial_status 0
48
 
49
 
50
###############################################################################
51
#                                                                             #
52
#                            SOURCE LIBRARIES                                 #
53
#                                                                             #
54
###############################################################################
55
 
56
# Get library path
57
set current_file [info script]
58
if {[file type $current_file]=="link"} {
59
    set current_file [file readlink $current_file]
60
}
61
set lib_path [file dirname $current_file]/../lib/tcl-lib
62
 
63
# Source library
64
source $lib_path/dbg_functions.tcl
65
 
66
# Source remaining files
67
source [file dirname $current_file]/../openmsp430-gdbproxy/server.tcl
68
source [file dirname $current_file]/../openmsp430-gdbproxy/commands.tcl
69
 
70
 
71
###############################################################################
72
#                                                                             #
73
#                            PARAMETER CHECK                                  #
74
#                                                                             #
75
###############################################################################
76
 
77
proc help {} {
78
    puts ""
79
    puts "USAGE   : openmsp430-gdbproxy.tcl \[-device   <communication device>\]"
80
    puts "                                  \[-baudrate <communication speed>\]"
81
    puts "                                  \[-port     <server port>\]"
82
    puts "                                  \[-shell]"
83
    puts "                                  \[-verbose\]"
84
    puts "                                  \[-help\]"
85
    puts ""
86
    puts "Examples: openmsp430-gdbproxy.tcl -device /dev/ttyUSB0 -baudrate  9600  -port 2000"
87
    puts "          openmsp430-gdbproxy.tcl -device COM2:        -baudrate 38400  -port 2000"
88
    puts ""
89
}
90
 
91
# Default values
92
set serial_device   [lindex [dbg_list_uart] end]
93
set serial_baudrate 115200
94
set server(port)    2000
95
set shell           0
96
set verbose         0
97
 
98
# Parse arguments
99
for {set i 0} {$i < $argc} {incr i} {
100
    switch -exact -- [lindex $argv $i] {
101
        -device   {set serial_device   [lindex $argv [expr $i+1]]; incr i}
102
        -baudrate {set serial_baudrate [lindex $argv [expr $i+1]]; incr i}
103
        -port     {set server(port)    [lindex $argv [expr $i+1]]; incr i}
104
        -shell    {set shell   1}
105
        -verbose  {set verbose 1}
106
        -h        {help; exit 0}
107
        -help     {help; exit 0}
108
        default   {}
109
    }
110
}
111
 
112
# Source additional library for graphical interface
113
if {!$shell} {
114
    source $lib_path/combobox.tcl
115
    package require combobox 2.3
116
    catch {namespace import combobox::*}
117
}
118
 
119
# Small functions to display messages
120
proc putsLog {string {nonewline 0}} {
121
    global server
122
    global shell
123
    if {$shell} {
124
        if {$nonewline} {
125
            puts -nonewline $string
126
        } else {
127
            puts $string
128
        }
129
    } else {
130
        if {$nonewline} {
131
            $server(log) insert end "$string"
132
        } else {
133
            $server(log) insert end "$string\n"
134
        }
135
        $server(log) see end
136
    }
137
}
138
proc putsVerbose {string} {
139
    global verbose
140
    if {$verbose} {
141
        putsLog "$string"
142
    }
143
}
144
 
145
###############################################################################
146
#                               SHELL MODE                                    #
147
###############################################################################
148
if {$shell} {
149
 
150
    # Connect to device
151
    if {![GetDevice]} {
152
        puts "ERROR: Could not open $serial_device"
153
        puts "INFO:  Available serial ports are:"
154
        foreach port [dbg_list_uart] {
155
            puts "INFO:                               -  $port"
156
        }
157
        exit 1
158
    }
159
 
160
    # Display info
161
    puts "INFO: Sucessfully connected with the openMSP430 target."
162
    set sizes [GetCPU_ID_SIZE]
163
    puts "INFO: ROM Size - [lindex $sizes 0] B"
164
    puts "INFO: RAM Size - [lindex $sizes 1] B"
165
    puts "INFO: $hw_break(num) Hardware Brea/Watch-point unit(s) detected"
166
    puts ""
167
 
168
    # Reset & Stop CPU
169
    ExecutePOR_Halt
170
 
171
    # Start server for GDB
172
    if {![startServer]} {
173
        exit 1
174
    }
175
 
176
    vwait forever
177
}
178
 
179
 
180
###############################################################################
181
#                                 GUI MODE                                    #
182
###############################################################################
183
 
184
####################################
185
#   CREATE & PLACE MAIN WIDGETS    #
186
####################################
187
 
188
wm title    . "openMSP430 GDB Proxy"
189
wm iconname . "openMSP430 GDB Proxy"
190
 
191
# Create the Main Menu budget
192
frame  .menu
193
pack   .menu   -side top -padx 10 -pady 10 -fill x
194
 
195
# Create the Serial port Menu budget
196
frame  .serial
197
pack   .serial -side top -padx 10 -pady 10 -fill x
198
 
199
# Create the Server Menu budget
200
frame  .server
201
pack   .server -side top -padx 10 -pady 10 -fill x
202
 
203
 
204
####################################
205
#  CREATE THE REST                 #
206
####################################
207
 
208
# Exit button
209
button .menu.exit -text "Exit" -command {stopServer; exit 0}
210
pack   .menu.exit -side left
211
 
212
 
213
# Serial Port fields
214
label  .serial.l1      -text "Serial Port:"  -anchor w
215
pack   .serial.l1      -side left
216
set serial_device      [lindex [dbg_list_uart] end]
217
combobox .serial.p1    -textvariable serial_device -editable true
218
eval     .serial.p1    list insert end [dbg_list_uart]
219
pack   .serial.p1      -side left -padx 5
220
label  .serial.l2      -text "  Baudrate:" -anchor w
221
pack   .serial.l2      -side left
222
set serial_baudrate    115200
223
combobox .serial.p2    -textvariable serial_baudrate -editable true
224
eval     .serial.p2    list insert end [list    9600   19200  38400  57600 115200 \
225
                                              230400  460800 500000 576000 921600 \
226
                                             1000000 1152000]
227
pack   .serial.p2      -side left -padx 5
228
label  .serial.l3      -text "Disconnected" -anchor w -fg Red
229
pack   .serial.l3      -side left -padx 10
230
 
231
 
232
# Server Port field
233
frame  .server.port
234
pack   .server.port    -side top -fill x
235
label  .server.port.l1 -text "Proxy Server Port:" -anchor w
236
pack   .server.port.l1 -side left
237
entry  .server.port.p  -textvariable server(port) -relief sunken
238
pack   .server.port.p  -side left -padx 5
239
label  .server.port.l2 -text "Not running" -anchor w -fg Red
240
pack   .server.port.l2 -side left -padx 10
241
button .server.port.start -text "Start Proxy Server" -command {startServerGUI}
242
pack   .server.port.start -side right
243
 
244
 
245
# Create the text widget to log received messages
246
frame  .server.t
247
pack   .server.t     -side top -padx 10 -pady 10 -fill x
248
set server(log) [text   .server.t.log -width 80 -height 10 -borderwidth 2  \
249
                          -setgrid true -yscrollcommand {.server.t.scroll set}]
250
pack   .server.t.log -side left  -fill both -expand true
251
scrollbar .server.t.scroll -command {.server.t.log yview}
252
pack   .server.t.scroll -side right -fill both -expand true
253
 
254
 
255
# Log commands
256
frame  .server.cmd
257
pack   .server.cmd   -side top -fill x
258
button .server.cmd.clear -text "Clear log" -command {$server(log) delete 1.0 end}
259
pack   .server.cmd.clear -side left -padx 10
260
checkbutton .server.cmd.verbose -text "Verbose" -variable verbose
261
pack   .server.cmd.verbose -side right -padx 10

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.