1.进行SD卡或者EMMC读写,我们要先在VIVADO上对存储外设进行配置.
如下图所示,具体配置情况,依据相关开发板而定。
![](https://img-blog.csdnimg.cn/img_convert/ad94097c735222f674a1566b85533fe4.png)
![](https://img-blog.csdnimg.cn/img_convert/f3cf1263b1c30674d2695b1fb1649340.png)
相关引脚的电平配置一定不要出错,具体配置依据开发板而定。
![](https://img-blog.csdnimg.cn/img_convert/2d8f1a5ee1caa93f4f6938658d30eb0f.png)
2.ps端对sd卡或emmc进行文件操作时,首先要加载相应的库函数xiffls
![](https://img-blog.csdnimg.cn/img_convert/d9f6d7a0698948db7fb7469283e82e14.png)
![](https://img-blog.csdnimg.cn/img_convert/68cd306881f766fb140b4a5c0dcb14c2.png)
![](https://img-blog.csdnimg.cn/img_convert/eb286b13aa7bdc6c59c56ff34ef46925.png)
![](https://img-blog.csdnimg.cn/img_convert/b53e0f3138d56971509c71ceb62ae43b.png)
后续就可以在libaray中找到xiffls的相关例程
![](https://img-blog.csdnimg.cn/img_convert/968087d338ca2f08835af7526050d7e1.png)
3.同时存在SD卡和EMMC两个存储时,可以通过 path指定加载哪一个存储驱动。
path为“0:/”表示加载SD0驱动,为“1:/”表示加载SD1驱动。
![](https://img-blog.csdnimg.cn/img_convert/8d691a65470b9c344253e014254a0768.png)
4.f_open报错问题
对于我们要打开或创建的新文件,命名时应该带全路径,
![](https://img-blog.csdnimg.cn/img_convert/2f2b3807ef55e336d2cf6c86dc24d3b4.png)
如果命名如下
![](https://img-blog.csdnimg.cn/img_convert/c49f5b951173ce68942616023fa230a6.png)
则默认文件路径为“0:t21.txt”。
当加载是驱动0则不会出错,当加载是驱动1时,则f_open会因找不到驱动而打开文件失败。
5.f_gets报错
若f_gets报错如下:undefined reference to "f_gets",即表示f_gets未定义,
出现这个错误的原因是,在xiffls中我们没有使能字符串函数功能。
解决办法:
![](https://img-blog.csdnimg.cn/img_convert/0e5a4190a1a9fa426e10a8dff951be4f.png)
在xiffls中,将此变量命名为2。