From 9feb844b7ecba9d2b9892e3f5a10691615af7f32 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 8 May 2019 15:43:18 -0700 Subject: [PATCH] Fix crash in internal filesystem on nrf Fixes #1842 --- ports/nrf/supervisor/internal_flash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ports/nrf/supervisor/internal_flash.c b/ports/nrf/supervisor/internal_flash.c index 5713dea888..dcacd4d27f 100644 --- a/ports/nrf/supervisor/internal_flash.c +++ b/ports/nrf/supervisor/internal_flash.c @@ -97,7 +97,9 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32 count = MIN(num_blocks, count); if (page_addr != _flash_page_addr) { - nrf_nvm_safe_flash_page_write(_flash_page_addr, _flash_cache); + // Write out anything in cache before overwriting it. + supervisor_flash_flush(); + _flash_page_addr = page_addr; // Copy the current contents of the entire page into the cache.