This is an automated email from Gerrit.

"Tomas Vanek <[email protected]>" just uploaded a new patch set to Gerrit, which 
you can find at https://review.openocd.org/c/openocd/+/9179

-- gerrit

commit 59d142606b95389b4e55c594ba779a24d8e848e2
Author: Tomas Vanek <[email protected]>
Date:   Wed Oct 22 21:39:44 2025 +0200

    target/cortex_m: implement memory_ready() test
    
    Allow memory access as soon as debug_ap is initiated.
    This resolves chicken - egg problem in cortex_m_examine():
    examined flag had to be set at the start of examination
    to allow memory access during examination.
    
    Change-Id: I30b8bcb8c43775ebbd8e677da09189781bebb4ab
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c
index 42e9572602..e2fd8af6e0 100644
--- a/src/target/cortex_m.c
+++ b/src/target/cortex_m.c
@@ -2289,6 +2289,13 @@ void cortex_m_enable_watchpoints(struct target *target)
        }
 }
 
+static bool cortex_m_memory_ready(struct target *target)
+{
+       struct armv7m_common *armv7m = target_to_armv7m(target);
+
+       return armv7m->debug_ap != NULL;
+}
+
 static int cortex_m_read_memory(struct target *target, target_addr_t address,
        uint32_t size, uint32_t count, uint8_t *buffer)
 {
@@ -2776,8 +2783,6 @@ int cortex_m_examine(struct target *target)
        }
 
        if (!target_was_examined(target)) {
-               target_set_examined(target);
-
                /* Read from Device Identification Registers */
                retval = target_read_u32(target, CPUID, &cpuid);
                if (retval != ERROR_OK)
@@ -3382,6 +3387,7 @@ struct target_type cortexm_target = {
        .get_gdb_arch = arm_get_gdb_arch,
        .get_gdb_reg_list = armv7m_get_gdb_reg_list,
 
+       .memory_ready = cortex_m_memory_ready,
        .read_memory = cortex_m_read_memory,
        .write_memory = cortex_m_write_memory,
        .checksum_memory = armv7m_checksum_memory,

-- 

Reply via email to