为什么fatfs的f_rename很慢?

问题描述

我正在开发一个带有 stm32L496 + FreeRtos + FatFs 的数据记录器。数据记录器将数据保存到缓冲区,当缓冲区已满时,缓冲区会在 fatfs 和 SDMMC+DMA 的帮助下保存在 SD 卡上的文件中。 当工作文件太大(15Mo)时,这个文件被移动到另一个目录。但有时,由于f_rename(500ms)的时间很长,我已经超限了。我可以增加缓冲区来隐藏问题,但我不明白为什么这个功能需要这么多时间。

有人遇到这个问题吗? 我使用的是 fat32 格式的 Fatfs R0.12c。

我发现当函数调用“follow_path”、检查新文件是否存在以及当它调用变量“path”为空的“dir_find”时,代码需要很长时间。 (所以当这是最后一段时)。

在 f_rename 中:

# Custom cmake config file by jcarius to enable find_package(onnxruntime) without modifying LIBRARY_PATH and LD_LIBRARY_PATH
#
# This will define the following variables:
#   onnxruntime_FOUND        -- True if the system has the onnxruntime library
#   onnxruntime_INCLUDE_Dirs -- The include directories for onnxruntime
#   onnxruntime_LIBRARIES    -- Libraries to link against
#   onnxruntime_CXX_FLAGS    -- Additional (required) compiler flags

include(FindPackageHandleStandardArgs)

# Assume we are in <install-prefix>/share/cmake/onnxruntime/onnxruntimeConfig.cmake
get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(onnxruntime_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

set(onnxruntime_INCLUDE_Dirs ${onnxruntime_INSTALL_PREFIX}/include)
set(onnxruntime_LIBRARIES onnxruntime)
set(onnxruntime_CXX_FLAGS "") # no flags needed


find_library(onnxruntime_LIBRARY onnxruntime
    PATHS "${onnxruntime_INSTALL_PREFIX}/lib"
)

add_library(onnxruntime SHARED IMPORTED)
set_property(TARGET onnxruntime PROPERTY IMPORTED_LOCATION "${onnxruntime_LIBRARY}")
set_property(TARGET onnxruntime PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_Dirs}")
set_property(TARGET onnxruntime PROPERTY INTERFACE_COMPILE_OPTIONS "${onnxruntime_CXX_FLAGS}")

find_package_handle_standard_args(onnxruntime DEFAULT_MSG onnxruntime_LIBRARY onnxruntime_INCLUDE_Dirs)

在follow_path中:

/* At FAT12/FAT16/fat32 */
                mem_cpy(buf,djo.dir + DIR_Attr,21);   
                mem_cpy(&djn,&djo,sizeof (DIR));      
                res = follow_path(&djn,path_new);   ==> This is the problematic function   
                if (res == FR_OK) {                     
                    res = (djn.obj.sclust == djo.obj.sclust && djn.dptr == djo.dptr) ? FR_NO_FILE : FR_EXIST;
                }

如果我提高时钟速度,代码不会更快,所以我认为这是一个软件问题。

有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...