blob: 7fcfc35f05549d07ffae248d0d587a112ad1f6be [file] [log] [blame]
Marc Schink3578ec62016-03-17 16:23:03 +01001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2016 Marc Schink <flashrom-dev@marcschink.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17/*
18 * Driver for the J-Link hardware by SEGGER.
19 * See https://www.segger.com/ for more info.
20 */
21
22#include <stdlib.h>
23#include <stdbool.h>
24#include <stdint.h>
25#include <string.h>
26#include <errno.h>
27#include <libjaylink/libjaylink.h>
28
29#include "flash.h"
30#include "programmer.h"
31#include "spi.h"
32
33/*
34 * Maximum number of bytes that can be transferred at once via the JTAG
35 * interface, see jaylink_jtag_io().
36 */
Marc Schinka8c0b682020-08-22 11:29:22 +020037#define JTAG_MAX_TRANSFER_SIZE (32768 / 8)
Marc Schink3578ec62016-03-17 16:23:03 +010038
39/*
40 * Default base frequency in Hz. Used when the base frequency can not be
41 * retrieved from the device.
42 */
43#define DEFAULT_FREQ 16000000
44
45/*
46 * Default frequency divider. Used when the frequency divider can not be
47 * retrieved from the device.
48 */
49#define DEFAULT_FREQ_DIV 4
50
51/* Minimum target voltage required for operation in mV. */
52#define MIN_TARGET_VOLTAGE 1200
53
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +100054struct jlink_spi_data {
Anastasia Klimchuke4a97912021-04-26 10:58:16 +100055 struct jaylink_context *ctx;
56 struct jaylink_device_handle *devh;
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +100057 bool reset_cs;
58 bool enable_target_power;
59};
Marc Schink3578ec62016-03-17 16:23:03 +010060
Anastasia Klimchuke4a97912021-04-26 10:58:16 +100061static bool assert_cs(struct jlink_spi_data *jlink_data)
Marc Schink3578ec62016-03-17 16:23:03 +010062{
63 int ret;
64
Anastasia Klimchuke4a97912021-04-26 10:58:16 +100065 if (jlink_data->reset_cs) {
66 ret = jaylink_clear_reset(jlink_data->devh);
Marc Schink3578ec62016-03-17 16:23:03 +010067
68 if (ret != JAYLINK_OK) {
69 msg_perr("jaylink_clear_reset() failed: %s.\n", jaylink_strerror(ret));
70 return false;
71 }
72 } else {
Anastasia Klimchuke4a97912021-04-26 10:58:16 +100073 ret = jaylink_jtag_clear_trst(jlink_data->devh);
Marc Schink3578ec62016-03-17 16:23:03 +010074
75 if (ret != JAYLINK_OK) {
76 msg_perr("jaylink_jtag_clear_trst() failed: %s.\n", jaylink_strerror(ret));
77 return false;
78 }
79 }
80
81 return true;
82}
83
Anastasia Klimchuke4a97912021-04-26 10:58:16 +100084static bool deassert_cs(struct jlink_spi_data *jlink_data)
Marc Schink3578ec62016-03-17 16:23:03 +010085{
86 int ret;
87
Anastasia Klimchuke4a97912021-04-26 10:58:16 +100088 if (jlink_data->reset_cs) {
89 ret = jaylink_set_reset(jlink_data->devh);
Marc Schink3578ec62016-03-17 16:23:03 +010090
91 if (ret != JAYLINK_OK) {
92 msg_perr("jaylink_set_reset() failed: %s.\n", jaylink_strerror(ret));
93 return false;
94 }
95 } else {
Anastasia Klimchuke4a97912021-04-26 10:58:16 +100096 ret = jaylink_jtag_set_trst(jlink_data->devh);
Marc Schink3578ec62016-03-17 16:23:03 +010097
98 if (ret != JAYLINK_OK) {
99 msg_perr("jaylink_jtag_set_trst() failed: %s.\n", jaylink_strerror(ret));
100 return false;
101 }
102 }
103
104 return true;
105}
106
Edward O'Callaghan5eca4272020-04-12 17:27:53 +1000107static int jlink_spi_send_command(const struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
Marc Schink3578ec62016-03-17 16:23:03 +0100108 const unsigned char *writearr, unsigned char *readarr)
109{
110 uint32_t length;
111 uint8_t *buffer;
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000112 struct jlink_spi_data *jlink_data = flash->mst->spi.data;
Marc Schink3578ec62016-03-17 16:23:03 +0100113
114 length = writecnt + readcnt;
115
116 if (length > JTAG_MAX_TRANSFER_SIZE)
117 return SPI_INVALID_LENGTH;
118
119 buffer = malloc(length);
120
121 if (!buffer) {
122 msg_perr("Memory allocation failed.\n");
123 return SPI_GENERIC_ERROR;
124 }
125
126 /* Reverse all bytes because the device transfers data LSB first. */
127 reverse_bytes(buffer, writearr, writecnt);
128
129 memset(buffer + writecnt, 0x00, readcnt);
130
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000131 if (!assert_cs(jlink_data)) {
Marc Schink3578ec62016-03-17 16:23:03 +0100132 free(buffer);
133 return SPI_PROGRAMMER_ERROR;
134 }
135
136 int ret;
137
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000138 ret = jaylink_jtag_io(jlink_data->devh,
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +1000139 buffer, buffer, buffer, length * 8, JAYLINK_JTAG_VERSION_2);
Marc Schink3578ec62016-03-17 16:23:03 +0100140
141 if (ret != JAYLINK_OK) {
Angel Pons281ed262021-04-16 10:55:03 +0200142 msg_perr("jaylink_jtag_io() failed: %s.\n", jaylink_strerror(ret));
Marc Schink3578ec62016-03-17 16:23:03 +0100143 free(buffer);
144 return SPI_PROGRAMMER_ERROR;
145 }
146
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000147 if (!deassert_cs(jlink_data)) {
Marc Schink3578ec62016-03-17 16:23:03 +0100148 free(buffer);
149 return SPI_PROGRAMMER_ERROR;
150 }
151
152 /* Reverse all bytes because the device transfers data LSB first. */
153 reverse_bytes(readarr, buffer + writecnt, readcnt);
154 free(buffer);
155
156 return 0;
157}
158
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +1000159static struct spi_master spi_master_jlink_spi = {
Marc Schink3578ec62016-03-17 16:23:03 +0100160 /* Maximum data read size in one go (excluding opcode+address). */
161 .max_data_read = JTAG_MAX_TRANSFER_SIZE - 5,
162 /* Maximum data write size in one go (excluding opcode+address). */
163 .max_data_write = JTAG_MAX_TRANSFER_SIZE - 5,
164 .command = jlink_spi_send_command,
165 .multicommand = default_spi_send_multicommand,
166 .read = default_spi_read,
167 .write_256 = default_spi_write_256,
168 .write_aai = default_spi_write_aai,
169 .features = SPI_MASTER_4BA,
170};
171
172static int jlink_spi_shutdown(void *data)
173{
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000174 struct jlink_spi_data *jlink_data = data;
175 if (jlink_data->devh) {
176 if (jlink_data->enable_target_power) {
177 int ret = jaylink_set_target_power(jlink_data->devh, false);
Marc Schink137f02f2020-08-23 16:19:44 +0200178
179 if (ret != JAYLINK_OK) {
180 msg_perr("jaylink_set_target_power() failed: %s.\n",
181 jaylink_strerror(ret));
182 }
183 }
184
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000185 jaylink_close(jlink_data->devh);
Marc Schink137f02f2020-08-23 16:19:44 +0200186 }
Marc Schink3578ec62016-03-17 16:23:03 +0100187
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000188 jaylink_exit(jlink_data->ctx);
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +1000189
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000190 /* jlink_data->ctx, jlink_data->devh are freed by jaylink_close and jaylink_exit */
191 free(jlink_data);
Marc Schink3578ec62016-03-17 16:23:03 +0100192 return 0;
193}
194
Thomas Heijligencc853d82021-05-04 15:32:17 +0200195static int jlink_spi_init(void)
Marc Schink3578ec62016-03-17 16:23:03 +0100196{
197 char *arg;
198 unsigned long speed = 0;
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +1000199 struct jaylink_context *jaylink_ctx = NULL;
200 struct jaylink_device_handle *jaylink_devh = NULL;
201 bool reset_cs;
202 bool enable_target_power;
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000203 struct jlink_spi_data *jlink_data = NULL;
Marc Schink3578ec62016-03-17 16:23:03 +0100204
Marc Schink3578ec62016-03-17 16:23:03 +0100205 arg = extract_programmer_param("spispeed");
206
207 if (arg) {
208 char *endptr;
209
210 errno = 0;
211 speed = strtoul(arg, &endptr, 10);
212
213 if (*endptr != '\0' || errno != 0) {
214 msg_perr("Invalid SPI speed specified: %s.\n", arg);
215 free(arg);
216 return 1;
217 }
218
219 if (speed < 1) {
220 msg_perr("SPI speed must be at least 1 kHz.\n");
221 free(arg);
222 return 1;
223 }
224 }
225
226 free(arg);
227
228 int ret;
229 bool use_serial_number;
230 uint32_t serial_number;
231
232 arg = extract_programmer_param("serial");
233
234 if (arg) {
235 if (!strlen(arg)) {
Angel Pons281ed262021-04-16 10:55:03 +0200236 msg_perr("Empty serial number specified.\n");
Marc Schink3578ec62016-03-17 16:23:03 +0100237 free(arg);
238 return 1;
239 }
240
241 ret = jaylink_parse_serial_number(arg, &serial_number);
242
243 if (ret == JAYLINK_ERR) {
244 msg_perr("Invalid serial number specified: %s.\n", arg);
245 free(arg);
246 return 1;
247 } if (ret != JAYLINK_OK) {
248 msg_perr("jaylink_parse_serial_number() failed: %s.\n", jaylink_strerror(ret));
249 free(arg);
250 return 1;
251 }
252
253 use_serial_number = true;
254 } else {
255 use_serial_number = false;
256 }
257
258 free(arg);
259
260 reset_cs = true;
261 arg = extract_programmer_param("cs");
262
263 if (arg) {
264 if (!strcasecmp(arg, "reset")) {
265 reset_cs = true;
266 } else if (!strcasecmp(arg, "trst")) {
267 reset_cs = false;
268 } else {
269 msg_perr("Invalid chip select pin specified: '%s'.\n", arg);
270 free(arg);
271 return 1;
272 }
273 }
274
275 free(arg);
276
277 if (reset_cs)
278 msg_pdbg("Using RESET as chip select signal.\n");
279 else
280 msg_pdbg("Using TRST as chip select signal.\n");
281
Marc Schink137f02f2020-08-23 16:19:44 +0200282 enable_target_power = false;
283 arg = extract_programmer_param("power");
284
285 if (arg) {
286 if (!strcasecmp(arg, "on")) {
287 enable_target_power = true;
288 } else {
289 msg_perr("Invalid value for 'power' argument: '%s'.\n", arg);
290 free(arg);
291 return 1;
292 }
293 }
294
295 free(arg);
296
Marc Schink3578ec62016-03-17 16:23:03 +0100297 ret = jaylink_init(&jaylink_ctx);
298
299 if (ret != JAYLINK_OK) {
300 msg_perr("jaylink_init() failed: %s.\n", jaylink_strerror(ret));
301 return 1;
302 }
303
304 ret = jaylink_discovery_scan(jaylink_ctx, 0);
305
306 if (ret != JAYLINK_OK) {
Angel Pons281ed262021-04-16 10:55:03 +0200307 msg_perr("jaylink_discovery_scan() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000308 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100309 }
310
311 struct jaylink_device **devs;
312
313 ret = jaylink_get_devices(jaylink_ctx, &devs, NULL);
314
315 if (ret != JAYLINK_OK) {
316 msg_perr("jaylink_get_devices() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000317 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100318 }
319
320 if (!use_serial_number)
321 msg_pdbg("No device selected, using first device.\n");
322
323 size_t i;
324 struct jaylink_device *dev;
325 bool device_found = false;
326
327 for (i = 0; devs[i]; i++) {
328 if (use_serial_number) {
329 uint32_t tmp;
330
331 ret = jaylink_device_get_serial_number(devs[i], &tmp);
332
333 if (ret == JAYLINK_ERR_NOT_AVAILABLE) {
334 continue;
335 } else if (ret != JAYLINK_OK) {
336 msg_pwarn("jaylink_device_get_serial_number() failed: %s.\n",
337 jaylink_strerror(ret));
338 continue;
339 }
340
341 if (serial_number != tmp)
342 continue;
343 }
344
345 ret = jaylink_open(devs[i], &jaylink_devh);
346
347 if (ret == JAYLINK_OK) {
348 dev = devs[i];
349 device_found = true;
350 break;
351 }
352
353 jaylink_devh = NULL;
354 }
355
356 jaylink_free_devices(devs, true);
357
358 if (!device_found) {
359 msg_perr("No J-Link device found.\n");
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000360 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100361 }
362
363 size_t length;
364 char *firmware_version;
365
366 ret = jaylink_get_firmware_version(jaylink_devh, &firmware_version,
367 &length);
368
369 if (ret != JAYLINK_OK) {
370 msg_perr("jaylink_get_firmware_version() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000371 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100372 } else if (length > 0) {
373 msg_pdbg("Firmware: %s\n", firmware_version);
374 free(firmware_version);
375 }
376
377 ret = jaylink_device_get_serial_number(dev, &serial_number);
378
379 if (ret == JAYLINK_OK) {
380 msg_pdbg("S/N: %" PRIu32 "\n", serial_number);
381 } else if (ret == JAYLINK_ERR_NOT_AVAILABLE) {
382 msg_pdbg("S/N: N/A\n");
383 } else {
384 msg_perr("jaylink_device_get_serial_number() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000385 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100386 }
387
Angel Pons7e134562021-06-07 13:29:13 +0200388 uint8_t caps[JAYLINK_DEV_EXT_CAPS_SIZE] = { 0 };
Marc Schink3578ec62016-03-17 16:23:03 +0100389
Marc Schink3578ec62016-03-17 16:23:03 +0100390 ret = jaylink_get_caps(jaylink_devh, caps);
391
392 if (ret != JAYLINK_OK) {
393 msg_perr("jaylink_get_caps() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000394 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100395 }
396
397 if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_GET_EXT_CAPS)) {
398 ret = jaylink_get_extended_caps(jaylink_devh, caps);
399
400 if (ret != JAYLINK_OK) {
Angel Pons281ed262021-04-16 10:55:03 +0200401 msg_perr("jaylink_get_extended_caps() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000402 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100403 }
404 }
405
Marc Schink137f02f2020-08-23 16:19:44 +0200406 if (enable_target_power) {
407 if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SET_TARGET_POWER)) {
408 msg_perr("Device does not support target power.\n");
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000409 goto init_err;
Marc Schink137f02f2020-08-23 16:19:44 +0200410 }
411 }
412
Marc Schink3578ec62016-03-17 16:23:03 +0100413 uint32_t ifaces;
414
415 ret = jaylink_get_available_interfaces(jaylink_devh, &ifaces);
416
417 if (ret != JAYLINK_OK) {
418 msg_perr("jaylink_get_available_interfaces() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000419 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100420 }
421
422 if (!(ifaces & (1 << JAYLINK_TIF_JTAG))) {
423 msg_perr("Device does not support JTAG interface.\n");
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000424 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100425 }
426
427 ret = jaylink_select_interface(jaylink_devh, JAYLINK_TIF_JTAG, NULL);
428
429 if (ret != JAYLINK_OK) {
430 msg_perr("jaylink_select_interface() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000431 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100432 }
433
Marc Schink137f02f2020-08-23 16:19:44 +0200434 if (enable_target_power) {
435 ret = jaylink_set_target_power(jaylink_devh, true);
436
437 if (ret != JAYLINK_OK) {
438 msg_perr("jaylink_set_target_power() failed: %s.\n", jaylink_strerror(ret));
439 return 1;
440 }
441
442 /* Wait some time until the target is powered up. */
443 internal_sleep(10000);
444 }
445
Marc Schink3578ec62016-03-17 16:23:03 +0100446 struct jaylink_hardware_status hwstat;
447
448 ret = jaylink_get_hardware_status(jaylink_devh, &hwstat);
449
450 if (ret != JAYLINK_OK) {
451 msg_perr("jaylink_get_hardware_status() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000452 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100453 }
454
455 msg_pdbg("VTarget: %u.%03u V\n", hwstat.target_voltage / 1000,
456 hwstat.target_voltage % 1000);
457
458 if (hwstat.target_voltage < MIN_TARGET_VOLTAGE) {
459 msg_perr("Target voltage is below %u.%03u V. You need to attach VTref to the I/O voltage of "
460 "the chip.\n", MIN_TARGET_VOLTAGE / 1000, MIN_TARGET_VOLTAGE % 1000);
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000461 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100462 }
463
464 struct jaylink_speed device_speeds;
465
466 device_speeds.freq = DEFAULT_FREQ;
467 device_speeds.div = DEFAULT_FREQ_DIV;
468
469 if (jaylink_has_cap(caps, JAYLINK_DEV_CAP_GET_SPEEDS)) {
470 ret = jaylink_get_speeds(jaylink_devh, &device_speeds);
471
472 if (ret != JAYLINK_OK) {
473 msg_perr("jaylink_get_speeds() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000474 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100475 }
476 }
477
478 device_speeds.freq /= 1000;
479
480 msg_pdbg("Maximum SPI speed: %" PRIu32 " kHz\n", device_speeds.freq / device_speeds.div);
481
482 if (!speed) {
483 speed = device_speeds.freq / device_speeds.div;
484 msg_pdbg("SPI speed not specified, using %lu kHz.\n", speed);
485 }
486
487 if (speed > (device_speeds.freq / device_speeds.div)) {
488 msg_perr("Specified SPI speed of %lu kHz is too high. Maximum is %" PRIu32 " kHz.\n", speed,
489 device_speeds.freq / device_speeds.div);
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000490 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100491 }
492
493 ret = jaylink_set_speed(jaylink_devh, speed);
494
495 if (ret != JAYLINK_OK) {
496 msg_perr("jaylink_set_speed() failed: %s.\n", jaylink_strerror(ret));
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000497 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100498 }
499
500 msg_pdbg("SPI speed: %lu kHz\n", speed);
501
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000502 jlink_data = calloc(1, sizeof(*jlink_data));
503 if (!jlink_data) {
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +1000504 msg_perr("Unable to allocate space for SPI master data\n");
505 goto init_err;
506 }
507
508 /* jaylink_ctx, jaylink_devh are allocated by jaylink_init and jaylink_open */
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000509 jlink_data->ctx = jaylink_ctx;
510 jlink_data->devh = jaylink_devh;
511 jlink_data->reset_cs = reset_cs;
512 jlink_data->enable_target_power = enable_target_power;
513 spi_master_jlink_spi.data = jlink_data;
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +1000514
Marc Schink3578ec62016-03-17 16:23:03 +0100515 /* Ensure that the CS signal is not active initially. */
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000516 if (!deassert_cs(jlink_data))
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000517 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100518
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000519 if (register_shutdown(jlink_spi_shutdown, jlink_data))
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000520 goto init_err;
Marc Schink3578ec62016-03-17 16:23:03 +0100521 register_spi_master(&spi_master_jlink_spi);
522
523 return 0;
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000524
525init_err:
526 if (jaylink_devh)
527 jaylink_close(jaylink_devh);
528
529 jaylink_exit(jaylink_ctx);
530
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +1000531 /* jaylink_ctx, jaylink_devh are freed by jaylink_close and jaylink_exit */
Anastasia Klimchuke4a97912021-04-26 10:58:16 +1000532 if (jlink_data)
533 free(jlink_data);
Anastasia Klimchuk9e698f92021-04-21 12:21:49 +1000534
Anastasia Klimchuk00c2e802021-04-14 09:52:36 +1000535 return 1;
Marc Schink3578ec62016-03-17 16:23:03 +0100536}
Thomas Heijligencc853d82021-05-04 15:32:17 +0200537
538const struct programmer_entry programmer_jlink_spi = {
539 .name = "jlink_spi",
540 .type = OTHER,
541 .init = jlink_spi_init,
542 .devs.note = "SEGGER J-Link and compatible devices\n",
543 .map_flash_region = fallback_map,
544 .unmap_flash_region = fallback_unmap,
545 .delay = internal_delay,
546};