Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: swd command message swd naming #1640

Merged
merged 6 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions UsingRTT.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In another window open a debugger:
```
$ gdb
(gdb) target extended-remote /dev/ttyBmpGdb
(gdb) monitor swdp_scan
(gdb) monitor swd_scan
(gdb) attach 1
(gdb) monitor rtt
(gdb) run
Expand Down Expand Up @@ -154,7 +154,7 @@ As an example, if the RTT identifier is "IDENT STR":
```
$ gdb
(gdb) target extended-remote /dev/ttyBmpGdb
(gdb) monitor swdp_scan
(gdb) monitor swd_scan
(gdb) attach 1
(gdb) monitor rtt ident IDENT_STR
(gdb) monitor rtt
Expand Down Expand Up @@ -183,7 +183,7 @@ two COM ports. Connect an ansi terminal emulator to the higher numbered of the t
Sample gdb session:
```
(gdb) target extended-remote COM3
(gdb) monitor swdp_scan
(gdb) monitor swd_scan
(gdb) attach 1
(gdb) monitor rtt
(gdb) run
Expand Down Expand Up @@ -217,7 +217,7 @@ In another window :
```
gdb
(gdb) target extended-remote /dev/ttyBmpGdb
(gdb) monitor swdp_scan
(gdb) monitor swd_scan
(gdb) attach 1
(gdb) monitor rtt
(gdb) run
Expand All @@ -239,7 +239,7 @@ In another Terminal window, connect gdb to /dev/cu.usbmodemDDCEC9EC1 :
```
gdb
(gdb) target extended-remote /dev/cu.usbmodemDDCEC9EC1
(gdb) monitor swdp_scan
(gdb) monitor swd_scan
(gdb) attach 1
(gdb) monitor rtt
(gdb) run
Expand Down
2 changes: 1 addition & 1 deletion UsingSWO.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Attach to BMP to your PC:
gdb> target extended_remote /dev/ttyBmpGdb # Choose BMP as the remote target
gdb> mon traceswo # Start SWO output
gdb> mon traceswo 115200 # If async SWO is used, set the decoding baud rate that matches the target
gdb> mon swdp_scan # Scan for the SWD device
gdb> mon swd_scan # Scan for the SWD device
gdb> attach 1 # Attach to the device
gdb> run # Start the program execution
```
Expand Down
21 changes: 11 additions & 10 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* This file implements a basic command interpreter for GDB 'monitor'
* commands.
/*
* This file implements a basic command interpreter for GDB 'monitor' commands.
*/

#include "general.h"
Expand Down Expand Up @@ -56,7 +56,7 @@ static bool cmd_version(target_s *t, int argc, const char **argv);
static bool cmd_help(target_s *t, int argc, const char **argv);

static bool cmd_jtag_scan(target_s *target, int argc, const char **argv);
static bool cmd_swd_scan(target_s *t, int argc, const char **argv);
static bool cmd_swd_scan(target_s *target, int argc, const char **argv);
static bool cmd_auto_scan(target_s *t, int argc, const char **argv);
static bool cmd_frequency(target_s *t, int argc, const char **argv);
static bool cmd_targets(target_s *t, int argc, const char **argv);
Expand Down Expand Up @@ -174,12 +174,13 @@ bool cmd_version(target_s *t, int argc, const char **argv)
char ident[256];
gdb_ident(ident, sizeof(ident));
DEBUG_WARN("%s\n", ident);
DEBUG_WARN("Copyright (C) 2010-2023 Black Magic Debug Project\n");
DEBUG_WARN("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\n");
#else
perigoso marked this conversation as resolved.
Show resolved Hide resolved
gdb_out(BOARD_IDENT);
gdb_outf(", Hardware Version %d\n", platform_hwversion());
gdb_out("Copyright (C) 2022 Black Magic Debug Project\n");
gdb_out("License GPLv3+: GNU GPL version 3 or later "
"<http://gnu.org/licenses/gpl.html>\n\n");
gdb_out("Copyright (C) 2010-2023 Black Magic Debug Project\n");
gdb_out("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\n");
#endif

return true;
Expand Down Expand Up @@ -245,9 +246,9 @@ static bool cmd_jtag_scan(target_s *target, int argc, const char **argv)
return true;
}

