Firmware: optimize non-sector-aligned SD DMA reads (bugfix)
This commit is contained in:
parent
d7ad740843
commit
b8f4c9b584
12
src/ff.c
12
src/ff.c
@ -2639,8 +2639,16 @@ FRESULT f_lseek (
|
|||||||
fp->flag &= ~FA__DIRTY;
|
fp->flag &= ~FA__DIRTY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK)
|
if(!ff_sd_offload) {
|
||||||
ABORT(fp->fs, FR_DISK_ERR);
|
sd_offload_partial=0;
|
||||||
|
if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK)
|
||||||
|
ABORT(fp->fs, FR_DISK_ERR);
|
||||||
|
} else {
|
||||||
|
sd_offload_partial=1;
|
||||||
|
sd_offload_partial_start = fp->fptr % SS(fp->fs);
|
||||||
|
}
|
||||||
|
// if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK)
|
||||||
|
// ABORT(fp->fs, FR_DISK_ERR);
|
||||||
#endif
|
#endif
|
||||||
fp->dsect = dsc;
|
fp->dsect = dsc;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -800,10 +800,10 @@ void read_block(uint32_t address, uint8_t *buf) {
|
|||||||
&& last_block == address
|
&& last_block == address
|
||||||
&& last_offset == sd_offload_partial_start
|
&& last_offset == sd_offload_partial_start
|
||||||
&& sd_offload_partial) {
|
&& sd_offload_partial) {
|
||||||
stream_datablock(buf);
|
|
||||||
last_offset = sd_offload_partial_end & 0x1ff;
|
|
||||||
sd_offload_partial_start |= 0x8000;
|
sd_offload_partial_start |= 0x8000;
|
||||||
|
stream_datablock(buf);
|
||||||
during_blocktrans = TRANS_READ;
|
during_blocktrans = TRANS_READ;
|
||||||
|
last_offset = sd_offload_partial_end & 0x1ff;
|
||||||
sd_offload_partial = 0;
|
sd_offload_partial = 0;
|
||||||
} else {
|
} else {
|
||||||
if(during_blocktrans) {
|
if(during_blocktrans) {
|
||||||
@ -812,6 +812,7 @@ void read_block(uint32_t address, uint8_t *buf) {
|
|||||||
/* send STOP_TRANSMISSION to end an open READ/WRITE_MULTIPLE_BLOCK */
|
/* send STOP_TRANSMISSION to end an open READ/WRITE_MULTIPLE_BLOCK */
|
||||||
cmd_fast(STOP_TRANSMISSION, 0, 0x61, NULL, rsp);
|
cmd_fast(STOP_TRANSMISSION, 0, 0x61, NULL, rsp);
|
||||||
}
|
}
|
||||||
|
during_blocktrans = TRANS_READ;
|
||||||
last_block = address;
|
last_block = address;
|
||||||
if(!ccs) {
|
if(!ccs) {
|
||||||
address <<= 9;
|
address <<= 9;
|
||||||
@ -825,7 +826,6 @@ void read_block(uint32_t address, uint8_t *buf) {
|
|||||||
cmd_fast(READ_MULTIPLE_BLOCK, address, 0, buf, rsp);
|
cmd_fast(READ_MULTIPLE_BLOCK, address, 0, buf, rsp);
|
||||||
#endif
|
#endif
|
||||||
sd_offload_partial = 0;
|
sd_offload_partial = 0;
|
||||||
during_blocktrans = TRANS_READ;
|
|
||||||
}
|
}
|
||||||
// printf("trans state = %d\n", during_blocktrans);
|
// printf("trans state = %d\n", during_blocktrans);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user