swd_scan: Add '-m' as targetid argument to swd_scan to prepare multi-drop.
In a real multi-drop setup, the device to use must be specified.
This commit is contained in:
parent
8e2f6937d5
commit
c776e7a9a6
@ -219,8 +219,9 @@ static bool cmd_jtag_scan(target *t, int argc, char **argv)
|
|||||||
bool cmd_swdp_scan(target *t, int argc, char **argv)
|
bool cmd_swdp_scan(target *t, int argc, char **argv)
|
||||||
{
|
{
|
||||||
(void)t;
|
(void)t;
|
||||||
(void)argc;
|
volatile uint32_t targetid = 0;
|
||||||
(void)argv;
|
if (argc > 1)
|
||||||
|
targetid = strtol(argv[1], NULL, 0);
|
||||||
if (platform_target_voltage())
|
if (platform_target_voltage())
|
||||||
gdb_outf("Target voltage: %s\n", platform_target_voltage());
|
gdb_outf("Target voltage: %s\n", platform_target_voltage());
|
||||||
|
|
||||||
@ -231,9 +232,9 @@ bool cmd_swdp_scan(target *t, int argc, char **argv)
|
|||||||
volatile struct exception e;
|
volatile struct exception e;
|
||||||
TRY_CATCH (e, EXCEPTION_ALL) {
|
TRY_CATCH (e, EXCEPTION_ALL) {
|
||||||
#if PC_HOSTED == 1
|
#if PC_HOSTED == 1
|
||||||
devs = platform_adiv5_swdp_scan();
|
devs = platform_adiv5_swdp_scan(targetid);
|
||||||
#else
|
#else
|
||||||
devs = adiv5_swdp_scan();
|
devs = adiv5_swdp_scan(targetid);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
|
@ -35,10 +35,10 @@ typedef uint32_t target_addr;
|
|||||||
struct target_controller;
|
struct target_controller;
|
||||||
|
|
||||||
#if PC_HOSTED == 1
|
#if PC_HOSTED == 1
|
||||||
int platform_adiv5_swdp_scan(void);
|
int platform_adiv5_swdp_scan(uint32_t targetid);
|
||||||
int platform_jtag_scan(const uint8_t *lrlens);
|
int platform_jtag_scan(const uint8_t *lrlens);
|
||||||
#endif
|
#endif
|
||||||
int adiv5_swdp_scan(void);
|
int adiv5_swdp_scan(uint32_t targetid);
|
||||||
int jtag_scan(const uint8_t *lrlens);
|
int jtag_scan(const uint8_t *lrlens);
|
||||||
|
|
||||||
int target_foreach(void (*cb)(int i, target *t, void *context), void *context);
|
int target_foreach(void (*cb)(int i, target *t, void *context), void *context);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the Black Magic Debug project.
|
* This file is part of the Black Magic Debug project.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
* Copyright (C) 2020- 2021 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -119,14 +119,16 @@ void platform_init(int argc, char **argv)
|
|||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform_adiv5_swdp_scan(void)
|
int platform_adiv5_swdp_scan(uint32_t targetid)
|
||||||
{
|
{
|
||||||
info.is_jtag = false;
|
info.is_jtag = false;
|
||||||
platform_max_frequency_set(cl_opts.opt_max_swj_frequency);
|
platform_max_frequency_set(cl_opts.opt_max_swj_frequency);
|
||||||
|
if (targetid && (info.bmp_type != BMP_TYPE_BMP))
|
||||||
|
DEBUG_WARN("Ignoring TARGETID for now!\n");
|
||||||
switch (info.bmp_type) {
|
switch (info.bmp_type) {
|
||||||
case BMP_TYPE_BMP:
|
case BMP_TYPE_BMP:
|
||||||
case BMP_TYPE_LIBFTDI:
|
case BMP_TYPE_LIBFTDI:
|
||||||
return adiv5_swdp_scan();
|
return adiv5_swdp_scan(targetid);
|
||||||
break;
|
break;
|
||||||
case BMP_TYPE_STLINKV2:
|
case BMP_TYPE_STLINKV2:
|
||||||
{
|
{
|
||||||
|
@ -165,6 +165,7 @@ static void cl_help(char **argv)
|
|||||||
DEBUG_WARN("\t-p\t\t: Supplies power to the target (where applicable)\n");
|
DEBUG_WARN("\t-p\t\t: Supplies power to the target (where applicable)\n");
|
||||||
DEBUG_WARN("\t-R\t\t: Reset device\n");
|
DEBUG_WARN("\t-R\t\t: Reset device\n");
|
||||||
DEBUG_WARN("\t-H\t\t: Do not use high level commands (BMP-Remote)\n");
|
DEBUG_WARN("\t-H\t\t: Do not use high level commands (BMP-Remote)\n");
|
||||||
|
DEBUG_WARN("\t-m <target>\t: Use (target)id for SWD multi-drop.\n");
|
||||||
DEBUG_WARN("\t-M <string>\t: Run target specific monitor commands. Quote multi\n");
|
DEBUG_WARN("\t-M <string>\t: Run target specific monitor commands. Quote multi\n");
|
||||||
DEBUG_WARN("\t\t\t word strings. Run \"-M help\" for help.\n");
|
DEBUG_WARN("\t\t\t word strings. Run \"-M help\" for help.\n");
|
||||||
DEBUG_WARN("Flash operation modifiers options:\n");
|
DEBUG_WARN("Flash operation modifiers options:\n");
|
||||||
@ -183,7 +184,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||||||
opt->opt_flash_size = 16 * 1024 *1024;
|
opt->opt_flash_size = 16 * 1024 *1024;
|
||||||
opt->opt_flash_start = 0xffffffff;
|
opt->opt_flash_start = 0xffffffff;
|
||||||
opt->opt_max_swj_frequency = 4000000;
|
opt->opt_max_swj_frequency = 4000000;
|
||||||
while((c = getopt(argc, argv, "eEhHv:d:f:s:I:c:Cln:M:tVtTa:S:jpP:rR")) != -1) {
|
while((c = getopt(argc, argv, "eEhHv:d:f:s:I:c:Cln:m:M:tVtTa:S:jpP:rR")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
@ -270,6 +271,10 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||||||
if (optarg)
|
if (optarg)
|
||||||
opt->opt_target_dev = strtol(optarg, NULL, 0);
|
opt->opt_target_dev = strtol(optarg, NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
if (optarg)
|
||||||
|
opt->opt_targetid = strtol(optarg, NULL, 0);
|
||||||
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
opt->opt_mode = BMP_MODE_MONITOR;
|
opt->opt_mode = BMP_MODE_MONITOR;
|
||||||
if (optarg)
|
if (optarg)
|
||||||
@ -347,7 +352,7 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||||||
if (opt->opt_usejtag) {
|
if (opt->opt_usejtag) {
|
||||||
num_targets = platform_jtag_scan(NULL);
|
num_targets = platform_jtag_scan(NULL);
|
||||||
} else {
|
} else {
|
||||||
num_targets = platform_adiv5_swdp_scan();
|
num_targets = platform_adiv5_swdp_scan(opt->opt_targetid);
|
||||||
}
|
}
|
||||||
if (!num_targets) {
|
if (!num_targets) {
|
||||||
DEBUG_WARN("No target found\n");
|
DEBUG_WARN("No target found\n");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the Black Magic Debug project.
|
* This file is part of the Black Magic Debug project.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019 - 2020 Uwe Bonnes
|
* Copyright (C) 2019 - 2021 Uwe Bonnes
|
||||||
* Written by Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
* Written by Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -49,6 +49,7 @@ typedef struct BMP_CL_OPTIONS_s {
|
|||||||
char *opt_flash_file;
|
char *opt_flash_file;
|
||||||
char *opt_device;
|
char *opt_device;
|
||||||
char *opt_serial;
|
char *opt_serial;
|
||||||
|
uint32_t opt_targetid;
|
||||||
char *opt_ident_string;
|
char *opt_ident_string;
|
||||||
int opt_position;
|
int opt_position;
|
||||||
char *opt_cable;
|
char *opt_cable;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
* Copyright (C) 2011 Black Sphere Technologies Ltd.
|
||||||
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
|
||||||
|
* Copyright (C) 2020- 2021 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -33,10 +34,10 @@
|
|||||||
#define SWDP_ACK_WAIT 0x02
|
#define SWDP_ACK_WAIT 0x02
|
||||||
#define SWDP_ACK_FAULT 0x04
|
#define SWDP_ACK_FAULT 0x04
|
||||||
|
|
||||||
int adiv5_swdp_scan(void)
|
int adiv5_swdp_scan(uint32_t targetid)
|
||||||
{
|
{
|
||||||
uint32_t ack;
|
uint32_t ack;
|
||||||
|
(void) targetid;
|
||||||
target_list_free();
|
target_list_free();
|
||||||
#if PC_HOSTED == 1
|
#if PC_HOSTED == 1
|
||||||
if (platform_swdptap_init()) {
|
if (platform_swdptap_init()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user