From 4d18496a6fb80740f3e93caa5c51199122aaa951 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Thu, 6 Aug 2020 12:20:27 +0200 Subject: [PATCH] hosted: Allow to disable high level commands for BMP. Useful for tracking low level problems on native with hosted. --- src/platforms/hosted/platform.c | 7 ++++++- src/platforms/pc/cl_utils.c | 6 +++++- src/platforms/pc/cl_utils.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/platforms/hosted/platform.c b/src/platforms/hosted/platform.c index 1bb738a..e5bd906 100644 --- a/src/platforms/hosted/platform.c +++ b/src/platforms/hosted/platform.c @@ -263,9 +263,10 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info) return (found_debuggers == 1) ? 0 : -1; } +static BMP_CL_OPTIONS_t cl_opts; + void platform_init(int argc, char **argv) { - BMP_CL_OPTIONS_t cl_opts = {0}; cl_opts.opt_idstring = "Blackmagic PC-Hosted"; cl_init(&cl_opts, argc, argv); atexit(exit_function); @@ -426,6 +427,10 @@ void platform_adiv5_dp_defaults(ADIv5_DP_t *dp) { switch (info.bmp_type) { case BMP_TYPE_BMP: + if (cl_opts.opt_no_hl) { + DEBUG_WARN("Not using HL commands\n"); + return; + } return remote_adiv5_dp_defaults(dp); case BMP_TYPE_STLINKV2: return stlink_adiv5_dp_defaults(dp); diff --git a/src/platforms/pc/cl_utils.c b/src/platforms/pc/cl_utils.c index 1ff350e..f6efc7d 100644 --- a/src/platforms/pc/cl_utils.c +++ b/src/platforms/pc/cl_utils.c @@ -143,6 +143,7 @@ static void cl_help(char **argv, BMP_CL_OPTIONS_t *opt) DEBUG_WARN("\t-r\t\t: Read flash and write to binary file\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-H\t\t: Do not use high level commands (BMP-Remote)\n"); DEBUG_WARN("Flash operation modifiers options:\n"); DEBUG_WARN("\tDefault action with given file is to write to flash\n"); DEBUG_WARN("\t-a \t: Start flash operation at flash address \n" @@ -157,7 +158,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv) int c; opt->opt_target_dev = 1; opt->opt_flash_size = 16 * 1024 *1024; - while((c = getopt(argc, argv, "eEhv:d:s:I:c:CnltVta:S:jpP:rR")) != -1) { + while((c = getopt(argc, argv, "eEhHv:d:s:I:c:CnltVta:S:jpP:rR")) != -1) { switch(c) { case 'c': if (optarg) @@ -166,6 +167,9 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv) case 'h': cl_help(argv, opt); break; + case 'H': + opt->opt_no_hl = true; + break; case 'v': if (optarg) cl_debuglevel = strtol(optarg, NULL, 0) & (BMP_DEBUG_MAX - 1); diff --git a/src/platforms/pc/cl_utils.h b/src/platforms/pc/cl_utils.h index e2bd435..f6f7b1f 100644 --- a/src/platforms/pc/cl_utils.h +++ b/src/platforms/pc/cl_utils.h @@ -43,6 +43,7 @@ typedef struct BMP_CL_OPTIONS_s { bool opt_list_only; bool opt_connect_under_reset; bool external_resistor_swd; + bool opt_no_hl; char *opt_flash_file; char *opt_device; char *opt_serial;