From b4ac52d1f55b74c10af6906e03182836f9fddc76 Mon Sep 17 00:00:00 2001 From: fabalthazar Date: Sun, 14 Nov 2021 18:37:21 +0100 Subject: [PATCH] Hosted monitor command allowed as preliminary command --- src/platforms/pc/cl_utils.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/platforms/pc/cl_utils.c b/src/platforms/pc/cl_utils.c index 4271d990..7a438da1 100644 --- a/src/platforms/pc/cl_utils.c +++ b/src/platforms/pc/cl_utils.c @@ -290,7 +290,6 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv) opt->opt_targetid = strtol(optarg, NULL, 0); break; case 'M': - opt->opt_mode = BMP_MODE_MONITOR; if (optarg) opt->opt_monitor = optarg; break; @@ -321,7 +320,11 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv) if (opt->opt_mode == BMP_MODE_DEBUG) opt->opt_mode = BMP_MODE_FLASH_WRITE; opt->opt_flash_file = argv[optind]; + } else if ((opt->opt_mode == BMP_MODE_DEBUG) && + (opt->opt_monitor)) { + opt->opt_mode = BMP_MODE_MONITOR; // To avoid DEBUG mode } + /* Checks */ if ((opt->opt_flash_file) && ((opt->opt_mode == BMP_MODE_TEST ) || (opt->opt_mode == BMP_MODE_SWJ_TEST) || @@ -448,10 +451,6 @@ int cl_execute(BMP_CL_OPTIONS_t *opt) default: DEBUG_WARN("No test for this core type yet\n"); } - } else if (opt->opt_mode == BMP_MODE_MONITOR) { - res = command_process(t, opt->opt_monitor); - if (res) - DEBUG_WARN("Command \"%s\" failed\n", opt->opt_monitor); } if ((opt->opt_mode == BMP_MODE_TEST) || (opt->opt_mode == BMP_MODE_SWJ_TEST)) @@ -480,9 +479,14 @@ int cl_execute(BMP_CL_OPTIONS_t *opt) if (opt->opt_flash_size < map.size) /* restrict to size given on command line */ map.size = opt->opt_flash_size; + if (opt->opt_monitor) { + res = command_process(t, opt->opt_monitor); + if (res) + DEBUG_WARN("Command \"%s\" failed\n", opt->opt_monitor); + } if (opt->opt_mode == BMP_MODE_RESET) { target_reset(t); - } else if (opt->opt_mode == BMP_MODE_FLASH_ERASE) { + } else if (opt->opt_mode == BMP_MODE_FLASH_ERASE) { DEBUG_INFO("Erase %zu bytes at 0x%08" PRIx32 "\n", opt->opt_flash_size, opt->opt_flash_start); unsigned int erased = target_flash_erase(t, opt->opt_flash_start,