Avoid synchronous flushes to flash during Blackbox shutdown
This commit is contained in:
parent
acd4745a4e
commit
d6911e8b86
|
@ -415,7 +415,7 @@ void blackboxDeviceFlush(void)
|
|||
break;
|
||||
#ifdef USE_FLASHFS
|
||||
case BLACKBOX_DEVICE_FLASH:
|
||||
flashfsFlushSync();
|
||||
flashfsFlushAsync();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
@ -503,8 +503,7 @@ bool isBlackboxDeviceIdle(void)
|
|||
|
||||
#ifdef USE_FLASHFS
|
||||
case BLACKBOX_DEVICE_FLASH:
|
||||
flashfsFlushSync();
|
||||
return true;
|
||||
return flashfsFlushAsync();
|
||||
#endif
|
||||
|
||||
default:
|
||||
|
|
|
@ -295,12 +295,14 @@ static void flashfsAdvanceTailInBuffer(uint32_t delta)
|
|||
/**
|
||||
* If the flash is ready to accept writes, flush the buffer to it, otherwise schedule
|
||||
* a flush for later and return immediately.
|
||||
*
|
||||
* Returns true if all data in the buffer has been flushed to the device.
|
||||
*/
|
||||
void flashfsFlushAsync()
|
||||
bool flashfsFlushAsync()
|
||||
{
|
||||
if (flashfsBufferIsEmpty()) {
|
||||
shouldFlush = false;
|
||||
return; // Nothing to flush
|
||||
return true; // Nothing to flush
|
||||
}
|
||||
|
||||
uint8_t const * buffers[2];
|
||||
|
@ -312,6 +314,8 @@ void flashfsFlushAsync()
|
|||
flashfsAdvanceTailInBuffer(bytesWritten);
|
||||
|
||||
shouldFlush = !flashfsBufferIsEmpty();
|
||||
|
||||
return flashfsBufferIsEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,7 @@ void flashfsWrite(const uint8_t *data, unsigned int len, bool sync);
|
|||
|
||||
int flashfsReadAbs(uint32_t offset, uint8_t *data, unsigned int len);
|
||||
|
||||
void flashfsFlushAsync();
|
||||
bool flashfsFlushAsync();
|
||||
void flashfsFlushSync();
|
||||
|
||||
void flashfsInit();
|
||||
|
|
|
@ -772,7 +772,12 @@ static void cliFlashErase(char *cmdline)
|
|||
|
||||
printf("Erasing, please wait...\r\n");
|
||||
flashfsEraseCompletely();
|
||||
printf("Erased flash chip.\r\n");
|
||||
|
||||
while (!flashfsIsReady()) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
printf("Done.\r\n");
|
||||
}
|
||||
|
||||
static void cliFlashWrite(char *cmdline)
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
|
||||
#include "io/serial.h"
|
||||
#include "io/flashfs.h"
|
||||
|
||||
#include "io/gps.h"
|
||||
#include "io/escservo.h"
|
||||
#include "io/rc_controls.h"
|
||||
|
|
Loading…
Reference in New Issue