1 /***************************************************************************
2 * Copyright (C) 2011 by Mathias Kuester *
3 * Mathias Kuester <kesmtp@freenet.de> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 /* project specific includes */
25 #include <jtag/interface.h>
26 #include <transport/transport.h>
27 #include <helper/time_support.h>
29 #include <jtag/stlink/stlink_tcl.h>
30 #include <jtag/stlink/stlink_layout.h>
31 #include <jtag/stlink/stlink_interface.h>
33 #include <target/target.h>
35 static struct stlink_interface_s stlink_if
= { {0, 0, 0, 0}, 0, 0 };
37 int stlink_interface_open(void)
39 LOG_DEBUG("stlink_interface_open");
41 return stlink_if
.layout
->open(&stlink_if
);
44 int stlink_interface_init_target(struct target
*t
)
48 /* this is the interface for the current target and we
49 * can setup the private pointer in the tap structure
50 * if the interface match the tap idcode
52 res
= stlink_if
.layout
->api
->idcode(stlink_if
.fd
, &t
->tap
->idcode
);
57 unsigned ii
, limit
= t
->tap
->expected_ids_cnt
;
60 for (ii
= 0; ii
< limit
; ii
++) {
61 uint32_t expected
= t
->tap
->expected_ids
[ii
];
63 if (t
->tap
->idcode
== expected
) {
71 ("stlink_interface_init_target: target not found: idcode: %x ",
76 t
->tap
->priv
= &stlink_if
;
77 t
->tap
->hasidcode
= 1;
82 static int stlink_interface_init(void)
84 LOG_DEBUG("stlink_interface_init");
86 /* here we can initialize the layout */
87 return stlink_layout_init(&stlink_if
);
90 static int stlink_interface_quit(void)
92 LOG_DEBUG("stlink_interface_quit");
97 static int stlink_interface_speed(int speed
)
99 LOG_DEBUG("stlink_interface_speed: ignore speed %d", speed
);
104 static int stlink_interface_execute_queue(void)
106 LOG_DEBUG("stlink_interface_execute_queue: ignored");
111 COMMAND_HANDLER(stlink_interface_handle_device_desc_command
)
113 LOG_DEBUG("stlink_interface_handle_device_desc_command");
116 stlink_if
.param
.device_desc
= strdup(CMD_ARGV
[0]);
119 ("expected exactly one argument to stlink_device_desc <description>");
125 COMMAND_HANDLER(stlink_interface_handle_serial_command
)
127 LOG_DEBUG("stlink_interface_handle_serial_command");
130 stlink_if
.param
.serial
= strdup(CMD_ARGV
[0]);
133 ("expected exactly one argument to stlink_serial <serial-number>");
139 COMMAND_HANDLER(stlink_interface_handle_layout_command
)
141 LOG_DEBUG("stlink_interface_handle_layout_command");
144 LOG_ERROR("Need exactly one argument to stlink_layout");
145 return ERROR_COMMAND_SYNTAX_ERROR
;
148 if (stlink_if
.layout
) {
149 LOG_ERROR("already specified stlink_layout %s",
150 stlink_if
.layout
->name
);
151 return (strcmp(stlink_if
.layout
->name
, CMD_ARGV
[0]) != 0)
152 ? ERROR_FAIL
: ERROR_OK
;
155 for (const struct stlink_layout
*l
= stlink_layout_get_list(); l
->name
;
157 if (strcmp(l
->name
, CMD_ARGV
[0]) == 0) {
158 stlink_if
.layout
= l
;
163 LOG_ERROR("No STLINK layout '%s' found", CMD_ARGV
[0]);
167 COMMAND_HANDLER(stlink_interface_handle_vid_pid_command
)
169 LOG_DEBUG("stlink_interface_handle_vid_pid_command");
173 ("ignoring extra IDs in stlink_vid_pid (maximum is 1 pair)");
174 return ERROR_COMMAND_SYNTAX_ERROR
;
177 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[0], stlink_if
.param
.vid
);
178 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[1], stlink_if
.param
.pid
);
183 static const struct command_registration stlink_interface_command_handlers
[] = {
185 .name
= "stlink_device_desc",
186 .handler
= &stlink_interface_handle_device_desc_command
,
187 .mode
= COMMAND_CONFIG
,
188 .help
= "set the stlink device description of the STLINK device",
189 .usage
= "description_string",
192 .name
= "stlink_serial",
193 .handler
= &stlink_interface_handle_serial_command
,
194 .mode
= COMMAND_CONFIG
,
195 .help
= "set the serial number of the STLINK device",
196 .usage
= "serial_string",
199 .name
= "stlink_layout",
200 .handler
= &stlink_interface_handle_layout_command
,
201 .mode
= COMMAND_CONFIG
,
202 .help
= "set the layout of the STLINK to usb or sg",
203 .usage
= "layout_name",
206 .name
= "stlink_vid_pid",
207 .handler
= &stlink_interface_handle_vid_pid_command
,
208 .mode
= COMMAND_CONFIG
,
209 .help
= "the vendor and product ID of the STLINK device",
210 .usage
= "(vid pid)* ",
212 COMMAND_REGISTRATION_DONE
215 struct jtag_interface stlink_interface
= {
218 .commands
= stlink_interface_command_handlers
,
219 .transports
= stlink_transports
,
221 .init
= stlink_interface_init
,
222 .quit
= stlink_interface_quit
,
223 .speed
= stlink_interface_speed
,
224 .execute_queue
= stlink_interface_execute_queue
,
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)