Skip to content

Commit 7f8eec1

Browse files
committed
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 <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/9179 Reviewed-by: Antonio Borneo <[email protected]> Tested-by: jenkins
1 parent ba12fb9 commit 7f8eec1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/target/cortex_m.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,6 +2297,13 @@ void cortex_m_enable_watchpoints(struct target *target)
22972297
}
22982298
}
22992299

2300+
static bool cortex_m_memory_ready(struct target *target)
2301+
{
2302+
struct armv7m_common *armv7m = target_to_armv7m(target);
2303+
2304+
return armv7m->debug_ap;
2305+
}
2306+
23002307
static int cortex_m_read_memory(struct target *target, target_addr_t address,
23012308
uint32_t size, uint32_t count, uint8_t *buffer)
23022309
{
@@ -2799,8 +2806,6 @@ int cortex_m_examine(struct target *target)
27992806
}
28002807

28012808
if (!target_was_examined(target)) {
2802-
target_set_examined(target);
2803-
28042809
/* Read from Device Identification Registers */
28052810
retval = target_read_u32(target, CPUID, &cpuid);
28062811
if (retval != ERROR_OK)
@@ -3461,6 +3466,7 @@ struct target_type cortexm_target = {
34613466
.get_gdb_arch = arm_get_gdb_arch,
34623467
.get_gdb_reg_list = armv7m_get_gdb_reg_list,
34633468

3469+
.memory_ready = cortex_m_memory_ready,
34643470
.read_memory = cortex_m_read_memory,
34653471
.write_memory = cortex_m_write_memory,
34663472
.checksum_memory = armv7m_checksum_memory,

src/target/hla_target.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@ static int adapter_write_memory(struct target *target, target_addr_t address,
619619
return adapter->layout->api->write_mem(adapter->handle, address, size, count, buffer);
620620
}
621621

622+
static bool adapter_memory_ready(struct target *target)
623+
{
624+
return true;
625+
}
626+
622627
static const struct command_registration hla_command_handlers[] = {
623628
{
624629
.chain = arm_command_handlers,
@@ -661,6 +666,7 @@ struct target_type hla_target = {
661666
.get_gdb_arch = arm_get_gdb_arch,
662667
.get_gdb_reg_list = armv7m_get_gdb_reg_list,
663668

669+
.memory_ready = adapter_memory_ready,
664670
.read_memory = adapter_read_memory,
665671
.write_memory = adapter_write_memory,
666672
.checksum_memory = armv7m_checksum_memory,

0 commit comments

Comments
 (0)