From 474d1c31a0ecfeb79afc12bdb6c3a6a3055a5c1d Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Thu, 19 Dec 2024 14:13:57 +0000 Subject: [PATCH] Clear cache after writes, not before --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 44862a9..d674740 100644 --- a/main.cpp +++ b/main.cpp @@ -1980,7 +1980,6 @@ struct picoboot_memory_access : public memory_access { void write(uint32_t address, uint8_t *buffer, unsigned int size) override { vector write_data; // used when erasing flash if (flash == get_memory_type(address, model)) { - clear_cache(); // clear entire flash cache on any write, to be safe connection.exit_xip(); if (erase) { // Do automatically erase flash, and make it aligned @@ -2014,6 +2013,7 @@ struct picoboot_memory_access : public memory_access { } if (is_transfer_aligned(address, model) && is_transfer_aligned(address + size, model)) { connection.write(address, (uint8_t *) buffer, size); + clear_cache(); // clear entire flash cache after any write, to be safe } else { // for write, we must be correctly sized/aligned in 256 byte chunks std::stringstream sstream;