This is an automated email from Gerrit.

"Adrien Charruel <acharr...@nanoxplore.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8805

-- gerrit

commit 66a87e994a1ac4c01301ae0b9d338e3c64377c02
Author: Adrien Charruel <acharr...@nanoxplore.com>
Date:   Tue Mar 11 11:20:36 2025 +0100

    target/aarch64: Flush d- and i-caches when needed
    
    We need to flush caches each time memory is written.
    
    Change-Id: I6e469a9398b53d946a10d3d0f627b9924a239b41
    Signed-off-by: Adrien Grassein <agrass...@nanoxplore.com>
    Signed-off-by: Adrien Charruel <acharr...@nanoxplore.com>

diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index 9fb7672b4b..bb25124482 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -2511,6 +2511,10 @@ static int aarch64_read_phys_memory(struct target 
*target,
        int retval = ERROR_COMMAND_SYNTAX_ERROR;
 
        if (count && buffer) {
+               /* Flush any CPU cache */
+               retval = aarch64_flush_and_deactivate_caches(target);
+               if (retval != ERROR_OK)
+                       return retval;
                /* read memory through APB-AP */
                retval = aarch64_mmu_modify(target, 0);
                if (retval != ERROR_OK)
@@ -2537,6 +2541,7 @@ static int aarch64_read_memory(struct target *target, 
target_addr_t address,
                if (retval != ERROR_OK)
                        return retval;
        }
+
        return aarch64_read_cpu_memory(target, address, size, count, buffer);
 }
 
@@ -2547,6 +2552,11 @@ static int aarch64_write_phys_memory(struct target 
*target,
        int retval = ERROR_COMMAND_SYNTAX_ERROR;
 
        if (count && buffer) {
+               /* Flush any CPU cache */
+               retval = aarch64_flush_and_deactivate_caches(target);
+               if (retval != ERROR_OK)
+                       return retval;
+
                /* write memory through APB-AP */
                retval = aarch64_mmu_modify(target, 0);
                if (retval != ERROR_OK)
@@ -2574,6 +2584,7 @@ static int aarch64_write_memory(struct target *target, 
target_addr_t address,
                if (retval != ERROR_OK)
                        return retval;
        }
+
        return aarch64_write_cpu_memory(target, address, size, count, buffer);
 }
 

-- 

Reply via email to