Fix MSP flash read so it returns the actual bytes read from the flash,
and not the amount of bytes requested, which may be different depending on the constraints of the flash chip used.
This commit is contained in:
parent
25e1607292
commit
2627826cb7
|
@ -375,6 +375,8 @@ static void serializeDataflashReadReply(sbuf_t *dst, uint32_t address, const uin
|
|||
#endif
|
||||
|
||||
if (compressionMethod == NO_COMPRESSION) {
|
||||
|
||||
uint16_t *readLenPtr = (uint16_t *)sbufPtr(dst);
|
||||
if (!useLegacyFormat) {
|
||||
// new format supports variable read lengths
|
||||
sbufWriteU16(dst, readLen);
|
||||
|
@ -383,6 +385,11 @@ static void serializeDataflashReadReply(sbuf_t *dst, uint32_t address, const uin
|
|||
|
||||
const int bytesRead = flashfsReadAbs(address, sbufPtr(dst), readLen);
|
||||
|
||||
if (!useLegacyFormat) {
|
||||
// update the 'read length' with the actual amount read from flash.
|
||||
*readLenPtr = (uint16_t)bytesRead;
|
||||
}
|
||||
|
||||
sbufAdvance(dst, bytesRead);
|
||||
|
||||
if (useLegacyFormat) {
|
||||
|
|
Loading…
Reference in New Issue