This is an automated email from Gerrit.

"Amaury Pouly <amaury.po...@lowrisc.org>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7688

-- gerrit

commit aa6eb8d8fa2be2f4cda218a6f808c4d2ce00a020
Author: Amaury Pouly <amaury.po...@lowrisc.org>
Date:   Wed May 17 12:09:32 2023 +0100

    target/riscv-013: clear sticky error when DMI operation fails
    
    When a DMI operation does not succeed (either because of a timeout
    or an error), the specification says that the error in the `op`
    field is sticky and needs to cleared by writing `dmireset` in `dtmcs`.
    This is already done for timeouts in increase_dmi_busy_delay
    but not for errors.
    
    Change-Id: I7c5f27a5cf145511a1a8b64a45a586521e1cbe41
    Signed-off-by: Amaury Pouly <amaury.po...@lowrisc.org>

diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 4e6c8dc36d..2f4a8fe2e6 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -598,6 +598,7 @@ static int dmi_op_timeout(struct target *target, uint32_t 
*data_in,
                        break;
                } else {
                        LOG_ERROR("failed %s at 0x%x, status=%d", op_name, 
address, status);
+                       dtmcontrol_scan(target, DTM_DTMCS_DMIRESET);
                        return ERROR_FAIL;
                }
                if (time(NULL) - start > timeout_sec)
@@ -630,6 +631,7 @@ static int dmi_op_timeout(struct target *target, uint32_t 
*data_in,
                                        LOG_ERROR("Failed %s (NOP) at 0x%x; 
status=%d", op_name, address,
                                                        status);
                                }
+                               dtmcontrol_scan(target, DTM_DTMCS_DMIRESET);
                                return ERROR_FAIL;
                        }
                        if (time(NULL) - start > timeout_sec)

-- 

Reply via email to