Comment updates, allow CLI flash read to read more in one operation
This commit is contained in:
parent
3eb28f16ea
commit
2e14faeef6
|
@ -97,6 +97,7 @@ static uint8_t m25p16_readStatus()
|
|||
|
||||
bool m25p16_isReady()
|
||||
{
|
||||
// If couldBeBusy is false, don't bother to poll the flash chip for its status
|
||||
couldBeBusy = couldBeBusy && ((m25p16_readStatus() & M25P16_STATUS_FLAG_WRITE_IN_PROGRESS) != 0);
|
||||
|
||||
return !couldBeBusy;
|
||||
|
@ -126,7 +127,10 @@ static bool m25p16_readIdentification()
|
|||
|
||||
delay(50); // short delay required after initialisation of SPI device instance.
|
||||
|
||||
in[1] = 0; // Just in case transfer fails and writes nothing
|
||||
/* Just in case transfer fails and writes nothing, so we don't try to verify the ID against random garbage
|
||||
* from the stack:
|
||||
*/
|
||||
in[1] = 0;
|
||||
|
||||
ENABLE_M25P16;
|
||||
|
||||
|
|
|
@ -114,15 +114,11 @@ static uint32_t flashfsTransmitBufferUsed()
|
|||
|
||||
static uint32_t flashfsTransmitBufferRemaining()
|
||||
{
|
||||
/*
|
||||
* We subtract one from the actual transmit buffer remaining space to allow us to distinguish
|
||||
* between completely full and completely empty states, that would otherwise both have head = tail
|
||||
*/
|
||||
return FLASHFS_WRITE_BUFFER_USABLE - flashfsTransmitBufferUsed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the flash device to be ready to accept writes, then write the given buffers to flash.
|
||||
* Waits for the flash device to be ready to accept writes, then write the given buffers to flash sequentially.
|
||||
*
|
||||
* Advances the address of the beginning of the supplied buffers and reduces the size of the buffers according to how
|
||||
* many bytes get written.
|
||||
|
@ -150,7 +146,10 @@ static void flashfsWriteBuffers(uint8_t const **buffers, uint32_t *bufferSizes,
|
|||
uint32_t bytesTotalThisIteration;
|
||||
uint32_t bytesRemainThisIteration;
|
||||
|
||||
// If we would cross a page boundary, only write up to the boundary in this iteration:
|
||||
/*
|
||||
* Each page needs to be saved in a separate program operation, so
|
||||
* if we would cross a page boundary, only write up to the boundary in this iteration:
|
||||
*/
|
||||
if (tailIndexInPage + bytesTotalRemaining > geometry->pageSize) {
|
||||
bytesTotalThisIteration = geometry->pageSize - tailIndexInPage;
|
||||
} else {
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "drivers/gpio.h"
|
||||
#include "drivers/timer.h"
|
||||
#include "drivers/pwm_rx.h"
|
||||
#include "drivers/flash_m25p16.h"
|
||||
#include "flight/flight.h"
|
||||
#include "flight/mixer.h"
|
||||
#include "flight/navigation.h"
|
||||
|
@ -794,18 +793,21 @@ static void cliFlashRead(char *cmdline)
|
|||
printf("Missing length argument.\r\n");
|
||||
} else {
|
||||
length = atoi(nextArg);
|
||||
if (length > 32) {
|
||||
length = 32;
|
||||
printf("Length truncated to 32 bytes.\r\n");
|
||||
}
|
||||
|
||||
printf("Reading %u bytes at %u:\r\n", length, address);
|
||||
|
||||
flashfsSeekAbs(address);
|
||||
flashfsRead(buffer, length);
|
||||
|
||||
printf("Read %u bytes at %u:\r\n", length, address);
|
||||
while (length > 0) {
|
||||
int bytesToRead = length < 32 ? length : 32;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
printf("%c", (char) buffer[i]);
|
||||
flashfsRead(buffer, bytesToRead);
|
||||
|
||||
for (i = 0; i < bytesToRead; i++) {
|
||||
printf("%c", (char) buffer[i]);
|
||||
}
|
||||
|
||||
length -= bytesToRead;
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue