Skip to content

Commit c3d828c

Browse files
committed
target/esp32p4: fix write memory through cache
1 parent 31b58fc commit c3d828c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/target/espressif/esp32p4.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ static int esp32p4_write_memory(struct target *target, target_addr_t address,
443443
uint32_t size, uint32_t count, const uint8_t *buffer)
444444
{
445445
int map = -1;
446+
target_addr_t non_cacheable_address = address;
446447

447448
if (ESP32P4_ADDR_IS_CACHEABLE(address)) {
448449
/* Write-back is for dcache and l2 cache only */
@@ -454,9 +455,11 @@ static int esp32p4_write_memory(struct target *target, target_addr_t address,
454455
int res = esp32p4_sync_cache(target, address, size * count, map, ESP32P4_CACHE_SYNC_WRITEBACK);
455456
if (res != ERROR_OK)
456457
LOG_TARGET_WARNING(target, "Cache writeback failed! Write main memory anyway.");
458+
if (target->state == TARGET_RUNNING)
459+
non_cacheable_address = ESP32P4_NON_CACHEABLE_ADDR(address);
457460
}
458461

459-
int res = esp_riscv_write_memory(target, address, size, count, buffer);
462+
int res = esp_riscv_write_memory(target, non_cacheable_address, size, count, buffer);
460463

461464
if (map > 0) {
462465
/* Don't invalidate the L2CACHE here. We don't know if it has been written back to the PSRAM yet. */

0 commit comments

Comments
 (0)