aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Vanek <vanekt@fbl.cz>2022-08-01 19:06:35 +0200
committerTomas Vanek <vanekt@fbl.cz>2022-08-14 14:43:04 +0000
commitdee7b7d8212dbe94d5afd6bba736de4fcd1a05ac (patch)
tree1376e5cbb87fd3cb9b3f0f2827bc9218113e3fb1 /src
parentb6dad912b85d6bcd78c12a7a44065fb85dd8485a (diff)
downloadriscv-openocd-dee7b7d8212dbe94d5afd6bba736de4fcd1a05ac.zip
riscv-openocd-dee7b7d8212dbe94d5afd6bba736de4fcd1a05ac.tar.gz
riscv-openocd-dee7b7d8212dbe94d5afd6bba736de4fcd1a05ac.tar.bz2
target/arm: make 'arm core_state' command compatible with Cortex-M
Tcl command 'arm core_state' was exposed even on Cortex-M devices. However it returned message "Unsupported Command" without error status on such device. Set the only possible arm->core_state ARM_STATE_THUMB in armv7m init. Block setting core_state to arm on Cortex-M. Change-Id: I9525553ac8863a6cf77bbacbcd57e354b6cfe1ca Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7100 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
Diffstat (limited to 'src')
-rw-r--r--src/target/armv4_5.c23
-rw-r--r--src/target/armv7m.c1
2 files changed, 13 insertions, 11 deletions
diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c
index 2b34792..09cf143 100644
--- a/src/target/armv4_5.c
+++ b/src/target/armv4_5.c
@@ -905,32 +905,33 @@ COMMAND_HANDLER(handle_armv4_5_reg_command)
return ERROR_OK;
}
-COMMAND_HANDLER(handle_armv4_5_core_state_command)
+COMMAND_HANDLER(handle_arm_core_state_command)
{
struct target *target = get_current_target(CMD_CTX);
struct arm *arm = target_to_arm(target);
+ int ret = ERROR_OK;
if (!is_arm(arm)) {
command_print(CMD, "current target isn't an ARM");
return ERROR_FAIL;
}
- if (arm->core_type == ARM_CORE_TYPE_M_PROFILE) {
- /* armv7m not supported */
- command_print(CMD, "Unsupported Command");
- return ERROR_OK;
- }
-
if (CMD_ARGC > 0) {
- if (strcmp(CMD_ARGV[0], "arm") == 0)
- arm->core_state = ARM_STATE_ARM;
+ if (strcmp(CMD_ARGV[0], "arm") == 0) {
+ if (arm->core_type == ARM_CORE_TYPE_M_PROFILE) {
+ command_print(CMD, "arm mode not supported on Cortex-M");
+ ret = ERROR_FAIL;
+ } else {
+ arm->core_state = ARM_STATE_ARM;
+ }
+ }
if (strcmp(CMD_ARGV[0], "thumb") == 0)
arm->core_state = ARM_STATE_THUMB;
}
command_print(CMD, "core state: %s", arm_state_strings[arm->core_state]);
- return ERROR_OK;
+ return ret;
}
COMMAND_HANDLER(handle_arm_disassemble_command)
@@ -1126,7 +1127,7 @@ static const struct command_registration arm_exec_command_handlers[] = {
},
{
.name = "core_state",
- .handler = handle_armv4_5_core_state_command,
+ .handler = handle_arm_core_state_command,
.mode = COMMAND_EXEC,
.usage = "['arm'|'thumb']",
.help = "display/change ARM core state",
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index 4c46240..790e70e 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -854,6 +854,7 @@ int armv7m_init_arch_info(struct target *target, struct armv7m_common *armv7m)
/* Enable stimulus port #0 by default */
armv7m->trace_config.itm_ter[0] = 1;
+ arm->core_state = ARM_STATE_THUMB;
arm->core_type = ARM_CORE_TYPE_M_PROFILE;
arm->arch_info = armv7m;
arm->setup_semihosting = armv7m_setup_semihosting;