This is an automated email from Gerrit.

"Tomas Vanek <[email protected]>" just uploaded a new patch set to Gerrit, which 
you can find at https://review.openocd.org/c/openocd/+/9127

-- gerrit

commit bf3164e919adbd3ba893925c0b6995974129025d
Author: Tim Newsome <[email protected]>
Date:   Sat Sep 13 23:01:33 2025 +0200

    target, flash, doc: Create riscv repeat_read command
    
    Imported non-riscv part from
    https://github.com/riscv-collab/riscv-openocd/pull/510
    
    Introduce target_handle_md_output() parameter include_address.
    All callers set it true but riscv repeat_read command.
    
    Document repeat_read command.
    
    Checkpatch-ignore: NO_AUTHOR_SIGN_OFF
    
    Change-Id: I67b5aad15a33ad149d4047998b22407cb60098fd
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index b188f2175e..e66d69ecac 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -11533,6 +11533,12 @@ encountering the target being busy. This command 
resets those learned values
 after `wait` scans. It's only useful for testing OpenOCD itself.
 @end deffn
 
+@deffn {Command} {riscv repeat_read} count address [size=4]
+Quickly read count words of the given size from address. This can be useful
+to read out a buffer that's memory-mapped to be accessed through a single
+address, or to sample a changing value in a memory-mapped device.
+@end deffn
+
 @deffn {Command} {riscv set_command_timeout_sec} [seconds]
 Set the wall-clock timeout (in seconds) for individual commands. The default
 should work fine for all but the slowest targets (eg. simulators).
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index 0d41e49c8e..4d944dbe76 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -720,7 +720,8 @@ COMMAND_HANDLER(handle_flash_md_command)
 
        retval = flash_driver_read(bank, buffer, offset, sizebytes);
        if (retval == ERROR_OK)
-               target_handle_md_output(CMD, target, address, wordsize, count, 
buffer);
+               target_handle_md_output(CMD, target, address, wordsize, count,
+                               buffer, true);
 
        free(buffer);
 
diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c
index dc85a21800..8198438230 100644
--- a/src/target/dsp563xx.c
+++ b/src/target/dsp563xx.c
@@ -2146,7 +2146,8 @@ COMMAND_HANDLER(dsp563xx_mem_command)
                err = dsp563xx_read_memory(target, mem_type, address, 
sizeof(uint32_t),
                                count, buffer);
                if (err == ERROR_OK)
-                       target_handle_md_output(CMD, target, address, 
sizeof(uint32_t), count, buffer);
+                       target_handle_md_output(CMD, target, address, 
sizeof(uint32_t),
+                               count, buffer, true);
 
        } else {
                b = buffer;
diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c
index 99077b211e..ece53b610f 100644
--- a/src/target/riscv/riscv.c
+++ b/src/target/riscv/riscv.c
@@ -5237,7 +5237,7 @@ COMMAND_HANDLER(handle_repeat_read)
        };
        int result = r->access_memory(target, args);
        if (result == ERROR_OK)
-               target_handle_md_output(cmd, target, address, size, count, 
buffer);
+               target_handle_md_output(cmd, target, address, size, count, 
buffer, false);
        free(buffer);
        return result;
 }
diff --git a/src/target/target.c b/src/target/target.c
index 1428fac913..a9253425ed 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -3353,7 +3353,7 @@ COMMAND_HANDLER(handle_step_command)
 
 void target_handle_md_output(struct command_invocation *cmd,
                struct target *target, target_addr_t address, unsigned int size,
-               unsigned int count, const uint8_t *buffer)
+               unsigned int count, const uint8_t *buffer, bool include_address)
 {
        const unsigned int line_bytecnt = 32;
        unsigned int line_modulo = line_bytecnt / size;
@@ -3382,7 +3382,7 @@ void target_handle_md_output(struct command_invocation 
*cmd,
        }
 
        for (unsigned int i = 0; i < count; i++) {
-               if (i % line_modulo == 0) {
+               if (include_address && i % line_modulo == 0) {
                        output_len += snprintf(output + output_len,
                                        sizeof(output) - output_len,
                                        TARGET_ADDR_FMT ": ",
@@ -3466,7 +3466,7 @@ COMMAND_HANDLER(handle_md_command)
        struct target *target = get_current_target(CMD_CTX);
        int retval = fn(target, address, size, count, buffer);
        if (retval == ERROR_OK)
-               target_handle_md_output(CMD, target, address, size, count, 
buffer);
+               target_handle_md_output(CMD, target, address, size, count, 
buffer, true);
 
        free(buffer);
 
diff --git a/src/target/target.h b/src/target/target.h
index 6efcc7677b..744ac1e38a 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -775,7 +775,7 @@ void target_handle_event(struct target *t, enum 
target_event e);
 
 void target_handle_md_output(struct command_invocation *cmd,
        struct target *target, target_addr_t address, unsigned int size,
-       unsigned int count, const uint8_t *buffer);
+       unsigned int count, const uint8_t *buffer, bool include_address);
 
 int target_profiling_default(struct target *target, uint32_t *samples, uint32_t
                max_num_samples, uint32_t *num_samples, uint32_t seconds);

-- 

Reply via email to