From 6d932a8a1de47a3346aaf9d5ad31c0f759346a68 Mon Sep 17 00:00:00 2001 From: Milan Rossa Date: Thu, 12 Dec 2019 17:06:55 +0100 Subject: [PATCH] core/embed/unix/flash: Don't reopen flash emulation file. --- core/embed/unix/flash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/embed/unix/flash.c b/core/embed/unix/flash.c index ae907c7eb6..6a672107ae 100644 --- a/core/embed/unix/flash.c +++ b/core/embed/unix/flash.c @@ -83,7 +83,7 @@ const uint8_t STORAGE_SECTORS[STORAGE_SECTORS_COUNT] = { FLASH_SECTOR_STORAGE_2, }; -static uint8_t *FLASH_BUFFER; +static uint8_t *FLASH_BUFFER = NULL; static uint32_t FLASH_SIZE; static void flash_exit(void) { @@ -92,6 +92,8 @@ static void flash_exit(void) { } void flash_init(void) { + if (FLASH_BUFFER) return; + FLASH_SIZE = FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT] - FLASH_SECTOR_TABLE[0]; // check whether the file exists and it has the correct size