mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Stop Blackbox logging when flash fills up
This commit is contained in:
parent
80ea5e4419
commit
3b8e05fb46
5 changed files with 41 additions and 3 deletions
|
@ -1129,6 +1129,11 @@ void handleBlackbox(void)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Did we run out of room on the device? Stop!
|
||||||
|
if (isBlackboxDeviceFull()) {
|
||||||
|
blackboxSetState(BLACKBOX_STATE_STOPPED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool canUseBlackboxWithCurrentConfiguration(void)
|
static bool canUseBlackboxWithCurrentConfiguration(void)
|
||||||
|
|
|
@ -457,8 +457,9 @@ bool blackboxDeviceOpen(void)
|
||||||
break;
|
break;
|
||||||
#ifdef FLASHFS
|
#ifdef FLASHFS
|
||||||
case BLACKBOX_DEVICE_FLASH:
|
case BLACKBOX_DEVICE_FLASH:
|
||||||
if (flashfsGetSize() == 0)
|
if (flashfsGetSize() == 0 || isBlackboxDeviceFull()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
|
@ -509,3 +510,19 @@ bool isBlackboxDeviceIdle(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBlackboxDeviceFull(void)
|
||||||
|
{
|
||||||
|
switch (masterConfig.blackbox_device) {
|
||||||
|
case BLACKBOX_DEVICE_SERIAL:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#ifdef FLASHFS
|
||||||
|
case BLACKBOX_DEVICE_FLASH:
|
||||||
|
return flashfsIsEOF();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -42,3 +42,4 @@ bool blackboxDeviceOpen(void);
|
||||||
void blackboxDeviceClose(void);
|
void blackboxDeviceClose(void);
|
||||||
|
|
||||||
bool isBlackboxDeviceIdle(void);
|
bool isBlackboxDeviceIdle(void);
|
||||||
|
bool isBlackboxDeviceFull(void);
|
||||||
|
|
|
@ -18,12 +18,15 @@
|
||||||
/**
|
/**
|
||||||
* This provides a stream interface to a flash chip if one is present.
|
* This provides a stream interface to a flash chip if one is present.
|
||||||
*
|
*
|
||||||
* On statup, call flashfsInit after initialising the flash chip, in order to init the filesystem. This will
|
* On statup, call flashfsInit() after initialising the flash chip in order to init the filesystem. This will
|
||||||
* result in the file pointer being pointed at the first free block found, or at the end of the device if the
|
* result in the file pointer being pointed at the first free block found, or at the end of the device if the
|
||||||
* flash chip is full.
|
* flash chip is full.
|
||||||
*
|
*
|
||||||
* Note that bits can only be set to 0 when writing, not back to 1 from 0. You must erase sectors in order
|
* Note that bits can only be set to 0 when writing, not back to 1 from 0. You must erase sectors in order
|
||||||
* to bring bits back to 1 again.
|
* to bring bits back to 1 again.
|
||||||
|
*
|
||||||
|
* In future, we can add support for multiple different flash chips by adding a flash device driver vtable
|
||||||
|
* and make calls through that, at the moment flashfs just calls m25p16_* routines explicitly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -185,8 +188,12 @@ static uint32_t flashfsWriteBuffers(uint8_t const **buffers, uint32_t *bufferSiz
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we at EOF already? Abort.
|
// Are we at EOF already? Abort.
|
||||||
if (tailAddress >= flashfsGetSize())
|
if (flashfsIsEOF()) {
|
||||||
|
// May as well throw away any buffered data
|
||||||
|
flashfsClearBuffer();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
m25p16_pageProgramBegin(tailAddress);
|
m25p16_pageProgramBegin(tailAddress);
|
||||||
|
|
||||||
|
@ -532,6 +539,13 @@ int flashfsIdentifyStartOfFreeSpace()
|
||||||
return result * FREE_BLOCK_SIZE;
|
return result * FREE_BLOCK_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the file pointer is at the end of the device.
|
||||||
|
*/
|
||||||
|
bool flashfsIsEOF() {
|
||||||
|
return tailAddress >= flashfsGetSize();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call after initializing the flash chip in order to set up the filesystem.
|
* Call after initializing the flash chip in order to set up the filesystem.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -49,3 +49,4 @@ void flashfsFlushSync();
|
||||||
void flashfsInit();
|
void flashfsInit();
|
||||||
|
|
||||||
bool flashfsIsReady();
|
bool flashfsIsReady();
|
||||||
|
bool flashfsIsEOF();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue