From 948030bcee3d6942d3eb55abbf7b9f686443b155 Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Mon, 27 May 2024 09:44:42 +0900 Subject: [PATCH 01/15] Add pico_filesystem library --- .gitmodules | 3 + lib/pico-vfs | 1 + src/rp2_common/CMakeLists.txt | 4 +- src/rp2_common/pico_filesystem/CMakeLists.txt | 102 ++++++++++++++++++ .../pico_filesystem/include/pico/filesystem.h | 7 ++ .../pico/filesystem/blockdevice/flash.h | 3 + .../include/pico/filesystem/blockdevice/sd.h | 3 + .../include/pico/filesystem/filesystem/fat.h | 3 + .../pico/filesystem/filesystem/littlefs.h | 3 + 9 files changed, 128 insertions(+), 1 deletion(-) create mode 160000 lib/pico-vfs create mode 100644 src/rp2_common/pico_filesystem/CMakeLists.txt create mode 100644 src/rp2_common/pico_filesystem/include/pico/filesystem.h create mode 100644 src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/flash.h create mode 100644 src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/sd.h create mode 100644 src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/fat.h create mode 100644 src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/littlefs.h diff --git a/.gitmodules b/.gitmodules index 7c382da67..ba4b09c57 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "lib/btstack"] path = lib/btstack url = https://github.com/bluekitchen/btstack.git +[submodule "lib/pico-vfs"] + path = lib/pico-vfs + url = https://github.com/oyama/pico-vfs diff --git a/lib/pico-vfs b/lib/pico-vfs new file mode 160000 index 000000000..f2e70ab2f --- /dev/null +++ b/lib/pico-vfs @@ -0,0 +1 @@ +Subproject commit f2e70ab2f2200550447eaeb11da2d7d058b17f5d diff --git a/src/rp2_common/CMakeLists.txt b/src/rp2_common/CMakeLists.txt index 82f56f8c5..2ad6fef0a 100644 --- a/src/rp2_common/CMakeLists.txt +++ b/src/rp2_common/CMakeLists.txt @@ -61,6 +61,8 @@ if (NOT PICO_BARE_METAL) pico_add_subdirectory(pico_stdio_usb) pico_add_subdirectory(pico_i2c_slave) + pico_add_subdirectory(pico_filesystem) + # networking libraries - note dependency order is important pico_add_subdirectory(pico_async_context) pico_add_subdirectory(pico_btstack) @@ -85,4 +87,4 @@ set(CMAKE_EXECUTABLE_SUFFIX "${CMAKE_EXECUTABLE_SUFFIX}" PARENT_SCOPE) pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR}) pico_add_doxygen_exclude(${CMAKE_CURRENT_LIST_DIR}/cmsis) -pico_promote_common_scope_vars() \ No newline at end of file +pico_promote_common_scope_vars() diff --git a/src/rp2_common/pico_filesystem/CMakeLists.txt b/src/rp2_common/pico_filesystem/CMakeLists.txt new file mode 100644 index 000000000..a7da61ac6 --- /dev/null +++ b/src/rp2_common/pico_filesystem/CMakeLists.txt @@ -0,0 +1,102 @@ +if (NOT PICO_VFS_PATH) + set(PICO_VFS_PATH ${PROJECT_SOURCE_DIR}/lib/pico-vfs) + if (NOT EXISTS ${PICO_VFS_PATH}/tests) + message(WARNING "pico-vfs submodule has not been initialized: File system support will be unavailable +hint: try 'get submodule update --init' from your SDK directory (${PICO_SDK_PATH}).") + endif() +elseif (NOT EXISTS ${PICO_VFS_PATH}/tests) + message(WARNING "PICO_VFS_PATH specified but content not present.") +endif() + +if (EXISTS ${PICO_VFS_PATH}/tests) + message("pico-vfs available at ${PICO_VFS_PATH}/tests; enabling build support for file system.") + + pico_register_common_scope_var(PICO_VFS_PATH) + + set(BOARD pico_sdk) + set(FAMILY rp2040) + + pico_add_library(pico_filesystem_blockdevice_sd) + target_sources(pico_filesystem_blockdevice_sd INTERFACE + ${PICO_VFS_PATH}/src/blockdevice/sd.c) + target_include_directories(pico_filesystem_blockdevice_sd INTERFACE + ${PICO_VFS_PATH}/include) + target_link_libraries(pico_filesystem_blockdevice_sd INTERFACE + hardware_spi) + + pico_add_library(pico_filesystem_blockdevice_flash) + target_sources(pico_filesystem_blockdevice_flash INTERFACE + ${PICO_VFS_PATH}/src/blockdevice/flash.c) + target_include_directories(pico_filesystem_blockdevice_flash INTERFACE + ${PICO_VFS_PATH}/include) + target_link_libraries(pico_filesystem_blockdevice_flash INTERFACE + hardware_flash + hardware_sync + ) + + pico_add_library(pico_filesystem_filesystem_littlefs) + target_sources(pico_filesystem_filesystem_littlefs INTERFACE + ${PICO_VFS_PATH}/src/filesystem/littlefs.c + ${PICO_VFS_PATH}/vendor/littlefs/lfs.c + ${PICO_VFS_PATH}/vendor/littlefs/lfs_util.c + ) + target_include_directories(pico_filesystem_filesystem_littlefs INTERFACE + ${PICO_VFS_PATH}/vendor/littlefs) + target_compile_options(pico_filesystem_filesystem_littlefs INTERFACE -Wno-unused-function -Wno-null-dereference) + + pico_add_library(pico_filesystem_filesystem_fat) + target_sources(pico_filesystem_filesystem_fat INTERFACE + ${PICO_VFS_PATH}/src/filesystem/fat.c + ${PICO_VFS_PATH}/vendor/ff15/source/ff.c + ${PICO_VFS_PATH}/vendor/ff15/source/ffsystem.c + ${PICO_VFS_PATH}/vendor/ff15/source/ffunicode.c + ) + target_include_directories(pico_filesystem_filesystem_fat INTERFACE + ${PICO_VFS_PATH} + ${PICO_VFS_PATH}/include/filesystem/ChaN + ${PICO_VFS_PATH}/vendor/ff15/source + ) + + pico_add_library(pico_filesystem) + target_sources(pico_filesystem INTERFACE + ${PICO_VFS_PATH}/src/filesystem/vfs.c) + target_include_directories(pico_filesystem INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/include + ${PICO_VFS_PATH}/include) + + pico_add_library(pico_filesystem_default) + target_sources(pico_filesystem_default INTERFACE + ${PICO_VFS_PATH}/src/filesystem/fs_init.c) + target_include_directories(pico_filesystem_default INTERFACE + ${PICO_VFS_PATH}/include) + target_link_libraries(pico_filesystem_default INTERFACE + pico_filesystem + pico_filesystem_blockdevice_flash + pico_filesystem_filesystem_littlefs + ) + + + pico_promote_common_scope_vars() + + function(pico_enable_filesystem TARGET) + set(options "") + set(oneValueArgs SIZE AUTO_INIT) + set(multiValueArgs FS_INIT) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(ARG_SIZE) + target_compile_definitions(${TARGET} PRIVATE PICO_FS_DEFAULT_SIZE=${ARG_SIZE}) + endif() + + if(ARG_FS_INIT) + target_sources(${TARGET} PRIVATE ${ARG_FS_INIT}) + else() + target_link_libraries(${TARGET} PRIVATE pico_filesystem_default) + endif() + + if(ARG_AUTO_INIT) + target_compile_definitions(${TARGET} PRIVATE PICO_FS_AUTO_INIT=1) + endif() + endfunction() + +endif() diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem.h b/src/rp2_common/pico_filesystem/include/pico/filesystem.h new file mode 100644 index 000000000..f554e9a1b --- /dev/null +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem.h @@ -0,0 +1,7 @@ +#pragma once + +#include "filesystem/vfs.h" + +#if !defined(PICO_FS_DEFAULT_SIZE) +#define PICO_FS_DEFAULT_SIZE 1441792 +#endif diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/flash.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/flash.h new file mode 100644 index 000000000..a07541a84 --- /dev/null +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/flash.h @@ -0,0 +1,3 @@ +#pragma once + +#include "blockdevice/flash.h" diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/sd.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/sd.h new file mode 100644 index 000000000..578d0b0bb --- /dev/null +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/sd.h @@ -0,0 +1,3 @@ +#pragma once + +#include "blockdevice/sd.h" diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/fat.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/fat.h new file mode 100644 index 000000000..f253168c5 --- /dev/null +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/fat.h @@ -0,0 +1,3 @@ +#pragma once + +#include "filesystem/fat.h" diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/littlefs.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/littlefs.h new file mode 100644 index 000000000..7dd038bc5 --- /dev/null +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/littlefs.h @@ -0,0 +1,3 @@ +#pragma once + +#include "filesystem/littlefs.h" From 23e8aa325d1e221fcec7e9b73a2807f1fd58414a Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Mon, 27 May 2024 10:29:57 +0900 Subject: [PATCH 02/15] Move littlefs to lib to organise sub-module hierarchy --- .gitmodules | 3 +++ lib/littlefs | 1 + src/rp2_common/pico_filesystem/CMakeLists.txt | 13 ++++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 160000 lib/littlefs diff --git a/.gitmodules b/.gitmodules index ba4b09c57..a3ce7cd97 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "lib/pico-vfs"] path = lib/pico-vfs url = https://github.com/oyama/pico-vfs +[submodule "lib/littlefs"] + path = lib/littlefs + url = git@github.com:littlefs-project/littlefs.git diff --git a/lib/littlefs b/lib/littlefs new file mode 160000 index 000000000..d01280e64 --- /dev/null +++ b/lib/littlefs @@ -0,0 +1 @@ +Subproject commit d01280e64934a09ba16cac60cf9d3a37e228bb66 diff --git a/src/rp2_common/pico_filesystem/CMakeLists.txt b/src/rp2_common/pico_filesystem/CMakeLists.txt index a7da61ac6..aeef87975 100644 --- a/src/rp2_common/pico_filesystem/CMakeLists.txt +++ b/src/rp2_common/pico_filesystem/CMakeLists.txt @@ -2,7 +2,11 @@ if (NOT PICO_VFS_PATH) set(PICO_VFS_PATH ${PROJECT_SOURCE_DIR}/lib/pico-vfs) if (NOT EXISTS ${PICO_VFS_PATH}/tests) message(WARNING "pico-vfs submodule has not been initialized: File system support will be unavailable -hint: try 'get submodule update --init' from your SDK directory (${PICO_SDK_PATH}).") +hint: try 'git submodule update --init' from your SDK directory (${PICO_SDK_PATH}).") + endif() + if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/littlefs/tests) + message(WARNING "littlefs submodule has not been initialized: File system support will be unavailabel +hint: try 'git submodule update --init' from your SDK directory (${PICO_SDK_PATH}).") endif() elseif (NOT EXISTS ${PICO_VFS_PATH}/tests) message(WARNING "PICO_VFS_PATH specified but content not present.") @@ -37,11 +41,11 @@ if (EXISTS ${PICO_VFS_PATH}/tests) pico_add_library(pico_filesystem_filesystem_littlefs) target_sources(pico_filesystem_filesystem_littlefs INTERFACE ${PICO_VFS_PATH}/src/filesystem/littlefs.c - ${PICO_VFS_PATH}/vendor/littlefs/lfs.c - ${PICO_VFS_PATH}/vendor/littlefs/lfs_util.c + ${PROJECT_SOURCE_DIR}/lib/littlefs/lfs.c + ${PROJECT_SOURCE_DIR}/lib/littlefs/lfs_util.c ) target_include_directories(pico_filesystem_filesystem_littlefs INTERFACE - ${PICO_VFS_PATH}/vendor/littlefs) + ${PROJECT_SOURCE_DIR}/lib/littlefs) target_compile_options(pico_filesystem_filesystem_littlefs INTERFACE -Wno-unused-function -Wno-null-dereference) pico_add_library(pico_filesystem_filesystem_fat) @@ -75,7 +79,6 @@ if (EXISTS ${PICO_VFS_PATH}/tests) pico_filesystem_filesystem_littlefs ) - pico_promote_common_scope_vars() function(pico_enable_filesystem TARGET) From f2ded214a631e9f0b282c925405579813767986b Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Mon, 27 May 2024 14:25:54 +0900 Subject: [PATCH 03/15] Set maximum volume size in CMakeLists.txt --- lib/pico-vfs | 2 +- src/rp2_common/pico_filesystem/CMakeLists.txt | 39 ++++++++++++++----- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/pico-vfs b/lib/pico-vfs index f2e70ab2f..0adf3f481 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit f2e70ab2f2200550447eaeb11da2d7d058b17f5d +Subproject commit 0adf3f481a267143c8bba11475ccb6efc7be4edb diff --git a/src/rp2_common/pico_filesystem/CMakeLists.txt b/src/rp2_common/pico_filesystem/CMakeLists.txt index aeef87975..6668341ad 100644 --- a/src/rp2_common/pico_filesystem/CMakeLists.txt +++ b/src/rp2_common/pico_filesystem/CMakeLists.txt @@ -81,25 +81,44 @@ if (EXISTS ${PICO_VFS_PATH}/tests) pico_promote_common_scope_vars() + # + # File system enable and customise function + # function(pico_enable_filesystem TARGET) set(options "") - set(oneValueArgs SIZE AUTO_INIT) + set(oneValueArgs SIZE AUTO_INIT MAX_FAT_VOLUME MAX_MOUNTPOINT) set(multiValueArgs FS_INIT) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + # Default file system size in bytes. Must be a multiple of 4096 bytes if(ARG_SIZE) target_compile_definitions(${TARGET} PRIVATE PICO_FS_DEFAULT_SIZE=${ARG_SIZE}) endif() - if(ARG_FS_INIT) - target_sources(${TARGET} PRIVATE ${ARG_FS_INIT}) - else() - target_link_libraries(${TARGET} PRIVATE pico_filesystem_default) - endif() + # Add custom fs_init.c source files + if(ARG_FS_INIT) + target_sources(${TARGET} PRIVATE ${ARG_FS_INIT}) + else() + target_link_libraries(${TARGET} PRIVATE pico_filesystem_default) + endif() - if(ARG_AUTO_INIT) - target_compile_definitions(${TARGET} PRIVATE PICO_FS_AUTO_INIT=1) - endif() - endfunction() + # Enable automatic execution of fs_init() + if(ARG_AUTO_INIT) + target_compile_definitions(${TARGET} PRIVATE PICO_FS_AUTO_INIT=1) + endif() + # Maximum number of file system mount points + if(ARG_MAX_MOUNTPOINT) + target_compile_definitions(${TARGET} PRIVATE PICO_VFS_MAX_MOUNTPOINT=${ARG_MAX_MOUNTPOINT}) + else() + target_compile_definitions(${TARGET} PRIVATE PICO_VFS_MAX_MOUNTPOINT=8) + endif() + + # Maximum number of volumes in a FAT file system + if(ARG_MAX_FAT_VOLUME) + target_compile_definitions(${TARGET} PRIVATE PICO_VFS_MAX_FAT_VOLUME=${ARG_MAX_FAT_VOLUME}) + else() + target_compile_definitions(${TARGET} PRIVATE PICO_VFS_MAX_FAT_VOLUME=4) + endif() + endfunction() endif() From bccbd39e223164dfe1d2990fec66878c279719fd Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Mon, 27 May 2024 15:01:17 +0900 Subject: [PATCH 04/15] add SPDX-License-Identifier --- src/rp2_common/pico_filesystem/include/pico/filesystem.h | 3 +++ .../include/pico/filesystem/blockdevice/flash.h | 3 +++ .../pico_filesystem/include/pico/filesystem/blockdevice/sd.h | 3 +++ .../pico_filesystem/include/pico/filesystem/filesystem/fat.h | 3 +++ .../include/pico/filesystem/filesystem/littlefs.h | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem.h b/src/rp2_common/pico_filesystem/include/pico/filesystem.h index f554e9a1b..806b1c135 100644 --- a/src/rp2_common/pico_filesystem/include/pico/filesystem.h +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem.h @@ -1,3 +1,6 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + */ #pragma once #include "filesystem/vfs.h" diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/flash.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/flash.h index a07541a84..47e7436d3 100644 --- a/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/flash.h +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/flash.h @@ -1,3 +1,6 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + */ #pragma once #include "blockdevice/flash.h" diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/sd.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/sd.h index 578d0b0bb..13368c5c5 100644 --- a/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/sd.h +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/sd.h @@ -1,3 +1,6 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + */ #pragma once #include "blockdevice/sd.h" diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/fat.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/fat.h index f253168c5..1c90f6895 100644 --- a/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/fat.h +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/fat.h @@ -1,3 +1,6 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + */ #pragma once #include "filesystem/fat.h" diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/littlefs.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/littlefs.h index 7dd038bc5..ceae143a7 100644 --- a/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/littlefs.h +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem/littlefs.h @@ -1,3 +1,6 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + */ #pragma once #include "filesystem/littlefs.h" From 4a9d82daa856cbc628556ef9a931877ee7288592 Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Mon, 27 May 2024 15:05:14 +0900 Subject: [PATCH 05/15] Unify submodule location with https --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index a3ce7cd97..e67a5d595 100644 --- a/.gitmodules +++ b/.gitmodules @@ -15,7 +15,7 @@ url = https://github.com/bluekitchen/btstack.git [submodule "lib/pico-vfs"] path = lib/pico-vfs - url = https://github.com/oyama/pico-vfs + url = https://github.com/oyama/pico-vfs.git [submodule "lib/littlefs"] path = lib/littlefs - url = git@github.com:littlefs-project/littlefs.git + url = https://github.com/littlefs-project/littlefs.git From a3b7a04ee3f8d66f7e1235752a2ff7e24a9ab5e8 Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Tue, 28 May 2024 12:29:05 +0900 Subject: [PATCH 06/15] Modification of pico-vfs to issue file descriptors that do not conflict with STDIN/OUT/ERR --- lib/pico-vfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pico-vfs b/lib/pico-vfs index 0adf3f481..dab80d428 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit 0adf3f481a267143c8bba11475ccb6efc7be4edb +Subproject commit dab80d42849356ea3da99fb48fc25022fecaa807 From 0b163750c030f1c242d9843f10966eba6e32d34d Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Tue, 28 May 2024 13:43:31 +0900 Subject: [PATCH 07/15] Incorporate pico-vfs updates that issue file descriptors that do not conflict with STDIN/OUT/ERR --- lib/pico-vfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pico-vfs b/lib/pico-vfs index dab80d428..91108cff5 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit dab80d42849356ea3da99fb48fc25022fecaa807 +Subproject commit 91108cff5a502150e1d291971422ec67be9b975f From a1842a01638c779224f428bbb6c67139b9436a8a Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Tue, 28 May 2024 23:46:35 +0900 Subject: [PATCH 08/15] Fixed stdin/stdout/stderr processing in pico-vfs --- lib/pico-vfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pico-vfs b/lib/pico-vfs index 91108cff5..200ec85db 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit 91108cff5a502150e1d291971422ec67be9b975f +Subproject commit 200ec85db7cb1970dbde102e0bf4704b1b0ad167 From 6ec22384008cd371fb7ac98c24ad03ea07d7135c Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Wed, 29 May 2024 17:35:51 +0900 Subject: [PATCH 09/15] Resource management bug fixed and heap blockdevice added --- .gitmodules | 3 +++ lib/pico-vfs | 2 +- littlefs | 1 + src/rp2_common/pico_filesystem/CMakeLists.txt | 6 ++++++ .../include/pico/filesystem/blockdevice/heap.h | 6 ++++++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 160000 littlefs create mode 100644 src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/heap.h diff --git a/.gitmodules b/.gitmodules index e67a5d595..fb32e44cd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "lib/littlefs"] path = lib/littlefs url = https://github.com/littlefs-project/littlefs.git +[submodule "littlefs"] + path = littlefs + url = git@github.com:littlefs-project/littlefs.git diff --git a/lib/pico-vfs b/lib/pico-vfs index 200ec85db..4e51f3869 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit 200ec85db7cb1970dbde102e0bf4704b1b0ad167 +Subproject commit 4e51f3869dddd2dbf3b5b4f494ee0cea80f65896 diff --git a/littlefs b/littlefs new file mode 160000 index 000000000..d01280e64 --- /dev/null +++ b/littlefs @@ -0,0 +1 @@ +Subproject commit d01280e64934a09ba16cac60cf9d3a37e228bb66 diff --git a/src/rp2_common/pico_filesystem/CMakeLists.txt b/src/rp2_common/pico_filesystem/CMakeLists.txt index 6668341ad..cf9792a34 100644 --- a/src/rp2_common/pico_filesystem/CMakeLists.txt +++ b/src/rp2_common/pico_filesystem/CMakeLists.txt @@ -38,6 +38,12 @@ if (EXISTS ${PICO_VFS_PATH}/tests) hardware_sync ) + pico_add_library(pico_filesystem_blockdevice_heap) + target_sources(pico_filesystem_blockdevice_heap INTERFACE + ${PICO_VFS_PATH}/src/blockdevice/heap.c) + target_include_directories(pico_filesystem_blockdevice_heap INTERFACE + ${PICO_VFS_PATH}/include) + pico_add_library(pico_filesystem_filesystem_littlefs) target_sources(pico_filesystem_filesystem_littlefs INTERFACE ${PICO_VFS_PATH}/src/filesystem/littlefs.c diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/heap.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/heap.h new file mode 100644 index 000000000..b75836db6 --- /dev/null +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice/heap.h @@ -0,0 +1,6 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + */ +#pragma once + +#include "blockdevice/heap.h" From f274fdc9dd9a0d43d195243d9b0e8c070facf2a9 Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Wed, 29 May 2024 18:54:23 +0900 Subject: [PATCH 10/15] Remove unnecessary git submodules --- .gitmodules | 3 --- littlefs | 1 - 2 files changed, 4 deletions(-) delete mode 160000 littlefs diff --git a/.gitmodules b/.gitmodules index fb32e44cd..e67a5d595 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,6 +19,3 @@ [submodule "lib/littlefs"] path = lib/littlefs url = https://github.com/littlefs-project/littlefs.git -[submodule "littlefs"] - path = littlefs - url = git@github.com:littlefs-project/littlefs.git diff --git a/littlefs b/littlefs deleted file mode 160000 index d01280e64..000000000 --- a/littlefs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d01280e64934a09ba16cac60cf9d3a37e228bb66 From 231ee5d51e68e6b8128f93674cf5ad9e681b2da3 Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Thu, 30 May 2024 21:39:13 +0900 Subject: [PATCH 11/15] Add block device and file system base headers --- lib/pico-vfs | 2 +- .../pico_filesystem/include/pico/filesystem/blockdevice.h | 7 +++++++ .../pico_filesystem/include/pico/filesystem/filesystem.h | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice.h create mode 100644 src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem.h diff --git a/lib/pico-vfs b/lib/pico-vfs index 4e51f3869..4fbf8bff5 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit 4e51f3869dddd2dbf3b5b4f494ee0cea80f65896 +Subproject commit 4fbf8bff556e1d45d916c9300b8366a7807021d0 diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice.h new file mode 100644 index 000000000..49542822e --- /dev/null +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/blockdevice.h @@ -0,0 +1,7 @@ +/* + * Copyright 2024, Hiroyuki OYAMA. All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + */ +#pragma once + +#include "blockdevice/blockdevice.h" diff --git a/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem.h b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem.h new file mode 100644 index 000000000..ea9779ef8 --- /dev/null +++ b/src/rp2_common/pico_filesystem/include/pico/filesystem/filesystem.h @@ -0,0 +1,7 @@ +/* + * Copyright 2024, Hiroyuki OYAMA. All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause + */ +#pragma once + +#include "filesystem/filesystem.h" From 34613c9182d7fa5dd4c9c8bf8c2e3a5fa6d30b35 Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Thu, 6 Jun 2024 21:10:31 +0900 Subject: [PATCH 12/15] Fix POSIX incompatibility lseek issue in FatFs --- lib/pico-vfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pico-vfs b/lib/pico-vfs index 4fbf8bff5..4e4ae1513 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit 4fbf8bff556e1d45d916c9300b8366a7807021d0 +Subproject commit 4e4ae151321f494ae92f1b19efa180f8399bd56e From 599b91dad3728089e6ee083c45c72fd8fae9f995 Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Mon, 17 Jun 2024 11:13:03 +0900 Subject: [PATCH 13/15] Improve SDHC card support. Add multi-core testing. --- lib/pico-vfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pico-vfs b/lib/pico-vfs index 4e4ae1513..a4346e9a7 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit 4e4ae151321f494ae92f1b19efa180f8399bd56e +Subproject commit a4346e9a72b50926c713021af819d60ed5b81ddc From 12e8e50b9b9c54a48520e22fe39abc4b64b92ece Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Mon, 2 Sep 2024 15:39:24 +0900 Subject: [PATCH 14/15] Aligned with pico-sdk v2.0.0 build layout --- lib/pico-vfs | 2 +- src/cmake/rp2_common.cmake | 2 ++ src/rp2_common/pico_filesystem/CMakeLists.txt | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/pico-vfs b/lib/pico-vfs index a4346e9a7..1fd30d1eb 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit a4346e9a72b50926c713021af819d60ed5b81ddc +Subproject commit 1fd30d1eb8c4524621428ecc9b30dedffadf84a5 diff --git a/src/cmake/rp2_common.cmake b/src/cmake/rp2_common.cmake index 494b1202b..6ee773346 100644 --- a/src/cmake/rp2_common.cmake +++ b/src/cmake/rp2_common.cmake @@ -120,6 +120,8 @@ if (NOT PICO_BARE_METAL) pico_add_subdirectory(rp2_common/pico_stdio_usb) pico_add_subdirectory(rp2_common/pico_i2c_slave) + pico_add_subdirectory(rp2_common/pico_filesystem) + # networking libraries - note dependency order is important pico_add_subdirectory(rp2_common/pico_async_context) pico_add_subdirectory(rp2_common/pico_btstack) diff --git a/src/rp2_common/pico_filesystem/CMakeLists.txt b/src/rp2_common/pico_filesystem/CMakeLists.txt index cf9792a34..bea05f78e 100644 --- a/src/rp2_common/pico_filesystem/CMakeLists.txt +++ b/src/rp2_common/pico_filesystem/CMakeLists.txt @@ -17,16 +17,15 @@ if (EXISTS ${PICO_VFS_PATH}/tests) pico_register_common_scope_var(PICO_VFS_PATH) - set(BOARD pico_sdk) - set(FAMILY rp2040) - pico_add_library(pico_filesystem_blockdevice_sd) target_sources(pico_filesystem_blockdevice_sd INTERFACE ${PICO_VFS_PATH}/src/blockdevice/sd.c) target_include_directories(pico_filesystem_blockdevice_sd INTERFACE ${PICO_VFS_PATH}/include) target_link_libraries(pico_filesystem_blockdevice_sd INTERFACE - hardware_spi) + hardware_spi + pico_sync + ) pico_add_library(pico_filesystem_blockdevice_flash) target_sources(pico_filesystem_blockdevice_flash INTERFACE @@ -34,8 +33,10 @@ if (EXISTS ${PICO_VFS_PATH}/tests) target_include_directories(pico_filesystem_blockdevice_flash INTERFACE ${PICO_VFS_PATH}/include) target_link_libraries(pico_filesystem_blockdevice_flash INTERFACE + hardware_exception hardware_flash - hardware_sync + pico_sync + pico_flash ) pico_add_library(pico_filesystem_blockdevice_heap) @@ -43,6 +44,7 @@ if (EXISTS ${PICO_VFS_PATH}/tests) ${PICO_VFS_PATH}/src/blockdevice/heap.c) target_include_directories(pico_filesystem_blockdevice_heap INTERFACE ${PICO_VFS_PATH}/include) + target_link_libraries(pico_filesystem_blockdevice_heap INTERFACE pico_sync) pico_add_library(pico_filesystem_filesystem_littlefs) target_sources(pico_filesystem_filesystem_littlefs INTERFACE @@ -53,6 +55,7 @@ if (EXISTS ${PICO_VFS_PATH}/tests) target_include_directories(pico_filesystem_filesystem_littlefs INTERFACE ${PROJECT_SOURCE_DIR}/lib/littlefs) target_compile_options(pico_filesystem_filesystem_littlefs INTERFACE -Wno-unused-function -Wno-null-dereference) + target_link_libraries(pico_filesystem_filesystem_littlefs INTERFACE pico_sync) pico_add_library(pico_filesystem_filesystem_fat) target_sources(pico_filesystem_filesystem_fat INTERFACE @@ -66,6 +69,7 @@ if (EXISTS ${PICO_VFS_PATH}/tests) ${PICO_VFS_PATH}/include/filesystem/ChaN ${PICO_VFS_PATH}/vendor/ff15/source ) + target_link_libraries(pico_filesystem_filesystem_fat INTERFACE pico_sync) pico_add_library(pico_filesystem) target_sources(pico_filesystem INTERFACE @@ -73,6 +77,10 @@ if (EXISTS ${PICO_VFS_PATH}/tests) target_include_directories(pico_filesystem INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include ${PICO_VFS_PATH}/include) + target_link_libraries(pico_filesystem INTERFACE + pico_clib_interface + pico_sync + ) pico_add_library(pico_filesystem_default) target_sources(pico_filesystem_default INTERFACE From 5cc96b743a57523ad6f7eb3fb26b03fd9e666022 Mon Sep 17 00:00:00 2001 From: Hiroyuki OYAMA Date: Thu, 5 Sep 2024 14:59:03 +0900 Subject: [PATCH 15/15] RISC-V core-supported pico-vfs ingestion --- lib/pico-vfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pico-vfs b/lib/pico-vfs index 1fd30d1eb..30362eb00 160000 --- a/lib/pico-vfs +++ b/lib/pico-vfs @@ -1 +1 @@ -Subproject commit 1fd30d1eb8c4524621428ecc9b30dedffadf84a5 +Subproject commit 30362eb00ac60bdd786e9b623a1dcfc91e808b69