Merge 5cc96b743a57523ad6f7eb3fb26b03fd9e666022 into fed7188e527baa922f4130b90b39dc64e3dd8eef

This commit is contained in:
Hiroyuki OYAMA 2025-04-14 18:32:14 +00:00 committed by GitHub
commit 6b1cdc642f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 202 additions and 0 deletions

6
.gitmodules vendored
View File

@ -13,3 +13,9 @@
[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.git
[submodule "lib/littlefs"]
path = lib/littlefs
url = https://github.com/littlefs-project/littlefs.git

1
lib/littlefs Submodule

@ -0,0 +1 @@
Subproject commit d01280e64934a09ba16cac60cf9d3a37e228bb66

1
lib/pico-vfs Submodule

@ -0,0 +1 @@
Subproject commit 30362eb00ac60bdd786e9b623a1dcfc91e808b69

View File

@ -123,6 +123,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)

View File

@ -0,0 +1,138 @@
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 '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.")
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)
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_sync
)
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_exception
hardware_flash
pico_sync
pico_flash
)
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)
target_link_libraries(pico_filesystem_blockdevice_heap INTERFACE pico_sync)
pico_add_library(pico_filesystem_filesystem_littlefs)
target_sources(pico_filesystem_filesystem_littlefs INTERFACE
${PICO_VFS_PATH}/src/filesystem/littlefs.c
${PROJECT_SOURCE_DIR}/lib/littlefs/lfs.c
${PROJECT_SOURCE_DIR}/lib/littlefs/lfs_util.c
)
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
${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
)
target_link_libraries(pico_filesystem_filesystem_fat INTERFACE pico_sync)
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)
target_link_libraries(pico_filesystem INTERFACE
pico_clib_interface
pico_sync
)
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()
#
# File system enable and customise function
#
function(pico_enable_filesystem TARGET)
set(options "")
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()
# 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()
# 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()

View File

@ -0,0 +1,10 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "filesystem/vfs.h"
#if !defined(PICO_FS_DEFAULT_SIZE)
#define PICO_FS_DEFAULT_SIZE 1441792
#endif

View File

@ -0,0 +1,7 @@
/*
* Copyright 2024, Hiroyuki OYAMA. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "blockdevice/blockdevice.h"

View File

@ -0,0 +1,6 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "blockdevice/flash.h"

View File

@ -0,0 +1,6 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "blockdevice/heap.h"

View File

@ -0,0 +1,6 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "blockdevice/sd.h"

View File

@ -0,0 +1,7 @@
/*
* Copyright 2024, Hiroyuki OYAMA. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "filesystem/filesystem.h"

View File

@ -0,0 +1,6 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "filesystem/fat.h"

View File

@ -0,0 +1,6 @@
/*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "filesystem/littlefs.h"