fa2d2c6127a59953867621e9322d2417e60d52ae
[openocd.git] / src / openocd.c
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20
21 #define OPENOCD_VERSION "Open On-Chip Debugger " VERSION " (" PKGBLDDATE ") svn:" PKGBLDREV
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include "log.h"
28 #include "types.h"
29 #include "jtag.h"
30 #include "configuration.h"
31 #include "interpreter.h"
32 #include "xsvf.h"
33 #include "target.h"
34 #include "flash.h"
35 #include "nand.h"
36 #include "pld.h"
37
38 #include "command.h"
39 #include "server.h"
40 #include "telnet_server.h"
41 #include "gdb_server.h"
42
43 #include <sys/time.h>
44 #include <sys/types.h>
45 #include <strings.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <unistd.h>
50 #include <errno.h>
51
52 /* Give TELNET a way to find out what version this is */
53 int handle_version_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
54 {
55 command_print(cmd_ctx, OPENOCD_VERSION);
56
57 return ERROR_OK;
58 }
59
60 void exit_handler(void)
61 {
62 /* close JTAG interface */
63 if (jtag && jtag->quit)
64 jtag->quit();
65 }
66
67 /* implementations of OpenOCD that uses multithreading needs to lock OpenOCD while calling
68 * OpenOCD fn's. No-op in vanilla OpenOCD
69 */
70 void lockBigLock()
71 {
72 }
73 void unlockBigLock()
74 {
75 }
76
77
78 int main(int argc, char *argv[])
79 {
80 /* initialize commandline interface */
81 command_context_t *cmd_ctx, *cfg_cmd_ctx;
82 cmd_ctx = command_init();
83
84 register_command(cmd_ctx, NULL, "version", handle_version_command,
85 COMMAND_EXEC, "show OpenOCD version");
86
87 /* register subsystem commands */
88 server_register_commands(cmd_ctx);
89 telnet_register_commands(cmd_ctx);
90 gdb_register_commands(cmd_ctx);
91 log_register_commands(cmd_ctx);
92 jtag_register_commands(cmd_ctx);
93 interpreter_register_commands(cmd_ctx);
94 xsvf_register_commands(cmd_ctx);
95 target_register_commands(cmd_ctx);
96 flash_register_commands(cmd_ctx);
97 nand_register_commands(cmd_ctx);
98 pld_register_commands(cmd_ctx);
99
100 if (log_init(cmd_ctx) != ERROR_OK)
101 return EXIT_FAILURE;
102 LOG_DEBUG("log init complete");
103
104 LOG_OUTPUT( OPENOCD_VERSION "\n" );
105
106
107 /* DANGER!!! make sure that the line below does not appear in a patch, do not remove */
108 /* DANGER!!! make sure that the line below does not appear in a patch, do not remove */
109 /* DANGER!!! make sure that the line below does not appear in a patch, do not remove */
110 /* DANGER!!! make sure that the line below does not appear in a patch, do not remove */
111 /* DANGER!!! make sure that the line below does not appear in a patch, do not remove */
112 LOG_OUTPUT( "$URL$\n");
113 /* DANGER!!! make sure that the line above does not appear in a patch, do not remove */
114 /* DANGER!!! make sure that the line above does not appear in a patch, do not remove */
115 /* DANGER!!! make sure that the line above does not appear in a patch, do not remove */
116 /* DANGER!!! make sure that the line above does not appear in a patch, do not remove */
117 /* DANGER!!! make sure that the line above does not appear in a patch, do not remove */
118
119 cfg_cmd_ctx = copy_command_context(cmd_ctx);
120 cfg_cmd_ctx->mode = COMMAND_CONFIG;
121 command_set_output_handler(cfg_cmd_ctx, configuration_output_handler, NULL);
122
123 if (parse_cmdline_args(cfg_cmd_ctx, argc, argv) != ERROR_OK)
124 return EXIT_FAILURE;
125
126 if (parse_config_file(cfg_cmd_ctx) != ERROR_OK)
127 return EXIT_FAILURE;
128
129 command_done(cfg_cmd_ctx);
130
131 command_set_output_handler(cmd_ctx, configuration_output_handler, NULL);
132
133 atexit(exit_handler);
134
135 if (jtag_init(cmd_ctx) != ERROR_OK)
136 return EXIT_FAILURE;
137 LOG_DEBUG("jtag init complete");
138
139 if (target_init(cmd_ctx) != ERROR_OK)
140 return EXIT_FAILURE;
141 LOG_DEBUG("target init complete");
142
143 if (flash_init_drivers(cmd_ctx) != ERROR_OK)
144 return EXIT_FAILURE;
145 LOG_DEBUG("flash init complete");
146
147 if (nand_init(cmd_ctx) != ERROR_OK)
148 return EXIT_FAILURE;
149 LOG_DEBUG("NAND init complete");
150
151 if (pld_init(cmd_ctx) != ERROR_OK)
152 return EXIT_FAILURE;
153 LOG_DEBUG("pld init complete");
154
155 /* initialize tcp server */
156 server_init();
157
158 /* initialize telnet subsystem */
159 telnet_init("Open On-Chip Debugger");
160 gdb_init();
161
162 /* call any target resets */
163 if (target_init_reset(cmd_ctx) != ERROR_OK)
164 return EXIT_FAILURE;
165 LOG_DEBUG("target init reset complete");
166
167 /* handle network connections */
168 server_loop(cmd_ctx);
169
170 /* shut server down */
171 server_quit();
172
173 /* free commandline interface */
174 command_done(cmd_ctx);
175
176 return EXIT_SUCCESS;
177 }
178

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)