target/cortex_m, hla_target: 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.

hla_target has memory ready to access as soon as the adapter
is initialized so we can simply return true.

Change-Id: I30b8bcb8c43775ebbd8e677da09189781bebb4ab
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9179
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
This commit is contained in:
Tomas Vanek
2025-10-22 21:39:44 +02:00
parent ba12fb9b95
commit 7f8eec108b
2 changed files with 14 additions and 2 deletions

View File

@@ -2297,6 +2297,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;
}
static int cortex_m_read_memory(struct target *target, target_addr_t address,
uint32_t size, uint32_t count, uint8_t *buffer)
{
@@ -2799,8 +2806,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)
@@ -3461,6 +3466,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,

View File

@@ -619,6 +619,11 @@ static int adapter_write_memory(struct target *target, target_addr_t address,
return adapter->layout->api->write_mem(adapter->handle, address, size, count, buffer);
}
static bool adapter_memory_ready(struct target *target)
{
return true;
}
static const struct command_registration hla_command_handlers[] = {
{
.chain = arm_command_handlers,
@@ -661,6 +666,7 @@ struct target_type hla_target = {
.get_gdb_arch = arm_get_gdb_arch,
.get_gdb_reg_list = armv7m_get_gdb_reg_list,
.memory_ready = adapter_memory_ready,
.read_memory = adapter_read_memory,
.write_memory = adapter_write_memory,
.checksum_memory = armv7m_checksum_memory,