fprime-community / fprime-arduino

An implementation allowing fprime to be run on a limite number of Arduino compatible devices.
Apache License 2.0
24 stars 11 forks source link

Implementing SD Card as Os::File #28

Open ethancheez opened 4 months ago

ethancheez commented 4 months ago

Add support for a file system on Arduino platforms, using an SD card.

See these additions:

@LeStarch I would like your expertise/opinion on this. Do you think this is worth adding? Or is work being done to implement a microFS within FPrime that would perform better (or make more sense) compared to an SD card instance?

Edit: An argument to use an SD card over a microFS is memory usage. External storage means the file system would not have to tap into the internal FLASH/RAM, which is already very limited for most Arduino platforms

So far I have done small tests with this and was able to read/write multiple files, create directories, delete files, move files etc.

A possible design flaw with this is that I had to use new ::File within the constructor and store the Arduino File class as a pointer to m_fd.

Adding this new feature will hopefully allow the integrating of FileUplink and FileDownlink for Baremetal applications. Edit: FileDownlink and Uplink works

ethancheez commented 4 months ago

I also had to comment out two lines in fprime/Os/CMakeLists.txt:87 to:

if (FPRIME_USE_BAREMETAL_SCHEDULER)
    add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Baremetal/TaskRunner/")
    foreach (ITER_ITEM IN LISTS SOURCE_FILES)
        if (ITER_ITEM MATCHES "Task\\.cpp$")
            list(REMOVE_ITEM SOURCE_FILES "${ITER_ITEM}")
        endif()
    endforeach()
    # list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/File.cpp")
    # list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/FileSystem.cpp")
    list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/IntervalTimer.cpp")
    list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/Mutex.cpp")
    list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/Queue.cpp")
    list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/SystemResources.cpp")
    list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Baremetal/Task.cpp")
endif()

These lines would force the use of the Baremetal versions of File.cpp and FileSystem.cpp and would prevent my Arduino versions to be used. Unsure if there is a better way to do this.