bool cmd_swd_scan(target_s *t, int argc, const char **argv)
bool cmd_swd_scan(target_s *target, int argc, const char **argv)
{
(void)t;
(void)target;
volatile uint32_t targetid = 0;
if (argc > 1)
targetid = strtoul(argv[1], NULL, 0);
Expand Down Expand Up @@ -278,7 +279,7 @@ bool cmd_swd_scan(target_s *t, int argc, const char **argv)
if (!scan_result) {
platform_target_clk_output_enable(false);
platform_nrst_set_val(false);
gdb_out("SW-DP scan failed!\n");
gdb_out("SWD scan failed!\n");
return false;
}

Expand Down Expand Up @@ -319,7 +320,7 @@ bool cmd_auto_scan(target_s *t, int argc, const char **argv)
if (scan_result)
break;

gdb_out("SW-DP scan found no devices.\n");
gdb_out("SWD scan found no devices.\n");
}
switch (e.type) {
case EXCEPTION_TIMEOUT:
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/hosted/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ bool scan_for_targets(const bmda_cli_options_s *const opt)
DEBUG_WARN("JTAG scan found no devices, trying SWD.\n");
if (bmda_swd_scan(opt->opt_targetid))
return true;
DEBUG_ERROR("SW-DP scan failed!\n");
DEBUG_ERROR("SWD scan failed!\n");
return false;
}

Expand Down
1 change: 0 additions & 1 deletion src/target/adiv5.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@
typedef struct adiv5_access_port adiv5_access_port_s;
typedef struct adiv5_debug_port adiv5_debug_port_s;

/* Try to keep this somewhat absract for later adding SW-DP */
struct adiv5_debug_port {
int refcnt;

Expand Down
18 changes: 11 additions & 7 deletions src/target/adiv5_swd.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* This file implements the SW-DP specific functions of the
/*
* This file implements the SWD specific functions of the
* ARM Debug Interface v5 Architecture Specification, ARM doc IHI0031A.
*/

Expand Down Expand Up @@ -109,15 +110,18 @@ static void jtag_to_swd_sequence()
*/

/* ARM deprecates use of these sequences on devices where the dormant state of operation is implemented */
DEBUG_WARN("Deprecated TAG-to-SWD sequence\n");
DEBUG_WARN("Deprecated JTAG to SWD sequence\n");

/* SWD interface must be in reset state */
swd_line_reset_sequence(false);

/* Send the 16-bit JTAG-to-SWD select sequence on SWDIOTMS */
/* Send the 16-bit JTAG-to-SWD select sequence on SWDIO/TMS */
swd_proc.seq_out(ADIV5_JTAG_TO_SWD_SELECT_SEQUENCE, 16U);

/* This ensures that if SWJ-DP was already in SWD operation before sending the select sequence, the interface enters reset state */
/*
* This ensures that if a SWD/JTAG DP was already in SWD operation before sending the select sequence,
* the interface enters reset state
*/
swd_line_reset_sequence(true);
}

Expand Down Expand Up @@ -272,12 +276,12 @@ bool adiv5_swd_scan(const uint32_t targetid)
* have never seen before. However, if the debug tools can be provided with the target ID of such targets by the user
* then the contents of the target can be auto-detected as normal.
* To protect against multiple selected devices all driving the line simultaneously SWD protocol version 2 requires:
* - For multi-drop SWJ-DP, the JTAG connection is selected out of powerup reset. JTAG does not drive the line.
* - For multi-drop SW-DP, the DP is in the dormant state out of powerup reset.
* - For multi-drop SWD/JTAG DPs, the JTAG connection is selected out of powerup reset. JTAG does not drive the line.
* - For multi-drop SWD DPs, the DP is in the dormant state out of powerup reset.
*/
void adiv5_swd_multidrop_scan(adiv5_debug_port_s *const dp, const uint32_t targetid)
{
DEBUG_INFO("Handling swd multi-drop, TARGETID 0x%08" PRIx32 "\n", targetid);
DEBUG_INFO("Handling SWD multi-drop, TARGETID 0x%08" PRIx32 "\n", targetid);

/* Scan all 16 possible instances (4-bit instance ID) */
for (size_t instance = 0; instance < 16U; instance++) {
Expand Down
3 changes: 2 additions & 1 deletion src/target/jtag_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ bool jtag_scan(void)

/*
* Initialise the JTAG backend if it's not already
* This will automatically do the SWD-to-JTAG sequence just in case we've got any SWJ-DP's in chain
* This will automatically do the SWD-to-JTAG sequence just in case we've got
* any SWD/JTAG DPs in the chain
*/
DEBUG_INFO("Resetting TAP\n");
#if PC_HOSTED == 1
Expand Down