mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Add support for discovering beginning of free space on flash chip
This commit is contained in:
parent
f7d227a208
commit
5651e65a0b
6 changed files with 142 additions and 29 deletions
|
@ -533,13 +533,14 @@ reset:
|
|||
|
||||
static void serializeDataflashSummaryReply(void)
|
||||
{
|
||||
headSerialReply(3 * 4);
|
||||
#ifdef FLASHFS
|
||||
const flashGeometry_t *geometry = flashfsGetGeometry();
|
||||
headSerialReply(2 * 4);
|
||||
serialize32(geometry->sectors);
|
||||
serialize32(geometry->totalSize);
|
||||
serialize32(flashfsGetOffset()); // Effectively the current number of bytes stored on the volume
|
||||
#else
|
||||
headSerialReply(2 * 4);
|
||||
serialize32(0);
|
||||
serialize32(0);
|
||||
serialize32(0);
|
||||
#endif
|
||||
|
@ -548,22 +549,19 @@ static void serializeDataflashSummaryReply(void)
|
|||
#ifdef FLASHFS
|
||||
static void serializeDataflashReadReply(uint32_t address, uint8_t size)
|
||||
{
|
||||
enum { DATAFLASH_READ_REPLY_CHUNK_SIZE = 128 };
|
||||
|
||||
uint8_t buffer[DATAFLASH_READ_REPLY_CHUNK_SIZE];
|
||||
uint8_t buffer[128];
|
||||
int bytesRead;
|
||||
|
||||
if (size > DATAFLASH_READ_REPLY_CHUNK_SIZE) {
|
||||
size = DATAFLASH_READ_REPLY_CHUNK_SIZE;
|
||||
if (size > sizeof(buffer)) {
|
||||
size = sizeof(buffer);
|
||||
}
|
||||
|
||||
headSerialReply(4 + size);
|
||||
|
||||
serialize32(address);
|
||||
|
||||
flashfsSeekAbs(address);
|
||||
// bytesRead will be lower than that requested if we reach end of volume
|
||||
bytesRead = flashfsRead(buffer, size);
|
||||
bytesRead = flashfsReadAbs(address, buffer, size);
|
||||
|
||||
for (int i = 0; i < bytesRead; i++) {
|
||||
serialize8(buffer[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue