runners: stlink_gdbserver: make it possible to disable SWD mode
The "--swd" argument had both an action='store_true' and default value of
True so it wasn't possible to disable it: providing the argument would set
its value to True, and not providing it would use the default=True!
Add a new argument "--no-swd" which shares its destination variable with
"--swd", but with action='store_false', such that either can be provided
to enable/disable SWD mode. Both arguments are placed in a mutually
exclusive group and use a common help message.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
diff --git a/scripts/west_commands/runners/stlink_gdbserver.py b/scripts/west_commands/runners/stlink_gdbserver.py
index da98682..213f61e 100644
--- a/scripts/west_commands/runners/stlink_gdbserver.py
+++ b/scripts/west_commands/runners/stlink_gdbserver.py
@@ -100,7 +100,10 @@
def do_add_parser(cls, parser: argparse.ArgumentParser):
# Expose a subset of the ST-LINK GDB server arguments
parser.add_argument(
- "--swd", action='store_true', default=True, help="Enable SWD debug mode"
+ "--swd",
+ default=True,
+ action=argparse.BooleanOptionalAction,
+ help="Enable SWD debug mode (default: %(default)s)\nUse --no-swd to disable.",
)
parser.add_argument("--apid", type=int, default=0, help="Target DAP ID")
parser.add_argument(