5 studio配置SD卡和虚拟文件系统,测试SD卡写入速度只有100多KB/s?

发布于 2020-09-15 14:11:27

我用rtthread studio中的sd卡使用虚拟文件系统例程写入数据,我测的写入速度为120kb/s,看了下它的有关于sd卡初始化的代码,看不太懂,然后看了下原子的sd卡初始化过程,发现sd卡初始化后需要再设置下时钟,但是在rtt里面我没有找到相关的配置,有大佬知道什么原因导致速度过慢吗?怎么解决,求教,测试sd卡写入速度代码如下:

    int fd, size;
    float speed ;
    float speed_time;
    int i;
    char buf[20];
    int8_t s[256] = "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!"
            "RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer! RT-Thread Programmer!";
    char buffer[80];


    /* 以创建和读写模式打开 /text.txt 文件,如果该文件不存在则创建该文件 */


    rt_kprintf("Write ...........\n");
    rt_kprintf("tick is :%d !\n", rt_tick_get());
    speed =  rt_tick_get();
    fd = open("/text.txt", O_WRONLY | O_CREAT | O_APPEND);
    if (fd>= 0)
    {
        for (i = 0; i < 1024; ++i) {
            write(fd, s, sizeof(s));
        }
        close(fd);
        rt_kprintf("tick is :%d !\n", rt_tick_get());
        speed = rt_tick_get()-speed;
        speed_time = 1000/speed;
        speed_time = (sizeof(s)*speed_time);
        sprintf((char*)buf, "%3.1f",(float)speed_time);
        rt_kprintf("Write done. speed:%f kb/s\n",speed_time);
    }
      /* 以只读模式打开 /text.txt 文件 */
    fd = open("/text.txt", O_RDONLY);
    if (fd>= 0)
    {
        size = read(fd, buffer, sizeof(buffer));
        close(fd);
//        rt_kprintf("Read from file test.txt : %s \n", buffer);
        if (size < 0)
            return ;
    }

  }

查看更多

关注者
1
被浏览
219
lizhen9880
lizhen9880 认证专家 2020-09-15

可做如下尝试:

方法1

如下drv_sdio.h中,默认SDIO_MAX_FREQ只有1M,将SDIO_MAX_FREQ根据自己的MCU SDIO的最高频率改大,可改到24M
image.png
如果这样做有效,建议你按照方法2来

方法2

建议你修改board/Kconfig,增加如下配置

if BSP_USING_SDCARD
    config SDIO_MAX_FREQ
        int "sdio max freq"
        range 0 24000000
        default 1000000
    endif

这样会在rt_config.h中增加SDIO_MAX_FREQ宏,drv_sdio.h中失效(如果你的Kconfig中已经有该项了,直接配置即可)

3 个回答
chenyingchun
chenyingchun 2020-09-16

请按照lizhen9880的建议再试一下看看, 我这边用的F413, SDIO_MAX_FREQ 设置的50000000, 实测下来,写入速度可以最高可以达到3MByte/s
SDIO.png

aozima
aozima 2020-09-15
拒绝白嫖,拒绝键盘侠!

测速可以用这个 examples\file\writespeed.c

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览