mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
disable all interrupts when reading from spiffs
this fixes any possible resets caused by interrupt routines trying to read the flash while there is an ongoing spiffs operation
This commit is contained in:
parent
62a460f0b8
commit
b902e86cb1
@ -135,7 +135,7 @@ void ets_intr_unlock();
|
|||||||
extern uint32_t interruptsState;
|
extern uint32_t interruptsState;
|
||||||
|
|
||||||
#define interrupts() xt_enable_interrupts(interruptsState)
|
#define interrupts() xt_enable_interrupts(interruptsState)
|
||||||
#define noInterrupts() xt_disable_interrupts(interruptsState, 15)
|
#define noInterrupts() __asm__ __volatile__("rsil %0,15; esync; isync; dsync" : "=a" (interruptsState))
|
||||||
|
|
||||||
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
|
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
|
||||||
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
|
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "flashmem.h"
|
#include "flashmem.h"
|
||||||
#include "esp8266_peri.h"
|
#include "esp8266_peri.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
// Based on NodeMCU platform_flash
|
// Based on NodeMCU platform_flash
|
||||||
// https://github.com/nodemcu/nodemcu-firmware
|
// https://github.com/nodemcu/nodemcu-firmware
|
||||||
@ -98,7 +99,10 @@ uint32_t flashmem_read( void *to, uint32_t fromaddr, uint32_t size )
|
|||||||
bool flashmem_erase_sector( uint32_t sector_id )
|
bool flashmem_erase_sector( uint32_t sector_id )
|
||||||
{
|
{
|
||||||
WDT_RESET();
|
WDT_RESET();
|
||||||
return spi_flash_erase_sector( sector_id ) == SPI_FLASH_RESULT_OK;
|
noInterrupts();
|
||||||
|
bool erased = spi_flash_erase_sector( sector_id ) == SPI_FLASH_RESULT_OK;
|
||||||
|
interrupts();
|
||||||
|
return erased;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPIFlashInfo flashmem_get_info()
|
SPIFlashInfo flashmem_get_info()
|
||||||
@ -186,9 +190,9 @@ uint32_t flashmem_write_internal( const void *from, uint32_t toaddr, uint32_t si
|
|||||||
os_memcpy(apbuf, from, size);
|
os_memcpy(apbuf, from, size);
|
||||||
}
|
}
|
||||||
WDT_RESET();
|
WDT_RESET();
|
||||||
ETS_UART_INTR_DISABLE();
|
noInterrupts();
|
||||||
r = spi_flash_write(toaddr, apbuf?(uint32 *)apbuf:(uint32 *)from, size);
|
r = spi_flash_write(toaddr, apbuf?(uint32 *)apbuf:(uint32 *)from, size);
|
||||||
ETS_UART_INTR_ENABLE();
|
interrupts();
|
||||||
if(apbuf)
|
if(apbuf)
|
||||||
os_free(apbuf);
|
os_free(apbuf);
|
||||||
if(SPI_FLASH_RESULT_OK == r)
|
if(SPI_FLASH_RESULT_OK == r)
|
||||||
@ -204,9 +208,9 @@ uint32_t flashmem_read_internal( void *to, uint32_t fromaddr, uint32_t size )
|
|||||||
fromaddr -= INTERNAL_FLASH_START_ADDRESS;
|
fromaddr -= INTERNAL_FLASH_START_ADDRESS;
|
||||||
SpiFlashOpResult r;
|
SpiFlashOpResult r;
|
||||||
WDT_RESET();
|
WDT_RESET();
|
||||||
ETS_UART_INTR_DISABLE();
|
noInterrupts();
|
||||||
r = spi_flash_read(fromaddr, (uint32 *)to, size);
|
r = spi_flash_read(fromaddr, (uint32 *)to, size);
|
||||||
ETS_UART_INTR_ENABLE();
|
interrupts();
|
||||||
if(SPI_FLASH_RESULT_OK == r)
|
if(SPI_FLASH_RESULT_OK == r)
|
||||||
return size;
|
return size;
|
||||||
else{
|
else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user