diff options
-rw-r--r-- | src/Hardware/NonVolatileMemory.cpp | 12 | ||||
-rw-r--r-- | src/Platform.cpp | 13 |
2 files changed, 8 insertions, 17 deletions
diff --git a/src/Hardware/NonVolatileMemory.cpp b/src/Hardware/NonVolatileMemory.cpp index 1a5e8582..d36e6dae 100644 --- a/src/Hardware/NonVolatileMemory.cpp +++ b/src/Hardware/NonVolatileMemory.cpp @@ -26,14 +26,11 @@ void NonVolatileMemory::EnsureRead() noexcept #elif defined(__LPC17xx__) # error //TODO #elif SAM4E || SAM4S || SAME70 + const bool cacheEnabled = Cache::Disable(); + flash_read_user_signature(reinterpret_cast<uint32_t*>(&buffer), sizeof(buffer)/sizeof(uint32_t)); + if (cacheEnabled) { - TaskCriticalSectionLocker lock; // prevent scheduling while the cache is disabled - const bool cacheEnabled = Cache::Disable(); - flash_read_user_signature(reinterpret_cast<uint32_t*>(&buffer), sizeof(buffer)/sizeof(uint32_t)); - if (cacheEnabled) - { - Cache::Enable(); - } + Cache::Enable(); } #else # error Unsupported processor @@ -79,7 +76,6 @@ void NonVolatileMemory::EnsureWritten() noexcept if (state == NvmState::writeNeeded) { # if SAM4E || SAM4S || SAME70 - TaskCriticalSectionLocker lock; // prevent scheduling while the cache is disabled const bool cacheEnabled = Cache::Disable(); flash_write_user_signature(reinterpret_cast<const uint32_t*>(&buffer)); if (cacheEnabled) diff --git a/src/Platform.cpp b/src/Platform.cpp index 0e1200d7..c14cf285 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -862,16 +862,11 @@ void Platform::ReadUniqueId() # else memset(uniqueId, 0, sizeof(uniqueId)); - uint32_t rc; + const bool cacheWasEnabled = Cache::Disable(); + const uint32_t rc = flash_read_unique_id(uniqueId); + if (cacheWasEnabled) { - // Prevent scheduling while we have the cache disabled - TaskCriticalSectionLocker lock; - const bool cacheWasEnabled = Cache::Disable(); - rc = flash_read_unique_id(uniqueId, 4); - if (cacheWasEnabled) - { - Cache::Enable(); - } + Cache::Enable(); } if (rc == 0) |