54 "Note: fatfs tests MUST start with \"fatfs\" keyword\n" 56 "Note: fatfs prefix is optional\n" 59 #ifdef FATFS_UTILS_FULL
60 "fatfs attrib file p1 p2\n" 63 "fatfs copy file1 file2\n" 64 "fatfs create file str\n" 70 #ifdef FATFS_UTILS_FULL
77 #ifdef FATFS_UTILS_FULL
81 "fatfs rename old new\n" 115 if(
MATCH(ptr,
"fatfs") )
118 if ( !ptr ||
MATCH(ptr,
"help") )
131 if (
MATCHARGS(ptr,
"ls", (ind + 0), argc))
135 printf(
"ind:%d,argc:%d\n", ind, argc);
136 for(i=ind;i<argc;++i)
149 if (
MATCHARGS(ptr,
"mmc_test",(ind+0),argc ))
155 if (
MATCHARGS(ptr,
"mmc_init",(ind+0),argc))
161 if (
MATCHARGS(ptr,
"status", (ind + 1), argc))
167 #ifdef FATFS_UTILS_FULL 168 if (
MATCHARGS(ptr,
"attrib",(ind+3),argc))
174 if (
MATCHARGS(ptr,
"cat", (ind + 1), argc))
181 if (
MATCHARGS(ptr,
"cd", (ind + 1), argc))
188 if (
MATCHARGS(ptr,
"copy", (ind + 2), argc))
194 if (
MATCHARGS(ptr,
"create", (ind + 2), argc))
200 if (
MATCHARGS(ptr,
"mkdir", (ind + 1), argc))
206 if (
MATCHARGS(ptr,
"mkfs", (ind + 0), argc))
226 if (
MATCHARGS(ptr,
"pwd", (ind + 0), argc))
231 #endif // #if _FS_RPATH >= 2 232 #endif // #if _FS_RPATH 235 if (
MATCHARGS(ptr,
"rename", (ind + 2), argc))
241 if (
MATCHARGS(ptr,
"rmdir", (ind + 1), argc))
247 if (
MATCHARGS(ptr,
"rm", (ind + 1), argc))
253 if (
MATCHARGS(ptr,
"stat", (ind + 1), argc))
273 printf(
"==============================\n");
274 printf(
"START MMC TEST\n");
276 printf(
"MMC Directory List\n");
279 #ifdef FATFS_UTILS_FULL 302 printf(
"==============================\n");
331 printf(
"Listing:[%s]\n",buff);
334 if (res) {
put_rc(res);
return; }
346 s1++; p1 += fno.
fsize;
354 printf(
"%4u File(s),%10lu bytes total\n%4u Dir(s)", s1, p1, s2);
356 printf(
", %10luK bytes free\n", p1 * fs->
csize / 2);
361 #ifdef FATFS_UTILS_FULL 380 printf(
"Reading[%s]\n", name);
392 printf(
"Calloc failed!\n");
400 res =
f_read(&fp, ptr, 512, &s1);
403 printf(
"cat read error\n");
429 printf(
"%lu bytes\n", size);
455 printf(
"Opening %s\n", from);
462 printf(
"Creating %s\n", to);
473 printf(
"Calloc failed!\n");
482 res =
f_read(&file1, ptr, MSIZE, &s1);
483 if (res || s1 == 0)
break;
484 res =
f_write(&file2, ptr, s1, &s2);
486 printf(
"Copied: %08ld\r", size);
487 if (res || s2 < s1)
break;
491 printf(
"%lu bytes copied.\n", size);
512 printf(
"Creating [%s]\n", name);
513 printf(
"Text[%s]\n", str);
534 printf(
"Write error - wanted(%d) got(%d)\n",s1,len);
554 printf(
"cd [%s]\n", name);
571 printf(
"mkdir [%s]\n", name);
591 printf(
"pwd [%s]\n", str);
604 void fatfs_rename(
const char *oldpath,
const char *newpath)
626 printf(
"rm [%s]\n", name);
640 printf(
"rmdir [%s]\n", name);
659 printf(
"stat [%s]\n", name);
660 res =
f_stat(name, &info);
MEMSPACE size_t WEAK_ATR strlen(const char *str)
String Length.
MEMSPACE void fatfs_rm(char *name)
MEMSPACE FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
MEMSPACE void fatfs_stat(char *name)
Master include file for project Includes all project includes and defines here.
MEMSPACE void fatfs_cat(char *name)
Common Linux/POSIX time functions.
MEMSPACE FRESULT f_chmod(const TCHAR *path, BYTE attr, BYTE mask)
MEMSPACE FRESULT f_readdir(DIR *dp, FILINFO *fno)
static struct ip_info info
MEMSPACE FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
MEMSPACE FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs)
MEMSPACE FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
MEMSPACE FRESULT f_close(FIL *fp)
MEMSPACE FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
MEMSPACE void mmc_test(void)
Perform key FatFs diagnostics tests.
MEMSPACE FRESULT f_opendir(DIR *dp, const TCHAR *path)
MEMSPACE FRESULT f_mkdir(const TCHAR *path)
void optimistic_yield(uint32_t interval_us)
MEMSPACE void fatfs_status(char *ptr)
Compute space used, number of directories and files contained used by a drive.
MEMSPACE int fatfs_tests(int argc, char *argv[])
FatFs test parser.
int putchar(int c)
put a character to stdout See fdevopen() sets stream->put get for TTY devices
MEMSPACE WEAK_ATR char * strcpy(char *dest, const char *src)
copy a string
MEMSPACE void put_rc(int rc)
display FatFs return code as ascii string
MEMSPACE void fatfs_rename(const char *oldpath, const char *newpath)
MEMSPACE void * safemalloc(size_t size)
Safe Malloc - Display Error message if Malloc fails.
MEMSPACE long atol(const char *str)
Convert ASCII string to number in base 10.
MEMSPACE int mmc_init(int verbose)
Initialize MMC and FatFs interface, display diagnostics.
MEMSPACE int uart_putc(uint8 uart_no, char c)
Write a byte from a uart with NL to CR/NL conversion Note: This function waits/blocks util the write ...
MEMSPACE void fatfs_cd(char *name)
Math IO functions, and verious conversion code with floating point support.
Various string and character functions.
MEMSPACE void fatfs_mkdir(char *name)
MEMSPACE void fatfs_filinfo_list(FILINFO *info)
Display FILINFO structure in a readable format.
MEMSPACE FRESULT f_unlink(const TCHAR *path)
MEMSPACE void fatfs_ls(char *name)
MEMSPACE void fatfs_help(int full)
Display FatFs test diagnostics help menu.
MEMSPACE void wdt_reset(void)
reset watchdog
MEMSPACE int printf(const char *format,...)
MEMSPACE int MATCHARGS(char *str, char *pat, int min, int argc)
Match two strings and compare argument index Display message if the number of arguments is too few...
MEMSPACE void fatfs_pwd(void)
MEMSPACE void fatfs_copy(char *from, char *to)
MEMSPACE FRESULT f_stat(const TCHAR *path, FILINFO *fno)
MEMSPACE FRESULT f_getcwd(TCHAR *buff, UINT len)
MEMSPACE void safefree(void *p)
Safe free - Only free a pointer if it is in malloc memory range. We want to try to catch frees of sta...
MEMSPACE FRESULT f_chdir(const TCHAR *path)
MEMSPACE void fatfs_rmdir(char *name)
MEMSPACE FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
MEMSPACE void * safecalloc(size_t nmemb, size_t size)
Safe Calloc - Display Error message if Calloc fails.
MEMSPACE void fatfs_create(char *name, char *str)
MEMSPACE FRESULT f_mkfs(const TCHAR *path, BYTE opt, DWORD au, void *work, UINT len)