diff options
author | Damien George <damien.p.george@gmail.com> | 2018-09-12 15:58:42 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-09-12 15:58:42 +1000 |
commit | 6b3d6da74b107a50ac3f8373d3ee48f22e82b5fa (patch) | |
tree | df84358df86b5f0bd5f64bc74ab42b3e396b7016 | |
parent | 0941a467e71eb316d15e1e824f6e0d955054651b (diff) |
stm32/flashbdev: Protect flash writes from cache flushing and USB MSC.
-rw-r--r-- | ports/stm32/flashbdev.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ports/stm32/flashbdev.c b/ports/stm32/flashbdev.c index 395662c8b..7ad909afe 100644 --- a/ports/stm32/flashbdev.c +++ b/ports/stm32/flashbdev.c @@ -265,8 +265,10 @@ bool flash_bdev_writeblock(const uint8_t *src, uint32_t block) { // bad block number return false; } + uint32_t basepri = raise_irq_pri(IRQ_PRI_FLASH); // prevent cache flushing and USB access uint8_t *dest = flash_cache_get_addr_for_write(flash_addr); memcpy(dest, src, FLASH_BLOCK_SIZE); + restore_irq_pri(basepri); return true; } |