FatFs R0.14, released October 14, 2019
This commit is contained in:
+49
-45
@@ -10,9 +10,9 @@
|
||||
#include "diskio.h" /* Declarations of disk functions */
|
||||
|
||||
|
||||
static
|
||||
DWORD pn ( /* Pseudo random number generator */
|
||||
DWORD pns /* 0:Initialize, !0:Read */
|
||||
|
||||
static DWORD pn ( /* Pseudo random number generator */
|
||||
DWORD pns /* 0:Initialize, !0:Read */
|
||||
)
|
||||
{
|
||||
static DWORD lfsr;
|
||||
@@ -50,8 +50,8 @@ int test_diskio (
|
||||
|
||||
printf("test_diskio(%u, %u, 0x%08X, 0x%08X)\n", pdrv, ncyc, (UINT)buff, sz_buff);
|
||||
|
||||
if (sz_buff < _MAX_SS + 4) {
|
||||
printf("Insufficient work area to run program.\n");
|
||||
if (sz_buff < FF_MAX_SS + 8) {
|
||||
printf("Insufficient work area to run the program.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ int test_diskio (
|
||||
}
|
||||
|
||||
/* Single sector write test */
|
||||
printf("**** Single sector write test 1 ****\n");
|
||||
printf("**** Single sector write test ****\n");
|
||||
lba = 0;
|
||||
for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n] = (BYTE)pn(0);
|
||||
printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba);
|
||||
@@ -145,52 +145,56 @@ int test_diskio (
|
||||
}
|
||||
for (n = 0, pn(pns); n < sz_sect && pbuff[n] == (BYTE)pn(0); n++) ;
|
||||
if (n == sz_sect) {
|
||||
printf(" Data matched.\n");
|
||||
printf(" Read data matched.\n");
|
||||
} else {
|
||||
printf("Failed: Read data differs from the data written.\n");
|
||||
printf(" Read data differs from the data written.\n");
|
||||
return 10;
|
||||
}
|
||||
pns++;
|
||||
|
||||
printf("**** Multiple sector write test ****\n");
|
||||
lba = 1; ns = sz_buff / sz_sect;
|
||||
lba = 5; ns = sz_buff / sz_sect;
|
||||
if (ns > 4) ns = 4;
|
||||
for (n = 0, pn(pns); n < (UINT)(sz_sect * ns); n++) pbuff[n] = (BYTE)pn(0);
|
||||
printf(" disk_write(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);
|
||||
dr = disk_write(pdrv, pbuff, lba, ns);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
if (ns > 1) {
|
||||
for (n = 0, pn(pns); n < (UINT)(sz_sect * ns); n++) pbuff[n] = (BYTE)pn(0);
|
||||
printf(" disk_write(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);
|
||||
dr = disk_write(pdrv, pbuff, lba, ns);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 11;
|
||||
}
|
||||
printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv);
|
||||
dr = disk_ioctl(pdrv, CTRL_SYNC, 0);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 12;
|
||||
}
|
||||
memset(pbuff, 0, sz_sect * ns);
|
||||
printf(" disk_read(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);
|
||||
dr = disk_read(pdrv, pbuff, lba, ns);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 13;
|
||||
}
|
||||
for (n = 0, pn(pns); n < (UINT)(sz_sect * ns) && pbuff[n] == (BYTE)pn(0); n++) ;
|
||||
if (n == (UINT)(sz_sect * ns)) {
|
||||
printf(" Read data matched.\n");
|
||||
} else {
|
||||
printf(" Read data differs from the data written.\n");
|
||||
return 14;
|
||||
}
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 11;
|
||||
}
|
||||
printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv);
|
||||
dr = disk_ioctl(pdrv, CTRL_SYNC, 0);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 12;
|
||||
}
|
||||
memset(pbuff, 0, sz_sect * ns);
|
||||
printf(" disk_read(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);
|
||||
dr = disk_read(pdrv, pbuff, lba, ns);
|
||||
if (dr == RES_OK) {
|
||||
printf(" - ok.\n");
|
||||
} else {
|
||||
printf(" - failed.\n");
|
||||
return 13;
|
||||
}
|
||||
for (n = 0, pn(pns); n < (UINT)(sz_sect * ns) && pbuff[n] == (BYTE)pn(0); n++) ;
|
||||
if (n == (UINT)(sz_sect * ns)) {
|
||||
printf(" Data matched.\n");
|
||||
} else {
|
||||
printf("Failed: Read data differs from the data written.\n");
|
||||
return 14;
|
||||
printf(" Test skipped.\n");
|
||||
}
|
||||
pns++;
|
||||
|
||||
printf("**** Single sector write test (misaligned address) ****\n");
|
||||
printf("**** Single sector write test (unaligned buffer address) ****\n");
|
||||
lba = 5;
|
||||
for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n+3] = (BYTE)pn(0);
|
||||
printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+3), lba);
|
||||
@@ -220,9 +224,9 @@ int test_diskio (
|
||||
}
|
||||
for (n = 0, pn(pns); n < sz_sect && pbuff[n+5] == (BYTE)pn(0); n++) ;
|
||||
if (n == sz_sect) {
|
||||
printf(" Data matched.\n");
|
||||
printf(" Read data matched.\n");
|
||||
} else {
|
||||
printf("Failed: Read data differs from the data written.\n");
|
||||
printf(" Read data differs from the data written.\n");
|
||||
return 18;
|
||||
}
|
||||
pns++;
|
||||
@@ -274,9 +278,9 @@ int test_diskio (
|
||||
}
|
||||
for (n = 0, pn(pns); pbuff[n] == (BYTE)pn(0) && n < (UINT)(sz_sect * 2); n++) ;
|
||||
if (n == (UINT)(sz_sect * 2)) {
|
||||
printf(" Data matched.\n");
|
||||
printf(" Read data matched.\n");
|
||||
} else {
|
||||
printf("Failed: Read data differs from the data written.\n");
|
||||
printf(" Read data differs from the data written.\n");
|
||||
return 24;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* Raw Read/Write Throughput Checker */
|
||||
/*---------------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <systimer.h>
|
||||
#include "diskio.h"
|
||||
#include "ff.h"
|
||||
|
||||
|
||||
int test_raw_speed (
|
||||
BYTE pdrv, /* Physical drive number */
|
||||
DWORD lba, /* Start LBA for read/write test */
|
||||
DWORD len, /* Number of bytes to read/write (must be multiple of sz_buff) */
|
||||
void* buff, /* Read/write buffer */
|
||||
UINT sz_buff /* Size of read/write buffer (must be multiple of FF_MAX_SS) */
|
||||
)
|
||||
{
|
||||
WORD ss;
|
||||
DWORD ofs, tmr;
|
||||
|
||||
|
||||
#if FF_MIN_SS != FF_MAX_SS
|
||||
if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &ss) != RES_OK) {
|
||||
printf("\ndisk_ioctl() failed.\n");
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
ss = FF_MAX_SS;
|
||||
#endif
|
||||
|
||||
printf("Starting raw write test at sector %lu in %u bytes of data chunks...", lba, sz_buff);
|
||||
tmr = systimer();
|
||||
for (ofs = 0; ofs < len / ss; ofs += sz_buff / ss) {
|
||||
if (disk_write(pdrv, buff, lba + ofs, sz_buff / ss) != RES_OK) {
|
||||
printf("\ndisk_write() failed.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (disk_ioctl(pdrv, CTRL_SYNC, 0) != RES_OK) {
|
||||
printf("\ndisk_ioctl() failed.\n");
|
||||
return 0;
|
||||
}
|
||||
tmr = systimer() - tmr;
|
||||
printf("\n%lu bytes written and it took %lu timer ticks.\n", len, tmr);
|
||||
|
||||
printf("Starting raw read test at sector %lu in %u bytes of data chunks...", lba, sz_buff);
|
||||
tmr = systimer();
|
||||
for (ofs = 0; ofs < len / ss; ofs += sz_buff / ss) {
|
||||
if (disk_read(pdrv, buff, lba + ofs, sz_buff / ss) != RES_OK) {
|
||||
printf("\ndisk_read() failed.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
tmr = systimer() - tmr;
|
||||
printf("\n%lu bytes read and it took %lu timer ticks.\n", len, tmr);
|
||||
|
||||
printf("Test completed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 15 KiB |
Reference in New Issue
Block a user