From 471ba19a7754442a4cfdc782fda19ca72d9d1f93 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sat, 25 Jun 2022 20:42:21 +0200 Subject: [PATCH] adiv5.c: Read all CIDR data in one call. E.g on STM32WXXX AP1 with C2BOOT not set, the AP base registers have valid values but reading them fails and turns the AP unusable. BMDA reading CIDR with multiple calls will will loop and finally hang up BMD. Other target devices may show similar behaviour. Reading CIDR with a single call allows recovery from in that case and additional spares target transactions. --- src/target/adiv5.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/target/adiv5.c b/src/target/adiv5.c index af6251a..961af57 100644 --- a/src/target/adiv5.c +++ b/src/target/adiv5.c @@ -294,9 +294,10 @@ static uint32_t adiv5_mem_read32(ADIv5_AP_t *ap, uint32_t addr) static uint32_t adiv5_ap_read_id(ADIv5_AP_t *ap, uint32_t addr) { uint32_t res = 0; + uint8_t data[16]; + adiv5_mem_read(ap, data, addr, sizeof(data)); for (int i = 0; i < 4; i++) { - uint32_t x = adiv5_mem_read32(ap, addr + 4 * i); - res |= (x & 0xff) << (i * 8); + res |= (data[4 * i] << (i * 8)); } return res; }