From 8d772d048be484a89d90c5496dd73a57a0c24f4a Mon Sep 17 00:00:00 2001 From: dragonmux Date: Fri, 5 Aug 2022 15:40:50 +0100 Subject: [PATCH] rp: Cleaned up ROM table function table readout --- src/target/rp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/target/rp.c b/src/target/rp.c index c7258b0b..d4ae1e55 100644 --- a/src/target/rp.c +++ b/src/target/rp.c @@ -54,6 +54,7 @@ #define SSI_DR0_ADDR 0x18000060U #define QSPI_CTRL_ADDR 0x4001800cU +#define BOOTROM_FUNC_TABLE_ADDR 0x00000014U #define FLASHSIZE_4K_SECTOR (4U * 1024U) #define FLASHSIZE_32K_BLOCK (32U * 1024U) #define FLASHSIZE_64K_BLOCK (64U * 1024U) @@ -161,7 +162,8 @@ static bool rp_attach(target *t) struct rp_priv_s *ps = (struct rp_priv_s*)t->target_storage; uint16_t table[RP_MAX_TABLE_SIZE]; - uint16_t table_offset = target_mem_read32( t, BOOTROM_MAGIC_ADDR + 4); + /* We have to do a 32-bit read here but the pointer contained is only 16-bit. */ + uint16_t table_offset = target_mem_read32(t, BOOTROM_FUNC_TABLE_ADDR) & 0x0000ffffU; if (target_mem_read(t, table, table_offset, RP_MAX_TABLE_SIZE) || rp_fill_table(ps, table, RP_MAX_TABLE_SIZE)) return false;