Skip to content

Commit

Permalink
target/riscv: fix error on exit with uninitialized target
Browse files Browse the repository at this point in the history
riscv_deinit_target() tries to get_target_type() even
if the examination failed or was not called at all.
dtm_version is not known and an annoying error is printed:

  Error: [riscv.cpu.0] Unsupported DTM version: -1
  Error: [riscv.cpu.0] Could not identify target type.

Avoid calling get_target_type() if dtm_version is
DTM_DTMCS_VERSION_UNKNOWN.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I48239b1b11561357e845f3a6cb3a8e3b19e35715
  • Loading branch information
tom-van committed Feb 11, 2024
1 parent b7e7a03 commit 2ff738d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/target/riscv/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,12 @@ static void riscv_deinit_target(struct target *target)
LOG_TARGET_DEBUG(target, "riscv_deinit_target()");

struct riscv_info *info = target->arch_info;
struct target_type *tt = get_target_type(target);
if (!tt)
LOG_TARGET_ERROR(target, "Could not identify target type.");
struct target_type *tt = NULL;
if (info->dtm_version != DTM_DTMCS_VERSION_UNKNOWN) {
tt = get_target_type(target);
if (!tt)
LOG_TARGET_ERROR(target, "Could not identify target type.");
}

if (riscv_flush_registers(target) != ERROR_OK)
LOG_TARGET_ERROR(target, "Failed to flush registers. Ignoring this error.");
Expand Down

0 comments on commit 2ff738d

Please sign in to comment.