1 /***************************************************************************
2 * Copyright (C) 2006 by Anders Larsen *
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 #include <jtag/interface.h>
31 #define AT91C_BASE_SYS (0xfffff000)
39 #define PIO_PER (0) /* PIO enable */
40 #define PIO_OER (4) /* output enable */
41 #define PIO_ODR (5) /* output disable */
42 #define PIO_SODR (12) /* set output data */
43 #define PIO_CODR (13) /* clear output data */
44 #define PIO_PDSR (15) /* pin data status */
45 #define PIO_PPUER (25) /* pull-up enable */
47 #define NC (0) /* not connected */
84 int TDO_PIO
; /* PIO holding TDO */
85 uint32_t TDO_MASK
; /* TDO bitmask */
86 int TRST_PIO
; /* PIO holding TRST */
87 uint32_t TRST_MASK
; /* TRST bitmask */
88 int TMS_PIO
; /* PIO holding TMS */
89 uint32_t TMS_MASK
; /* TMS bitmask */
90 int TCK_PIO
; /* PIO holding TCK */
91 uint32_t TCK_MASK
; /* TCK bitmask */
92 int TDI_PIO
; /* PIO holding TDI */
93 uint32_t TDI_MASK
; /* TDI bitmask */
94 int SRST_PIO
; /* PIO holding SRST */
95 uint32_t SRST_MASK
; /* SRST bitmask */
98 static struct device_t devices
[] =
100 { "rea_ecr", PIOD
, P27
, PIOA
, NC
, PIOD
, P23
, PIOD
, P24
, PIOD
, P26
, PIOC
, P5
},
105 static char* at91rm9200_device
;
107 /* interface variables
109 static struct device_t
* device
;
110 static int dev_mem_fd
;
111 static void *sys_controller
;
112 static uint32_t* pio_base
;
114 /* low level command set
116 static int at91rm9200_read(void);
117 static void at91rm9200_write(int tck
, int tms
, int tdi
);
118 static void at91rm9200_reset(int trst
, int srst
);
120 static int at91rm9200_speed(int speed
);
121 static int at91rm9200_register_commands(struct command_context
*cmd_ctx
);
122 static int at91rm9200_init(void);
123 static int at91rm9200_quit(void);
125 struct jtag_interface at91rm9200_interface
=
127 .name
= "at91rm9200",
129 .supported
= DEBUG_CAP_TMS_SEQ
,
130 .execute_queue
= bitbang_execute_queue
,
132 .speed
= at91rm9200_speed
,
133 .register_commands
= at91rm9200_register_commands
,
134 .init
= at91rm9200_init
,
135 .quit
= at91rm9200_quit
,
138 static struct bitbang_interface at91rm9200_bitbang
=
140 .read
= at91rm9200_read
,
141 .write
= at91rm9200_write
,
142 .reset
= at91rm9200_reset
,
146 static int at91rm9200_read(void)
148 return (pio_base
[device
->TDO_PIO
+ PIO_PDSR
] & device
->TDO_MASK
) != 0;
151 static void at91rm9200_write(int tck
, int tms
, int tdi
)
154 pio_base
[device
->TCK_PIO
+ PIO_SODR
] = device
->TCK_MASK
;
156 pio_base
[device
->TCK_PIO
+ PIO_CODR
] = device
->TCK_MASK
;
159 pio_base
[device
->TMS_PIO
+ PIO_SODR
] = device
->TMS_MASK
;
161 pio_base
[device
->TMS_PIO
+ PIO_CODR
] = device
->TMS_MASK
;
164 pio_base
[device
->TDI_PIO
+ PIO_SODR
] = device
->TDI_MASK
;
166 pio_base
[device
->TDI_PIO
+ PIO_CODR
] = device
->TDI_MASK
;
169 /* (1) assert or (0) deassert reset lines */
170 static void at91rm9200_reset(int trst
, int srst
)
173 pio_base
[device
->TRST_PIO
+ PIO_SODR
] = device
->TRST_MASK
;
175 pio_base
[device
->TRST_PIO
+ PIO_CODR
] = device
->TRST_MASK
;
178 pio_base
[device
->SRST_PIO
+ PIO_SODR
] = device
->SRST_MASK
;
180 pio_base
[device
->SRST_PIO
+ PIO_CODR
] = device
->SRST_MASK
;
183 static int at91rm9200_speed(int speed
)
189 static int at91rm9200_handle_device_command(struct command_context
*cmd_ctx
, char *cmd
, char **CMD_ARGV
, int argc
)
194 /* only if the device name wasn't overwritten by cmdline */
195 if (at91rm9200_device
== 0)
197 at91rm9200_device
= malloc(strlen(CMD_ARGV
[0]) + sizeof(char));
198 strcpy(at91rm9200_device
, CMD_ARGV
[0]);
204 static const struct command_registration at91rm9200_command_handlers
[] = {
206 .name
= "at91rm9200_device",
207 .handler
= &at91rm9200_handle_device_command
,
208 .mode
= COMMAND_CONFIG
,
209 .help
= "query armjtagew info",
213 static int at91rm9200_register_commands(struct command_context
*cmd_ctx
)
215 return register_commands(cmd_ctx
, NULL
, at91rm9200_command_handlers
);
218 static int at91rm9200_init(void)
220 struct device_t
*cur_device
;
222 cur_device
= devices
;
224 if (at91rm9200_device
== NULL
|| at91rm9200_device
[0] == 0)
226 at91rm9200_device
= "rea_ecr";
227 LOG_WARNING("No at91rm9200 device specified, using default 'rea_ecr'");
230 while (cur_device
->name
)
232 if (strcmp(cur_device
->name
, at91rm9200_device
) == 0)
242 LOG_ERROR("No matching device found for %s", at91rm9200_device
);
243 return ERROR_JTAG_INIT_FAILED
;
246 bitbang_interface
= &at91rm9200_bitbang
;
248 dev_mem_fd
= open("/dev/mem", O_RDWR
| O_SYNC
);
249 if (dev_mem_fd
< 0) {
251 return ERROR_JTAG_INIT_FAILED
;
254 sys_controller
= mmap(NULL
, 4096, PROT_READ
| PROT_WRITE
,
255 MAP_SHARED
, dev_mem_fd
, AT91C_BASE_SYS
);
256 if (sys_controller
== MAP_FAILED
) {
259 return ERROR_JTAG_INIT_FAILED
;
261 pio_base
= (uint32_t*)sys_controller
+ 0x100;
264 * Configure TDO as an input, and TDI, TCK, TMS, TRST, SRST
265 * as outputs. Drive TDI and TCK low, and TMS/TRST/SRST high.
267 pio_base
[device
->TDI_PIO
+ PIO_CODR
] = device
->TDI_MASK
;
268 pio_base
[device
->TDI_PIO
+ PIO_OER
] = device
->TDI_MASK
;
269 pio_base
[device
->TDI_PIO
+ PIO_PER
] = device
->TDI_MASK
;
270 pio_base
[device
->TCK_PIO
+ PIO_CODR
] = device
->TCK_MASK
;
271 pio_base
[device
->TCK_PIO
+ PIO_OER
] = device
->TCK_MASK
;
272 pio_base
[device
->TCK_PIO
+ PIO_PER
] = device
->TCK_MASK
;
273 pio_base
[device
->TMS_PIO
+ PIO_SODR
] = device
->TMS_MASK
;
274 pio_base
[device
->TMS_PIO
+ PIO_OER
] = device
->TMS_MASK
;
275 pio_base
[device
->TMS_PIO
+ PIO_PER
] = device
->TMS_MASK
;
276 pio_base
[device
->TRST_PIO
+ PIO_SODR
] = device
->TRST_MASK
;
277 pio_base
[device
->TRST_PIO
+ PIO_OER
] = device
->TRST_MASK
;
278 pio_base
[device
->TRST_PIO
+ PIO_PER
] = device
->TRST_MASK
;
279 pio_base
[device
->SRST_PIO
+ PIO_SODR
] = device
->SRST_MASK
;
280 pio_base
[device
->SRST_PIO
+ PIO_OER
] = device
->SRST_MASK
;
281 pio_base
[device
->SRST_PIO
+ PIO_PER
] = device
->SRST_MASK
;
282 pio_base
[device
->TDO_PIO
+ PIO_ODR
] = device
->TDO_MASK
;
283 pio_base
[device
->TDO_PIO
+ PIO_PPUER
] = device
->TDO_MASK
;
284 pio_base
[device
->TDO_PIO
+ PIO_PER
] = device
->TDO_MASK
;
289 static int at91rm9200_quit(void)
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)