You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
| 2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
| 2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
| 2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
| 2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
| 2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
| 2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
| 2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
| 2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
| 2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
| 2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
| 2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
| 2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
| 2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
| 2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
| 2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
| 2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(54) |
Sep
(47) |
Oct
(15) |
Nov
(44) |
Dec
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-25 09:28:58
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via ba03d13c29fba9f5e4e97121c47eb3b7857aa92d (commit)
from 8f92e520bbd76917fd3ed18b9b9bb4099044da14 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ba03d13c29fba9f5e4e97121c47eb3b7857aa92d
Author: Tomas Vanek <va...@fb...>
Date: Tue Aug 6 17:39:44 2024 +0200
flash/nor/rp2040: allow flash size override from cfg
Do not enforce hard-wired size 32 MiB
Signed-off-by: Tomas Vanek <va...@fb...>
Change-Id: I54608f75cc13996fda38ebd5d330e3b1893c2fd9
Reviewed-on: https://review.openocd.org/c/openocd/+/8446
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jon...@ra...>
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/flash/nor/rp2040.c b/src/flash/nor/rp2040.c
index ed8341d1f..5faba57a0 100644
--- a/src/flash/nor/rp2040.c
+++ b/src/flash/nor/rp2040.c
@@ -887,7 +887,10 @@ static int rp2040_flash_probe(struct flash_bank *bank)
bank->write_end_alignment = 256;
// Max size -- up to two devices (two chip selects) in adjacent 24-bit address windows
- bank->size = 32 * 1024 * 1024;
+ if (bank->size == 0) {
+ /* TODO: get real flash size */
+ bank->size = 32 * 1024 * 1024;
+ }
bank->num_sectors = bank->size / 4096;
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/rp2040.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-25 09:28:22
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 8f92e520bbd76917fd3ed18b9b9bb4099044da14 (commit)
via ca966d3d7f28875e4872e691c3fdce27867ddab0 (commit)
from 2e8e1a3da386685a2a572bcc85f043505a7b3d94 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8f92e520bbd76917fd3ed18b9b9bb4099044da14
Author: Luke Wren <lu...@ra...>
Date: Tue Aug 6 11:57:04 2024 +0100
flash/nor/rp2040: Fix incorrect erase bounds calculation
when erase region does not start at 0
Signed-off-by: Tomas Vanek <va...@fb...>
Signed-off-by: Luke Wren <lu...@ra...>
Change-Id: I2b9db61e8ac837b6c6431aacf3b73ed3a1772fbc
Reviewed-on: https://review.openocd.org/c/openocd/+/8445
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jon...@ra...>
diff --git a/src/flash/nor/rp2040.c b/src/flash/nor/rp2040.c
index 9151b6878..ed8341d1f 100644
--- a/src/flash/nor/rp2040.c
+++ b/src/flash/nor/rp2040.c
@@ -821,7 +821,7 @@ static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsig
goto cleanup_and_return;
uint32_t offset_next = bank->sectors[first].offset;
- uint32_t offset_last = bank->sectors[last].offset + bank->sectors[last].size - bank->sectors[first].offset;
+ uint32_t offset_last = bank->sectors[last].offset + bank->sectors[last].size;
/* Break erase into multiple calls to avoid timeout on large erase. Choose 128k chunk which has
fairly low ROM call overhead and empirically seems to avoid the default keep_alive() limit
commit ca966d3d7f28875e4872e691c3fdce27867ddab0
Author: Luke Wren <lu...@ra...>
Date: Thu Jul 25 10:55:41 2024 +0100
flash/nor/rp2040: Avoid ROM call timeout on long erases by splitting into chunks
Also add keep_alive() to erase/program to avoid nasty GDB message.
TV: Fixed style problems.
Signed-off-by: Tomas Vanek <va...@fb...>
Signed-off-by: Luke Wren <lu...@ra...>
Change-Id: Ibb18775aeed192361ae1585bfdaad03760583cf3
Reviewed-on: https://review.openocd.org/c/openocd/+/8444
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jon...@ra...>
diff --git a/src/flash/nor/rp2040.c b/src/flash/nor/rp2040.c
index a9995f8c6..9151b6878 100644
--- a/src/flash/nor/rp2040.c
+++ b/src/flash/nor/rp2040.c
@@ -510,11 +510,10 @@ static int rp2xxx_call_rom_func_batch(struct target *target, struct rp2040_flash
}
if (err != ERROR_OK) {
LOG_ERROR("Failed to call ROM function batch\n");
- /* This case is hit when loading new ROM images on FPGA, but can also be
- hit on real hardware if you swap two devices with different ROM
- versions without restarting OpenOCD: */
- LOG_INFO("Repopulating ROM address cache after failed ROM call");
- /* We ignore the error because we have already failed, this is just
+ /* This case is hit when loading new ROM images on FPGA, but can also be hit on real
+ hardware if you swap two devices with different ROM versions without restarting OpenOCD: */
+ LOG_ROM_SYMBOL_DEBUG("Repopulating ROM address cache after failed ROM call");
+ /* We ignore the error on this next call because we have already failed, this is just
recovery for the next attempt. */
(void)rp2xxx_populate_rom_pointer_cache(target, priv);
return err;
@@ -757,6 +756,7 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
write_size /* count */
};
err = rp2xxx_call_rom_func(target, priv, priv->jump_flash_range_program, args, ARRAY_SIZE(args));
+ keep_alive();
if (err != ERROR_OK) {
LOG_ERROR("Failed to invoke flash programming code on target");
break;
@@ -820,19 +820,50 @@ static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsig
if (err != ERROR_OK)
goto cleanup_and_return;
- LOG_DEBUG("Remote call flash_range_erase");
+ uint32_t offset_next = bank->sectors[first].offset;
+ uint32_t offset_last = bank->sectors[last].offset + bank->sectors[last].size - bank->sectors[first].offset;
+
+ /* Break erase into multiple calls to avoid timeout on large erase. Choose 128k chunk which has
+ fairly low ROM call overhead and empirically seems to avoid the default keep_alive() limit
+ as well as our ROM call timeout. */
+ const uint32_t erase_chunk_size = 128 * 1024;
+
+ /* Promote log level for long erases to provide feedback */
+ bool requires_loud_prints = offset_last - offset_next >= 2 * erase_chunk_size;
+ enum log_levels chunk_log_level = requires_loud_prints ? LOG_LVL_INFO : LOG_LVL_DEBUG;
+
+ while (offset_next < offset_last) {
+ uint32_t remaining = offset_last - offset_next;
+ uint32_t call_size = remaining < erase_chunk_size ? remaining : erase_chunk_size;
+ /* Shorten the first call of a large erase if necessary to align subsequent calls */
+ if (offset_next % erase_chunk_size != 0 && call_size == erase_chunk_size)
+ call_size = erase_chunk_size - offset_next % erase_chunk_size;
+
+ LOG_CUSTOM_LEVEL(chunk_log_level,
+ " Erase chunk: 0x%08" PRIx32 " -> 0x%08" PRIx32,
+ offset_next,
+ offset_next + call_size - 1
+ );
- uint32_t args[4] = {
- bank->sectors[first].offset, /* addr */
- bank->sectors[last].offset + bank->sectors[last].size - bank->sectors[first].offset, /* count */
- 65536, /* block_size */
- 0xd8 /* block_cmd */
- };
+ /* This ROM function uses the optimal mixture of 4k 20h and 64k D8h erases, without
+ over-erase. This is why we force the flash_bank sector size attribute to 4k even if
+ OpenOCD prefers to give the block size instead. */
+ uint32_t args[4] = {
+ offset_next,
+ call_size,
+ 65536, /* block_size */
+ 0xd8 /* block_cmd */
+ };
+
+ err = rp2xxx_call_rom_func(bank->target, priv, priv->jump_flash_range_erase, args, ARRAY_SIZE(args));
+ keep_alive();
+
+ if (err != ERROR_OK)
+ break;
+
+ offset_next += call_size;
+ }
- /* This ROM function will use the optimal mixture of 4k 20h and 64k D8h
- erases, without over-erase, as long as you just tell OpenOCD that your
- flash is made up of 4k sectors instead of letting it try to guess. */
- err = rp2xxx_call_rom_func(bank->target, priv, priv->jump_flash_range_erase, args, ARRAY_SIZE(args));
cleanup_and_return:
cleanup_after_raw_flash_cmd(bank);
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/rp2040.c | 63 +++++++++++++++++++++++++++++++++++++-------------
1 file changed, 47 insertions(+), 16 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-25 09:27:45
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 2e8e1a3da386685a2a572bcc85f043505a7b3d94 (commit)
via eb4a6342485a433ad01a18ef115236c2a29de900 (commit)
via 1ed49addc5030f6df414657ead6bfc70a0deabd9 (commit)
from ea775d49fc71253a95986eb5b1254b4861bdeb97 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2e8e1a3da386685a2a572bcc85f043505a7b3d94
Author: Luke Wren <lu...@ra...>
Date: Fri Jun 28 16:41:48 2024 +0100
flash/nor/rp2040: Fix up ROM table lookup for RP2350 A2
which has 16-bit well-known pointers.
Change-Id: Ia0838a0b062f73a9c5751abb48f1b4d55100bd1d
Signed-off-by: Tomas Vanek <va...@fb...>
Signed-off-by: Luke Wren <lu...@ra...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8443
Reviewed-by: Jonathan Bell <jon...@ra...>
Tested-by: jenkins
diff --git a/src/flash/nor/rp2040.c b/src/flash/nor/rp2040.c
index 764a034c6..a9995f8c6 100644
--- a/src/flash/nor/rp2040.c
+++ b/src/flash/nor/rp2040.c
@@ -331,8 +331,8 @@ static int rp2xxx_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_
/* Distinguish old-style RP2350 ROM table (A0, and earlier A1 builds)
based on position of table -- a high address means it is shared with
RISC-V, i.e. new-style. */
- uint32_t table_ptr;
- err = target_read_u32(target, BOOTROM_MAGIC_ADDR + 4, &table_ptr);
+ uint16_t table_ptr;
+ err = target_read_u16(target, BOOTROM_MAGIC_ADDR + 4, &table_ptr);
if (err != ERROR_OK)
return err;
if (table_ptr < 0x7c00)
commit eb4a6342485a433ad01a18ef115236c2a29de900
Author: graham sanderson <gra...@ra...>
Date: Sun Mar 24 18:33:24 2024 -0500
flash/nor/rp2040: RP2350 A1 changes
TV: cortex_m.c changes removed.
Change-Id: I85830f2d64f8afb86690737f9ae70dde5e6143e1
Signed-off-by: Tomas Vanek <va...@fb...>
Signed-off-by: graham sanderson <gra...@ra...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8442
Tested-by: jenkins
diff --git a/src/flash/nor/rp2040.c b/src/flash/nor/rp2040.c
index 1e582b433..764a034c6 100644
--- a/src/flash/nor/rp2040.c
+++ b/src/flash/nor/rp2040.c
@@ -256,13 +256,10 @@ static int rp2350_a0_lookup_symbol(struct target *target, uint16_t tag, uint16_t
return ERROR_FAIL;
}
-static int rp2350_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
+static int rp2350_lookup_rom_symbol(struct target *target, uint32_t ptr_to_entry,
+ uint16_t tag, uint16_t flags, uint16_t *symbol_out)
{
LOG_ROM_SYMBOL_DEBUG("Looking up ROM symbol '%c%c' in RP2350 A1 table", tag & 0xff, (tag >> 8) & 0xff);
- uint32_t ptr_to_entry;
- int err = target_read_u32(target, BOOTROM_MAGIC_ADDR + 4, &ptr_to_entry);
- if (err != ERROR_OK)
- return err;
/* On RP2350 A1, Each entry has a flag bitmap identifying the type of its
contents. The entry contains one halfword of data for each set flag
@@ -272,7 +269,7 @@ static int rp2350_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_
while (true) {
uint16_t entry_tag, entry_flags;
- err = target_read_u16(target, ptr_to_entry, &entry_tag);
+ uint32_t err = target_read_u16(target, ptr_to_entry, &entry_tag);
if (err != ERROR_OK)
return err;
if (entry_tag == 0) {
@@ -341,7 +338,7 @@ static int rp2xxx_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_
if (table_ptr < 0x7c00)
return rp2350_a0_lookup_symbol(target, tag, flags, symbol_out);
else
- return rp2350_lookup_rom_symbol(target, tag, flags, symbol_out);
+ return rp2350_lookup_rom_symbol(target, table_ptr, tag, flags, symbol_out);
} else if (magic == BOOTROM_RP2040_MAGIC) {
return rp2040_lookup_rom_symbol(target, tag, flags, symbol_out);
commit 1ed49addc5030f6df414657ead6bfc70a0deabd9
Author: Luke Wren <wre...@gm...>
Date: Wed Jul 14 16:36:13 2021 +0100
flash/nor/rp2040: Add RISC-V ROM algorithm batch call support
And add support for A1 ROM table.
TV: cortex_m smp change removed.
Fixed style problems.
'uint' replaced by unsigned int
Change-Id: Iff2710fa0734dc7074d8d490d8fae43dc27c0c2a
Signed-off-by: Tomas Vanek <va...@fb...>
Signed-off-by: Luke Wren <wre...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8441
Tested-by: jenkins
diff --git a/src/flash/nor/rp2040.c b/src/flash/nor/rp2040.c
index c53b54754..1e582b433 100644
--- a/src/flash/nor/rp2040.c
+++ b/src/flash/nor/rp2040.c
@@ -11,32 +11,27 @@
#include "spi.h"
#include <target/cortex_m.h>
-/* NOTE THAT THIS CODE REQUIRES FLASH ROUTINES in BOOTROM WITH FUNCTION TABLE PTR AT 0x00000010
- Your gdbinit should load the bootrom.elf if appropriate */
-
/* this is 'M' 'u', 1 (version) */
#define BOOTROM_RP2040_MAGIC 0x01754d
/* this is 'M' 'u', 2 (version) */
#define BOOTROM_RP2350_MAGIC 0x02754d
#define BOOTROM_MAGIC_ADDR 0x00000010
-#define RT_ARM_FUNC 0x1
-
-/* Call a ROM function via the debug trampoline
- Up to four arguments passed in r0...r3 as per ABI
- Function address is passed in r7
- the trampoline is needed because OpenOCD "algorithm" code insists on sw breakpoints. */
-
#define MAKE_TAG(a, b) (((b)<<8) | a)
-#define FUNC_DEBUG_TRAMPOLINE MAKE_TAG('D', 'T')
-#define FUNC_DEBUG_TRAMPOLINE_END MAKE_TAG('D', 'E')
-#define FUNC_FLASH_EXIT_XIP MAKE_TAG('E', 'X')
-#define FUNC_CONNECT_INTERNAL_FLASH MAKE_TAG('I', 'F')
-#define FUNC_FLASH_RANGE_ERASE MAKE_TAG('R', 'E')
-#define FUNC_FLASH_RANGE_PROGRAM MAKE_TAG('R', 'P')
-#define FUNC_FLASH_FLUSH_CACHE MAKE_TAG('F', 'C')
-#define FUNC_FLASH_ENTER_CMD_XIP MAKE_TAG('C', 'X')
-#define FUNC_BOOTROM_STATE_RESET MAKE_TAG('S', 'R')
+#define FUNC_FLASH_EXIT_XIP MAKE_TAG('E', 'X')
+#define FUNC_CONNECT_INTERNAL_FLASH MAKE_TAG('I', 'F')
+#define FUNC_FLASH_RANGE_ERASE MAKE_TAG('R', 'E')
+#define FUNC_FLASH_RANGE_PROGRAM MAKE_TAG('R', 'P')
+#define FUNC_FLASH_FLUSH_CACHE MAKE_TAG('F', 'C')
+#define FUNC_FLASH_ENTER_CMD_XIP MAKE_TAG('C', 'X')
+#define FUNC_BOOTROM_STATE_RESET MAKE_TAG('S', 'R')
+#define FUNC_FLASH_RESET_ADDRESS_TRANS MAKE_TAG('R', 'A')
+
+/* ROM table flags for RP2350 A1 ROM onwards */
+#define RT_FLAG_FUNC_RISCV 0x01
+#define RT_FLAG_FUNC_ARM_SEC 0x04
+#define RT_FLAG_FUNC_ARM_NONSEC 0x10
+#define RT_FLAG_DATA 0x40
// these form a bit set
#define BOOTROM_STATE_RESET_CURRENT_CORE 0x01
@@ -48,10 +43,14 @@
#define ACCESSCTRL_CFGRESET_OFFSET 0x40060008u
#define ACCESSCTRL_WRITE_PASSWORD 0xacce0000u
-// Calling bootrom functions requires the redundancy coprocessor (RCP) to be
-// initialised. Usually this is done first thing by the bootrom, but the
-// debugger may skip this, e.g. by resetting the cores and then running a
-// NO_FLASH binary, or by reset-halting the cores before flash programming.
+#define RP2XXX_MAX_ALGO_STACK_USAGE 1024
+#define RP2XXX_MAX_RAM_ALGO_SIZE 1024
+
+// Calling bootrom functions on Arm RP2350 requires the redundancy
+// coprocessor (RCP) to be initialised. Usually this is done first thing by
+// the bootrom, but the debugger may skip this, e.g. by resetting the cores
+// and then running a NO_FLASH binary, or by reset-halting the cores before
+// flash programming.
//
// The first case can be handled by a stub in the binary itself to initialise
// the RCP with dummy values if the bootrom has not already initialised it.
@@ -59,186 +58,500 @@
// requires the debugger itself to initialise the RCP, using this stub code:
static const int rcp_init_code_bkpt_offset = 24;
-static const uint16_t rcp_init_code[] = {
+static const uint8_t rcp_init_code[] = {
// Just enable the RCP which is fine if it already was (we assume no other
// co-processors are enabled at this point to save space)
- 0x4806, // ldr r0, = PPB_BASE + M33_CPACR_OFFSET
- 0xf45f, 0x4140, // movs r1, #M33_CPACR_CP7_BITS
- 0x6001, // str r1, [r0]
+ 0x06, 0x48, // ldr r0, = PPB_BASE + M33_CPACR_OFFSET
+ 0x5f, 0xf4, 0x40, 0x41, // movs r1, #M33_CPACR_CP7_BITS
+ 0x01, 0x60, // str r1, [r0]
// Only initialize canary seeds if they haven't been (as to do so twice is a fault)
- 0xee30, 0xf710, // mrc p7, #1, r15, c0, c0, #0
- 0xd404, // bmi 1f
+ 0x30, 0xee, 0x10, 0xf7, // mrc p7, #1, r15, c0, c0, #0
+ 0x04, 0xd4, // bmi 1f
// Todo should we use something random here and pass it into the algorithm?
- 0xec40, 0x0780, // mcrr p7, #8, r0, r0, c0
- 0xec40, 0x0781, // mcrr p7, #8, r0, r0, c1
+ 0x40, 0xec, 0x80, 0x07, // mcrr p7, #8, r0, r0, c0
+ 0x40, 0xec, 0x81, 0x07, // mcrr p7, #8, r0, r0, c1
// Let other core know
- 0xbf40, // sev
+ 0x40, 0xbf, // sev
// 1:
- 0xbe00, // bkpt (end of algorithm)
- 0x0000, // pad
- 0xed88, 0xe000 // PPB_BASE + M33_CPACR_OFFSET
+ 0x00, 0xbe, // bkpt (end of algorithm)
+ 0x00, 0x00, // pad
+ 0x88, 0xed, 0x00, 0xe0 // PPB_BASE + M33_CPACR_OFFSET
};
+// An algorithm stub that can be concatenated with a null-terminated list of
+// (PC, SP, r0-r3) records to perform a batch of ROM calls under a single
+// OpenOCD algorithm call, to save on algorithm overhead:
+#define ROM_CALL_BATCH_ALGO_SIZE_BYTES 32
+static const int rp2xxx_rom_call_batch_algo_bkpt_offset = ROM_CALL_BATCH_ALGO_SIZE_BYTES - 2;
+static const uint8_t rp2xxx_rom_call_batch_algo_armv6m[ROM_CALL_BATCH_ALGO_SIZE_BYTES] = {
+// <_start>:
+ 0x07, 0xa7, // add r7, pc, #28 ; (adr r7, 20 <_args>)
+// <_do_next>:
+ 0x10, 0xcf, // ldmia r7!, {r4}
+ 0x00, 0x2c, // cmp r4, #0
+ 0x0a, 0xd0, // beq.n 1e <_done>
+ 0x20, 0xcf, // ldmia r7!, {r5}
+ 0xad, 0x46, // mov sp, r5
+ 0x0f, 0xcf, // ldmia r7!, {r0, r1, r2, r3}
+ 0xa0, 0x47, // blx r4
+ 0xf7, 0xe7, // b.n 2 <_do_next>
+ 0xc0, 0x46, // nop
+ 0xc0, 0x46, // nop
+ 0xc0, 0x46, // nop
+ 0xc0, 0x46, // nop
+ 0xc0, 0x46, // nop
+ 0xc0, 0x46, // nop
+// <_done>:
+ 0x00, 0xbe, // bkpt 0x0000
+// <_args>:
+};
+
+// The same as rom_call_batch_algo_armv6m, but clearing stack limits before setting stack:
+static const uint8_t rp2xxx_rom_call_batch_algo_armv8m[ROM_CALL_BATCH_ALGO_SIZE_BYTES] = {
+// <_start>:
+ 0x07, 0xa7, // add r7, pc, #28 ; (adr r7, 20 <_args>)
+ 0x00, 0x20, // movs r0, #0
+ 0x80, 0xf3, 0x0a, 0x88, // msr MSPLIM, r0
+ 0x80, 0xf3, 0x0b, 0x88, // msr PSPLIM, r0
+// <_do_next>:
+ 0x10, 0xcf, // ldmia r7!, {r4}
+ 0x00, 0x2c, // cmp r4, #0
+ 0x05, 0xd0, // beq.n 1e <_done>
+ 0x20, 0xcf, // ldmia r7!, {r5}
+ 0xad, 0x46, // mov sp, r5
+ 0x0f, 0xcf, // ldmia r7!, {r0, r1, r2, r3}
+ 0xa0, 0x47, // blx r4
+ 0xf7, 0xe7, // b.n c <_do_next>
+ 0xc0, 0x46, // nop
+// <_done>:
+ 0x00, 0xbe, // bkpt 0x0000
+// <_args>:
+};
+
+// The same as rom_call_batch_algo_armv6m, but placing arguments in a0-a3 on RISC-V:
+static const uint8_t rp2xxx_rom_call_batch_algo_riscv[ROM_CALL_BATCH_ALGO_SIZE_BYTES] = {
+// <_start>:
+ 0x97, 0x04, 0x00, 0x00, // auipc s1,0
+ 0x93, 0x84, 0x04, 0x02, // add s1,s1,32 # 20 <_args>
+// <_do_next>:
+ 0x98, 0x40, // lw a4,0(s1)
+ 0x11, 0xcb, // beqz a4,1e <_done>
+ 0x03, 0xa1, 0x44, 0x00, // lw sp,4(s1)
+ 0x88, 0x44, // lw a0,8(s1)
+ 0xcc, 0x44, // lw a1,12(s1)
+ 0x90, 0x48, // lw a2,16(s1)
+ 0xd4, 0x48, // lw a3,20(s1)
+ 0xe1, 0x04, // add s1,s1,24
+ 0x02, 0x97, // jalr a4
+ 0xf5, 0xb7, // j 8 <_do_next>
+// <_done>:
+ 0x02, 0x90, // ebreak
+// <_args>:
+};
+
+typedef struct rp2xxx_rom_call_batch_record {
+ uint32_t pc;
+ uint32_t sp;
+ uint32_t args[4];
+} rp2xxx_rom_call_batch_record_t;
+
struct rp2040_flash_bank {
/* flag indicating successful flash probe */
bool probed;
/* stack used by Boot ROM calls */
struct working_area *stack;
+ /* static code scratchpad used for RAM algorithms -- allocated in advance
+ so that higher-level calls can just grab all remaining workarea: */
+ struct working_area *ram_algo_space;
/* function jump table populated by rp2040_flash_probe() */
- uint16_t jump_debug_trampoline;
- uint16_t jump_debug_trampoline_end;
uint16_t jump_flash_exit_xip;
uint16_t jump_connect_internal_flash;
uint16_t jump_flash_range_erase;
uint16_t jump_flash_range_program;
uint16_t jump_flush_cache;
+ uint16_t jump_flash_reset_address_trans;
uint16_t jump_enter_cmd_xip;
uint16_t jump_bootrom_reset_state;
};
-static uint32_t rp2040_lookup_symbol(struct target *target, uint32_t tag, uint16_t *symbol)
+#ifndef LOG_ROM_SYMBOL_DEBUG
+#define LOG_ROM_SYMBOL_DEBUG LOG_DEBUG
+#endif
+
+static int rp2040_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
{
- uint32_t magic, magic_addr;
- bool found_rp2040_magic, found_rp2350_magic;
- magic_addr = BOOTROM_MAGIC_ADDR;
- int err = target_read_u32(target, BOOTROM_MAGIC_ADDR, &magic);
+ LOG_ROM_SYMBOL_DEBUG("Looking up ROM symbol '%c%c' in RP2040 table", tag & 0xff, (tag >> 8) & 0xff);
+ if (flags != RT_FLAG_FUNC_ARM_SEC && flags != RT_FLAG_DATA) {
+ /* Note RT flags do not exist on RP2040, so just sanity check that we
+ are asked for a type of thing that actually exists in the ROM table */
+ LOG_ERROR("Only data and Secure Arm functions can be looked up in RP2040 ROM table");
+ return ERROR_FAIL;
+ }
+
+ uint16_t ptr_to_entry;
+ const unsigned int offset_magic_to_table_ptr = flags == RT_FLAG_DATA ? 6 : 4;
+ int err = target_read_u16(target, BOOTROM_MAGIC_ADDR + offset_magic_to_table_ptr, &ptr_to_entry);
if (err != ERROR_OK)
return err;
- magic &= 0xffffff; /* ignore bootrom version */
-
- found_rp2040_magic = magic == BOOTROM_RP2040_MAGIC;
- found_rp2350_magic = magic == BOOTROM_RP2350_MAGIC;
+ uint16_t entry_tag;
+ do {
+ err = target_read_u16(target, ptr_to_entry, &entry_tag);
+ if (err != ERROR_OK)
+ return err;
+ if (entry_tag == tag) {
+ /* 16 bit symbol is next */
+ err = target_read_u16(target, ptr_to_entry + 2, symbol_out);
+ if (err != ERROR_OK)
+ return err;
+ LOG_ROM_SYMBOL_DEBUG(" -> found: 0x%04x", *symbol_out);
+ return ERROR_OK;
+ }
+ ptr_to_entry += 4;
+ } while (entry_tag);
+ *symbol_out = 0;
+ return ERROR_FAIL;
+}
- if (!(found_rp2040_magic || found_rp2350_magic)) {
- LOG_ERROR("RP2040/RP2350 BOOT ROM not found");
- return ERROR_FAIL;
+static int rp2350_a0_lookup_symbol(struct target *target, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
+{
+ LOG_ROM_SYMBOL_DEBUG("Looking up ROM symbol '%c%c' in RP2350 A0 table", tag & 0xff, (tag >> 8) & 0xff);
+
+ /* RP2350 A0 table format is the same as RP2040 except with 16 bits of
+ flags after each 16-bit pointer. We ignore the flags, as each symbol
+ only has one datum associated with it. */
+
+ uint32_t magic_ptr = BOOTROM_MAGIC_ADDR;
+ if (flags == RT_FLAG_FUNC_RISCV) {
+ /* RP2350 A0 used split function tables for Arm/RISC-V -- not used on
+ any other device or any other version of this device. There is a
+ well-known RISC-V table at the top of ROM, matching the well-known
+ Arm table at the bottom of ROM. */
+ magic_ptr = 0x7decu;
+ } else if (flags != RT_FLAG_FUNC_ARM_SEC) {
+ LOG_WARNING("Ignoring non-default flags for RP2350 A0 lookup, hope you like Secure Arm functions");
}
- /* dereference the table pointer */
- uint16_t table_entry;
- err = target_read_u16(target, magic_addr + 4, &table_entry);
+ uint16_t ptr_to_entry;
+ const unsigned int offset_magic_to_table_ptr = 4;
+ int err = target_read_u16(target, magic_ptr + offset_magic_to_table_ptr, &ptr_to_entry);
if (err != ERROR_OK)
return err;
uint16_t entry_tag;
do {
- err = target_read_u16(target, table_entry, &entry_tag);
+ err = target_read_u16(target, ptr_to_entry, &entry_tag);
if (err != ERROR_OK)
return err;
if (entry_tag == tag) {
- if (found_rp2350_magic) {
- uint16_t flags;
- /* flags are next */
- err = target_read_u16(target, table_entry + 4, &flags);
- if (err != ERROR_OK)
- return err;
- //
- if (flags & RT_ARM_FUNC) {
- /* 16 bit symbol */
- return target_read_u16(target, table_entry + 2, symbol);
- }
- } else {
- /* 16 bit symbol is next */
- return target_read_u16(target, table_entry + 2, symbol);
- }
+ err = target_read_u16(target, ptr_to_entry + 2, symbol_out);
+ if (err != ERROR_OK)
+ return err;
+ LOG_ROM_SYMBOL_DEBUG(" -> found: 0x%04x", *symbol_out);
+ return ERROR_OK;
}
- table_entry += found_rp2350_magic ? 6 : 4;
+ ptr_to_entry += 6;
} while (entry_tag);
+ *symbol_out = 0;
return ERROR_FAIL;
}
-static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank *priv,
- uint16_t func_offset, uint32_t argdata[], unsigned int n_args)
+static int rp2350_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
{
- char *regnames[4] = { "r0", "r1", "r2", "r3" };
+ LOG_ROM_SYMBOL_DEBUG("Looking up ROM symbol '%c%c' in RP2350 A1 table", tag & 0xff, (tag >> 8) & 0xff);
+ uint32_t ptr_to_entry;
+ int err = target_read_u32(target, BOOTROM_MAGIC_ADDR + 4, &ptr_to_entry);
+ if (err != ERROR_OK)
+ return err;
- assert(n_args <= ARRAY_SIZE(regnames)); /* only allow register arguments */
+ /* On RP2350 A1, Each entry has a flag bitmap identifying the type of its
+ contents. The entry contains one halfword of data for each set flag
+ bit. There may be both Arm and RISC-V entries under the same tag, or
+ separate Arm Secure/NonSecure entries (or all three, why not). */
- if (!priv->stack) {
- LOG_ERROR("no stack for flash programming code");
+ while (true) {
+ uint16_t entry_tag, entry_flags;
+
+ err = target_read_u16(target, ptr_to_entry, &entry_tag);
+ if (err != ERROR_OK)
+ return err;
+ if (entry_tag == 0) {
+ *symbol_out = 0;
+ return ERROR_FAIL;
+ }
+ ptr_to_entry += 2;
+
+ err = target_read_u16(target, ptr_to_entry, &entry_flags);
+ if (err != ERROR_OK)
+ return err;
+ ptr_to_entry += 2;
+
+ uint16_t matching_flags = flags & entry_flags;
+
+ if (tag == entry_tag && matching_flags != 0) {
+ /* This is our entry, seek to the correct data item and return it. */
+ bool is_riscv_func = matching_flags & RT_FLAG_FUNC_RISCV;
+ while (!(matching_flags & 1)) {
+ if (entry_flags & 1)
+ ptr_to_entry += 2;
+
+ matching_flags >>= 1;
+ entry_flags >>= 1;
+ }
+ if (is_riscv_func) {
+ /* For RISC-V, the table entry itself is the entry point -- trick
+ to make shared function implementations smaller */
+ *symbol_out = ptr_to_entry;
+ return ERROR_OK;
+ }
+ err = target_read_u16(target, ptr_to_entry, symbol_out);
+ if (err != ERROR_OK)
+ return err;
+ LOG_ROM_SYMBOL_DEBUG(" -> found: 0x%04x", *symbol_out);
+ return ERROR_OK;
+ }
+ /* Skip past this entry */
+ while (entry_flags) {
+ if (entry_flags & 1)
+ ptr_to_entry += 2;
+
+ entry_flags >>= 1;
+ }
+ }
+}
+
+static int rp2xxx_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
+{
+ uint32_t magic;
+ int err = target_read_u32(target, BOOTROM_MAGIC_ADDR, &magic);
+ if (err != ERROR_OK)
+ return err;
+
+ /* Ignore version */
+ magic &= 0xffffff;
+
+ if (magic == BOOTROM_RP2350_MAGIC) {
+ /* Distinguish old-style RP2350 ROM table (A0, and earlier A1 builds)
+ based on position of table -- a high address means it is shared with
+ RISC-V, i.e. new-style. */
+ uint32_t table_ptr;
+ err = target_read_u32(target, BOOTROM_MAGIC_ADDR + 4, &table_ptr);
+ if (err != ERROR_OK)
+ return err;
+ if (table_ptr < 0x7c00)
+ return rp2350_a0_lookup_symbol(target, tag, flags, symbol_out);
+ else
+ return rp2350_lookup_rom_symbol(target, tag, flags, symbol_out);
+
+ } else if (magic == BOOTROM_RP2040_MAGIC) {
+ return rp2040_lookup_rom_symbol(target, tag, flags, symbol_out);
+ }
+ LOG_ERROR("RP2040/RP2350 BOOT ROM not found");
+ return ERROR_FAIL;
+}
+
+static int rp2xxx_populate_rom_pointer_cache(struct target *target, struct rp2040_flash_bank *priv)
+{
+ const uint16_t symtype_func = is_arm(target_to_arm(target))
+ ? RT_FLAG_FUNC_ARM_SEC : RT_FLAG_FUNC_RISCV;
+ int err;
+ err = rp2xxx_lookup_rom_symbol(target, FUNC_FLASH_EXIT_XIP,
+ symtype_func, &priv->jump_flash_exit_xip);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Function FUNC_FLASH_EXIT_XIP not found in RP2xxx ROM.");
+ return err;
+ }
+
+ err = rp2xxx_lookup_rom_symbol(target, FUNC_CONNECT_INTERNAL_FLASH,
+ symtype_func, &priv->jump_connect_internal_flash);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Function FUNC_CONNECT_INTERNAL_FLASH not found in RP2xxx ROM.");
+ return err;
+ }
+
+ err = rp2xxx_lookup_rom_symbol(target, FUNC_FLASH_RANGE_ERASE, symtype_func, &priv->jump_flash_range_erase);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Function FUNC_FLASH_RANGE_ERASE not found in RP2xxx ROM.");
+ return err;
+ }
+
+ err = rp2xxx_lookup_rom_symbol(target, FUNC_FLASH_RANGE_PROGRAM, symtype_func, &priv->jump_flash_range_program);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Function FUNC_FLASH_RANGE_PROGRAM not found in RP2xxx ROM.");
+ return err;
+ }
+
+ err = rp2xxx_lookup_rom_symbol(target, FUNC_FLASH_FLUSH_CACHE, symtype_func, &priv->jump_flush_cache);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Function FUNC_FLASH_FLUSH_CACHE not found in RP2xxx ROM.");
+ return err;
+ }
+
+ err = rp2xxx_lookup_rom_symbol(target, FUNC_FLASH_ENTER_CMD_XIP, symtype_func, &priv->jump_enter_cmd_xip);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Function FUNC_FLASH_ENTER_CMD_XIP not found in RP2xxx ROM.");
+ return err;
+ }
+
+ // From this point are optional functions which do not exist on e.g. RP2040
+ // or pre-production RP2350 ROM versions:
+
+ err = rp2xxx_lookup_rom_symbol(target, FUNC_BOOTROM_STATE_RESET, symtype_func, &priv->jump_bootrom_reset_state);
+ if (err != ERROR_OK) {
+ priv->jump_bootrom_reset_state = 0;
+ LOG_WARNING("Function FUNC_BOOTROM_STATE_RESET not found in RP2xxx ROM. (probably an RP2040 or an RP2350 A0)");
+ }
+
+ err = rp2xxx_lookup_rom_symbol(target, FUNC_FLASH_RESET_ADDRESS_TRANS,
+ symtype_func, &priv->jump_flash_reset_address_trans);
+ if (err != ERROR_OK) {
+ priv->jump_flash_reset_address_trans = 0;
+ LOG_WARNING("Function FUNC_FLASH_RESET_ADDRESS_TRANS not found in RP2xxx ROM. (probably an RP2040 or an RP2350 A0)");
+ }
+ return ERROR_OK;
+}
+
+// Call a list of PC + SP + r0-r3 function call tuples with a single OpenOCD
+// algorithm invocation, to amortise the algorithm overhead over multiple calls:
+static int rp2xxx_call_rom_func_batch(struct target *target, struct rp2040_flash_bank *priv,
+ rp2xxx_rom_call_batch_record_t *calls, unsigned int n_calls)
+{
+ // Note +1 is for the null terminator
+ unsigned int batch_words = 1 + (ROM_CALL_BATCH_ALGO_SIZE_BYTES +
+ n_calls * sizeof(rp2xxx_rom_call_batch_record_t)
+ ) / sizeof(uint32_t);
+
+ if (!priv->ram_algo_space) {
+ LOG_ERROR("No RAM code space allocated for ROM call");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
- target_addr_t stacktop = priv->stack->address + priv->stack->size;
+ if (priv->ram_algo_space->size < batch_words * sizeof(uint32_t)) {
+ LOG_ERROR("RAM code space too small for call batch size of %u\n", n_calls);
+ return ERROR_BUF_TOO_SMALL;
+ }
- LOG_DEBUG("Calling ROM func @0x%" PRIx16 " with %d arguments", func_offset, n_args);
+ LOG_DEBUG("Calling batch of %u ROM functions:", n_calls);
+ for (unsigned int i = 0; i < n_calls; ++i) {
+ LOG_DEBUG(" func @ %" PRIx32, calls[i].pc);
+ LOG_DEBUG(" sp = %" PRIx32, calls[i].sp);
+ for (int j = 0; j < 4; ++j)
+ LOG_DEBUG(" a%d = %" PRIx32, j, calls[i].args[j]);
+ }
LOG_DEBUG("Calling on core \"%s\"", target->cmd_name);
- struct reg_param args[ARRAY_SIZE(regnames) + 12];
- struct armv7m_algorithm alg_info;
+ if (n_calls <= 0) {
+ LOG_DEBUG("Returning early from call of 0 ROM functions");
+ return ERROR_OK;
+ }
- for (unsigned int i = 0; i < n_args; ++i) {
- init_reg_param(&args[i], regnames[i], 32, PARAM_OUT);
- buf_set_u32(args[i].value, 0, 32, argdata[i]);
- }
- /* Pass function pointer in r7 */
- unsigned int extra_args = 0;
- init_reg_param(&args[n_args + extra_args], "r7", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, func_offset);
- /* Set stack pointer, have seen the caching get confused by the aliases of sp so
- take the shotgun approach*/
- init_reg_param(&args[n_args + extra_args], "msp_s", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
- init_reg_param(&args[n_args + extra_args], "msp_ns", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
- init_reg_param(&args[n_args + extra_args], "psp_s", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
- init_reg_param(&args[n_args + extra_args], "psp_ns", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
- init_reg_param(&args[n_args + extra_args], "msp", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
- init_reg_param(&args[n_args + extra_args], "psp", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
- init_reg_param(&args[n_args + extra_args], "sp", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
- /* Clear stack pointer limits, as they may be above the algorithm stack */
- init_reg_param(&args[n_args + extra_args], "msplim_s", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, 0);
- init_reg_param(&args[n_args + extra_args], "psplim_s", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, 0);
- init_reg_param(&args[n_args + extra_args], "msplim_ns", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, 0);
- init_reg_param(&args[n_args + extra_args], "psplim_ns", 32, PARAM_OUT);
- buf_set_u32(args[n_args + extra_args++].value, 0, 32, 0);
-
- for (unsigned int i = 0; i < n_args + extra_args; ++i)
- LOG_DEBUG("Set %s = 0x%" PRIx32, args[i].reg_name, buf_get_u32(args[i].value, 0, 32));
+ const uint8_t *algo_code;
+ if (is_arm(target_to_arm(target))) {
+ if (target_to_arm(target)->arch == ARM_ARCH_V8M) {
+ LOG_DEBUG("Using algo: rp2xxx_rom_call_batch_algo_armv8m");
+ algo_code = rp2xxx_rom_call_batch_algo_armv8m;
+ } else {
+ LOG_DEBUG("Using algo: rp2xxx_rom_call_batch_algo_armv6m");
+ algo_code = rp2xxx_rom_call_batch_algo_armv6m;
+ }
+ } else {
+ LOG_DEBUG("Using algo: rp2xxx_rom_call_batch_algo_riscv");
+ algo_code = rp2xxx_rom_call_batch_algo_riscv;
+ }
- /* Actually call the function */
- alg_info.common_magic = ARMV7M_COMMON_MAGIC;
- alg_info.core_mode = ARM_MODE_THREAD;
- int err = target_run_algorithm(
- target,
- 0, NULL, /* No memory arguments */
- n_args + extra_args, args, /* User arguments + r7 + SPs */
- priv->jump_debug_trampoline, priv->jump_debug_trampoline_end,
- 3000, /* 3s timeout */
- &alg_info
+ int err = target_write_buffer(target,
+ priv->ram_algo_space->address,
+ ROM_CALL_BATCH_ALGO_SIZE_BYTES,
+ algo_code
);
- for (unsigned int i = 0; i < n_args + extra_args; ++i)
- destroy_reg_param(&args[i]);
- if (err != ERROR_OK)
- LOG_ERROR("Failed to invoke ROM function @0x%" PRIx16 "\n", func_offset);
- return err;
+ if (err != ERROR_OK) {
+ LOG_ERROR("Failed to write ROM batch algorithm to RAM code space\n");
+ return err;
+ }
+ err = target_write_buffer(target,
+ priv->ram_algo_space->address + ROM_CALL_BATCH_ALGO_SIZE_BYTES,
+ n_calls * sizeof(rp2xxx_rom_call_batch_record_t),
+ (const uint8_t *)calls
+ );
+ if (err != ERROR_OK) {
+ LOG_ERROR("Failed to write ROM batch records to RAM code space\n");
+ return err;
+ }
+ err = target_write_u32(target,
+ priv->ram_algo_space->address + (batch_words - 1) * sizeof(uint32_t),
+ 0
+ );
+ if (err != ERROR_OK) {
+ LOG_ERROR("Failed to write null terminator for ROM batch records\n");
+ return err;
+ }
+
+ // Call into the ROM batch algorithm -- this will in turn call each ROM
+ // call specified by the batch records.
+ target_addr_t algo_start_addr = priv->ram_algo_space->address;
+ target_addr_t algo_end_addr = priv->ram_algo_space->address + rp2xxx_rom_call_batch_algo_bkpt_offset;
+ unsigned int algo_timeout_ms = 3000;
+ if (is_arm(target_to_arm(target))) {
+ struct armv7m_algorithm alg_info;
+ alg_info.common_magic = ARMV7M_COMMON_MAGIC;
+ alg_info.core_mode = ARM_MODE_THREAD;
+ err = target_run_algorithm(target,
+ 0, NULL, /* No memory arguments */
+ 0, NULL, /* No register arguments */
+ algo_start_addr, algo_end_addr,
+ algo_timeout_ms,
+ &alg_info
+ );
+ } else {
+ // Presumed RISC-V -- there is no RISCV_COMMON_MAGIC on older OpenOCD
+ err = target_run_algorithm(target,
+ 0, NULL, /* No memory arguments */
+ 0, NULL, /* No register arguments */
+ algo_start_addr, algo_end_addr,
+ algo_timeout_ms,
+ NULL /* Currently no RISC-V-specific algorithm info */
+ );
+ }
+ if (err != ERROR_OK) {
+ LOG_ERROR("Failed to call ROM function batch\n");
+ /* This case is hit when loading new ROM images on FPGA, but can also be
+ hit on real hardware if you swap two devices with different ROM
+ versions without restarting OpenOCD: */
+ LOG_INFO("Repopulating ROM address cache after failed ROM call");
+ /* We ignore the error because we have already failed, this is just
+ recovery for the next attempt. */
+ (void)rp2xxx_populate_rom_pointer_cache(target, priv);
+ return err;
+ }
+ return ERROR_OK;
}
-static int rp2350_init_core(struct target *target, struct rp2040_flash_bank *priv)
+// Call a single ROM function, using the default algorithm stack.
+static int rp2xxx_call_rom_func(struct target *target, struct rp2040_flash_bank *priv,
+ uint16_t func_offset, uint32_t argdata[], unsigned int n_args)
{
+ assert(n_args <= 4); /* only allow register arguments -- capped at just 4 on Arm */
+
if (!priv->stack) {
LOG_ERROR("no stack for flash programming code");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
+ target_addr_t stacktop = priv->stack->address + priv->stack->size;
- struct armv7m_algorithm alg_info;
+ rp2xxx_rom_call_batch_record_t call = {
+ .pc = func_offset,
+ .sp = stacktop
+ };
+ for (unsigned int i = 0; i < n_args; ++i)
+ call.args[i] = argdata[i];
- // copy rcp_init code onto stack, as we don't actually need any stack during the call
- if (priv->stack->size < sizeof(rcp_init_code)) {
- LOG_ERROR("Working area too small for rcp_init");
- return ERROR_BUF_TOO_SMALL;
- }
+ return rp2xxx_call_rom_func_batch(target, priv, &call, 1);
+}
- // Attempt to reset ACCESSCTRL before running RCP init, in case Secure
- // access to SRAM has been blocked. (Also ROM, QMI regs are needed later)
+static int rp2350_init_accessctrl(struct target *target)
+{
+ // Attempt to reset ACCESSCTRL, in case Secure access to SRAM has been
+ // blocked, which will stop us from loading/running algorithms such as RCP
+ // init. (Also ROM, QMI regs are needed later)
uint32_t accessctrl_lock_reg;
if (target_read_u32(target, ACCESSCTRL_LOCK_OFFSET, &accessctrl_lock_reg) != ERROR_OK) {
LOG_ERROR("Failed to read ACCESSCTRL lock register");
@@ -254,30 +567,59 @@ static int rp2350_init_core(struct target *target, struct rp2040_flash_bank *pri
LOG_ERROR("ACCESSCTRL is locked, so can't reset permissions. Following steps might fail.\n");
} else {
LOG_DEBUG("Reset ACCESSCTRL permissions via CFGRESET\n");
- target_write_u32(target, ACCESSCTRL_CFGRESET_OFFSET, ACCESSCTRL_WRITE_PASSWORD | 1u);
+ return target_write_u32(target, ACCESSCTRL_CFGRESET_OFFSET, ACCESSCTRL_WRITE_PASSWORD | 1u);
+ }
+ return ERROR_OK;
+}
+
+static int rp2350_init_arm_core0(struct target *target, struct rp2040_flash_bank *priv)
+{
+ // Flash algorithms (and the RCP init stub called by this function) must
+ // run in the Secure state, so flip the state now before attempting to
+ // execute any code on the core.
+ uint32_t dscsr;
+ (void)target_read_u32(target, DCB_DSCSR, &dscsr);
+ LOG_DEBUG("DSCSR: %08x\n", dscsr);
+ if (!(dscsr & DSCSR_CDS)) {
+ LOG_DEBUG("Setting Current Domain Secure in DSCSR\n");
+ (void)target_write_u32(target, DCB_DSCSR, (dscsr & ~DSCSR_CDSKEY) | DSCSR_CDS);
+ (void)target_read_u32(target, DCB_DSCSR, &dscsr);
+ LOG_DEBUG("DSCSR*: %08x\n", dscsr);
+ }
+
+ if (!priv->stack) {
+ LOG_ERROR("No stack for flash programming code");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
+
+ if (!priv->ram_algo_space || priv->ram_algo_space->size < sizeof(rcp_init_code)) {
+ LOG_ERROR("No algorithm space for rcp_init code");
+ return ERROR_BUF_TOO_SMALL;
}
int err = target_write_memory(target,
- priv->stack->address,
+ priv->ram_algo_space->address,
1,
sizeof(rcp_init_code),
- (const uint8_t *)rcp_init_code
+ rcp_init_code
);
if (err != ERROR_OK) {
LOG_ERROR("Failed to load rcp_init algorithm into RAM\n");
return ERROR_FAIL;
}
- LOG_DEBUG("Calling rcp_init core \"%s\" code at 0x%" PRIx16 "\n", target->cmd_name, (uint32_t)priv->stack->address);
+ LOG_DEBUG("Calling rcp_init on core \"%s\", code at 0x%" PRIx32 "\n",
+ target->cmd_name, (uint32_t)priv->ram_algo_space->address);
/* Actually call the function */
+ struct armv7m_algorithm alg_info;
alg_info.common_magic = ARMV7M_COMMON_MAGIC;
alg_info.core_mode = ARM_MODE_THREAD;
err = target_run_algorithm(target,
0, NULL, /* No memory arguments */
0, NULL, /* No register arguments */
- priv->stack->address,
- priv->stack->address + rcp_init_code_bkpt_offset,
+ priv->ram_algo_space->address,
+ priv->ram_algo_space->address + rcp_init_code_bkpt_offset,
1000, /* 1s timeout */
&alg_info
);
@@ -286,80 +628,75 @@ static int rp2350_init_core(struct target *target, struct rp2040_flash_bank *pri
return err;
}
- uint32_t reset_args[1] = {
- BOOTROM_STATE_RESET_CURRENT_CORE
- };
- if (!priv->jump_bootrom_reset_state) {
- LOG_WARNING("RP2350 flash: no bootrom_reset_method\n");
- } else {
- err = rp2040_call_rom_func(target, priv, priv->jump_bootrom_reset_state, reset_args, ARRAY_SIZE(reset_args));
- if (err != ERROR_OK) {
- LOG_ERROR("RP2040 flash: failed to call reset core state");
- return err;
- }
- }
-
return err;
}
-static int setup_for_rom_call(struct flash_bank *bank)
+static int setup_for_raw_flash_cmd(struct flash_bank *bank)
{
struct rp2040_flash_bank *priv = bank->driver_priv;
-
struct target *target = bank->target;
int err = ERROR_OK;
+
if (!priv->stack) {
/* target_alloc_working_area always allocates multiples of 4 bytes, so no worry about alignment */
- const int STACK_SIZE = 256;
- target_alloc_working_area(bank->target, STACK_SIZE, &priv->stack);
+ err = target_alloc_working_area(bank->target, RP2XXX_MAX_ALGO_STACK_USAGE, &priv->stack);
if (err != ERROR_OK) {
- LOG_ERROR("Could not allocate stack for flash programming code");
+ LOG_ERROR("Could not allocate stack for flash programming code -- insufficient space");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
}
- // Flash algorithms must run in Secure state
- uint32_t dscsr;
- (void)target_read_u32(target, DCB_DSCSR, &dscsr);
- LOG_DEBUG("DSCSR: %08x\n", dscsr);
- if (!(dscsr & DSCSR_CDS)) {
- LOG_DEBUG("Setting Current Domain Secure in DSCSR\n");
- (void)target_write_u32(target, DCB_DSCSR, (dscsr & ~DSCSR_CDSKEY) | DSCSR_CDS);
- (void)target_read_u32(target, DCB_DSCSR, &dscsr);
- LOG_DEBUG("DSCSR*: %08x\n", dscsr);
+ if (!priv->ram_algo_space) {
+ err = target_alloc_working_area(bank->target, RP2XXX_MAX_RAM_ALGO_SIZE, &priv->ram_algo_space);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Could not allocate RAM code space for ROM calls -- insufficient space");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
}
- // hacky RP2350 check
- if (target_to_arm(target)->arch == ARM_ARCH_V8M) {
- err = rp2350_init_core(target, priv);
+ // hacky RP2350 check -- either RISC-V or v8-M
+ if (is_arm(target_to_arm(target)) ? target_to_arm(target)->arch == ARM_ARCH_V8M : true) {
+ err = rp2350_init_accessctrl(target);
if (err != ERROR_OK) {
- LOG_ERROR("RP2350 flash: failed to init core");
+ LOG_ERROR("Failed to init ACCESSCTRL before ROM call");
return err;
}
- }
- return err;
-}
-
-static int setup_for_raw_flash_cmd(struct flash_bank *bank)
-{
- struct rp2040_flash_bank *priv = bank->driver_priv;
- int err = setup_for_rom_call(bank);
- err = rp2040_call_rom_func(bank->target, priv, priv->jump_connect_internal_flash, NULL, 0);
- if (err != ERROR_OK) {
- LOG_ERROR("RP2040 flash: failed to setup for rom call");
- return err;
- }
-
- LOG_DEBUG("Connecting internal flash");
- err = rp2040_call_rom_func(bank->target, priv, priv->jump_connect_internal_flash, NULL, 0);
- if (err != ERROR_OK) {
- LOG_ERROR("RP2040 flash: failed to connect internal flash");
- return err;
+ if (is_arm(target_to_arm(target))) {
+ err = rp2350_init_arm_core0(target, priv);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Failed to init Arm core 0 before ROM call");
+ return err;
+ }
+ }
+ uint32_t reset_args[1] = {
+ BOOTROM_STATE_RESET_CURRENT_CORE
+ };
+ if (!priv->jump_bootrom_reset_state) {
+ LOG_WARNING("RP2350 flash: no bootrom_reset_method\n");
+ } else {
+ LOG_DEBUG("Clearing core 0 ROM state");
+ err = rp2xxx_call_rom_func(target, priv, priv->jump_bootrom_reset_state,
+ reset_args, ARRAY_SIZE(reset_args));
+ if (err != ERROR_OK) {
+ LOG_ERROR("RP2350 flash: failed to call reset core state");
+ return err;
+ }
+ }
}
- LOG_DEBUG("Kicking flash out of XIP mode");
- err = rp2040_call_rom_func(bank->target, priv, priv->jump_flash_exit_xip, NULL, 0);
+ LOG_DEBUG("Connecting flash IOs and issuing XIP exit sequence to flash");
+ rp2xxx_rom_call_batch_record_t calls[2] = {
+ {
+ .pc = priv->jump_connect_internal_flash,
+ .sp = priv->stack->address + priv->stack->size
+ },
+ {
+ .pc = priv->jump_flash_exit_xip,
+ .sp = priv->stack->address + priv->stack->size
+ }
+ };
+ err = rp2xxx_call_rom_func_batch(bank->target, priv, calls, 2);
if (err != ERROR_OK) {
LOG_ERROR("RP2040 flash: failed to exit flash XIP mode");
return err;
@@ -368,6 +705,25 @@ static int setup_for_raw_flash_cmd(struct flash_bank *bank)
return ERROR_OK;
}
+static void cleanup_after_raw_flash_cmd(struct flash_bank *bank)
+{
+ /* OpenOCD is prone to trashing work-area allocations on target state
+ transitions, which leaves us with stale work area pointers in our
+ driver state. Best to clean up our allocations manually after
+ completing each flash call, so we know to make fresh ones next time. */
+ LOG_DEBUG("Cleaning up after flash operations");
+ struct rp2040_flash_bank *priv = bank->driver_priv;
+ struct target *target = bank->target;
+ if (priv->stack) {
+ target_free_working_area(target, priv->stack);
+ priv->stack = 0;
+ }
+ if (priv->ram_algo_space) {
+ target_free_working_area(target, priv->ram_algo_space);
+ priv->ram_algo_space = 0;
+ }
+}
+
static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
LOG_DEBUG("Writing %d bytes starting at 0x%" PRIx32, count, offset);
@@ -378,13 +734,14 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
int err = setup_for_raw_flash_cmd(bank);
if (err != ERROR_OK)
- return err;
+ goto cleanup_and_return;
// Allocate as much memory as possible, rounded down to a whole number of flash pages
const unsigned int chunk_size = target_get_working_area_avail(target) & ~0xffu;
if (chunk_size == 0 || target_alloc_working_area(target, chunk_size, &bounce) != ERROR_OK) {
LOG_ERROR("Could not allocate bounce buffer for flash programming. Can't continue");
- return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ err = ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ goto cleanup_and_return;
}
LOG_DEBUG("Allocated flash bounce buffer @" TARGET_ADDR_FMT, bounce->address);
@@ -402,7 +759,7 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
bounce->address, /* data */
write_size /* count */
};
- err = rp2040_call_rom_func(target, priv, priv->jump_flash_range_program, args, ARRAY_SIZE(args));
+ err = rp2xxx_call_rom_func(target, priv, priv->jump_flash_range_program, args, ARRAY_SIZE(args));
if (err != ERROR_OK) {
LOG_ERROR("Failed to invoke flash programming code on target");
break;
@@ -415,20 +772,43 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
target_free_working_area(target, bounce);
if (err != ERROR_OK)
- return err;
+ goto cleanup_and_return;
+
+ // Flash is successfully programmed. We can now do a bit of poking to make
+ // the new flash contents visible to us via memory-mapped (XIP) interface
+ // in the 0x1... memory region.
+ //
+ // Note on RP2350 it's not *required* to call flash_enter_cmd_xip, since
+ // the ROM leaves flash XIPable by default in between direct-mode
+ // accesses, but there's no harm in calling it anyway.
- /* Flash is successfully programmed. We can now do a bit of poking to make the flash
- contents visible to us via memory-mapped (XIP) interface in the 0x1... memory region */
LOG_DEBUG("Flushing flash cache after write behind");
- err = rp2040_call_rom_func(bank->target, priv, priv->jump_flush_cache, NULL, 0);
+ err = rp2xxx_call_rom_func(bank->target, priv, priv->jump_flush_cache, NULL, 0);
+
+ rp2xxx_rom_call_batch_record_t finishing_calls[3] = {
+ {
+ .pc = priv->jump_flush_cache,
+ .sp = priv->stack->address + priv->stack->size
+ },
+ {
+ .pc = priv->jump_enter_cmd_xip,
+ .sp = priv->stack->address + priv->stack->size
+ },
+ {
+ .pc = priv->jump_flash_reset_address_trans,
+ .sp = priv->stack->address + priv->stack->size
+ }
+ };
+ // Note the last function does not exist on older devices:
+ int num_finishing_calls = priv->jump_flash_reset_address_trans ? 3 : 2;
+
+ err = rp2xxx_call_rom_func_batch(target, priv, finishing_calls, num_finishing_calls);
if (err != ERROR_OK) {
LOG_ERROR("RP2040 write: failed to flush flash cache");
- return err;
+ goto cleanup_and_return;
}
- LOG_DEBUG("Configuring SSI for execute-in-place");
- err = rp2040_call_rom_func(bank->target, priv, priv->jump_enter_cmd_xip, NULL, 0);
- if (err != ERROR_OK)
- LOG_ERROR("RP2040 write: failed to flush flash cache");
+cleanup_and_return:
+ cleanup_after_raw_flash_cmd(bank);
return err;
}
@@ -441,7 +821,7 @@ static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsig
int err = setup_for_raw_flash_cmd(bank);
if (err != ERROR_OK)
- return err;
+ goto cleanup_and_return;
LOG_DEBUG("Remote call flash_range_erase");
@@ -452,18 +832,13 @@ static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsig
0xd8 /* block_cmd */
};
- /*
- The RP2040 Boot ROM provides a _flash_range_erase() API call documented in Section 2.8.3.1.3:
- https://datasheets.raspberrypi.org/rp2040/rp2040-datasheet.pdf
- and the particular source code for said Boot ROM function can be found here:
- https://github.com/raspberrypi/pico-bootrom/blob/master/bootrom/program_flash_generic.c
-
- In theory, the function algorithm provides for erasing both a smaller "sector" (4096 bytes) and
- an optional larger "block" (size and command provided in args). OpenOCD's spi.c only uses "block" sizes.
- */
-
- err = rp2040_call_rom_func(bank->target, priv, priv->jump_flash_range_erase, args, ARRAY_SIZE(args));
+ /* This ROM function will use the optimal mixture of 4k 20h and 64k D8h
+ erases, without over-erase, as long as you just tell OpenOCD that your
+ flash is made up of 4k sectors instead of letting it try to guess. */
+ err = rp2xxx_call_rom_func(bank->target, priv, priv->jump_flash_range_erase, args, ARRAY_SIZE(args));
+cleanup_and_return:
+ cleanup_after_raw_flash_cmd(bank);
return err;
}
@@ -475,63 +850,9 @@ static int rp2040_flash_probe(struct flash_bank *bank)
struct rp2040_flash_bank *priv = bank->driver_priv;
struct target *target = bank->target;
- int err = rp2040_lookup_symbol(target, FUNC_DEBUG_TRAMPOLINE, &priv->jump_debug_trampoline);
- if (err != ERROR_OK) {
- LOG_ERROR("Debug trampoline not found in RP2040 ROM.");
- return err;
- }
- priv->jump_debug_trampoline &= ~1u; /* mask off thumb bit */
-
- err = rp2040_lookup_symbol(target, FUNC_DEBUG_TRAMPOLINE_END, &priv->jump_debug_trampoline_end);
- if (err != ERROR_OK) {
- LOG_ERROR("Debug trampoline end not found in RP2040 ROM.");
- return err;
- }
- priv->jump_debug_trampoline_end &= ~1u; /* mask off thumb bit */
-
- err = rp2040_lookup_symbol(target, FUNC_FLASH_EXIT_XIP, &priv->jump_flash_exit_xip);
- if (err != ERROR_OK) {
- LOG_ERROR("Function FUNC_FLASH_EXIT_XIP not found in RP2040 ROM.");
- return err;
- }
-
- err = rp2040_lookup_symbol(target, FUNC_CONNECT_INTERNAL_FLASH, &priv->jump_connect_internal_flash);
- if (err != ERROR_OK) {
- LOG_ERROR("Function FUNC_CONNECT_INTERNAL_FLASH not found in RP2040 ROM.");
- return err;
- }
-
- err = rp2040_lookup_symbol(target, FUNC_FLASH_RANGE_ERASE, &priv->jump_flash_range_erase);
- if (err != ERROR_OK) {
- LOG_ERROR("Function FUNC_FLASH_RANGE_ERASE not found in RP2040 ROM.");
- return err;
- }
- LOG_WARNING("GOT FLASH ERASE AT %08x\n", (int)priv->jump_flash_range_erase);
-
- err = rp2040_lookup_symbol(target, FUNC_FLASH_RANGE_PROGRAM, &priv->jump_flash_range_program);
- if (err != ERROR_OK) {
- LOG_ERROR("Function FUNC_FLASH_RANGE_PROGRAM not found in RP2040 ROM.");
- return err;
- }
-
- err = rp2040_lookup_symbol(target, FUNC_FLASH_FLUSH_CACHE, &priv->jump_flush_cache);
- if (err != ERROR_OK) {
- LOG_ERROR("Function FUNC_FLASH_FLUSH_CACHE not found in RP2040 ROM.");
- return err;
- }
-
- err = rp2040_lookup_symbol(target, FUNC_FLASH_ENTER_CMD_XIP, &priv->jump_enter_cmd_xip);
- if (err != ERROR_OK) {
- LOG_ERROR("Function FUNC_FLASH_ENTER_CMD_XIP not found in RP2040 ROM.");
+ int err = rp2xxx_populate_rom_pointer_cache(target, priv);
+ if (err != ERROR_OK)
return err;
- }
-
- err = rp2040_lookup_symbol(target, FUNC_BOOTROM_STATE_RESET, &priv->jump_bootrom_reset_state);
- if (err != ERROR_OK) {
- priv->jump_bootrom_reset_state = 0;
-// LOG_ERROR("Function FUNC_BOOTROM_STATE_RESET not found in RP2040 ROM.");
-// return err;
- }
/* the Boot ROM flash_range_program() routine requires page alignment */
bank->write_start_alignment = 256;
@@ -577,6 +898,7 @@ FLASH_BANK_COMMAND_HANDLER(rp2040_flash_bank_command)
{
struct rp2040_flash_bank *priv;
priv = malloc(sizeof(struct rp2040_flash_bank));
+ memset(priv, 0, sizeof(struct rp2040_flash_bank));
priv->probed = false;
/* Set up driver_priv */
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/rp2040.c | 873 +++++++++++++++++++++++++++++++++----------------
1 file changed, 596 insertions(+), 277 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-25 09:27:01
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via ea775d49fc71253a95986eb5b1254b4861bdeb97 (commit)
from 2aa0592e0fd90218ff55446ebb3a9233017e59f7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ea775d49fc71253a95986eb5b1254b4861bdeb97
Author: graham sanderson <gra...@ra...>
Date: Fri Nov 3 15:55:41 2023 -0500
flash/nor/rp2040: add RP2350 support
TV: Extracted RP2040/2350 flash driver part only.
Fixed style problems.
Change-Id: I88a7d5aa0a239ae93d72bd5671686b19c6ca11ad
Signed-off-by: Tomas Vanek <va...@fb...>
Signed-off-by: graham sanderson <gra...@ra...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8440
Tested-by: jenkins
diff --git a/src/flash/nor/rp2040.c b/src/flash/nor/rp2040.c
index b2ebd9c49..c53b54754 100644
--- a/src/flash/nor/rp2040.c
+++ b/src/flash/nor/rp2040.c
@@ -9,14 +9,19 @@
#include <target/algorithm.h>
#include <target/armv7m.h>
#include "spi.h"
+#include <target/cortex_m.h>
/* NOTE THAT THIS CODE REQUIRES FLASH ROUTINES in BOOTROM WITH FUNCTION TABLE PTR AT 0x00000010
Your gdbinit should load the bootrom.elf if appropriate */
/* this is 'M' 'u', 1 (version) */
-#define BOOTROM_MAGIC 0x01754d
+#define BOOTROM_RP2040_MAGIC 0x01754d
+/* this is 'M' 'u', 2 (version) */
+#define BOOTROM_RP2350_MAGIC 0x02754d
#define BOOTROM_MAGIC_ADDR 0x00000010
+#define RT_ARM_FUNC 0x1
+
/* Call a ROM function via the debug trampoline
Up to four arguments passed in r0...r3 as per ABI
Function address is passed in r7
@@ -31,6 +36,48 @@
#define FUNC_FLASH_RANGE_PROGRAM MAKE_TAG('R', 'P')
#define FUNC_FLASH_FLUSH_CACHE MAKE_TAG('F', 'C')
#define FUNC_FLASH_ENTER_CMD_XIP MAKE_TAG('C', 'X')
+#define FUNC_BOOTROM_STATE_RESET MAKE_TAG('S', 'R')
+
+// these form a bit set
+#define BOOTROM_STATE_RESET_CURRENT_CORE 0x01
+#define BOOTROM_STATE_RESET_OTHER_CORE 0x02
+#define BOOTROM_STATE_RESET_GLOBAL_STATE 0x04
+
+#define ACCESSCTRL_LOCK_OFFSET 0x40060000u
+#define ACCESSCTRL_LOCK_DEBUG_BITS 0x00000008u
+#define ACCESSCTRL_CFGRESET_OFFSET 0x40060008u
+#define ACCESSCTRL_WRITE_PASSWORD 0xacce0000u
+
+// Calling bootrom functions requires the redundancy coprocessor (RCP) to be
+// initialised. Usually this is done first thing by the bootrom, but the
+// debugger may skip this, e.g. by resetting the cores and then running a
+// NO_FLASH binary, or by reset-halting the cores before flash programming.
+//
+// The first case can be handled by a stub in the binary itself to initialise
+// the RCP with dummy values if the bootrom has not already initialised it.
+// (Note this case is only reachable via the debugger.) The second case
+// requires the debugger itself to initialise the RCP, using this stub code:
+
+static const int rcp_init_code_bkpt_offset = 24;
+static const uint16_t rcp_init_code[] = {
+ // Just enable the RCP which is fine if it already was (we assume no other
+ // co-processors are enabled at this point to save space)
+ 0x4806, // ldr r0, = PPB_BASE + M33_CPACR_OFFSET
+ 0xf45f, 0x4140, // movs r1, #M33_CPACR_CP7_BITS
+ 0x6001, // str r1, [r0]
+ // Only initialize canary seeds if they haven't been (as to do so twice is a fault)
+ 0xee30, 0xf710, // mrc p7, #1, r15, c0, c0, #0
+ 0xd404, // bmi 1f
+ // Todo should we use something random here and pass it into the algorithm?
+ 0xec40, 0x0780, // mcrr p7, #8, r0, r0, c0
+ 0xec40, 0x0781, // mcrr p7, #8, r0, r0, c1
+ // Let other core know
+ 0xbf40, // sev
+ // 1:
+ 0xbe00, // bkpt (end of algorithm)
+ 0x0000, // pad
+ 0xed88, 0xe000 // PPB_BASE + M33_CPACR_OFFSET
+};
struct rp2040_flash_bank {
/* flag indicating successful flash probe */
@@ -46,33 +93,31 @@ struct rp2040_flash_bank {
uint16_t jump_flash_range_program;
uint16_t jump_flush_cache;
uint16_t jump_enter_cmd_xip;
- /* detected model of SPI flash */
- const struct flash_device *dev;
+ uint16_t jump_bootrom_reset_state;
};
-/* guessed SPI flash description if autodetection disabled (same as win w25q16jv) */
-static const struct flash_device rp2040_default_spi_device =
- FLASH_ID("autodetect disabled", 0x03, 0x00, 0x02, 0xd8, 0xc7, 0, 0x100, 0x10000, 0);
-
static uint32_t rp2040_lookup_symbol(struct target *target, uint32_t tag, uint16_t *symbol)
{
- uint32_t magic;
+ uint32_t magic, magic_addr;
+ bool found_rp2040_magic, found_rp2350_magic;
+ magic_addr = BOOTROM_MAGIC_ADDR;
int err = target_read_u32(target, BOOTROM_MAGIC_ADDR, &magic);
if (err != ERROR_OK)
return err;
magic &= 0xffffff; /* ignore bootrom version */
- if (magic != BOOTROM_MAGIC) {
- if (!((magic ^ BOOTROM_MAGIC)&0xffff))
- LOG_ERROR("Incorrect RP2040 BOOT ROM version");
- else
- LOG_ERROR("RP2040 BOOT ROM not found");
+
+ found_rp2040_magic = magic == BOOTROM_RP2040_MAGIC;
+ found_rp2350_magic = magic == BOOTROM_RP2350_MAGIC;
+
+ if (!(found_rp2040_magic || found_rp2350_magic)) {
+ LOG_ERROR("RP2040/RP2350 BOOT ROM not found");
return ERROR_FAIL;
}
/* dereference the table pointer */
uint16_t table_entry;
- err = target_read_u16(target, BOOTROM_MAGIC_ADDR + 4, &table_entry);
+ err = target_read_u16(target, magic_addr + 4, &table_entry);
if (err != ERROR_OK)
return err;
@@ -82,16 +127,29 @@ static uint32_t rp2040_lookup_symbol(struct target *target, uint32_t tag, uint16
if (err != ERROR_OK)
return err;
if (entry_tag == tag) {
- /* 16 bit symbol is next */
- return target_read_u16(target, table_entry + 2, symbol);
+ if (found_rp2350_magic) {
+ uint16_t flags;
+ /* flags are next */
+ err = target_read_u16(target, table_entry + 4, &flags);
+ if (err != ERROR_OK)
+ return err;
+ //
+ if (flags & RT_ARM_FUNC) {
+ /* 16 bit symbol */
+ return target_read_u16(target, table_entry + 2, symbol);
+ }
+ } else {
+ /* 16 bit symbol is next */
+ return target_read_u16(target, table_entry + 2, symbol);
+ }
}
- table_entry += 4;
+ table_entry += found_rp2350_magic ? 6 : 4;
} while (entry_tag);
return ERROR_FAIL;
}
static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank *priv,
- uint16_t func_offset, uint32_t argdata[], unsigned int n_args, unsigned int timeout_ms)
+ uint16_t func_offset, uint32_t argdata[], unsigned int n_args)
{
char *regnames[4] = { "r0", "r1", "r2", "r3" };
@@ -103,9 +161,10 @@ static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank
}
target_addr_t stacktop = priv->stack->address + priv->stack->size;
- LOG_TARGET_DEBUG(target, "Calling ROM func @0x%" PRIx16 " with %u arguments", func_offset, n_args);
+ LOG_DEBUG("Calling ROM func @0x%" PRIx16 " with %d arguments", func_offset, n_args);
+ LOG_DEBUG("Calling on core \"%s\"", target->cmd_name);
- struct reg_param args[ARRAY_SIZE(regnames) + 2];
+ struct reg_param args[ARRAY_SIZE(regnames) + 12];
struct armv7m_algorithm alg_info;
for (unsigned int i = 0; i < n_args; ++i) {
@@ -113,14 +172,36 @@ static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank
buf_set_u32(args[i].value, 0, 32, argdata[i]);
}
/* Pass function pointer in r7 */
- init_reg_param(&args[n_args], "r7", 32, PARAM_OUT);
- buf_set_u32(args[n_args].value, 0, 32, func_offset);
- /* Setup stack */
- init_reg_param(&args[n_args + 1], "sp", 32, PARAM_OUT);
- buf_set_u32(args[n_args + 1].value, 0, 32, stacktop);
- unsigned int n_reg_params = n_args + 2; /* User arguments + r7 + sp */
-
- for (unsigned int i = 0; i < n_reg_params; ++i)
+ unsigned int extra_args = 0;
+ init_reg_param(&args[n_args + extra_args], "r7", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, func_offset);
+ /* Set stack pointer, have seen the caching get confused by the aliases of sp so
+ take the shotgun approach*/
+ init_reg_param(&args[n_args + extra_args], "msp_s", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
+ init_reg_param(&args[n_args + extra_args], "msp_ns", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
+ init_reg_param(&args[n_args + extra_args], "psp_s", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
+ init_reg_param(&args[n_args + extra_args], "psp_ns", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
+ init_reg_param(&args[n_args + extra_args], "msp", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
+ init_reg_param(&args[n_args + extra_args], "psp", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
+ init_reg_param(&args[n_args + extra_args], "sp", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, stacktop);
+ /* Clear stack pointer limits, as they may be above the algorithm stack */
+ init_reg_param(&args[n_args + extra_args], "msplim_s", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, 0);
+ init_reg_param(&args[n_args + extra_args], "psplim_s", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, 0);
+ init_reg_param(&args[n_args + extra_args], "msplim_ns", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, 0);
+ init_reg_param(&args[n_args + extra_args], "psplim_ns", 32, PARAM_OUT);
+ buf_set_u32(args[n_args + extra_args++].value, 0, 32, 0);
+
+ for (unsigned int i = 0; i < n_args + extra_args; ++i)
LOG_DEBUG("Set %s = 0x%" PRIx32, args[i].reg_name, buf_get_u32(args[i].value, 0, 32));
/* Actually call the function */
@@ -129,82 +210,158 @@ static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank
int err = target_run_algorithm(
target,
0, NULL, /* No memory arguments */
- n_reg_params, args, /* User arguments + r7 + sp */
+ n_args + extra_args, args, /* User arguments + r7 + SPs */
priv->jump_debug_trampoline, priv->jump_debug_trampoline_end,
- timeout_ms,
+ 3000, /* 3s timeout */
&alg_info
);
-
- for (unsigned int i = 0; i < n_reg_params; ++i)
+ for (unsigned int i = 0; i < n_args + extra_args; ++i)
destroy_reg_param(&args[i]);
-
if (err != ERROR_OK)
- LOG_ERROR("Failed to invoke ROM function @0x%" PRIx16, func_offset);
-
+ LOG_ERROR("Failed to invoke ROM function @0x%" PRIx16 "\n", func_offset);
return err;
}
-/* Finalize flash write/erase/read ID
- * - flush cache
- * - enters memory-mapped (XIP) mode to make flash data visible
- * - deallocates target ROM func stack if previously allocated
- */
-static int rp2040_finalize_stack_free(struct flash_bank *bank)
+static int rp2350_init_core(struct target *target, struct rp2040_flash_bank *priv)
{
- struct rp2040_flash_bank *priv = bank->driver_priv;
- struct target *target = bank->target;
+ if (!priv->stack) {
+ LOG_ERROR("no stack for flash programming code");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
- /* Always flush before returning to execute-in-place, to invalidate stale
- * cache contents. The flush call also restores regular hardware-controlled
- * chip select following a rp2040_flash_exit_xip().
- */
- LOG_DEBUG("Flushing flash cache after write behind");
- int err = rp2040_call_rom_func(target, priv, priv->jump_flush_cache, NULL, 0, 1000);
+ struct armv7m_algorithm alg_info;
+
+ // copy rcp_init code onto stack, as we don't actually need any stack during the call
+ if (priv->stack->size < sizeof(rcp_init_code)) {
+ LOG_ERROR("Working area too small for rcp_init");
+ return ERROR_BUF_TOO_SMALL;
+ }
+
+ // Attempt to reset ACCESSCTRL before running RCP init, in case Secure
+ // access to SRAM has been blocked. (Also ROM, QMI regs are needed later)
+ uint32_t accessctrl_lock_reg;
+ if (target_read_u32(target, ACCESSCTRL_LOCK_OFFSET, &accessctrl_lock_reg) != ERROR_OK) {
+ LOG_ERROR("Failed to read ACCESSCTRL lock register");
+ // Failed to read an APB register which should always be readable from
+ // any security/privilege level. Something fundamental is wrong. E.g.:
+ //
+ // - The debugger is attempting to perform Secure bus accesses on a
+ // system where Secure debug has been disabled
+ // - clk_sys or busfabric clock are stopped (try doing a rescue reset)
+ return ERROR_FAIL;
+ }
+ if (accessctrl_lock_reg & ACCESSCTRL_LOCK_DEBUG_BITS) {
+ LOG_ERROR("ACCESSCTRL is locked, so can't reset permissions. Following steps might fail.\n");
+ } else {
+ LOG_DEBUG("Reset ACCESSCTRL permissions via CFGRESET\n");
+ target_write_u32(target, ACCESSCTRL_CFGRESET_OFFSET, ACCESSCTRL_WRITE_PASSWORD | 1u);
+ }
+
+ int err = target_write_memory(target,
+ priv->stack->address,
+ 1,
+ sizeof(rcp_init_code),
+ (const uint8_t *)rcp_init_code
+ );
if (err != ERROR_OK) {
- LOG_ERROR("Failed to flush flash cache");
- /* Intentionally continue after error and try to setup xip anyway */
+ LOG_ERROR("Failed to load rcp_init algorithm into RAM\n");
+ return ERROR_FAIL;
}
- LOG_DEBUG("Configuring SSI for execute-in-place");
- err = rp2040_call_rom_func(target, priv, priv->jump_enter_cmd_xip, NULL, 0, 1000);
- if (err != ERROR_OK)
- LOG_ERROR("Failed to set SSI to XIP mode");
+ LOG_DEBUG("Calling rcp_init core \"%s\" code at 0x%" PRIx16 "\n", target->cmd_name, (uint32_t)priv->stack->address);
+
+ /* Actually call the function */
+ alg_info.common_magic = ARMV7M_COMMON_MAGIC;
+ alg_info.core_mode = ARM_MODE_THREAD;
+ err = target_run_algorithm(target,
+ 0, NULL, /* No memory arguments */
+ 0, NULL, /* No register arguments */
+ priv->stack->address,
+ priv->stack->address + rcp_init_code_bkpt_offset,
+ 1000, /* 1s timeout */
+ &alg_info
+ );
+ if (err != ERROR_OK) {
+ LOG_ERROR("Failed to invoke rcp_init\n");
+ return err;
+ }
+
+ uint32_t reset_args[1] = {
+ BOOTROM_STATE_RESET_CURRENT_CORE
+ };
+ if (!priv->jump_bootrom_reset_state) {
+ LOG_WARNING("RP2350 flash: no bootrom_reset_method\n");
+ } else {
+ err = rp2040_call_rom_func(target, priv, priv->jump_bootrom_reset_state, reset_args, ARRAY_SIZE(reset_args));
+ if (err != ERROR_OK) {
+ LOG_ERROR("RP2040 flash: failed to call reset core state");
+ return err;
+ }
+ }
- target_free_working_area(target, priv->stack);
- priv->stack = NULL;
return err;
}
-/* Prepare flash write/erase/read ID
- * - allocates a stack for target ROM func
- * - switches the SPI interface from memory-mapped mode to direct command mode
- * Always pair with a call of rp2040_finalize_stack_free()
- * after flash operation finishes or fails.
- */
-static int rp2040_stack_grab_and_prep(struct flash_bank *bank)
+static int setup_for_rom_call(struct flash_bank *bank)
{
struct rp2040_flash_bank *priv = bank->driver_priv;
+
struct target *target = bank->target;
- /* target_alloc_working_area always allocates multiples of 4 bytes, so no worry about alignment */
- const int STACK_SIZE = 256;
- int err = target_alloc_working_area(target, STACK_SIZE, &priv->stack);
+ int err = ERROR_OK;
+ if (!priv->stack) {
+ /* target_alloc_working_area always allocates multiples of 4 bytes, so no worry about alignment */
+ const int STACK_SIZE = 256;
+ target_alloc_working_area(bank->target, STACK_SIZE, &priv->stack);
+ if (err != ERROR_OK) {
+ LOG_ERROR("Could not allocate stack for flash programming code");
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ }
+ }
+
+ // Flash algorithms must run in Secure state
+ uint32_t dscsr;
+ (void)target_read_u32(target, DCB_DSCSR, &dscsr);
+ LOG_DEBUG("DSCSR: %08x\n", dscsr);
+ if (!(dscsr & DSCSR_CDS)) {
+ LOG_DEBUG("Setting Current Domain Secure in DSCSR\n");
+ (void)target_write_u32(target, DCB_DSCSR, (dscsr & ~DSCSR_CDSKEY) | DSCSR_CDS);
+ (void)target_read_u32(target, DCB_DSCSR, &dscsr);
+ LOG_DEBUG("DSCSR*: %08x\n", dscsr);
+ }
+
+ // hacky RP2350 check
+ if (target_to_arm(target)->arch == ARM_ARCH_V8M) {
+ err = rp2350_init_core(target, priv);
+ if (err != ERROR_OK) {
+ LOG_ERROR("RP2350 flash: failed to init core");
+ return err;
+ }
+ }
+ return err;
+}
+
+static int setup_for_raw_flash_cmd(struct flash_bank *bank)
+{
+ struct rp2040_flash_bank *priv = bank->driver_priv;
+ int err = setup_for_rom_call(bank);
+ err = rp2040_call_rom_func(bank->target, priv, priv->jump_connect_internal_flash, NULL, 0);
if (err != ERROR_OK) {
- LOG_ERROR("Could not allocate stack for flash programming code");
- return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ LOG_ERROR("RP2040 flash: failed to setup for rom call");
+ return err;
}
LOG_DEBUG("Connecting internal flash");
- err = rp2040_call_rom_func(target, priv, priv->jump_connect_internal_flash, NULL, 0, 1000);
+ err = rp2040_call_rom_func(bank->target, priv, priv->jump_connect_internal_flash, NULL, 0);
if (err != ERROR_OK) {
- LOG_ERROR("Failed to connect internal flash");
+ LOG_ERROR("RP2040 flash: failed to connect internal flash");
return err;
}
LOG_DEBUG("Kicking flash out of XIP mode");
- err = rp2040_call_rom_func(target, priv, priv->jump_flash_exit_xip, NULL, 0, 1000);
+ err = rp2040_call_rom_func(bank->target, priv, priv->jump_flash_exit_xip, NULL, 0);
if (err != ERROR_OK) {
- LOG_ERROR("Failed to exit flash XIP mode");
+ LOG_ERROR("RP2040 flash: failed to exit flash XIP mode");
return err;
}
@@ -217,27 +374,17 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
struct rp2040_flash_bank *priv = bank->driver_priv;
struct target *target = bank->target;
+ struct working_area *bounce;
- if (target->state != TARGET_HALTED) {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
- struct working_area *bounce = NULL;
-
- int err = rp2040_stack_grab_and_prep(bank);
+ int err = setup_for_raw_flash_cmd(bank);
if (err != ERROR_OK)
- goto cleanup;
-
- unsigned int avail_pages = target_get_working_area_avail(target) / priv->dev->pagesize;
- /* We try to allocate working area rounded down to device page size,
- * al least 1 page, at most the write data size
- */
- unsigned int chunk_size = MIN(MAX(avail_pages, 1) * priv->dev->pagesize, count);
- err = target_alloc_working_area(target, chunk_size, &bounce);
- if (err != ERROR_OK) {
+ return err;
+
+ // Allocate as much memory as possible, rounded down to a whole number of flash pages
+ const unsigned int chunk_size = target_get_working_area_avail(target) & ~0xffu;
+ if (chunk_size == 0 || target_alloc_working_area(target, chunk_size, &bounce) != ERROR_OK) {
LOG_ERROR("Could not allocate bounce buffer for flash programming. Can't continue");
- goto cleanup;
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
LOG_DEBUG("Allocated flash bounce buffer @" TARGET_ADDR_FMT, bounce->address);
@@ -255,8 +402,7 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
bounce->address, /* data */
write_size /* count */
};
- err = rp2040_call_rom_func(target, priv, priv->jump_flash_range_program,
- args, ARRAY_SIZE(args), 3000);
+ err = rp2040_call_rom_func(target, priv, priv->jump_flash_range_program, args, ARRAY_SIZE(args));
if (err != ERROR_OK) {
LOG_ERROR("Failed to invoke flash programming code on target");
break;
@@ -266,40 +412,44 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
offset += write_size;
count -= write_size;
}
-
-cleanup:
target_free_working_area(target, bounce);
- rp2040_finalize_stack_free(bank);
+ if (err != ERROR_OK)
+ return err;
+ /* Flash is successfully programmed. We can now do a bit of poking to make the flash
+ contents visible to us via memory-mapped (XIP) interface in the 0x1... memory region */
+ LOG_DEBUG("Flushing flash cache after write behind");
+ err = rp2040_call_rom_func(bank->target, priv, priv->jump_flush_cache, NULL, 0);
+ if (err != ERROR_OK) {
+ LOG_ERROR("RP2040 write: failed to flush flash cache");
+ return err;
+ }
+ LOG_DEBUG("Configuring SSI for execute-in-place");
+ err = rp2040_call_rom_func(bank->target, priv, priv->jump_enter_cmd_xip, NULL, 0);
+ if (err != ERROR_OK)
+ LOG_ERROR("RP2040 write: failed to flush flash cache");
return err;
}
static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
{
struct rp2040_flash_bank *priv = bank->driver_priv;
- struct target *target = bank->target;
-
- if (target->state != TARGET_HALTED) {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
uint32_t start_addr = bank->sectors[first].offset;
uint32_t length = bank->sectors[last].offset + bank->sectors[last].size - start_addr;
LOG_DEBUG("RP2040 erase %d bytes starting at 0x%" PRIx32, length, start_addr);
- int err = rp2040_stack_grab_and_prep(bank);
+ int err = setup_for_raw_flash_cmd(bank);
if (err != ERROR_OK)
- goto cleanup;
+ return err;
LOG_DEBUG("Remote call flash_range_erase");
uint32_t args[4] = {
bank->sectors[first].offset, /* addr */
bank->sectors[last].offset + bank->sectors[last].size - bank->sectors[first].offset, /* count */
- priv->dev->sectorsize, /* block_size */
- priv->dev->erase_cmd /* block_cmd */
+ 65536, /* block_size */
+ 0xd8 /* block_cmd */
};
/*
@@ -309,15 +459,10 @@ static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsig
https://github.com/raspberrypi/pico-bootrom/blob/master/bootrom/program_flash_generic.c
In theory, the function algorithm provides for erasing both a smaller "sector" (4096 bytes) and
- an optional larger "block" (size and command provided in args).
+ an optional larger "block" (size and command provided in args). OpenOCD's spi.c only uses "block" sizes.
*/
- unsigned int timeout_ms = 2000 * (last - first) + 1000;
- err = rp2040_call_rom_func(target, priv, priv->jump_flash_range_erase,
- args, ARRAY_SIZE(args), timeout_ms);
-
-cleanup:
- rp2040_finalize_stack_free(bank);
+ err = rp2040_call_rom_func(bank->target, priv, priv->jump_flash_range_erase, args, ARRAY_SIZE(args));
return err;
}
@@ -325,67 +470,11 @@ cleanup:
/* -----------------------------------------------------------------------------
Driver probing etc */
-static int rp2040_ssel_active(struct target *target, bool active)
-{
- const target_addr_t qspi_ctrl_addr = 0x4001800c;
- const uint32_t qspi_ctrl_outover_low = 2UL << 8;
- const uint32_t qspi_ctrl_outover_high = 3UL << 8;
- uint32_t state = (active) ? qspi_ctrl_outover_low : qspi_ctrl_outover_high;
- uint32_t val;
-
- int err = target_read_u32(target, qspi_ctrl_addr, &val);
- if (err != ERROR_OK)
- return err;
-
- val = (val & ~qspi_ctrl_outover_high) | state;
-
- err = target_write_u32(target, qspi_ctrl_addr, val);
- if (err != ERROR_OK)
- return err;
-
- return ERROR_OK;
-}
-
-static int rp2040_spi_read_flash_id(struct target *target, uint32_t *devid)
-{
- uint32_t device_id = 0;
- const target_addr_t ssi_dr0 = 0x18000060;
-
- int err = rp2040_ssel_active(target, true);
-
- /* write RDID request into SPI peripheral's FIFO */
- for (int count = 0; (count < 4) && (err == ERROR_OK); count++)
- err = target_write_u32(target, ssi_dr0, SPIFLASH_READ_ID);
-
- /* by this time, there is a receive FIFO entry for every write */
- for (int count = 0; (count < 4) && (err == ERROR_OK); count++) {
- uint32_t status;
- err = target_read_u32(target, ssi_dr0, &status);
-
- device_id >>= 8;
- device_id |= (status & 0xFF) << 24;
- }
-
- if (err == ERROR_OK)
- *devid = device_id >> 8;
-
- int err2 = rp2040_ssel_active(target, false);
- if (err2 != ERROR_OK)
- LOG_ERROR("SSEL inactive failed");
-
- return err;
-}
-
static int rp2040_flash_probe(struct flash_bank *bank)
{
struct rp2040_flash_bank *priv = bank->driver_priv;
struct target *target = bank->target;
- if (target->state != TARGET_HALTED) {
- LOG_ERROR("Target not halted");
- return ERROR_TARGET_NOT_HALTED;
- }
-
int err = rp2040_lookup_symbol(target, FUNC_DEBUG_TRAMPOLINE, &priv->jump_debug_trampoline);
if (err != ERROR_OK) {
LOG_ERROR("Debug trampoline not found in RP2040 ROM.");
@@ -417,6 +506,7 @@ static int rp2040_flash_probe(struct flash_bank *bank)
LOG_ERROR("Function FUNC_FLASH_RANGE_ERASE not found in RP2040 ROM.");
return err;
}
+ LOG_WARNING("GOT FLASH ERASE AT %08x\n", (int)priv->jump_flash_range_erase);
err = rp2040_lookup_symbol(target, FUNC_FLASH_RANGE_PROGRAM, &priv->jump_flash_range_program);
if (err != ERROR_OK) {
@@ -436,50 +526,25 @@ static int rp2040_flash_probe(struct flash_bank *bank)
return err;
}
- if (bank->size) {
- /* size overridden, suppress reading SPI flash ID */
- priv->dev = &rp2040_default_spi_device;
- LOG_DEBUG("SPI flash autodetection disabled, using configured size");
-
- } else {
- /* zero bank size in cfg, read SPI flash ID and autodetect */
- err = rp2040_stack_grab_and_prep(bank);
-
- uint32_t device_id = 0;
- if (err == ERROR_OK)
- err = rp2040_spi_read_flash_id(target, &device_id);
-
- rp2040_finalize_stack_free(bank);
-
- if (err != ERROR_OK)
- return err;
-
- /* search for a SPI flash Device ID match */
- priv->dev = NULL;
- for (const struct flash_device *p = flash_devices; p->name ; p++)
- if (p->device_id == device_id) {
- priv->dev = p;
- break;
- }
-
- if (!priv->dev) {
- LOG_ERROR("Unknown flash device (ID 0x%08" PRIx32 ")", device_id);
- return ERROR_FAIL;
- }
- LOG_INFO("Found flash device '%s' (ID 0x%08" PRIx32 ")",
- priv->dev->name, priv->dev->device_id);
-
- bank->size = priv->dev->size_in_bytes;
+ err = rp2040_lookup_symbol(target, FUNC_BOOTROM_STATE_RESET, &priv->jump_bootrom_reset_state);
+ if (err != ERROR_OK) {
+ priv->jump_bootrom_reset_state = 0;
+// LOG_ERROR("Function FUNC_BOOTROM_STATE_RESET not found in RP2040 ROM.");
+// return err;
}
/* the Boot ROM flash_range_program() routine requires page alignment */
- bank->write_start_alignment = priv->dev->pagesize;
- bank->write_end_alignment = priv->dev->pagesize;
+ bank->write_start_alignment = 256;
+ bank->write_end_alignment = 256;
+
+ // Max size -- up to two devices (two chip selects) in adjacent 24-bit address windows
+ bank->size = 32 * 1024 * 1024;
+
+ bank->num_sectors = bank->size / 4096;
- bank->num_sectors = bank->size / priv->dev->sectorsize;
- LOG_INFO("RP2040 B0 Flash Probe: %" PRIu32 " bytes @" TARGET_ADDR_FMT ", in %u sectors\n",
+ LOG_INFO("RP2040 Flash Probe: %d bytes @" TARGET_ADDR_FMT ", in %d sectors\n",
bank->size, bank->base, bank->num_sectors);
- bank->sectors = alloc_block_array(0, priv->dev->sectorsize, bank->num_sectors);
+ bank->sectors = alloc_block_array(0, 4096, bank->num_sectors);
if (!bank->sectors)
return ERROR_FAIL;
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/rp2040.c | 483 ++++++++++++++++++++++++++++---------------------
1 file changed, 274 insertions(+), 209 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:25:57
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 2aa0592e0fd90218ff55446ebb3a9233017e59f7 (commit)
from 498e5590297e11a9c952d4210c6236fe8105241f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2aa0592e0fd90218ff55446ebb3a9233017e59f7
Author: Antonio Borneo <bor...@gm...>
Date: Sun Apr 6 14:59:50 2025 +0200
flash: stellaris: fix deprecated command
The driver directly runs a TCL command that has been renamed with
commit 4d99e77419e3 ("jtag/hla: Restructure commands"), while the
original name has been deprecated.
Update the TCL command to the new syntax.
Change-Id: I2fc9ef9a209bae1d78951e253d54164b2ac00cdd
Signed-off-by: Antonio Borneo <bor...@gm...>
Fixes: 4d99e77419e3 ("jtag/hla: Restructure commands")
Reviewed-on: https://review.openocd.org/c/openocd/+/8832
Reviewed-by: zapb <de...@za...>
Tested-by: jenkins
diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c
index 1f53b2f35..f7dcc6f0e 100644
--- a/src/flash/nor/stellaris.c
+++ b/src/flash/nor/stellaris.c
@@ -1342,7 +1342,7 @@ COMMAND_HANDLER(stellaris_handle_recover_command)
* cycle to recover.
*/
- Jim_Eval_Named(CMD_CTX->interp, "catch { hla_command \"debug unlock\" }", NULL, 0);
+ Jim_Eval_Named(CMD_CTX->interp, "catch { hla command \"debug unlock\" }", NULL, 0);
if (!strcmp(Jim_GetString(Jim_GetResult(CMD_CTX->interp), NULL), "0")) {
retval = ERROR_OK;
goto user_action;
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/stellaris.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:25:34
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 498e5590297e11a9c952d4210c6236fe8105241f (commit)
from 797dc7aba74152115898084dd00a50757b20c985 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 498e5590297e11a9c952d4210c6236fe8105241f
Author: Junhui Liu <jun...@pi...>
Date: Wed Mar 26 23:05:39 2025 +0800
tcl/target: Add RCPU support for Spacemit K1
Add support for the Real-Time CPU (RCPU) of K1, which is a 32-bit RISC-V
N308 High-Efficiency Processor Core designed by Nuclei System Technology
Co. Ltd.
The JTAG interface can be configured to connect to either X60s or RCPU
processors. To enable JTAG for RCPU, set TARGET to "rcpu".
For example:
openocd -c "set TARGET rcpu" -f interface/cmsis-dap.cfg \
-f target/spacemit-k1.cfg
Change-Id: I9cd62fac332137afac17efa52702818de8f0b6f5
Signed-off-by: Junhui Liu <jun...@pi...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8821
Reviewed-by: liangzhen <zhe...@sp...>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/tcl/target/spacemit-k1.cfg b/tcl/target/spacemit-k1.cfg
index ef5d7833d..e57d1adbc 100644
--- a/tcl/target/spacemit-k1.cfg
+++ b/tcl/target/spacemit-k1.cfg
@@ -10,6 +10,21 @@ transport select jtag
adapter speed 2000
+# Set TARGET to "rcpu" to enable JTAG for RCPU
+if { [info exists TARGET] } {
+ set _TARGET $TARGET
+} else {
+ set _TARGET x60
+}
+
+if { $_TARGET == "rcpu" } {
+ set CPUTAPID 0x10308A6D
+ set DRVAL 0xe
+} else {
+ set CPUTAPID 0x10000E21
+ set DRVAL 0xa
+}
+
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
@@ -23,44 +38,49 @@ if { [info exists CORES] } {
}
if { [info exists SECJTAG] } {
- jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10000E21
+ jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $CPUTAPID
} else {
jtag newtap pre unknown -irlen 1 -expected-id 0x00000000 -disable
jtag configure pre.unknown -event tap-enable ""
- jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10000E21 -disable
+ jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $CPUTAPID -disable
jtag configure $_CHIPNAME.cpu -event tap-enable ""
jtag newtap post unknown -irlen 9 -expected-id 0x08501C0D -ignore-version
jtag configure post.unknown -event setup {
- global _CHIPNAME
+ global _CHIPNAME DRVAL
irscan post.unknown 0x98
- drscan post.unknown 16 0xa
+ drscan post.unknown 16 $DRVAL
jtag tapenable pre.unknown
jtag tapenable $_CHIPNAME.cpu
}
}
-set _TARGETNAME $_CHIPNAME.cpu
-set DBGBASE {0x0 0x400}
-set _smp_command "target smp"
+set _TARGETNAME $_CHIPNAME.cpu_$_TARGET
+
+if { $_TARGET == "rcpu" } {
+ target create $_TARGETNAME.0 riscv -chain-position $_CHIPNAME.cpu
+} else {
+ set DBGBASE {0x0 0x400}
+ set _smp_command "target smp"
-for { set _core 0 } { $_core < $_cores } { incr _core } {
- target create $_TARGETNAME.$_core riscv -chain-position $_TARGETNAME \
- -coreid [expr {$_core % 4}] -dbgbase [lindex $DBGBASE [expr {$_core / 4}]]
+ for { set _core 0 } { $_core < $_cores } { incr _core } {
+ target create $_TARGETNAME.$_core riscv -chain-position $_CHIPNAME.cpu \
+ -coreid [expr {$_core % 4}] -dbgbase [lindex $DBGBASE [expr {$_core / 4}]]
- if { [expr {$_core % 4}] == 0 } {
- $_TARGETNAME.$_core configure -rtos hwthread
+ if { [expr {$_core % 4}] == 0 } {
+ $_TARGETNAME.$_core configure -rtos hwthread
+ }
+
+ set _smp_command "$_smp_command $_TARGETNAME.$_core"
}
- set _smp_command "$_smp_command $_TARGETNAME.$_core"
+ eval $_smp_command
}
-eval $_smp_command
-
set _SPEED 8000
$_TARGETNAME.0 configure -event examine-start {
-----------------------------------------------------------------------
Summary of changes:
tcl/target/spacemit-k1.cfg | 50 ++++++++++++++++++++++++++++++++--------------
1 file changed, 35 insertions(+), 15 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:25:01
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 797dc7aba74152115898084dd00a50757b20c985 (commit)
from 9a09d38478e2fbe7a9482af11b0fafb04689355d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 797dc7aba74152115898084dd00a50757b20c985
Author: HAOUES Ahmed <ahm...@st...>
Date: Tue Mar 25 14:29:30 2025 +0100
flash/stm32l4x: support STM32C05/09x devices
STM32C05/09x devices are similar to STM32C03/07x devices
Change-Id: I77c803356c32f06699c14622828585609c90a136
Signed-off-by: HAOUES Ahmed <ahm...@st...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8618
Reviewed-by: Tomas Vanek <va...@fb...>
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c
index fa57db8bb..f16333201 100644
--- a/src/flash/nor/stm32l4x.c
+++ b/src/flash/nor/stm32l4x.c
@@ -303,10 +303,18 @@ static const struct stm32l4_rev stm32c03xx_revs[] = {
{ 0x1000, "A" }, { 0x1001, "Z" },
};
+static const struct stm32l4_rev stm32c05xx_revs[] = {
+ { 0x1000, "A" },
+};
+
static const struct stm32l4_rev stm32c071xx_revs[] = {
{ 0x1001, "Z" },
};
+static const struct stm32l4_rev stm32c09xx_revs[] = {
+ { 0x1000, "A" },
+};
+
static const struct stm32l4_rev stm32g05_g06xx_revs[] = {
{ 0x1000, "A" },
};
@@ -450,6 +458,18 @@ static const struct stm32l4_part_info stm32l4_parts[] = {
.otp_base = 0x1FFF7000,
.otp_size = 1024,
},
+ {
+ .id = DEVID_STM32C05XX,
+ .revs = stm32c05xx_revs,
+ .num_revs = ARRAY_SIZE(stm32c05xx_revs),
+ .device_str = "STM32C05xx",
+ .max_flash_size_kb = 64,
+ .flags = F_NONE,
+ .flash_regs_base = 0x40022000,
+ .fsize_addr = 0x1FFF75A0,
+ .otp_base = 0x1FFF7000,
+ .otp_size = 1024,
+ },
{
.id = DEVID_STM32C071XX,
.revs = stm32c071xx_revs,
@@ -462,6 +482,18 @@ static const struct stm32l4_part_info stm32l4_parts[] = {
.otp_base = 0x1FFF7000,
.otp_size = 1024,
},
+ {
+ .id = DEVID_STM32C09XX,
+ .revs = stm32c09xx_revs,
+ .num_revs = ARRAY_SIZE(stm32c09xx_revs),
+ .device_str = "STM32C09xx",
+ .max_flash_size_kb = 256,
+ .flags = F_NONE,
+ .flash_regs_base = 0x40022000,
+ .fsize_addr = 0x1FFF75A0,
+ .otp_base = 0x1FFF7000,
+ .otp_size = 1024,
+ },
{
.id = DEVID_STM32U53_U54XX,
.revs = stm32u53_u54xx_revs,
@@ -2021,7 +2053,9 @@ static int stm32l4_probe(struct flash_bank *bank)
case DEVID_STM32L43_L44XX:
case DEVID_STM32C01XX:
case DEVID_STM32C03XX:
+ case DEVID_STM32C05XX:
case DEVID_STM32C071XX:
+ case DEVID_STM32C09XX:
case DEVID_STM32G05_G06XX:
case DEVID_STM32G07_G08XX:
case DEVID_STM32U031XX:
diff --git a/src/flash/nor/stm32l4x.h b/src/flash/nor/stm32l4x.h
index 3199d4f6d..07b3615a2 100644
--- a/src/flash/nor/stm32l4x.h
+++ b/src/flash/nor/stm32l4x.h
@@ -88,6 +88,8 @@
#define DEVID_STM32L47_L48XX 0x415
#define DEVID_STM32L43_L44XX 0x435
#define DEVID_STM32C01XX 0x443
+#define DEVID_STM32C05XX 0x44C
+#define DEVID_STM32C09XX 0x44D
#define DEVID_STM32C03XX 0x453
#define DEVID_STM32U53_U54XX 0x455
#define DEVID_STM32G05_G06XX 0x456
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/stm32l4x.c | 34 ++++++++++++++++++++++++++++++++++
src/flash/nor/stm32l4x.h | 2 ++
2 files changed, 36 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:24:26
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 9a09d38478e2fbe7a9482af11b0fafb04689355d (commit)
from 61890e3dc3201ce38e5af7f6b561389a123448e0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 9a09d38478e2fbe7a9482af11b0fafb04689355d
Author: Antonio Borneo <bor...@gm...>
Date: Sun Apr 6 14:10:28 2025 +0200
target: drop unused parameter to target_create()
The parameter Jim_Interp to the target API target_create() is not
used by any target.
Drop it.
Change-Id: I67c492078a6c808db974505f9e297c45165f64d0
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8831
Tested-by: jenkins
Reviewed-by: Tomas Vanek <va...@fb...>
diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index ce7808e3a..101cb1440 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -2814,7 +2814,7 @@ static int aarch64_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int armv8r_target_create(struct target *target, Jim_Interp *interp)
+static int armv8r_target_create(struct target *target)
{
struct aarch64_private_config *pc = target->private_config;
struct aarch64_common *aarch64;
@@ -2833,7 +2833,7 @@ static int armv8r_target_create(struct target *target, Jim_Interp *interp)
return aarch64_init_arch_info(target, aarch64, pc->adiv5_config.dap);
}
-static int aarch64_target_create(struct target *target, Jim_Interp *interp)
+static int aarch64_target_create(struct target *target)
{
struct aarch64_private_config *pc = target->private_config;
struct aarch64_common *aarch64;
diff --git a/src/target/arc.c b/src/target/arc.c
index 8757cafed..f2482c25e 100644
--- a/src/target/arc.c
+++ b/src/target/arc.c
@@ -1424,7 +1424,7 @@ static void arc_deinit_target(struct target *target)
}
-static int arc_target_create(struct target *target, Jim_Interp *interp)
+static int arc_target_create(struct target *target)
{
struct arc_common *arc = calloc(1, sizeof(*arc));
diff --git a/src/target/arm11.c b/src/target/arm11.c
index 756b36b95..583830f94 100644
--- a/src/target/arm11.c
+++ b/src/target/arm11.c
@@ -1079,7 +1079,7 @@ static int arm11_remove_breakpoint(struct target *target,
return ERROR_OK;
}
-static int arm11_target_create(struct target *target, Jim_Interp *interp)
+static int arm11_target_create(struct target *target)
{
struct arm11_common *arm11;
diff --git a/src/target/arm720t.c b/src/target/arm720t.c
index beab632c2..d1433dde7 100644
--- a/src/target/arm720t.c
+++ b/src/target/arm720t.c
@@ -412,7 +412,7 @@ static int arm720t_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int arm720t_target_create(struct target *target, Jim_Interp *interp)
+static int arm720t_target_create(struct target *target)
{
struct arm720t_common *arm720t = calloc(1, sizeof(*arm720t));
diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c
index 393d3b46a..2f59254af 100644
--- a/src/target/arm7tdmi.c
+++ b/src/target/arm7tdmi.c
@@ -669,7 +669,7 @@ int arm7tdmi_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int arm7tdmi_target_create(struct target *target, Jim_Interp *interp)
+static int arm7tdmi_target_create(struct target *target)
{
struct arm7_9_common *arm7_9;
diff --git a/src/target/arm920t.c b/src/target/arm920t.c
index 53b4d9d15..95cfd7ceb 100644
--- a/src/target/arm920t.c
+++ b/src/target/arm920t.c
@@ -833,7 +833,7 @@ static int arm920t_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int arm920t_target_create(struct target *target, Jim_Interp *interp)
+static int arm920t_target_create(struct target *target)
{
struct arm920t_common *arm920t;
diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c
index add90c997..053110656 100644
--- a/src/target/arm926ejs.c
+++ b/src/target/arm926ejs.c
@@ -702,7 +702,7 @@ int arm926ejs_init_arch_info(struct target *target, struct arm926ejs_common *arm
return ERROR_OK;
}
-static int arm926ejs_target_create(struct target *target, Jim_Interp *interp)
+static int arm926ejs_target_create(struct target *target)
{
struct arm926ejs_common *arm926ejs = calloc(1, sizeof(struct arm926ejs_common));
diff --git a/src/target/arm946e.c b/src/target/arm946e.c
index 03f7e443f..828e70f4b 100644
--- a/src/target/arm946e.c
+++ b/src/target/arm946e.c
@@ -79,7 +79,7 @@ static int arm946e_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int arm946e_target_create(struct target *target, Jim_Interp *interp)
+static int arm946e_target_create(struct target *target)
{
struct arm946e_common *arm946e = calloc(1, sizeof(struct arm946e_common));
diff --git a/src/target/arm966e.c b/src/target/arm966e.c
index 8598d29d9..b6bcc8ba9 100644
--- a/src/target/arm966e.c
+++ b/src/target/arm966e.c
@@ -38,7 +38,7 @@ int arm966e_init_arch_info(struct target *target, struct arm966e_common *arm966e
return ERROR_OK;
}
-static int arm966e_target_create(struct target *target, Jim_Interp *interp)
+static int arm966e_target_create(struct target *target)
{
struct arm966e_common *arm966e = calloc(1, sizeof(struct arm966e_common));
diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c
index 7e31306b6..8ab12de32 100644
--- a/src/target/arm9tdmi.c
+++ b/src/target/arm9tdmi.c
@@ -765,7 +765,7 @@ int arm9tdmi_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int arm9tdmi_target_create(struct target *target, Jim_Interp *interp)
+static int arm9tdmi_target_create(struct target *target)
{
struct arm7_9_common *arm7_9 = calloc(1, sizeof(struct arm7_9_common));
diff --git a/src/target/avr32_ap7k.c b/src/target/avr32_ap7k.c
index 1b051dc01..94962c205 100644
--- a/src/target/avr32_ap7k.c
+++ b/src/target/avr32_ap7k.c
@@ -510,7 +510,7 @@ static int avr32_ap7k_init_target(struct command_context *cmd_ctx,
return ERROR_OK;
}
-static int avr32_ap7k_target_create(struct target *target, Jim_Interp *interp)
+static int avr32_ap7k_target_create(struct target *target)
{
struct avr32_ap7k_common *ap7k = calloc(1, sizeof(struct
avr32_ap7k_common));
diff --git a/src/target/avrt.c b/src/target/avrt.c
index 3afe32015..e25718bcc 100644
--- a/src/target/avrt.c
+++ b/src/target/avrt.c
@@ -16,7 +16,7 @@
#define AVR_JTAG_INS_LEN 4
/* forward declarations */
-static int avr_target_create(struct target *target, Jim_Interp *interp);
+static int avr_target_create(struct target *target);
static int avr_init_target(struct command_context *cmd_ctx, struct target *target);
static int avr_arch_state(struct target *target);
@@ -68,7 +68,7 @@ struct target_type avr_target = {
.init_target = avr_init_target,
};
-static int avr_target_create(struct target *target, Jim_Interp *interp)
+static int avr_target_create(struct target *target)
{
struct avr_common *avr = calloc(1, sizeof(struct avr_common));
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index 9c6064558..ee27e1b21 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -3126,7 +3126,7 @@ static int cortex_a_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int cortex_a_target_create(struct target *target, Jim_Interp *interp)
+static int cortex_a_target_create(struct target *target)
{
struct cortex_a_common *cortex_a;
struct adiv5_private_config *pc;
@@ -3148,7 +3148,7 @@ static int cortex_a_target_create(struct target *target, Jim_Interp *interp)
return cortex_a_init_arch_info(target, cortex_a, pc->dap);
}
-static int cortex_r4_target_create(struct target *target, Jim_Interp *interp)
+static int cortex_r4_target_create(struct target *target)
{
struct cortex_a_common *cortex_a;
struct adiv5_private_config *pc;
diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c
index e17f23c1d..ba9d83d79 100644
--- a/src/target/cortex_m.c
+++ b/src/target/cortex_m.c
@@ -2916,7 +2916,7 @@ static int cortex_m_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int cortex_m_target_create(struct target *target, Jim_Interp *interp)
+static int cortex_m_target_create(struct target *target)
{
struct adiv5_private_config *pc;
diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c
index 9b6f4756c..dc85a2180 100644
--- a/src/target/dsp563xx.c
+++ b/src/target/dsp563xx.c
@@ -880,7 +880,7 @@ static void dsp563xx_invalidate_x_context(struct target *target,
}
}
-static int dsp563xx_target_create(struct target *target, Jim_Interp *interp)
+static int dsp563xx_target_create(struct target *target)
{
struct dsp563xx_common *dsp563xx = calloc(1, sizeof(struct dsp563xx_common));
diff --git a/src/target/dsp5680xx.c b/src/target/dsp5680xx.c
index 3f9a6742c..65efbae32 100644
--- a/src/target/dsp5680xx.c
+++ b/src/target/dsp5680xx.c
@@ -855,7 +855,7 @@ static int eonce_pc_store(struct target *target)
return ERROR_OK;
}
-static int dsp5680xx_target_create(struct target *target, Jim_Interp *interp)
+static int dsp5680xx_target_create(struct target *target)
{
struct dsp5680xx_common *dsp5680xx =
calloc(1, sizeof(struct dsp5680xx_common));
diff --git a/src/target/esirisc.c b/src/target/esirisc.c
index da40928da..fac5dc72e 100644
--- a/src/target/esirisc.c
+++ b/src/target/esirisc.c
@@ -1575,7 +1575,7 @@ static int esirisc_identify(struct target *target)
return ERROR_OK;
}
-static int esirisc_target_create(struct target *target, Jim_Interp *interp)
+static int esirisc_target_create(struct target *target)
{
struct jtag_tap *tap = target->tap;
struct esirisc_common *esirisc;
diff --git a/src/target/espressif/esp32.c b/src/target/espressif/esp32.c
index 4deb5e070..399ba8e7c 100644
--- a/src/target/espressif/esp32.c
+++ b/src/target/espressif/esp32.c
@@ -326,7 +326,7 @@ static const struct esp_semihost_ops esp32_semihost_ops = {
.prepare = esp32_disable_wdts
};
-static int esp32_target_create(struct target *target, Jim_Interp *interp)
+static int esp32_target_create(struct target *target)
{
struct xtensa_debug_module_config esp32_dm_cfg = {
.dbg_ops = &esp32_dbg_ops,
diff --git a/src/target/espressif/esp32s2.c b/src/target/espressif/esp32s2.c
index 4f3914f66..b86e43e62 100644
--- a/src/target/espressif/esp32s2.c
+++ b/src/target/espressif/esp32s2.c
@@ -445,7 +445,7 @@ static const struct esp_semihost_ops esp32s2_semihost_ops = {
.prepare = esp32s2_disable_wdts
};
-static int esp32s2_target_create(struct target *target, Jim_Interp *interp)
+static int esp32s2_target_create(struct target *target)
{
struct xtensa_debug_module_config esp32s2_dm_cfg = {
.dbg_ops = &esp32s2_dbg_ops,
diff --git a/src/target/espressif/esp32s3.c b/src/target/espressif/esp32s3.c
index 7507c11c2..82413f77f 100644
--- a/src/target/espressif/esp32s3.c
+++ b/src/target/espressif/esp32s3.c
@@ -320,7 +320,7 @@ static const struct esp_semihost_ops esp32s3_semihost_ops = {
.prepare = esp32s3_disable_wdts
};
-static int esp32s3_target_create(struct target *target, Jim_Interp *interp)
+static int esp32s3_target_create(struct target *target)
{
struct xtensa_debug_module_config esp32s3_dm_cfg = {
.dbg_ops = &esp32s3_dbg_ops,
diff --git a/src/target/fa526.c b/src/target/fa526.c
index 38b7ab2e9..d832d3e7d 100644
--- a/src/target/fa526.c
+++ b/src/target/fa526.c
@@ -329,7 +329,7 @@ static int fa526_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int fa526_target_create(struct target *target, Jim_Interp *interp)
+static int fa526_target_create(struct target *target)
{
struct arm920t_common *arm920t = calloc(1, sizeof(struct arm920t_common));
diff --git a/src/target/feroceon.c b/src/target/feroceon.c
index 840ca1b62..cf2c838b7 100644
--- a/src/target/feroceon.c
+++ b/src/target/feroceon.c
@@ -622,7 +622,7 @@ static void feroceon_common_setup(struct target *target)
arm7_9->wp1_used_default = -1;
}
-static int feroceon_target_create(struct target *target, Jim_Interp *interp)
+static int feroceon_target_create(struct target *target)
{
struct arm926ejs_common *arm926ejs = calloc(1, sizeof(struct arm926ejs_common));
@@ -640,7 +640,7 @@ static int feroceon_target_create(struct target *target, Jim_Interp *interp)
return ERROR_OK;
}
-static int dragonite_target_create(struct target *target, Jim_Interp *interp)
+static int dragonite_target_create(struct target *target)
{
struct arm966e_common *arm966e = calloc(1, sizeof(struct arm966e_common));
diff --git a/src/target/hla_target.c b/src/target/hla_target.c
index ef05df202..983cd8739 100644
--- a/src/target/hla_target.c
+++ b/src/target/hla_target.c
@@ -187,8 +187,7 @@ static int adapter_init_target(struct command_context *cmd_ctx,
return ERROR_OK;
}
-static int adapter_target_create(struct target *target,
- Jim_Interp *interp)
+static int adapter_target_create(struct target *target)
{
LOG_DEBUG("%s", __func__);
struct adiv5_private_config *pc = target->private_config;
diff --git a/src/target/ls1_sap.c b/src/target/ls1_sap.c
index 692f4cc9e..49335a8b9 100644
--- a/src/target/ls1_sap.c
+++ b/src/target/ls1_sap.c
@@ -17,7 +17,7 @@ struct ls1_sap {
struct jtag_tap *tap;
};
-static int ls1_sap_target_create(struct target *target, Jim_Interp *interp)
+static int ls1_sap_target_create(struct target *target)
{
struct ls1_sap *ls1_sap = calloc(1, sizeof(struct ls1_sap));
diff --git a/src/target/mem_ap.c b/src/target/mem_ap.c
index fdc52c307..c5618c9cc 100644
--- a/src/target/mem_ap.c
+++ b/src/target/mem_ap.c
@@ -24,7 +24,7 @@ struct mem_ap {
uint64_t ap_num;
};
-static int mem_ap_target_create(struct target *target, Jim_Interp *interp)
+static int mem_ap_target_create(struct target *target)
{
struct mem_ap *mem_ap;
struct adiv5_private_config *pc;
diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c
index dc7450108..4e27914a9 100644
--- a/src/target/mips_m4k.c
+++ b/src/target/mips_m4k.c
@@ -1158,7 +1158,7 @@ static int mips_m4k_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int mips_m4k_target_create(struct target *target, Jim_Interp *interp)
+static int mips_m4k_target_create(struct target *target)
{
struct mips_m4k_common *mips_m4k = calloc(1, sizeof(struct mips_m4k_common));
diff --git a/src/target/mips_mips64.c b/src/target/mips_mips64.c
index 85e377937..a181a154e 100644
--- a/src/target/mips_mips64.c
+++ b/src/target/mips_mips64.c
@@ -1082,7 +1082,7 @@ static int mips_mips64_init_target(struct command_context *cmd_ctx,
return mips64_build_reg_cache(target);
}
-static int mips_mips64_target_create(struct target *target, Jim_Interp *interp)
+static int mips_mips64_target_create(struct target *target)
{
struct mips_mips64_common *mips_mips64;
struct mips64_common *mips64;
diff --git a/src/target/openrisc/or1k.c b/src/target/openrisc/or1k.c
index 4b9d3bca6..4aa2bd734 100644
--- a/src/target/openrisc/or1k.c
+++ b/src/target/openrisc/or1k.c
@@ -1097,7 +1097,7 @@ static int or1k_init_target(struct command_context *cmd_ctx,
return ERROR_OK;
}
-static int or1k_target_create(struct target *target, Jim_Interp *interp)
+static int or1k_target_create(struct target *target)
{
if (!target->tap)
return ERROR_FAIL;
diff --git a/src/target/quark_d20xx.c b/src/target/quark_d20xx.c
index 90cf6670e..931f0dab7 100644
--- a/src/target/quark_d20xx.c
+++ b/src/target/quark_d20xx.c
@@ -32,7 +32,7 @@
#include "lakemont.h"
#include "x86_32_common.h"
-static int quark_d20xx_target_create(struct target *t, Jim_Interp *interp)
+static int quark_d20xx_target_create(struct target *t)
{
struct x86_32_common *x86_32 = calloc(1, sizeof(struct x86_32_common));
if (!x86_32) {
diff --git a/src/target/quark_x10xx.c b/src/target/quark_x10xx.c
index 0daa642b8..2abc32ab7 100644
--- a/src/target/quark_x10xx.c
+++ b/src/target/quark_x10xx.c
@@ -40,7 +40,7 @@
#include "lakemont.h"
#include "x86_32_common.h"
-static int quark_x10xx_target_create(struct target *t, Jim_Interp *interp)
+static int quark_x10xx_target_create(struct target *t)
{
struct x86_32_common *x86_32 = calloc(1, sizeof(*x86_32));
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index 6a8577f5c..11ef8f9b9 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -427,7 +427,7 @@ static struct target_type *get_target_type(struct target *target)
}
}
-static int riscv_create_target(struct target *target, Jim_Interp *interp)
+static int riscv_create_target(struct target *target)
{
LOG_DEBUG("riscv_create_target()");
target->arch_info = calloc(1, sizeof(struct riscv_info));
diff --git a/src/target/stm8.c b/src/target/stm8.c
index 76482e878..c80ea0eb2 100644
--- a/src/target/stm8.c
+++ b/src/target/stm8.c
@@ -1106,8 +1106,7 @@ static int stm8_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int stm8_target_create(struct target *target,
- Jim_Interp *interp)
+static int stm8_target_create(struct target *target)
{
struct stm8_common *stm8 = calloc(1, sizeof(struct stm8_common));
diff --git a/src/target/target.c b/src/target/target.c
index 99481622d..40c8d3ed3 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -5865,7 +5865,7 @@ COMMAND_HANDLER(handle_target_create)
}
if (target->type->target_create) {
- retval = (*target->type->target_create)(target, CMD_CTX->interp);
+ retval = (*target->type->target_create)(target);
if (retval != ERROR_OK) {
LOG_DEBUG("target_create failed");
free(target->cmd_name);
diff --git a/src/target/target_type.h b/src/target/target_type.h
index ce98cbad2..eddedbf34 100644
--- a/src/target/target_type.h
+++ b/src/target/target_type.h
@@ -194,7 +194,7 @@ struct target_type {
const struct command_registration *commands;
/* called when target is created */
- int (*target_create)(struct target *target, Jim_Interp *interp);
+ int (*target_create)(struct target *target);
/* called for various config parameters */
/* returns JIM_CONTINUE - if option not understood */
diff --git a/src/target/xscale.c b/src/target/xscale.c
index 5cc790a31..84318a905 100644
--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -3012,7 +3012,7 @@ static int xscale_init_arch_info(struct target *target,
return ERROR_OK;
}
-static int xscale_target_create(struct target *target, Jim_Interp *interp)
+static int xscale_target_create(struct target *target)
{
struct xscale_common *xscale;
diff --git a/src/target/xtensa/xtensa_chip.c b/src/target/xtensa/xtensa_chip.c
index ce6d35cab..aab7ee37c 100644
--- a/src/target/xtensa/xtensa_chip.c
+++ b/src/target/xtensa/xtensa_chip.c
@@ -81,7 +81,7 @@ static const struct xtensa_power_ops xtensa_chip_dm_pwr_ops = {
.queue_reg_write = xtensa_dm_queue_pwr_reg_write
};
-static int xtensa_chip_target_create(struct target *target, Jim_Interp *interp)
+static int xtensa_chip_target_create(struct target *target)
{
struct xtensa_debug_module_config xtensa_chip_dm_cfg = {
.dbg_ops = &xtensa_chip_dm_dbg_ops,
-----------------------------------------------------------------------
Summary of changes:
src/target/aarch64.c | 4 ++--
src/target/arc.c | 2 +-
src/target/arm11.c | 2 +-
src/target/arm720t.c | 2 +-
src/target/arm7tdmi.c | 2 +-
src/target/arm920t.c | 2 +-
src/target/arm926ejs.c | 2 +-
src/target/arm946e.c | 2 +-
src/target/arm966e.c | 2 +-
src/target/arm9tdmi.c | 2 +-
src/target/avr32_ap7k.c | 2 +-
src/target/avrt.c | 4 ++--
src/target/cortex_a.c | 4 ++--
src/target/cortex_m.c | 2 +-
src/target/dsp563xx.c | 2 +-
src/target/dsp5680xx.c | 2 +-
src/target/esirisc.c | 2 +-
src/target/espressif/esp32.c | 2 +-
src/target/espressif/esp32s2.c | 2 +-
src/target/espressif/esp32s3.c | 2 +-
src/target/fa526.c | 2 +-
src/target/feroceon.c | 4 ++--
src/target/hla_target.c | 3 +--
src/target/ls1_sap.c | 2 +-
src/target/mem_ap.c | 2 +-
src/target/mips_m4k.c | 2 +-
src/target/mips_mips64.c | 2 +-
src/target/openrisc/or1k.c | 2 +-
src/target/quark_d20xx.c | 2 +-
src/target/quark_x10xx.c | 2 +-
src/target/riscv/riscv.c | 2 +-
src/target/stm8.c | 3 +--
src/target/target.c | 2 +-
src/target/target_type.h | 2 +-
src/target/xscale.c | 2 +-
src/target/xtensa/xtensa_chip.c | 2 +-
36 files changed, 40 insertions(+), 42 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:23:42
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 61890e3dc3201ce38e5af7f6b561389a123448e0 (commit)
from 1d9b34baa3c5087f2a3387523c6c556b4e4f1afb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 61890e3dc3201ce38e5af7f6b561389a123448e0
Author: Antonio Borneo <bor...@gm...>
Date: Sun Dec 3 15:41:27 2023 +0100
target: rewrite function target_configure() as COMMAND_HELPER
The function target_configure() is used by the commands
'target create', 'configure' and 'cget', already rewritten as
COMMAND_HANDLER.
Rewrite the common function as COMMAND_HELPER.
While there:
- fix the check on arguments, even if it should be coded better;
- keep jimtcl code for target_type::target_jim_configure() and for
rtos_create(); these would be rewritten later on.
Change-Id: I7e5699ca6d124e34d3b2199714e3ce584bfcce80
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8829
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index 4bd2f24cc..99481622d 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -214,8 +214,6 @@ static const struct nvp nvp_target_event[] = {
{ .name = NULL, .value = -1 }
};
-static const struct jim_nvp *jim_nvp_target_event = (const struct jim_nvp *)nvp_target_event;
-
static const struct nvp nvp_target_state[] = {
{ .name = "unknown", .value = TARGET_UNKNOWN },
{ .name = "running", .value = TARGET_RUNNING },
@@ -238,7 +236,7 @@ static const struct nvp nvp_target_debug_reason[] = {
{ .name = NULL, .value = -1 },
};
-static const struct jim_nvp nvp_target_endian[] = {
+static const struct nvp nvp_target_endian[] = {
{ .name = "big", .value = TARGET_BIG_ENDIAN },
{ .name = "little", .value = TARGET_LITTLE_ENDIAN },
{ .name = "be", .value = TARGET_BIG_ENDIAN },
@@ -2844,8 +2842,7 @@ COMMAND_HANDLER(handle_targets_command)
marker,
target_name(target),
target_type_name(target),
- jim_nvp_value2name_simple(nvp_target_endian,
- target->endianness)->name,
+ nvp_value2name(nvp_target_endian, target->endianness)->name,
target->tap->dotted_name,
state);
}
@@ -4859,7 +4856,7 @@ enum target_cfg_param {
TCFG_GDB_MAX_CONNECTIONS,
};
-static struct jim_nvp nvp_config_opts[] = {
+static struct nvp nvp_config_opts[] = {
{ .name = "-type", .value = TCFG_TYPE },
{ .name = "-event", .value = TCFG_EVENT },
{ .name = "-work-area-virt", .value = TCFG_WORK_AREA_VIRT },
@@ -4877,78 +4874,71 @@ static struct jim_nvp nvp_config_opts[] = {
{ .name = NULL, .value = -1 }
};
-static int target_configure(struct jim_getopt_info *goi, struct target *target)
+static COMMAND_HELPER(target_configure, struct target *target, unsigned int index, bool is_configure)
{
- struct jim_nvp *n;
- Jim_Obj *o;
- jim_wide w;
- int e;
+ const struct nvp *n;
+ int retval;
/* parse config or cget options ... */
- while (goi->argc > 0) {
- Jim_SetEmptyResult(goi->interp);
- /* jim_getopt_debug(goi); */
-
+ while (index < CMD_ARGC) {
if (target->type->target_jim_configure) {
/* target defines a configure function */
/* target gets first dibs on parameters */
- e = (*(target->type->target_jim_configure))(target, goi);
+ struct jim_getopt_info goi;
+ jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - index, CMD_JIMTCL_ARGV + index);
+ goi.is_configure = is_configure;
+ int e = (*target->type->target_jim_configure)(target, &goi);
+ index = CMD_ARGC - goi.argc;
if (e == JIM_OK) {
/* more? */
continue;
}
if (e == JIM_ERR) {
/* An error */
- return e;
+ int reslen;
+ const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
+ if (reslen > 0)
+ command_print(CMD, "%s", result);
+ return ERROR_FAIL;
}
/* otherwise we 'continue' below */
}
- e = jim_getopt_nvp(goi, nvp_config_opts, &n);
- if (e != JIM_OK) {
- jim_getopt_nvp_unknown(goi, nvp_config_opts, 0);
- return e;
+ n = nvp_name2value(nvp_config_opts, CMD_ARGV[index]);
+ if (!n->name) {
+ nvp_unknown_command_print(CMD, nvp_config_opts, NULL, CMD_ARGV[index]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
+ index++;
switch (n->value) {
case TCFG_TYPE:
/* not settable */
- if (goi->is_configure) {
- Jim_SetResultFormatted(goi->interp,
- "not settable: %s", n->name);
- return JIM_ERR;
- } else {
-no_params:
- if (goi->argc != 0) {
- Jim_WrongNumArgs(goi->interp,
- goi->argc, goi->argv,
- "NO PARAMS");
- return JIM_ERR;
- }
+ if (is_configure) {
+ command_print(CMD, "not settable: %s", n->name);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
- Jim_SetResultString(goi->interp,
- target_type_name(target), -1);
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, "%s", target_type_name(target));
/* loop for more */
break;
+
case TCFG_EVENT:
- if (goi->argc == 0) {
- Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ...");
- return JIM_ERR;
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing event-name");
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
- e = jim_getopt_nvp(goi, jim_nvp_target_event, &n);
- if (e != JIM_OK) {
- jim_getopt_nvp_unknown(goi, jim_nvp_target_event, 1);
- return e;
+ n = nvp_name2value(nvp_target_event, CMD_ARGV[index]);
+ if (!n->name) {
+ nvp_unknown_command_print(CMD, nvp_target_event, CMD_ARGV[index - 1], CMD_ARGV[index]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
+ index++;
- if (goi->is_configure) {
- if (goi->argc != 1) {
- Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ?EVENT-BODY?");
- return JIM_ERR;
- }
- } else {
- if (goi->argc != 0) {
- Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name?");
- return JIM_ERR;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing event-body");
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
}
@@ -4964,20 +4954,20 @@ no_params:
if (&teap->list == &target->events_action)
teap = NULL;
- if (goi->is_configure) {
+ if (is_configure) {
/* START_DEPRECATED_TPIU */
if (n->value == TARGET_EVENT_TRACE_CONFIG)
LOG_INFO("DEPRECATED target event %s; use TPIU events {pre,post}-{enable,disable}", n->name);
/* END_DEPRECATED_TPIU */
- jim_getopt_obj(goi, &o);
- if (Jim_Length(o) == 0) {
+ if (strlen(CMD_ARGV[index]) == 0) {
/* empty action, drop existing one */
if (teap) {
list_del(&teap->list);
Jim_DecrRefCount(teap->interp, teap->body);
free(teap);
}
+ index++;
break;
}
@@ -4988,10 +4978,12 @@ no_params:
replace = false;
}
teap->event = n->value;
- teap->interp = goi->interp;
+ teap->interp = CMD_CTX->interp;
if (teap->body)
Jim_DecrRefCount(teap->interp, teap->body);
- teap->body = Jim_DuplicateObj(goi->interp, o);
+ /* use jim object to keep its reference on tcl file and line */
+ /* TODO: need duplicate? isn't IncrRefCount enough? */
+ teap->body = Jim_DuplicateObj(teap->interp, CMD_JIMTCL_ARGV[index++]);
/*
* FIXME:
* Tcl/TK - "tk events" have a nice feature.
@@ -5008,219 +5000,266 @@ no_params:
/* add to head of event list */
list_add(&teap->list, &target->events_action);
}
- Jim_SetEmptyResult(goi->interp);
} else {
- /* get */
- if (!teap)
- Jim_SetEmptyResult(goi->interp);
- else
- Jim_SetResult(goi->interp, Jim_DuplicateObj(goi->interp, teap->body));
+ /* cget */
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
+ if (teap)
+ command_print(CMD, "%s", Jim_GetString(teap->body, NULL));
}
}
/* loop for more */
break;
case TCFG_WORK_AREA_VIRT:
- if (goi->is_configure) {
- target_free_all_working_areas(target);
- e = jim_getopt_wide(goi, &w);
- if (e != JIM_OK)
- return e;
- target->working_area_virt = w;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ COMMAND_PARSE_NUMBER(u64, CMD_ARGV[index], target->working_area_virt);
+ index++;
target->working_area_virt_spec = true;
+ target_free_all_working_areas(target);
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, TARGET_ADDR_FMT, target->working_area_virt);
}
- Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->working_area_virt));
/* loop for more */
break;
case TCFG_WORK_AREA_PHYS:
- if (goi->is_configure) {
- target_free_all_working_areas(target);
- e = jim_getopt_wide(goi, &w);
- if (e != JIM_OK)
- return e;
- target->working_area_phys = w;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ COMMAND_PARSE_NUMBER(u64, CMD_ARGV[index], target->working_area_phys);
+ index++;
target->working_area_phys_spec = true;
+ target_free_all_working_areas(target);
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, TARGET_ADDR_FMT, target->working_area_phys);
}
- Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->working_area_phys));
/* loop for more */
break;
case TCFG_WORK_AREA_SIZE:
- if (goi->is_configure) {
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ COMMAND_PARSE_NUMBER(u32, CMD_ARGV[index], target->working_area_size);
+ index++;
target_free_all_working_areas(target);
- e = jim_getopt_wide(goi, &w);
- if (e != JIM_OK)
- return e;
- target->working_area_size = w;
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, "0x%08" PRIx32, target->working_area_size);
}
- Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->working_area_size));
/* loop for more */
break;
case TCFG_WORK_AREA_BACKUP:
- if (goi->is_configure) {
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ retval = command_parse_bool_arg(CMD_ARGV[index], &target->backup_working_area);
+ if (retval != ERROR_OK)
+ return retval;
+ index++;
target_free_all_working_areas(target);
- e = jim_getopt_wide(goi, &w);
- if (e != JIM_OK)
- return e;
- /* make this boolean */
- target->backup_working_area = (w != 0);
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, target->backup_working_area ? "1" : "0");
}
- Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->backup_working_area ? 1 : 0));
- /* loop for more e*/
+ /* loop for more */
break;
-
case TCFG_ENDIAN:
- if (goi->is_configure) {
- e = jim_getopt_nvp(goi, nvp_target_endian, &n);
- if (e != JIM_OK) {
- jim_getopt_nvp_unknown(goi, nvp_target_endian, 1);
- return e;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ n = nvp_name2value(nvp_target_endian, CMD_ARGV[index]);
+ if (!n->name) {
+ nvp_unknown_command_print(CMD, nvp_target_endian, CMD_ARGV[index - 1], CMD_ARGV[index]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
+ index++;
target->endianness = n->value;
} else {
- if (goi->argc != 0)
- goto no_params;
- }
- n = jim_nvp_value2name_simple(nvp_target_endian, target->endianness);
- if (!n->name) {
- target->endianness = TARGET_LITTLE_ENDIAN;
- n = jim_nvp_value2name_simple(nvp_target_endian, target->endianness);
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ n = nvp_value2name(nvp_target_endian, target->endianness);
+ if (!n->name) {
+ target->endianness = TARGET_LITTLE_ENDIAN;
+ n = nvp_value2name(nvp_target_endian, target->endianness);
+ }
+ command_print(CMD, "%s", n->name);
}
- Jim_SetResultString(goi->interp, n->name, -1);
/* loop for more */
break;
case TCFG_COREID:
- if (goi->is_configure) {
- e = jim_getopt_wide(goi, &w);
- if (e != JIM_OK)
- return e;
- target->coreid = (int32_t)w;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ COMMAND_PARSE_NUMBER(s32, CMD_ARGV[index], target->coreid);
+ index++;
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, "%" PRIi32, target->coreid);
}
- Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->coreid));
/* loop for more */
break;
case TCFG_CHAIN_POSITION:
- if (goi->is_configure) {
- Jim_Obj *o_t;
- struct jtag_tap *tap;
-
+ if (is_configure) {
if (target->has_dap) {
- Jim_SetResultString(goi->interp,
- "target requires -dap parameter instead of -chain-position!", -1);
- return JIM_ERR;
+ command_print(CMD, "target requires -dap parameter instead of -chain-position!");
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
- e = jim_getopt_obj(goi, &o_t);
- if (e != JIM_OK)
- return e;
- tap = jtag_tap_by_jim_obj(goi->interp, o_t);
- if (!tap)
- return JIM_ERR;
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ struct jtag_tap *tap = jtag_tap_by_string(CMD_ARGV[index]);
+ if (!tap) {
+ command_print(CMD, "Tap '%s' could not be found", CMD_ARGV[index]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ index++;
target->tap = tap;
target->tap_configured = true;
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, "%s", target->tap->dotted_name);
}
- Jim_SetResultString(goi->interp, target->tap->dotted_name, -1);
- /* loop for more e*/
+ /* loop for more */
break;
+
case TCFG_DBGBASE:
- if (goi->is_configure) {
- e = jim_getopt_wide(goi, &w);
- if (e != JIM_OK)
- return e;
- target->dbgbase = (uint32_t)w;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ COMMAND_PARSE_NUMBER(u32, CMD_ARGV[index], target->dbgbase);
+ index++;
target->dbgbase_set = true;
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, "0x%08" PRIx32, target->dbgbase);
}
- Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->dbgbase));
/* loop for more */
break;
+
case TCFG_RTOS:
- /* RTOS */
- {
- int result = rtos_create(goi, target);
- if (result != JIM_OK)
- return result;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+ struct jim_getopt_info goi;
+ jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - index, CMD_JIMTCL_ARGV + index);
+ index++;
+ goi.is_configure = true;
+ int resval = rtos_create(&goi, target);
+ int reslen;
+ const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
+ if (reslen > 0)
+ command_print(CMD, "%s", result);
+ if (resval != JIM_OK)
+ return ERROR_FAIL;
+ } else {
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ if (target->rtos)
+ command_print(CMD, "%s", target->rtos->type->name);
}
/* loop for more */
break;
case TCFG_DEFER_EXAMINE:
- /* DEFER_EXAMINE */
- target->defer_examine = true;
+ if (is_configure)
+ target->defer_examine = true;
+ else
+ command_print(CMD, "%s", target->defer_examine ? "true" : "false");
/* loop for more */
break;
case TCFG_GDB_PORT:
- if (goi->is_configure) {
- struct command_context *cmd_ctx = current_command_context(goi->interp);
- if (cmd_ctx->mode != COMMAND_CONFIG) {
- Jim_SetResultString(goi->interp, "-gdb-port must be configured before 'init'", -1);
- return JIM_ERR;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+
+ /* TODO: generalize test of COMMAND_CONFIG */
+ if (CMD_CTX->mode != COMMAND_CONFIG) {
+ command_print(CMD, "-gdb-port must be configured before 'init'");
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
- const char *s;
- e = jim_getopt_string(goi, &s, NULL);
- if (e != JIM_OK)
- return e;
+ char *s = strdup(CMD_ARGV[index]);
+ if (!s) {
+ LOG_ERROR("Out of memory");
+ return ERROR_FAIL;
+ }
free(target->gdb_port_override);
- target->gdb_port_override = strdup(s);
+ target->gdb_port_override = s;
+ index++;
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, "%s", target->gdb_port_override ? target->gdb_port_override : "undefined");
}
- Jim_SetResultString(goi->interp, target->gdb_port_override ? target->gdb_port_override : "undefined", -1);
/* loop for more */
break;
case TCFG_GDB_MAX_CONNECTIONS:
- if (goi->is_configure) {
- struct command_context *cmd_ctx = current_command_context(goi->interp);
- if (cmd_ctx->mode != COMMAND_CONFIG) {
- Jim_SetResultString(goi->interp, "-gdb-max-connections must be configured before 'init'", -1);
- return JIM_ERR;
+ if (is_configure) {
+ if (index == CMD_ARGC) {
+ command_print(CMD, "missing argument to %s", CMD_ARGV[index - 1]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+
+ if (CMD_CTX->mode != COMMAND_CONFIG) {
+ command_print(CMD, "-gdb-max-connections must be configured before 'init'");
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
- e = jim_getopt_wide(goi, &w);
- if (e != JIM_OK)
- return e;
- target->gdb_max_connections = (w < 0) ? CONNECTION_LIMIT_UNLIMITED : (int)w;
+ COMMAND_PARSE_NUMBER(int, CMD_ARGV[index], target->gdb_max_connections);
+ index++;
+ if (target->gdb_max_connections < 0)
+ target->gdb_max_connections = CONNECTION_LIMIT_UNLIMITED;
} else {
- if (goi->argc != 0)
- goto no_params;
+ if (index != CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, "%d", target->gdb_max_connections);
}
- Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->gdb_max_connections));
+ /* loop for more */
break;
}
- } /* while (goi->argc) */
-
+ }
- /* done - we return */
- return JIM_OK;
+ return ERROR_OK;
}
COMMAND_HANDLER(handle_target_configure)
@@ -5228,23 +5267,11 @@ COMMAND_HANDLER(handle_target_configure)
if (!CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
- struct jim_getopt_info goi;
-
- jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC, CMD_JIMTCL_ARGV);
- goi.is_configure = !strcmp(CMD_NAME, "configure");
+ bool is_configure = !strcmp(CMD_NAME, "configure");
struct target *target = get_current_target(CMD_CTX);
- int e = target_configure(&goi, target);
-
- int reslen;
- const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
- if (reslen > 0)
- command_print(CMD, "%s", result);
-
- if (e != JIM_OK)
- return ERROR_FAIL;
- return ERROR_OK;
+ return CALL_COMMAND_HANDLER(target_configure, target, 0, is_configure);
}
COMMAND_HANDLER(handle_target_examine)
@@ -5803,18 +5830,9 @@ COMMAND_HANDLER(handle_target_create)
}
/* Do the rest as "configure" options */
- struct jim_getopt_info goi;
- jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - 2, CMD_JIMTCL_ARGV + 2);
-
- goi.is_configure = 1;
- int e = target_configure(&goi, target);
-
- int reslen;
- const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
- if (reslen > 0)
- command_print(CMD, "%s", result);
-
- if (e == JIM_OK) {
+ bool is_configure = true;
+ retval = CALL_COMMAND_HANDLER(target_configure, target, 2, is_configure);
+ if (retval == ERROR_OK) {
if (target->has_dap) {
if (!target->dap_configured) {
command_print(CMD, "-dap ?name? required when creating target");
@@ -5829,8 +5847,6 @@ COMMAND_HANDLER(handle_target_create)
/* tap must be set after target was configured */
if (!target->tap)
retval = ERROR_COMMAND_ARGUMENT_INVALID;
- } else {
- retval = ERROR_FAIL;
}
if (retval != ERROR_OK) {
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 434 +++++++++++++++++++++++++++-------------------------
1 file changed, 225 insertions(+), 209 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:23:16
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 1d9b34baa3c5087f2a3387523c6c556b4e4f1afb (commit)
from 29e4a366222b96aac89dbec11e5f4a83a6a83bbe (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1d9b34baa3c5087f2a3387523c6c556b4e4f1afb
Author: Antonio Borneo <bor...@gm...>
Date: Sat Dec 2 23:40:56 2023 +0100
target: rewrite commands 'configure' and 'cget' as COMMAND_HANDLER
Rewrite only the command, but still use the old jimtcl specific
code shared with 'target create'.
Change-Id: Ie5e1c9eb237531121c2d143d1732cf281dfdc9ff
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8828
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index 9d9d73a28..4bd2f24cc 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -5223,22 +5223,28 @@ no_params:
return JIM_OK;
}
-static int jim_target_configure(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
+COMMAND_HANDLER(handle_target_configure)
{
- struct command *c = jim_to_command(interp);
+ if (!CMD_ARGC)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
struct jim_getopt_info goi;
- jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
- goi.is_configure = !strcmp(c->name, "configure");
- if (goi.argc < 1) {
- Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
- "missing: -option ...");
- return JIM_ERR;
- }
- struct command_context *cmd_ctx = current_command_context(interp);
- assert(cmd_ctx);
- struct target *target = get_current_target(cmd_ctx);
- return target_configure(&goi, target);
+ jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC, CMD_JIMTCL_ARGV);
+ goi.is_configure = !strcmp(CMD_NAME, "configure");
+
+ struct target *target = get_current_target(CMD_CTX);
+ int e = target_configure(&goi, target);
+
+ int reslen;
+ const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
+ if (reslen > 0)
+ command_print(CMD, "%s", result);
+
+ if (e != JIM_OK)
+ return ERROR_FAIL;
+
+ return ERROR_OK;
}
COMMAND_HANDLER(handle_target_examine)
@@ -5491,14 +5497,14 @@ static const struct command_registration target_instance_command_handlers[] = {
{
.name = "configure",
.mode = COMMAND_ANY,
- .jim_handler = jim_target_configure,
+ .handler = handle_target_configure,
.help = "configure a new target for use",
.usage = "[target_attribute ...]",
},
{
.name = "cget",
.mode = COMMAND_ANY,
- .jim_handler = jim_target_configure,
+ .handler = handle_target_configure,
.help = "returns the specified target attribute",
.usage = "target_attribute",
},
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:22:43
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 29e4a366222b96aac89dbec11e5f4a83a6a83bbe (commit)
via 4a616ca4d83919fea03bf084ff326f584de558d7 (commit)
from a1ecf0a03d9812c285618ed995ea818eba020be3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 29e4a366222b96aac89dbec11e5f4a83a6a83bbe
Author: Antonio Borneo <bor...@gm...>
Date: Sat Dec 2 23:01:44 2023 +0100
target: rewrite command 'target create' as COMMAND_HANDLER
Rewrite only the command, but still use the old jimtcl specific
code shared with 'configure' and 'cget'.
Change-Id: I7cf220e494f0ebbf123f8075b1feb9251fd7f569
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8827
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index 3f16caaff..9d9d73a28 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -5673,44 +5673,29 @@ static const struct command_registration target_instance_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
-static int target_create(struct jim_getopt_info *goi)
+COMMAND_HANDLER(handle_target_create)
{
- Jim_Obj *new_cmd;
- Jim_Cmd *cmd;
- const char *cp;
- int e;
+ int retval = ERROR_OK;
int x;
- struct target *target;
- struct command_context *cmd_ctx;
- cmd_ctx = current_command_context(goi->interp);
- assert(cmd_ctx);
-
- if (goi->argc < 3) {
- Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ?type? ..options...");
- return JIM_ERR;
- }
+ if (CMD_ARGC < 4)
+ return ERROR_COMMAND_SYNTAX_ERROR;
- /* COMMAND */
- jim_getopt_obj(goi, &new_cmd);
- /* does this command exist? */
- cmd = Jim_GetCommand(goi->interp, new_cmd, JIM_NONE);
- if (cmd) {
- cp = Jim_GetString(new_cmd, NULL);
- Jim_SetResultFormatted(goi->interp, "Command/target: %s Exists", cp);
- return JIM_ERR;
+ /* check if the target name clashes with an existing command name */
+ Jim_Cmd *jimcmd = Jim_GetCommand(CMD_CTX->interp, CMD_JIMTCL_ARGV[0], JIM_NONE);
+ if (jimcmd) {
+ command_print(CMD, "Command/target: %s Exists", CMD_ARGV[0]);
+ return ERROR_FAIL;
}
/* TYPE */
- e = jim_getopt_string(goi, &cp, NULL);
- if (e != JIM_OK)
- return e;
+ const char *cp = CMD_ARGV[1];
struct transport *tr = get_current_transport();
if (tr && tr->override_target) {
- e = tr->override_target(&cp);
- if (e != ERROR_OK) {
- LOG_ERROR("The selected transport doesn't support this target");
- return JIM_ERR;
+ retval = tr->override_target(&cp);
+ if (retval != ERROR_OK) {
+ command_print(CMD, "The selected transport doesn't support this target");
+ return retval;
}
LOG_INFO("The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD");
}
@@ -5722,28 +5707,29 @@ static int target_create(struct jim_getopt_info *goi)
}
}
if (!target_types[x]) {
- Jim_SetResultFormatted(goi->interp, "Unknown target type %s, try one of ", cp);
+ char *all = NULL;
for (x = 0 ; target_types[x] ; x++) {
- if (target_types[x + 1]) {
- Jim_AppendStrings(goi->interp,
- Jim_GetResult(goi->interp),
- target_types[x]->name,
- ", ", NULL);
- } else {
- Jim_AppendStrings(goi->interp,
- Jim_GetResult(goi->interp),
- " or ",
- target_types[x]->name, NULL);
+ char *prev = all;
+ if (all)
+ all = alloc_printf("%s, %s", all, target_types[x]->name);
+ else
+ all = alloc_printf("%s", target_types[x]->name);
+ free(prev);
+ if (!all) {
+ LOG_ERROR("Out of memory");
+ return ERROR_FAIL;
}
}
- return JIM_ERR;
+ command_print(CMD, "Unknown target type %s, try one of %s", cp, all);
+ free(all);
+ return ERROR_FAIL;
}
/* Create it */
- target = calloc(1, sizeof(struct target));
+ struct target *target = calloc(1, sizeof(struct target));
if (!target) {
LOG_ERROR("Out of memory");
- return JIM_ERR;
+ return ERROR_FAIL;
}
/* set empty smp cluster */
@@ -5754,7 +5740,7 @@ static int target_create(struct jim_getopt_info *goi)
if (!target->type) {
LOG_ERROR("Out of memory");
free(target);
- return JIM_ERR;
+ return ERROR_FAIL;
}
memcpy(target->type, target_types[x], sizeof(struct target_type));
@@ -5787,7 +5773,7 @@ static int target_create(struct jim_getopt_info *goi)
LOG_ERROR("Out of memory");
free(target->type);
free(target);
- return JIM_ERR;
+ return ERROR_FAIL;
}
target->dbgmsg = NULL;
@@ -5801,45 +5787,54 @@ static int target_create(struct jim_getopt_info *goi)
target->gdb_port_override = NULL;
target->gdb_max_connections = 1;
- cp = Jim_GetString(new_cmd, NULL);
- target->cmd_name = strdup(cp);
+ target->cmd_name = strdup(CMD_ARGV[0]);
if (!target->cmd_name) {
LOG_ERROR("Out of memory");
free(target->trace_info);
free(target->type);
free(target);
- return JIM_ERR;
+ return ERROR_FAIL;
}
/* Do the rest as "configure" options */
- goi->is_configure = true;
- e = target_configure(goi, target);
+ struct jim_getopt_info goi;
+ jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC - 2, CMD_JIMTCL_ARGV + 2);
+
+ goi.is_configure = 1;
+ int e = target_configure(&goi, target);
+
+ int reslen;
+ const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
+ if (reslen > 0)
+ command_print(CMD, "%s", result);
if (e == JIM_OK) {
if (target->has_dap) {
if (!target->dap_configured) {
- Jim_SetResultString(goi->interp, "-dap ?name? required when creating target", -1);
- e = JIM_ERR;
+ command_print(CMD, "-dap ?name? required when creating target");
+ retval = ERROR_COMMAND_ARGUMENT_INVALID;
}
} else {
if (!target->tap_configured) {
- Jim_SetResultString(goi->interp, "-chain-position ?name? required when creating target", -1);
- e = JIM_ERR;
+ command_print(CMD, "-chain-position ?name? required when creating target");
+ retval = ERROR_COMMAND_ARGUMENT_INVALID;
}
}
/* tap must be set after target was configured */
if (!target->tap)
- e = JIM_ERR;
+ retval = ERROR_COMMAND_ARGUMENT_INVALID;
+ } else {
+ retval = ERROR_FAIL;
}
- if (e != JIM_OK) {
+ if (retval != ERROR_OK) {
rtos_destroy(target);
free(target->gdb_port_override);
free(target->trace_info);
free(target->type);
free(target->private_config);
free(target);
- return e;
+ return retval;
}
if (target->endianness == TARGET_ENDIAN_UNKNOWN) {
@@ -5848,8 +5843,8 @@ static int target_create(struct jim_getopt_info *goi)
}
if (target->type->target_create) {
- e = (*(target->type->target_create))(target, goi->interp);
- if (e != ERROR_OK) {
+ retval = (*target->type->target_create)(target, CMD_CTX->interp);
+ if (retval != ERROR_OK) {
LOG_DEBUG("target_create failed");
free(target->cmd_name);
rtos_destroy(target);
@@ -5858,15 +5853,15 @@ static int target_create(struct jim_getopt_info *goi)
free(target->type);
free(target->private_config);
free(target);
- return JIM_ERR;
+ return retval;
}
}
/* create the target specific commands */
if (target->type->commands) {
- e = register_commands(cmd_ctx, NULL, target->type->commands);
- if (e != ERROR_OK)
- LOG_ERROR("unable to register '%s' commands", cp);
+ retval = register_commands(CMD_CTX, NULL, target->type->commands);
+ if (retval != ERROR_OK)
+ LOG_ERROR("unable to register '%s' commands", CMD_ARGV[0]);
}
/* now - create the new target name command */
@@ -5881,7 +5876,7 @@ static int target_create(struct jim_getopt_info *goi)
};
const struct command_registration target_commands[] = {
{
- .name = cp,
+ .name = CMD_ARGV[0],
.mode = COMMAND_ANY,
.help = "target command group",
.usage = "",
@@ -5889,8 +5884,8 @@ static int target_create(struct jim_getopt_info *goi)
},
COMMAND_REGISTRATION_DONE
};
- e = register_commands_override_target(cmd_ctx, NULL, target_commands, target);
- if (e != ERROR_OK) {
+ retval = register_commands_override_target(CMD_CTX, NULL, target_commands, target);
+ if (retval != ERROR_OK) {
if (target->type->deinit_target)
target->type->deinit_target(target);
free(target->cmd_name);
@@ -5899,14 +5894,14 @@ static int target_create(struct jim_getopt_info *goi)
free(target->trace_info);
free(target->type);
free(target);
- return JIM_ERR;
+ return retval;
}
/* append to end of list */
append_to_list_all_targets(target);
- cmd_ctx->current_target = target;
- return JIM_OK;
+ CMD_CTX->current_target = target;
+ return ERROR_OK;
}
COMMAND_HANDLER(handle_target_current)
@@ -6027,18 +6022,6 @@ COMMAND_HANDLER(handle_target_smp)
return retval;
}
-static int jim_target_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
- struct jim_getopt_info goi;
- jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
- if (goi.argc < 3) {
- Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
- "<name> <target_type> [<target_options> ...]");
- return JIM_ERR;
- }
- return target_create(&goi);
-}
-
static const struct command_registration target_subcommand_handlers[] = {
{
.name = "init",
@@ -6050,7 +6033,7 @@ static const struct command_registration target_subcommand_handlers[] = {
{
.name = "create",
.mode = COMMAND_CONFIG,
- .jim_handler = jim_target_create,
+ .handler = handle_target_create,
.usage = "name type '-chain-position' name [options ...]",
.help = "Creates and selects a new target",
},
commit 4a616ca4d83919fea03bf084ff326f584de558d7
Author: Antonio Borneo <bor...@gm...>
Date: Sat Dec 2 18:40:47 2023 +0100
target: rewrite command 'invoke-event' as COMMAND_HANDLER
The command shares with command 'target create' the
struct jim_nvp nvp_target_event[]
- Convert the 'struct jim_nvp' in 'struct nvp'.
- Create an alias 'struct jim_nvp' to decouple the commands
'invoke-event' and 'target create', abusing the fact that the
actual layout of the two struct's type is the same. This alias
will be dropped in a following change.
- Rewrite the command 'invoke-event' and the helper function
target_event_name().
Change-Id: I537732fe4c08042cc02bcd0f72142254d7968fa6
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8826
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index 36ad0eec8..3f16caaff 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -162,7 +162,7 @@ static const char *target_strerror_safe(int err)
return n->name;
}
-static const struct jim_nvp nvp_target_event[] = {
+static const struct nvp nvp_target_event[] = {
{ .value = TARGET_EVENT_GDB_HALT, .name = "gdb-halt" },
{ .value = TARGET_EVENT_HALTED, .name = "halted" },
@@ -214,6 +214,8 @@ static const struct jim_nvp nvp_target_event[] = {
{ .name = NULL, .value = -1 }
};
+static const struct jim_nvp *jim_nvp_target_event = (const struct jim_nvp *)nvp_target_event;
+
static const struct nvp nvp_target_state[] = {
{ .name = "unknown", .value = TARGET_UNKNOWN },
{ .name = "running", .value = TARGET_RUNNING },
@@ -283,7 +285,7 @@ const char *target_state_name(const struct target *t)
const char *target_event_name(enum target_event event)
{
const char *cp;
- cp = jim_nvp_value2name_simple(nvp_target_event, event)->name;
+ cp = nvp_value2name(nvp_target_event, event)->name;
if (!cp) {
LOG_ERROR("Invalid target event: %d", (int)(event));
cp = "(*BUG*unknown*BUG*)";
@@ -4932,9 +4934,9 @@ no_params:
return JIM_ERR;
}
- e = jim_getopt_nvp(goi, nvp_target_event, &n);
+ e = jim_getopt_nvp(goi, jim_nvp_target_event, &n);
if (e != JIM_OK) {
- jim_getopt_nvp_unknown(goi, nvp_target_event, 1);
+ jim_getopt_nvp_unknown(goi, jim_nvp_target_event, 1);
return e;
}
@@ -5469,26 +5471,20 @@ COMMAND_HANDLER(handle_target_debug_reason)
return ERROR_OK;
}
-static int jim_target_invoke_event(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+COMMAND_HANDLER(handle_target_invoke_event)
{
- struct jim_getopt_info goi;
- jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
- if (goi.argc != 1) {
- const char *cmd_name = Jim_GetString(argv[0], NULL);
- Jim_SetResultFormatted(goi.interp, "%s <eventname>", cmd_name);
- return JIM_ERR;
- }
- struct jim_nvp *n;
- int e = jim_getopt_nvp(&goi, nvp_target_event, &n);
- if (e != JIM_OK) {
- jim_getopt_nvp_unknown(&goi, nvp_target_event, 1);
- return e;
+ if (CMD_ARGC != 1)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
+ const struct nvp *n = nvp_name2value(nvp_target_event, CMD_ARGV[0]);
+ if (!n->name) {
+ nvp_unknown_command_print(CMD, nvp_target_event, NULL, CMD_ARGV[0]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
- struct command_context *cmd_ctx = current_command_context(interp);
- assert(cmd_ctx);
- struct target *target = get_current_target(cmd_ctx);
+
+ struct target *target = get_current_target(CMD_CTX);
target_handle_event(target, n->value);
- return JIM_OK;
+ return ERROR_OK;
}
static const struct command_registration target_instance_command_handlers[] = {
@@ -5670,7 +5666,7 @@ static const struct command_registration target_instance_command_handlers[] = {
{
.name = "invoke-event",
.mode = COMMAND_EXEC,
- .jim_handler = jim_target_invoke_event,
+ .handler = handle_target_invoke_event,
.help = "invoke handler for specified event",
.usage = "event_name",
},
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 187 +++++++++++++++++++++++-----------------------------
1 file changed, 83 insertions(+), 104 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:22:02
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via a1ecf0a03d9812c285618ed995ea818eba020be3 (commit)
from cfed1f78db635b504e4d11da537e614adfd57d3f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a1ecf0a03d9812c285618ed995ea818eba020be3
Author: Antonio Borneo <bor...@gm...>
Date: Sun Apr 6 01:20:44 2025 +0200
target: don't free working areas during 'configure -chain-position'
Since commit ef1cfb23947b ("Duane Ellis: "target as an [tcl]
object" feature.") merged in 2008, the commands:
$target_name configure -chain-position ...
target create ... -chain-position ...
cause the allocated working area to be freed.
There is no reason for this, it is probably caused by an incorrect
copy/paste from the author.
Drop the call to target_free_all_working_areas().
Change-Id: I61a9303afe7fee6953669218330635c0b965b20d
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8825
Reviewed-by: Tomas Vanek <va...@fb...>
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index 8c5c8e5e3..36ad0eec8 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -5128,7 +5128,6 @@ no_params:
return JIM_ERR;
}
- target_free_all_working_areas(target);
e = jim_getopt_obj(goi, &o_t);
if (e != JIM_OK)
return e;
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 1 -
1 file changed, 1 deletion(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:21:21
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via cfed1f78db635b504e4d11da537e614adfd57d3f (commit)
from 16c5c1b353b06602d81a8a81f5243154a6c366cc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit cfed1f78db635b504e4d11da537e614adfd57d3f
Author: Antonio Borneo <bor...@gm...>
Date: Sat Apr 5 17:04:43 2025 +0200
list: silent scan-build false positive
With commit c023534e7b6f ("target: use list for target events")
scan build incorrectly states that list_add() would be called with
the field 'next' of the parameter 'head' (thus 'head->next') set
to NULL. Then, list_add() would call linux_list_add() with the
parameter 'next' set to NULL that will cause a NULL dereference.
While this can really happen with broken code, it's not the case
with the code from the change above.
Add assert() in linux_list_add() to silent scan build on this
false positive and to detect future incorrect use of the list.
Change-Id: Iec7f3d70237312b646ac58f76ecaab2fa25eab41
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8824
Tested-by: jenkins
diff --git a/src/helper/list.h b/src/helper/list.h
index ba07f1556..89b8468ec 100644
--- a/src/helper/list.h
+++ b/src/helper/list.h
@@ -35,6 +35,7 @@
/* begin OpenOCD changes */
+#include <assert.h>
#include <stddef.h>
struct list_head {
@@ -109,6 +110,9 @@ static inline void
linux_list_add(struct list_head *new, struct list_head *prev,
struct list_head *next)
{
+ assert(next);
+ assert(prev);
+
next->prev = new;
new->next = next;
new->prev = prev;
-----------------------------------------------------------------------
Summary of changes:
src/helper/list.h | 4 ++++
1 file changed, 4 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:19:07
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 16c5c1b353b06602d81a8a81f5243154a6c366cc (commit)
from 339763ed2d9a00ac1f2418403bd29c324d1c7e6e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 16c5c1b353b06602d81a8a81f5243154a6c366cc
Author: Antonio Borneo <bor...@gm...>
Date: Sat Dec 2 17:34:57 2023 +0100
command: rewrite command 'capture' as COMMAND_HANDLER
While there, use Jim_EvalObj() to execute the subcommand, so any
error will correctly report the TCL file and the line number that
have originated the error, instead of the silly:
> capture {bogus command}
command.c:703: Error: invalid command name "bogus"
at file "command.c", line 703
Change-Id: Ic75a6146d6cedf49e808d98501fa1a7d4235b58a
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8587
Tested-by: jenkins
diff --git a/src/helper/command.c b/src/helper/command.c
index 923b091a8..218f0581e 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -31,8 +31,7 @@
#define __THIS__FILE__ "command.c"
struct log_capture_state {
- Jim_Interp *interp;
- Jim_Obj *output;
+ char *output;
};
static int unregister_command(struct command_context *context,
@@ -59,73 +58,6 @@ void *jimcmd_privdata(Jim_Cmd *cmd)
return cmd->isproc ? NULL : cmd->u.native.privData;
}
-static void tcl_output(void *privData, const char *file, unsigned int line,
- const char *function, const char *string)
-{
- struct log_capture_state *state = privData;
- Jim_AppendString(state->interp, state->output, string, strlen(string));
-}
-
-static struct log_capture_state *command_log_capture_start(Jim_Interp *interp)
-{
- /* capture log output and return it. A garbage collect can
- * happen, so we need a reference count to this object */
- Jim_Obj *jim_output = Jim_NewStringObj(interp, "", 0);
- if (!jim_output)
- return NULL;
-
- Jim_IncrRefCount(jim_output);
-
- struct log_capture_state *state = malloc(sizeof(*state));
- if (!state) {
- LOG_ERROR("Out of memory");
- Jim_DecrRefCount(interp, jim_output);
- return NULL;
- }
-
- state->interp = interp;
- state->output = jim_output;
-
- log_add_callback(tcl_output, state);
-
- return state;
-}
-
-/* Classic openocd commands provide progress output which we
- * will capture and return as a Tcl return value.
- *
- * However, if a non-openocd command has been invoked, then it
- * makes sense to return the tcl return value from that command.
- *
- * The tcl return value is empty for openocd commands that provide
- * progress output.
- *
- * For other commands, we prepend the logs to the tcl return value.
- */
-static void command_log_capture_finish(struct log_capture_state *state)
-{
- if (!state)
- return;
-
- log_remove_callback(tcl_output, state);
-
- int loglen;
- const char *log_result = Jim_GetString(state->output, &loglen);
- int reslen;
- const char *cmd_result = Jim_GetString(Jim_GetResult(state->interp), &reslen);
-
- // Just in case the log doesn't end with a newline, we add it
- if (loglen != 0 && reslen != 0 && log_result[loglen - 1] != '\n')
- Jim_AppendString(state->interp, state->output, "\n", 1);
-
- Jim_AppendString(state->interp, state->output, cmd_result, reslen);
-
- Jim_SetResult(state->interp, state->output);
- Jim_DecrRefCount(state->interp, state->output);
-
- free(state);
-}
-
static int command_retval_set(Jim_Interp *interp, int retval)
{
int *return_retval = Jim_GetAssocData(interp, "retval");
@@ -680,15 +612,28 @@ COMMAND_HANDLER(handle_echo)
return ERROR_OK;
}
-/* Return both the progress output (LOG_INFO and higher)
+static void tcl_output(void *privData, const char *file, unsigned int line,
+ const char *function, const char *string)
+{
+ struct log_capture_state *state = privData;
+ char *old = state->output;
+
+ state->output = alloc_printf("%s%s", old ? old : "", string);
+ free(old);
+ if (!state->output)
+ LOG_ERROR("Out of memory");
+}
+
+/*
+ * Return both the progress output (LOG_INFO and higher)
* and the tcl return value of a command.
*/
-static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+COMMAND_HANDLER(handle_command_capture)
{
- if (argc != 2)
- return JIM_ERR;
+ struct log_capture_state state = {NULL};
- struct log_capture_state *state = command_log_capture_start(interp);
+ if (CMD_ARGC != 1)
+ return ERROR_COMMAND_SYNTAX_ERROR;
/* disable polling during capture. This avoids capturing output
* from polling.
@@ -698,14 +643,24 @@ static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
*/
bool save_poll_mask = jtag_poll_mask();
- const char *str = Jim_GetString(argv[1], NULL);
- int retcode = Jim_Eval_Named(interp, str, __THIS__FILE__, __LINE__);
+ log_add_callback(tcl_output, &state);
+
+ int jimretval = Jim_EvalObj(CMD_CTX->interp, CMD_JIMTCL_ARGV[0]);
+ const char *cmd_result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), NULL);
+
+ log_remove_callback(tcl_output, &state);
jtag_poll_unmask(save_poll_mask);
- command_log_capture_finish(state);
+ if (state.output && *state.output)
+ command_print(CMD, "%s", state.output);
+
+ if (cmd_result && *cmd_result)
+ command_print(CMD, "%s", cmd_result);
+
+ free(state.output);
- return retcode;
+ return (jimretval == JIM_OK) ? ERROR_OK : ERROR_FAIL;
}
struct help_entry {
@@ -1133,7 +1088,7 @@ static const struct command_registration command_builtin_handlers[] = {
{
.name = "capture",
.mode = COMMAND_ANY,
- .jim_handler = jim_capture,
+ .handler = handle_command_capture,
.help = "Capture progress output and return as tcl return value. If the "
"progress output was empty, return tcl return value.",
.usage = "command",
-----------------------------------------------------------------------
Summary of changes:
src/helper/command.c | 113 ++++++++++++++++-----------------------------------
1 file changed, 34 insertions(+), 79 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-19 09:18:34
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 339763ed2d9a00ac1f2418403bd29c324d1c7e6e (commit)
from 6834f022b96fb1c7f5829166578e01a0ac223cb0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 339763ed2d9a00ac1f2418403bd29c324d1c7e6e
Author: Antonio Borneo <bor...@gm...>
Date: Sat Dec 2 17:06:17 2023 +0100
command: rewrite command 'command mode' as COMMAND_HANDLER
Another step to drop jim_handler.
Change-Id: I85cb567386a5aceb36aa273f8b66cbfd4a637c3f
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8586
Tested-by: jenkins
Reviewed-by: Evgeniy Naydanov <evg...@sy...>
diff --git a/src/helper/command.c b/src/helper/command.c
index 3d4379d06..923b091a8 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -843,22 +843,19 @@ COMMAND_HANDLER(handle_help_command)
return retval;
}
-static char *alloc_concatenate_strings(int argc, Jim_Obj * const *argv)
+static char *alloc_concatenate_strings(int argc, const char **argv)
{
- char *prev, *all;
- int i;
-
assert(argc >= 1);
- all = strdup(Jim_GetString(argv[0], NULL));
+ char *all = strdup(argv[0]);
if (!all) {
LOG_ERROR("Out of memory");
return NULL;
}
- for (i = 1; i < argc; ++i) {
- prev = all;
- all = alloc_printf("%s %s", all, Jim_GetString(argv[i], NULL));
+ for (int i = 1; i < argc; ++i) {
+ char *prev = all;
+ all = alloc_printf("%s %s", all, argv[i]);
free(prev);
if (!all) {
LOG_ERROR("Out of memory");
@@ -944,17 +941,16 @@ static enum command_mode get_command_mode(Jim_Interp *interp, const char *cmd_na
return c->mode;
}
-static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
+COMMAND_HANDLER(handle_command_mode)
{
- struct command_context *cmd_ctx = current_command_context(interp);
- enum command_mode mode = cmd_ctx->mode;
+ enum command_mode mode = CMD_CTX->mode;
- if (argc > 1) {
- char *full_name = alloc_concatenate_strings(argc - 1, argv + 1);
+ if (CMD_ARGC) {
+ char *full_name = alloc_concatenate_strings(CMD_ARGC, CMD_ARGV);
if (!full_name)
- return JIM_ERR;
+ return ERROR_FAIL;
- mode = get_command_mode(interp, full_name);
+ mode = get_command_mode(CMD_CTX->interp, full_name);
free(full_name);
}
@@ -975,8 +971,8 @@ static int jim_command_mode(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
mode_str = "unknown";
break;
}
- Jim_SetResultString(interp, mode_str, -1);
- return JIM_OK;
+ command_print(CMD, "%s", mode_str);
+ return ERROR_OK;
}
int help_del_all_commands(struct command_context *cmd_ctx)
@@ -1115,7 +1111,7 @@ static const struct command_registration command_subcommand_handlers[] = {
{
.name = "mode",
.mode = COMMAND_ANY,
- .jim_handler = jim_command_mode,
+ .handler = handle_command_mode,
.usage = "[command_name ...]",
.help = "Returns the command modes allowed by a command: "
"'any', 'config', or 'exec'. If no command is "
-----------------------------------------------------------------------
Summary of changes:
src/helper/command.c | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-05 06:26:04
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 6834f022b96fb1c7f5829166578e01a0ac223cb0 (commit)
from e45d66fd9a2f43ddc106957ca141f8734dc757a5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6834f022b96fb1c7f5829166578e01a0ac223cb0
Author: Sofiane HAMAM <sof...@sm...>
Date: Fri Mar 28 12:31:17 2025 +0100
Makefile.am: Use SOURCE_DATE_EPOCH environment variable
This package defines PKGBLDDATE as build timestamp which makes
it non reproducible. Use SOURCE_DATE_EPOCH if it is found, otherwise
use build timestamp. Following best practices, see :
https://reproducible-builds.org/docs/source-date-epoch/
The patch is BSD compatible too.
Change-Id: I26c1a00f2e8059ae31fe72a794b5962af5a84f44
Co-developed-by: Yoann Congal <yoa...@sm...>
Signed-off-by: Yoann Congal <yoa...@sm...>
Signed-off-by: Sofiane HAMAM <sof...@sm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8619
Reviewed-by: Antonio Borneo <bor...@gm...>
Reviewed-by: Paul Fertser <fer...@gm...>
Tested-by: jenkins
diff --git a/src/Makefile.am b/src/Makefile.am
index 4d1c1a250..4dbe93fee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,7 +34,10 @@ if RELEASE
else
%C%_libopenocd_la_CPPFLAGS += -DRELSTR=\"`$(top_srcdir)/guess-rev.sh $(top_srcdir)`\"
%C%_libopenocd_la_CPPFLAGS += -DGITVERSION=\"`cd $(top_srcdir) && git describe`\"
-%C%_libopenocd_la_CPPFLAGS += -DPKGBLDDATE=\"`date +%F-%R`\"
+%C%_libopenocd_la_CPPFLAGS += -DPKGBLDDATE=\"`DATE_FMT=+%F-%R; \
+ SOURCE_DATE_EPOCH="$${SOURCE_DATE_EPOCH:-$$(date +%s)}"; \
+ date -u -d "@$$SOURCE_DATE_EPOCH" "$$DATE_FMT" 2>/dev/null || \
+ date -u -r "$$SOURCE_DATE_EPOCH" "$$DATE_FMT" 2>/dev/null || date -u "$$DATE_FMT"`\"
endif
# add default CPPFLAGS
-----------------------------------------------------------------------
Summary of changes:
src/Makefile.am | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-05 06:25:38
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via e45d66fd9a2f43ddc106957ca141f8734dc757a5 (commit)
from 9eb2426411aa0c1c13f5fc59801ac3cb3319f476 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e45d66fd9a2f43ddc106957ca141f8734dc757a5
Author: R. Diez <rdi...@ya...>
Date: Sat Mar 22 23:35:23 2025 +0100
configure.ac: show the rshim adapter in the config summary
Also enable this adapter by default (auto).
Change-Id: Ic302041ecb9e88ca58b03f9675fa92fb3d558821
Signed-off-by: R. Diez <rdi...@ya...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8811
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
diff --git a/configure.ac b/configure.ac
index b63c70e1f..84ca03bf0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,6 +187,9 @@ m4_define([JTAG_DPI_ADAPTER],
m4_define([JTAG_VPI_ADAPTER],
[[[jtag_vpi], [JTAG VPI Adapter], [JTAG_VPI]]])
+m4_define([RSHIM_ADAPTER],
+ [[[rshim], [BlueField SoC via rshim], [RSHIM]]])
+
# The word 'Adapter' in "Dummy Adapter" below must begin with a capital letter
# because there is an M4 macro called 'adapter'.
m4_define([DUMMY_ADAPTER],
@@ -285,10 +288,6 @@ AS_IF([test "x$debug_malloc" = "xyes" -a "x$have_glibc" = "xyes"], [
AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
])
-AC_ARG_ENABLE([rshim],
- AS_HELP_STRING([--enable-rshim], [Enable building the rshim driver]),
- [build_rshim=$enableval], [build_rshim=no])
-
AC_ARG_ENABLE([dmem],
AS_HELP_STRING([--enable-dmem], [Enable building the dmem driver]),
[build_dmem=$enableval], [build_dmem=no])
@@ -320,6 +319,7 @@ AC_ARG_ADAPTERS([
VDEBUG_ADAPTER,
JTAG_DPI_ADAPTER,
JTAG_VPI_ADAPTER,
+ RSHIM_ADAPTER,
PCIE_ADAPTERS,
LIBJAYLINK_ADAPTERS
],[auto])
@@ -383,19 +383,24 @@ AC_ARG_ENABLE([sysfsgpio],
AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
[build_sysfsgpio=$enableval], [build_sysfsgpio=no])
+can_build_rshim=no
+
AS_CASE([$host_os],
[linux*], [
is_linux=yes
+ can_build_rshim=yes
],
[
AS_IF([test "x$build_sysfsgpio" = "xyes"], [
AC_MSG_ERROR([sysfsgpio is only available on linux])
])
- AS_CASE([$host_os], [freebsd*], [],
+ AS_CASE([$host_os], [freebsd*], [
+ can_build_rshim=yes
+ ],
[
- AS_IF([test "x$build_rshim" = "xyes"], [
- AC_MSG_ERROR([build_rshim is only available on linux or freebsd])
+ AS_IF([test "x$enable_rshim" = "xyes"], [
+ AC_MSG_ERROR([rshim is only available on linux or freebsd])
])
])
@@ -514,12 +519,6 @@ AS_IF([test "x$build_parport" = "xyes"], [
AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
])
-AS_IF([test "x$build_rshim" = "xyes"], [
- AC_DEFINE([BUILD_RSHIM], [1], [1 if you want to debug BlueField SoC via rshim.])
-], [
- AC_DEFINE([BUILD_RSHIM], [0], [0 if you don't want to debug BlueField SoC via rshim.])
-])
-
AS_IF([test "x$build_dmem" = "xyes"], [
AC_DEFINE([BUILD_DMEM], [1], [1 if you want to debug via Direct Mem.])
], [
@@ -718,6 +717,8 @@ PROCESS_ADAPTERS([LINUXSPIDEV_ADAPTER], ["x$is_linux" = "xyes"], [Linux spidev])
PROCESS_ADAPTERS([VDEBUG_ADAPTER], [true], [unused])
PROCESS_ADAPTERS([JTAG_DPI_ADAPTER], [true], [unused])
PROCESS_ADAPTERS([JTAG_VPI_ADAPTER], [true], [unused])
+PROCESS_ADAPTERS([RSHIM_ADAPTER], ["x$can_build_rshim" = "xyes"],
+ [internal error: validation should happen beforehand])
PROCESS_ADAPTERS([DUMMY_ADAPTER], [true], [unused])
AS_IF([test "x$enable_linuxgpiod" != "xno"], [
@@ -783,7 +784,6 @@ AM_CONDITIONAL([USE_LIBFTDI], [test "x$use_libftdi" = "xyes"])
AM_CONDITIONAL([USE_LIBGPIOD], [test "x$use_libgpiod" = "xyes"])
AM_CONDITIONAL([USE_HIDAPI], [test "x$use_hidapi" = "xyes"])
AM_CONDITIONAL([USE_LIBJAYLINK], [test "x$use_libjaylink" = "xyes"])
-AM_CONDITIONAL([RSHIM], [test "x$build_rshim" = "xyes"])
AM_CONDITIONAL([DMEM], [test "x$build_dmem" = "xyes"])
AM_CONDITIONAL([HAVE_CAPSTONE], [test "x$enable_capstone" != "xno"])
@@ -876,6 +876,7 @@ m4_foreach([adapter], [USB1_ADAPTERS,
VDEBUG_ADAPTER,
JTAG_DPI_ADAPTER,
JTAG_VPI_ADAPTER,
+ RSHIM_ADAPTER,
DUMMY_ADAPTER,
OPTIONAL_LIBRARIES,
COVERAGE],
-----------------------------------------------------------------------
Summary of changes:
configure.ac | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-05 06:25:08
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 9eb2426411aa0c1c13f5fc59801ac3cb3319f476 (commit)
from 160f7b3e5d9aa78dbbb6eff63681621aed712ab6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 9eb2426411aa0c1c13f5fc59801ac3cb3319f476
Author: R. Diez <rdi...@ya...>
Date: Sun Mar 23 22:04:20 2025 +0100
configure.ac: show the Remote Bitbang driver in the config summary
Also enable this driver by default (auto).
Change-Id: I112d6c8c0796d0dc464651feb1f7f81fa8b93910
Signed-off-by: R. Diez <rdi...@ya...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8817
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/configure.ac b/configure.ac
index 75c8e5d8a..b63c70e1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,6 +164,9 @@ m4_define([LIBFTDI_USB1_ADAPTERS],
m4_define([LIBGPIOD_ADAPTERS],
[[[linuxgpiod], [Linux GPIO bitbang through libgpiod], [LINUXGPIOD]]])
+m4_define([REMOTE_BITBANG_ADAPTER],
+ [[[remote_bitbang], [Remote Bitbang driver], [REMOTE_BITBANG]]])
+
m4_define([LIBJAYLINK_ADAPTERS],
[[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
@@ -310,6 +313,7 @@ AC_ARG_ADAPTERS([
LIBFTDI_ADAPTERS,
LIBFTDI_USB1_ADAPTERS,
LIBGPIOD_ADAPTERS,
+ REMOTE_BITBANG_ADAPTER,
LINUXSPIDEV_ADAPTER,
SERIAL_PORT_ADAPTERS,
DUMMY_ADAPTER,
@@ -413,10 +417,6 @@ AC_ARG_ENABLE([internal-libjaylink],
[Enable building internal libjaylink]),
[use_internal_libjaylink=$enableval], [use_internal_libjaylink=no])
-AC_ARG_ENABLE([remote-bitbang],
- AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang driver]),
- [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
-
AS_CASE(["${host_cpu}"],
[i?86|x86*], [],
[
@@ -611,13 +611,6 @@ AS_IF([test "x$use_internal_jimtcl" = "xyes"], [
])
])
-AS_IF([test "x$build_remote_bitbang" = "xyes"], [
- build_bitbang=yes
- AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang driver.])
-], [
- AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang driver.])
-])
-
AS_IF([test "x$build_sysfsgpio" = "xyes"], [
build_bitbang=yes
AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
@@ -716,6 +709,7 @@ PROCESS_ADAPTERS([HIDAPI_USB1_ADAPTERS], ["x$use_hidapi" = "xyes" -a "x$use_libu
PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi])
PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x])
PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [Linux libgpiod])
+PROCESS_ADAPTERS([REMOTE_BITBANG_ADAPTER], [true], [unused])
PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2])
PROCESS_ADAPTERS([PCIE_ADAPTERS], ["x$is_linux" = "xyes"], [Linux build])
PROCESS_ADAPTERS([SERIAL_PORT_ADAPTERS], ["x$can_build_buspirate" = "xyes"],
@@ -730,6 +724,10 @@ AS_IF([test "x$enable_linuxgpiod" != "xno"], [
build_bitbang=yes
])
+AS_IF([test "x$enable_remote_bitbang" != "xno"], [
+ build_bitbang=yes
+])
+
AS_IF([test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno" -o "x$enable_nulink" != "xno"], [
AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
AM_CONDITIONAL([HLADAPTER], [true])
@@ -774,7 +772,6 @@ AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x$enable_usb_blaster_2" != "xno"])
AM_CONDITIONAL([AMTJTAGACCEL], [test "x$build_amtjtagaccel" = "xyes"])
AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])
-AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"])
AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"])
AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"])
AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"])
@@ -873,6 +870,7 @@ m4_foreach([adapter], [USB1_ADAPTERS,
HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS,
LIBFTDI_USB1_ADAPTERS,
LIBGPIOD_ADAPTERS,
+ REMOTE_BITBANG_ADAPTER,
LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS,
LINUXSPIDEV_ADAPTER,
VDEBUG_ADAPTER,
-----------------------------------------------------------------------
Summary of changes:
configure.ac | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-05 06:24:41
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 160f7b3e5d9aa78dbbb6eff63681621aed712ab6 (commit)
via c023534e7b6f61dddf91fc6ca4644d4071bb73dc (commit)
from 04124c77f48b9748b88b4ccf77a36665855ee73e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 160f7b3e5d9aa78dbbb6eff63681621aed712ab6
Author: Antonio Borneo <bor...@gm...>
Date: Sun Mar 23 15:27:37 2025 +0100
target: remove events that are set to empty string
Current code allows replacing the body of an existing event, but
it doesn't provides a way to remove it.
Replacing the event with an empty string makes the event still
present and visible through
$target_name eventlist
The presence of empty events makes more complex checking for the
event not set or set to empty.
Remove the event when set to empty string.
While there, add 'Jim_Length' to the list of allowed CamelCase
symbols, avoiding the associated checkpatch error.
Change-Id: I1ec2e1a71d298a0eba0b6863902645bcc6c4cb09
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8814
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index 53850bf28..8c5c8e5e3 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4968,6 +4968,17 @@ no_params:
LOG_INFO("DEPRECATED target event %s; use TPIU events {pre,post}-{enable,disable}", n->name);
/* END_DEPRECATED_TPIU */
+ jim_getopt_obj(goi, &o);
+ if (Jim_Length(o) == 0) {
+ /* empty action, drop existing one */
+ if (teap) {
+ list_del(&teap->list);
+ Jim_DecrRefCount(teap->interp, teap->body);
+ free(teap);
+ }
+ break;
+ }
+
bool replace = true;
if (!teap) {
/* create new */
@@ -4976,7 +4987,6 @@ no_params:
}
teap->event = n->value;
teap->interp = goi->interp;
- jim_getopt_obj(goi, &o);
if (teap->body)
Jim_DecrRefCount(teap->interp, teap->body);
teap->body = Jim_DuplicateObj(goi->interp, o);
diff --git a/tools/scripts/camelcase.txt b/tools/scripts/camelcase.txt
index b78790200..6c6c28daa 100644
--- a/tools/scripts/camelcase.txt
+++ b/tools/scripts/camelcase.txt
@@ -122,6 +122,7 @@ Jim_GetWide
Jim_IncrRefCount
Jim_InitStaticExtensions
Jim_Interp
+Jim_Length
Jim_ListAppendElement
Jim_ListGetIndex
Jim_ListLength
commit c023534e7b6f61dddf91fc6ca4644d4071bb73dc
Author: Antonio Borneo <bor...@gm...>
Date: Sun Mar 23 12:09:28 2025 +0100
target: use list for target events
To simplify removing an event when it's set to an empty string,
switch event list from hardcoded simply linked list to helper's
double linked list.
While there, move the declaration of struct target_event_action
in 'target.c' as it is not anymore visible outside.
Change-Id: I799754c80055dc6d22db55aca483757e833714ff
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8813
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index 3b62e0db0..53850bf28 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -31,6 +31,7 @@
#endif
#include <helper/align.h>
+#include <helper/list.h>
#include <helper/nvp.h>
#include <helper/time_support.h>
#include <jtag/jtag.h>
@@ -52,6 +53,13 @@
/* default halt wait timeout (ms) */
#define DEFAULT_HALT_TIMEOUT 5000
+struct target_event_action {
+ enum target_event event;
+ Jim_Interp *interp;
+ Jim_Obj *body;
+ struct list_head list;
+};
+
static int target_read_buffer_default(struct target *target, target_addr_t address,
uint32_t count, uint8_t *buffer);
static int target_write_buffer_default(struct target *target, target_addr_t address,
@@ -2194,12 +2202,11 @@ static void target_destroy(struct target *target)
jtag_unregister_event_callback(jtag_enable_callback, target);
- struct target_event_action *teap = target->event_action;
- while (teap) {
- struct target_event_action *next = teap->next;
+ struct target_event_action *teap, *temp;
+ list_for_each_entry_safe(teap, temp, &target->events_action, list) {
+ list_del(&teap->list);
Jim_DecrRefCount(teap->interp, teap->body);
free(teap);
- teap = next;
}
target_free_all_working_areas(target);
@@ -4663,7 +4670,7 @@ void target_handle_event(struct target *target, enum target_event e)
struct target_event_action *teap;
int retval;
- for (teap = target->event_action; teap; teap = teap->next) {
+ list_for_each_entry(teap, &target->events_action, list) {
if (teap->event == e) {
LOG_DEBUG("target: %s (%s) event: %d (%s) action: %s",
target_name(target),
@@ -4826,7 +4833,7 @@ bool target_has_event_action(const struct target *target, enum target_event even
{
struct target_event_action *teap;
- for (teap = target->event_action; teap; teap = teap->next) {
+ list_for_each_entry(teap, &target->events_action, list) {
if (teap->event == event)
return true;
}
@@ -4946,13 +4953,14 @@ no_params:
{
struct target_event_action *teap;
- teap = target->event_action;
/* replace existing? */
- while (teap) {
+ list_for_each_entry(teap, &target->events_action, list)
if (teap->event == (enum target_event)n->value)
break;
- teap = teap->next;
- }
+
+ /* not found! */
+ if (&teap->list == &target->events_action)
+ teap = NULL;
if (goi->is_configure) {
/* START_DEPRECATED_TPIU */
@@ -4986,8 +4994,7 @@ no_params:
if (!replace) {
/* add to head of event list */
- teap->next = target->event_action;
- target->event_action = teap;
+ list_add(&teap->list, &target->events_action);
}
Jim_SetEmptyResult(goi->interp);
} else {
@@ -5402,19 +5409,19 @@ COMMAND_HANDLER(handle_target_wait_state)
COMMAND_HANDLER(handle_target_event_list)
{
struct target *target = get_current_target(CMD_CTX);
- struct target_event_action *teap = target->event_action;
+ struct target_event_action *teap;
command_print(CMD, "Event actions for target %s\n",
target_name(target));
command_print(CMD, "%-25s | Body", "Event");
command_print(CMD, "------------------------- | "
"----------------------------------------");
- while (teap) {
+
+ list_for_each_entry(teap, &target->events_action, list)
command_print(CMD, "%-25s | %s",
target_event_name(teap->event),
Jim_GetString(teap->body, NULL));
- teap = teap->next;
- }
+
command_print(CMD, "***END***");
return ERROR_OK;
}
@@ -5767,6 +5774,8 @@ static int target_create(struct jim_getopt_info *goi)
target->halt_issued = false;
+ INIT_LIST_HEAD(&target->events_action);
+
/* initialize trace information */
target->trace_info = calloc(1, sizeof(struct trace));
if (!target->trace_info) {
diff --git a/src/target/target.h b/src/target/target.h
index 47f02ec26..b698f250c 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -139,7 +139,7 @@ struct target {
*/
bool running_alg;
- struct target_event_action *event_action;
+ struct list_head events_action;
bool reset_halt; /* attempt resetting the CPU into the halted mode? */
target_addr_t working_area; /* working area (initialised RAM). Evaluated
@@ -295,13 +295,6 @@ enum target_event {
TARGET_EVENT_SEMIHOSTING_USER_CMD_0X107 = 0x107,
};
-struct target_event_action {
- enum target_event event;
- Jim_Interp *interp;
- Jim_Obj *body;
- struct target_event_action *next;
-};
-
bool target_has_event_action(const struct target *target, enum target_event event);
struct target_event_callback {
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 53 ++++++++++++++++++++++++++++++---------------
src/target/target.h | 9 +-------
tools/scripts/camelcase.txt | 1 +
3 files changed, 38 insertions(+), 25 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-05 06:23:33
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 04124c77f48b9748b88b4ccf77a36665855ee73e (commit)
from 169d463a3d3c91f62c980aba287b5e110b310ad0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 04124c77f48b9748b88b4ccf77a36665855ee73e
Author: Antonio Borneo <bor...@gm...>
Date: Sat Mar 29 22:51:59 2025 +0100
target: fix memory leak in handle_target_write_memory()
Commit f55ec6d44922 ("target: rewrite command 'write_memory' as
COMMAND_HANDLER") adds a new return statement without freeing the
allocated buffer.
Add the needed free().
Fixes: f55ec6d44922 ("target: rewrite command 'write_memory' as COMMAND_HANDLER")
Change-Id: I676d658118b32f4d7cc71eda3436bb52f1966cd8
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8822
Tested-by: jenkins
diff --git a/src/target/target.c b/src/target/target.c
index 7baeeddd0..3b62e0db0 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4608,6 +4608,7 @@ COMMAND_HANDLER(handle_target_write_memory)
int jimretval = Jim_GetWide(CMD_CTX->interp, tmp, &element_wide);
if (jimretval != JIM_OK) {
command_print(CMD, "invalid value \"%s\"", Jim_GetString(tmp, NULL));
+ free(buffer);
return ERROR_COMMAND_ARGUMENT_INVALID;
}
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 1 +
1 file changed, 1 insertion(+)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-04-01 04:51:30
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 169d463a3d3c91f62c980aba287b5e110b310ad0 (commit)
from fe3aa0a4bc185828cb318715b055dc64518bd9eb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 169d463a3d3c91f62c980aba287b5e110b310ad0
Author: Tomas Vanek <va...@fb...>
Date: Tue Feb 11 17:59:00 2025 +0100
tcl/target/nordic/nrf54l: minor corrections
Add SWD multidrop setting.
Fix the name of AP #1 to AUX-AP
Set AUX-AP CSW Prot bit[0] to make RISC-V debug accessible on AUX-AP.
Change-Id: I496e07acfe90dd858e4403176a8330d8c1a0b560
Signed-off-by: Tomas Vanek <va...@fb...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8752
Tested-by: jenkins
Reviewed-by: zapb <de...@za...>
diff --git a/tcl/target/nordic/nrf54l.cfg b/tcl/target/nordic/nrf54l.cfg
index 70ead1365..3e14055f1 100644
--- a/tcl/target/nordic/nrf54l.cfg
+++ b/tcl/target/nordic/nrf54l.cfg
@@ -27,18 +27,35 @@ if { [info exists CPUTAPID] } {
set _CPUTAPID 0x6ba02477
}
+# Multidrop instance ID should be configurable by FW in TAD TINSTANCE register.
+# Writes to the register are ignored due to a silicon erratum.
+if { [info exists SWD_INSTANCE_ID] } {
+ set _SWD_INSTANCE_ID $SWD_INSTANCE_ID
+} else {
+ set _SWD_INSTANCE_ID 0
+}
+
transport select swd
swd newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
-dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
+
+if { [info exists SWD_MULTIDROP] } {
+ dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu -dp-id 0x001c0289 -instance-id $_SWD_INSTANCE_ID
+} else {
+ dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
+}
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap -ap-num 0
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
-# Create target for the control access port (CTRL-AP).
-target create $_CHIPNAME.ctrl mem_ap -dap $_CHIPNAME.dap -ap-num 1
+# Create target for the AUX access port (AUX-AP).
+target create $_CHIPNAME.aux mem_ap -dap $_CHIPNAME.dap -ap-num 1
+
+# AUX-AP is accessible only if CSW Prot[0] bit (Data Access) is set
+$_CHIPNAME.dap apsel 1
+$_CHIPNAME.dap apcsw 0x01000000 0x01000000
adapter speed 1000
-----------------------------------------------------------------------
Summary of changes:
tcl/target/nordic/nrf54l.cfg | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-03-29 22:09:36
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via fe3aa0a4bc185828cb318715b055dc64518bd9eb (commit)
from f885a8d76c96ec94e2f7a4c4fadd57dfe384a8ac (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fe3aa0a4bc185828cb318715b055dc64518bd9eb
Author: Antonio Borneo <bor...@gm...>
Date: Sat Dec 2 15:04:09 2023 +0100
target: rewrite command 'get_reg' as COMMAND_HANDLER
Print one register per line. Repeated registers will be printed
each time.
While there, fix the 'usage' string.
Change-Id: I4eb21696705bdf15cd2cb7a4a9caa41f9ffdbf64
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8583
Tested-by: jenkins
Reviewed-by: Evgeniy Naydanov <evg...@sy...>
diff --git a/src/target/target.c b/src/target/target.c
index 2f736f0e8..7baeeddd0 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4701,63 +4701,46 @@ void target_handle_event(struct target *target, enum target_event e)
}
}
-static int target_jim_get_reg(Jim_Interp *interp, int argc,
- Jim_Obj * const *argv)
+COMMAND_HANDLER(handle_target_get_reg)
{
- bool force = false;
+ if (CMD_ARGC < 1 || CMD_ARGC > 2)
+ return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 3) {
- const char *option = Jim_GetString(argv[1], NULL);
+ bool force = false;
+ Jim_Obj *next_argv = CMD_JIMTCL_ARGV[0];
- if (!strcmp(option, "-force")) {
- argc--;
- argv++;
- force = true;
- } else {
- Jim_SetResultFormatted(interp, "invalid option '%s'", option);
- return JIM_ERR;
+ if (CMD_ARGC == 2) {
+ if (strcmp(CMD_ARGV[0], "-force")) {
+ command_print(CMD, "invalid argument '%s', must be '-force'", CMD_ARGV[0]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
- }
- if (argc != 2) {
- Jim_WrongNumArgs(interp, 1, argv, "[-force] list");
- return JIM_ERR;
+ force = true;
+ next_argv = CMD_JIMTCL_ARGV[1];
}
- const int length = Jim_ListLength(interp, argv[1]);
+ const int length = Jim_ListLength(CMD_CTX->interp, next_argv);
- Jim_Obj *result_dict = Jim_NewDictObj(interp, NULL, 0);
-
- if (!result_dict)
- return JIM_ERR;
-
- struct command_context *cmd_ctx = current_command_context(interp);
- assert(cmd_ctx);
- const struct target *target = get_current_target(cmd_ctx);
+ const struct target *target = get_current_target(CMD_CTX);
for (int i = 0; i < length; i++) {
- Jim_Obj *elem = Jim_ListGetIndex(interp, argv[1], i);
-
- if (!elem)
- return JIM_ERR;
+ Jim_Obj *elem = Jim_ListGetIndex(CMD_CTX->interp, next_argv, i);
const char *reg_name = Jim_String(elem);
- struct reg *reg = register_get_by_name(target->reg_cache, reg_name,
- false);
+ struct reg *reg = register_get_by_name(target->reg_cache, reg_name, false);
if (!reg || !reg->exist) {
- Jim_SetResultFormatted(interp, "unknown register '%s'", reg_name);
- return JIM_ERR;
+ command_print(CMD, "unknown register '%s'", reg_name);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
if (force || !reg->valid) {
int retval = reg->type->get(reg);
if (retval != ERROR_OK) {
- Jim_SetResultFormatted(interp, "failed to read register '%s'",
- reg_name);
- return JIM_ERR;
+ command_print(CMD, "failed to read register '%s'", reg_name);
+ return retval;
}
}
@@ -4765,27 +4748,15 @@ static int target_jim_get_reg(Jim_Interp *interp, int argc,
if (!reg_value) {
LOG_ERROR("Failed to allocate memory");
- return JIM_ERR;
+ return ERROR_FAIL;
}
- char *tmp = alloc_printf("0x%s", reg_value);
+ command_print(CMD, "%s 0x%s", reg_name, reg_value);
free(reg_value);
-
- if (!tmp) {
- LOG_ERROR("Failed to allocate memory");
- return JIM_ERR;
- }
-
- Jim_DictAddElement(interp, result_dict, elem,
- Jim_NewStringObj(interp, tmp, -1));
-
- free(tmp);
}
- Jim_SetResult(interp, result_dict);
-
- return JIM_OK;
+ return ERROR_OK;
}
COMMAND_HANDLER(handle_set_reg_command)
@@ -5577,9 +5548,9 @@ static const struct command_registration target_instance_command_handlers[] = {
{
.name = "get_reg",
.mode = COMMAND_EXEC,
- .jim_handler = target_jim_get_reg,
+ .handler = handle_target_get_reg,
.help = "Get register values from the target",
- .usage = "list",
+ .usage = "[-force] list",
},
{
.name = "set_reg",
@@ -6712,9 +6683,9 @@ static const struct command_registration target_exec_command_handlers[] = {
{
.name = "get_reg",
.mode = COMMAND_EXEC,
- .jim_handler = target_jim_get_reg,
+ .handler = handle_target_get_reg,
.help = "Get register values from the target",
- .usage = "list",
+ .usage = "[-force] list",
},
{
.name = "set_reg",
-----------------------------------------------------------------------
Summary of changes:
src/target/target.c | 81 +++++++++++++++++------------------------------------
1 file changed, 26 insertions(+), 55 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-03-29 18:27:53
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via f885a8d76c96ec94e2f7a4c4fadd57dfe384a8ac (commit)
from a9fa3392670659dfd558d8733911ffce9538e2d2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f885a8d76c96ec94e2f7a4c4fadd57dfe384a8ac
Author: Adrien Grassein <agr...@na...>
Date: Thu Jan 18 11:54:15 2024 +0100
target/aarch64: Cleanup on exit
Restore target configuration on exit so that OpenOCD get correct values
when restarting.
Change-Id: I8cbba1fdae1d3c4a580197b7a97691443780ed06
Signed-off-by: Adrien Grassein <agr...@na...>
Signed-off-by: Adrien Charruel <ach...@na...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8654
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index 609965ba5..ce7808e3a 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -2857,6 +2857,14 @@ static void aarch64_deinit_target(struct target *target)
struct aarch64_common *aarch64 = target_to_aarch64(target);
struct armv8_common *armv8 = &aarch64->armv8_common;
struct arm_dpm *dpm = &armv8->dpm;
+ uint64_t address;
+
+ if (target->state == TARGET_HALTED) {
+ // Restore the previous state of the target (gp registers, MMU, caches, etc)
+ int retval = aarch64_restore_one(target, true, &address, false, false);
+ if (retval != ERROR_OK)
+ LOG_TARGET_ERROR(target, "Failed to restore target state");
+ }
if (armv8->debug_ap)
dap_put_ap(armv8->debug_ap);
-----------------------------------------------------------------------
Summary of changes:
src/target/aarch64.c | 8 ++++++++
1 file changed, 8 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-03-29 18:27:26
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via a9fa3392670659dfd558d8733911ffce9538e2d2 (commit)
from a86fdfc73548a2b317ed8e61a618ebff2ee4f5e2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a9fa3392670659dfd558d8733911ffce9538e2d2
Author: Marek Vasut <mar...@gm...>
Date: Fri Aug 23 01:29:12 2024 +0200
tcl/target: Add Renesas R-Car Gen4 R8A779G0 V4H and R8A779H0 V4M targets
Add support for Renesas R-Car Gen4 R8A779G0 V4H and R8A779H0 V4M SoCs.
Those contain 4x CA76 and 3x CR52 cores.
Change-Id: I4a701f0fec4dd574fc099a221d464ccc55db6252
Signed-off-by: Marek Vasut <mar...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8807
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/tcl/target/renesas_rcar_gen3.cfg b/tcl/target/renesas_rcar_gen3.cfg
index 73b3003a9..f6bc5e4c8 100644
--- a/tcl/target/renesas_rcar_gen3.cfg
+++ b/tcl/target/renesas_rcar_gen3.cfg
@@ -90,6 +90,18 @@ switch $_soc {
set _num_cr52 1
set _boot_core CA76
}
+ V4H {
+ set _CHIPNAME r8a779g0
+ set _num_ca76 4
+ set _num_cr52 3
+ set _boot_core CR52
+ }
+ V4M {
+ set _CHIPNAME r8a779h0
+ set _num_ca76 4
+ set _num_cr52 3
+ set _boot_core CR52
+ }
default {
error "'$_soc' is invalid!"
}
@@ -126,8 +138,8 @@ set CA57_DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000}
set CA57_CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000}
set CA53_DBGBASE {0x80C10000 0x80D10000 0x80E10000 0x80F10000}
set CA53_CTIBASE {0x80C20000 0x80D20000 0x80E20000 0x80F20000}
-set CR52_DBGBASE 0x80c10000
-set CR52_CTIBASE 0x80c20000
+set CR52_DBGBASE {0x80C10000 0x80D10000 0x80E10000}
+set CR52_CTIBASE {0x80C20000 0x80D20000 0x80E20000}
set CR7_DBGBASE 0x80910000
set CR7_CTIBASE 0x80918000
@@ -159,24 +171,27 @@ proc setup_a5x {core_name dbgbase ctibase num boot} {
proc setup_crx {core_name dbgbase ctibase num boot} {
global _CHIPNAME
global _DAPNAME
+ global smp_targets
global _targets
for { set _core 0 } { $_core < $num } { incr _core } {
- set _TARGETNAME $_CHIPNAME.$core_name
+ set _TARGETNAME $_CHIPNAME.$core_name.$_core
set _CTINAME $_TARGETNAME.cti
- cti create $_CTINAME -dap $_DAPNAME -ap-num 1 -baseaddr $ctibase
+ cti create $_CTINAME -dap $_DAPNAME -ap-num 1 -baseaddr [lindex $ctibase $_core]
if { $core_name == "r52" } {
set _command "target create $_TARGETNAME armv8r -dap $_DAPNAME \
- -ap-num 1 -dbgbase $dbgbase -cti $_CTINAME"
+ -ap-num 1 -dbgbase [lindex $dbgbase $_core] -cti $_CTINAME"
} else {
set _command "target create $_TARGETNAME cortex_r4 -dap $_DAPNAME \
- -ap-num 1 -dbgbase $dbgbase"
+ -ap-num 1 -dbgbase [lindex $dbgbase $_core]"
}
- if { $boot == 1 } {
+ if { $_core == 0 && $boot == 1 } {
set _targets "$_TARGETNAME"
} else {
set _command "$_command -defer-examine"
}
+ set smp_targets "$smp_targets $_TARGETNAME"
eval $_command
+ $_TARGETNAME configure -event examine-end { halt }
}
}
-----------------------------------------------------------------------
Summary of changes:
tcl/target/renesas_rcar_gen3.cfg | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|
|
From: openocd-gerrit <ope...@us...> - 2025-03-29 18:27:06
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via a86fdfc73548a2b317ed8e61a618ebff2ee4f5e2 (commit)
from 5773ff9d82a06e7e270dd71fc3d4352815384292 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a86fdfc73548a2b317ed8e61a618ebff2ee4f5e2
Author: Antonio Borneo <bor...@gm...>
Date: Sun Mar 16 11:50:04 2025 +0100
target: drop last instances of 'target->cmd_name'
The helper function 'target_name()' or, better, the log functions
'LOG_TARGET_xxx(target, ...)' should be used in place of taking
the target name directly from 'target->cmd_name'.
Replace the remaining instances in the code.
While there:
- address some indentation,
- drop trailing punctuation in log message,
- replace one LOG WARNING with LOG_TARGET_WARNING.
Change-Id: Ie6cf4c174ffe91b975c983e4697c735766267041
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8806
Tested-by: jenkins
Reviewed-by: zapb <de...@za...>
diff --git a/src/target/armv7a.c b/src/target/armv7a.c
index e22d309a0..c14155e01 100644
--- a/src/target/armv7a.c
+++ b/src/target/armv7a.c
@@ -101,14 +101,14 @@ static int armv7a_read_midr(struct target *target)
armv7a->arch = (midr >> 16) & 0xf;
armv7a->variant = (midr >> 20) & 0xf;
armv7a->implementor = (midr >> 24) & 0xff;
- LOG_DEBUG("%s rev %" PRIx32 ", partnum %" PRIx32 ", arch %" PRIx32
- ", variant %" PRIx32 ", implementor %" PRIx32,
- target->cmd_name,
- armv7a->rev,
- armv7a->partnum,
- armv7a->arch,
- armv7a->variant,
- armv7a->implementor);
+ LOG_TARGET_DEBUG(target,
+ "rev %" PRIx32 ", partnum %" PRIx32 ", arch %" PRIx32
+ ", variant %" PRIx32 ", implementor %" PRIx32,
+ armv7a->rev,
+ armv7a->partnum,
+ armv7a->arch,
+ armv7a->variant,
+ armv7a->implementor);
done:
dpm->finish(dpm);
diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index b32fec270..9c6064558 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -2923,14 +2923,12 @@ static int cortex_a_examine_first(struct target *target)
armv7a->debug_ap->memaccess_tck = 80;
if (!target->dbgbase_set) {
- LOG_DEBUG("%s's dbgbase is not set, trying to detect using the ROM table",
- target->cmd_name);
+ LOG_TARGET_DEBUG(target, "dbgbase is not set, trying to detect using the ROM table");
/* Lookup Processor DAP */
retval = dap_lookup_cs_component(armv7a->debug_ap, ARM_CS_C9_DEVTYPE_CORE_DEBUG,
&armv7a->debug_base, target->coreid);
if (retval != ERROR_OK) {
- LOG_ERROR("Can't detect %s's dbgbase from the ROM table; you need to specify it explicitly.",
- target->cmd_name);
+ LOG_TARGET_ERROR(target, "Can't detect dbgbase from the ROM table; you need to specify it explicitly");
return retval;
}
LOG_DEBUG("Detected core %" PRId32 " dbgbase: " TARGET_ADDR_FMT,
@@ -2939,8 +2937,9 @@ static int cortex_a_examine_first(struct target *target)
armv7a->debug_base = target->dbgbase;
if ((armv7a->debug_base & (1UL<<31)) == 0)
- LOG_WARNING("Debug base address for target %s has bit 31 set to 0. Access to debug registers will likely fail!\n"
- "Please fix the target configuration.", target_name(target));
+ LOG_TARGET_WARNING(target,
+ "Debug base address has bit 31 set to 0. Access to debug registers will likely fail!\n"
+ "Please fix the target configuration");
retval = mem_ap_read_atomic_u32(armv7a->debug_ap,
armv7a->debug_base + CPUDBG_DIDR, &didr);
diff --git a/src/target/espressif/esp32_apptrace.c b/src/target/espressif/esp32_apptrace.c
index 3202fd3d6..307096019 100644
--- a/src/target/espressif/esp32_apptrace.c
+++ b/src/target/espressif/esp32_apptrace.c
@@ -649,7 +649,7 @@ static int esp32_apptrace_wait4halt(struct esp32_apptrace_cmd_ctx *ctx, struct t
if (res != ERROR_OK)
return res;
if (target->state == TARGET_HALTED) {
- LOG_USER("%s: HALTED", target->cmd_name);
+ LOG_TARGET_USER(target, "HALTED");
break;
}
alive_sleep(500);
diff --git a/src/target/espressif/esp_xtensa_apptrace.c b/src/target/espressif/esp_xtensa_apptrace.c
index 5741ab030..313f6ce77 100644
--- a/src/target/espressif/esp_xtensa_apptrace.c
+++ b/src/target/espressif/esp_xtensa_apptrace.c
@@ -277,7 +277,7 @@ static int esp_xtensa_swdbg_activate(struct target *target, int enab)
xtensa_dm_queue_tdi_idle(&xtensa->dbg_mod);
int res = xtensa_dm_queue_execute(&xtensa->dbg_mod);
if (res != ERROR_OK) {
- LOG_ERROR("%s: writing DCR failed!", target->cmd_name);
+ LOG_TARGET_ERROR(target, "writing DCR failed");
return res;
}
-----------------------------------------------------------------------
Summary of changes:
src/target/armv7a.c | 16 ++++++++--------
src/target/cortex_a.c | 11 +++++------
src/target/espressif/esp32_apptrace.c | 2 +-
src/target/espressif/esp_xtensa_apptrace.c | 2 +-
4 files changed, 15 insertions(+), 16 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|