打印
[应用方案]

FATFS 没法访问第二卷目录

[复制链接]
277|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
sadicy|  楼主 | 2022-7-17 09:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
使用SD卡和Flash做2个磁盘,将SD或flash做为卷0,程序都可以正常访问目录,文件,另外可以对卷1进行格式化,但是却访问不了卷1的目录;有没有知道什么问题的?

void ShowSDFiles(u8 index)
{
FILINFO finfo;
DIR dirs;
char path[100] = {""};
printf("\nSD file system starting! \n");
disk_initialize(index);
printf("f_mount %d\n", f_mount(index, &fs));
printf("f_mkfs %d\n", f_mkfs(index, 0, 512)); // SD 卡时为4096
printf("----------------------------------------------------\n");
printf("f_opendir(&dirs, \"/\") = %d;\n", f_opendir(&dirs, "/"));
if(f_opendir(&dirs, path) == FR_OK)
{
  while(f_readdir(&dirs, &finfo) == FR_OK)
  {
   if(!finfo.fname[0]) break;
   if (finfo.fattrib & AM_ARC)
   {
    printf("            file name is: %s    ", finfo.fname);
    printf("file size is: %d \n", finfo.fsize);
    if(File_type_Check((u8 *)finfo.fname, "txt"))
    {
     printf("file contex is:");
     res = f_open(&fsrc, finfo.fname, FA_OPEN_EXISTING | FA_READ);
     while(1)
     {
      memset(buffer, 0, sizeof(buffer));
      if(f_gets(buffer, 512, &fsrc))
      {
       printf("%s", buffer);
      }
      else break;
     }
     f_close(&fsrc);
    }
   }
   else
   {
    printf("Path name is: %s\n", finfo.fname);
    continue; //break;
   }
  }
  res = f_open(&fsrc, "armjishu.txt", FA_CREATE_ALWAYS | FA_WRITE);
  res = f_write(&fsrc, &armjishu, sizeof(text), &bw);
  f_close(&fsrc);
else
{
  printf(" err: f_opendir\n");
}
printf("----------------------------------------------------\n");
f_mount(index, NULL);
}


使用特权

评论回复
沙发
littlelida| | 2022-7-20 15:34 | 只看该作者
文件系统涉及的 太多了,
一步一步的试,只能
或者哪位大神直接有过类似的

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

166

主题

1036

帖子

2

粉丝