Skip to content

Commit

Permalink
hosted/cli: Add a cmdline option for HID CMSIS-DAP
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed Sep 29, 2024
1 parent ba4cbe7 commit cece044
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/platforms/hosted/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ static const getopt_option_s long_options[] = {
#ifdef ENABLE_GPIOD
{"gpiod", required_argument, NULL, 'g'},
#endif
{"allow-fallback", no_argument, NULL, 'k'},
{NULL, 0, NULL, 0},
};

Expand All @@ -264,7 +265,7 @@ void cl_init(bmda_cli_options_s *opt, int argc, char **argv)
opt->opt_mode = BMP_MODE_DEBUG;
while (true) {
const int option =
getopt_long(argc, argv, "eEFhHv:Od:f:s:I:c:Cln:m:M:wVtTa:S:jApP:rR::" GPIOD_ARG_STR, long_options, NULL);
getopt_long(argc, argv, "eEFhHv:Od:f:s:I:c:Cln:m:M:wVtTa:S:jApP:rR::k" GPIOD_ARG_STR, long_options, NULL);
if (option == -1)
break;

Expand Down Expand Up @@ -421,6 +422,9 @@ void cl_init(bmda_cli_options_s *opt, int argc, char **argv)
if (optarg)
opt->opt_gpio_map = optarg;
#endif
case 'k':
opt->opt_cmsisdap_allow_fallback = true;
break;
}
}
if (optind && argv[optind]) {
Expand Down
1 change: 1 addition & 0 deletions src/platforms/hosted/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct bmda_cli_options {
uint32_t opt_max_frequency;
size_t opt_flash_size;
char *opt_gpio_map;
bool opt_cmsisdap_allow_fallback;
} bmda_cli_options_s;

void cl_init(bmda_cli_options_s *opt, int argc, char **argv);
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/hosted/cmsis_dap.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static bool dap_init_bulk(void)
}

/* LPC845 Breakout Board Rev. 0 reports an invalid response with > 65 bytes */
bool dap_init(void)
bool dap_init(bool allow_fallback)
{
/* Initialise the adaptor via a suitable protocol */
if (bmda_probe_info.in_ep && bmda_probe_info.out_ep)
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/hosted/cmsis_dap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "adiv5.h"
#include "cli.h"

bool dap_init(void);
bool dap_init(bool allow_fallback);
void dap_exit_function(void);
void dap_adiv5_dp_init(adiv5_debug_port_s *dp);
void dap_adiv6_dp_init(adiv5_debug_port_s *dp);
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/hosted/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void platform_init(int argc, char **argv)
break;

case PROBE_TYPE_CMSIS_DAP:
if (!dap_init())
if (!dap_init(cl_opts.opt_cmsisdap_allow_fallback))
exit(1);
break;

Expand Down

0 comments on commit cece044

Please sign in to comment.