Skip to content

Commit

Permalink
Add littlefs file system and update Sys.IO.FileSystem (#2911)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jul 23, 2024
1 parent 828e15b commit bf46e5d
Show file tree
Hide file tree
Showing 229 changed files with 16,172 additions and 13,362 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/All/Dockerfile.All
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-all:v2.47
FROM ghcr.io/nanoframework/dev-container-all:v2.48
4 changes: 2 additions & 2 deletions .devcontainer/All/Dockerfile.All.SRC
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ RUN git clone --branch nf-build https://github.com/nanoframework/STM32CubeL4.git
RUN git clone --branch v6.4.0_rel --recursive https://github.com/eclipse-threadx/threadx.git --depth 1 ./sources/AzureRTOS \
&& git clone --branch v6.3.0_rel --recursive https://github.com/eclipse-threadx/netxduo.git --depth 1 ./sources/NetxDuo

# Clone dependent repos (mbedtls, fatfs and spiffs)
# Clone dependent repos (mbedtls, fatfs and littlefs)
RUN git clone --branch mbedtls-2.28.5 https://github.com/ARMmbed/mbedtls.git --depth 1 ./sources/mbedtls \
&& git clone --branch R0.15 https://github.com/abbrev/fatfs.git --depth 1 ./sources/fatfs \
&& git clone --branch nf-build https://github.com/nanoframework/spiffs.git --depth 1 ./sources/spiffs
&& git clone --branch v2.9.3 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs

# Clone FreeRTOS and what is needed for ESP32
RUN git clone --branch V10.4.1-kernel-only https://github.com/FreeRTOS/FreeRTOS-Kernel.git --depth 1 ./sources/FreeRTOS \
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/All/scripts/git-pull-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ cd /sources/CMSIS_5
git pull origin 5.5.1
cd /sources/lwip
git pull origin STABLE-2_1_3_RELEASE
cd /sources/spiffs
git pull origin nf-build
cd /sources/littlefs
git pull origin v2.9.3
cd /sources/SimpleLinkCC32
git pull origin 4.10.00.07
cd /sources/SimpleLinkCC13
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/AzureRTOS/Dockerfile.AzureRTOS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-azure-rtos:v1.26
FROM ghcr.io/nanoframework/dev-container-azure-rtos:v1.27
4 changes: 2 additions & 2 deletions .devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ RUN git clone --branch nf-build https://github.com/nanoframework/STM32CubeL4.git
RUN git clone --branch v6.4.0_rel --recursive https://github.com/eclipse-threadx/threadx.git --depth 1 ./sources/AzureRTOS \
&& git clone --branch v6.4.0_rel --recursive https://github.com/eclipse-threadx/netxduo.git --depth 1 ./sources/NetxDuo

# Clone dependent repos (mbedtls, fatfs and spiffs)
# Clone dependent repos (mbedtls, fatfs and littlefs)
RUN git clone --branch mbedtls-2.28.5 https://github.com/ARMmbed/mbedtls.git --depth 1 ./sources/mbedtls \
&& git clone --branch R0.15 https://github.com/abbrev/fatfs.git --depth 1 ./sources/fatfs \
&& git clone --branch nf-build https://github.com/nanoframework/spiffs.git --depth 1 ./sources/spiffs
&& git clone --branch v2.9.3 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs

# set gcc location
ARG TMP_GCC_PATH=/usr/local/bin/gcc
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/ChibiOS/Dockerfile.ChibiOS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-chibios:v1.27
FROM ghcr.io/nanoframework/dev-container-chibios:v1.28
4 changes: 2 additions & 2 deletions .devcontainer/ChibiOS/Dockerfile.ChibiOS.SRC
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ RUN git clone --branch nf-build https://github.com/nanoframework/STM32CubeL4.git
&& git clone --branch nf-build https://github.com/nanoframework/STM32CubeH7.git --depth 1 ./sources/STM32CubeH7 \
&& git clone --branch chibios-21.11.x https://github.com/ChibiOS/ChibiOS-Contrib.git --depth 1 ./sources/ChibiOs-Contrib

# Clone dependent repos (mbedtls, fatfs and spiffs etc.)
# Clone dependent repos (mbedtls, fatfs and littlefs etc.)
RUN git clone --branch mbedtls-2.28.5 https://github.com/ARMmbed/mbedtls.git --depth 1 ./sources/mbedtls \
&& git clone --branch R0.15 https://github.com/abbrev/fatfs.git --depth 1 ./sources/fatfs \
&& git clone --branch nf-build https://github.com/nanoframework/spiffs.git --depth 1 ./sources/spiffs \
&& git clone --branch v2.9.3 https://github.com/littlefs-project/littlefs --depth 1 ./sources/littlefs \
&& git clone --branch STABLE-2_1_3_RELEASE https://github.com/lwip-tcpip/lwip.git --depth 1 ./sources/lwip

# set gcc location
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/TI/Dockerfile.TI
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-ti:v1.22
FROM ghcr.io/nanoframework/dev-container-ti:v1.23
1 change: 0 additions & 1 deletion .devcontainer/TI/Dockerfile.TI.SRC
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ RUN mkdir -p /tmp/dc-extracted/titools \
&& curl -o /tmp/dc-downloads/titools.zip $TI_TOOL_URL -L \
&& unzip -d /tmp/dc-extracted/titools /tmp/dc-downloads/titools.zip


FROM ubuntu:latest AS devcontainer

# Avoid warnings by switching to noninteractive
Expand Down
4 changes: 2 additions & 2 deletions CMake/Modules/FindCHIBIOS_FATFS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ foreach(SRC_FILE ${FATFS_SRCS})

find_file(FATFS_SRC_FILE ${SRC_FILE}
PATHS
${CMAKE_SOURCE_DIR}/targets/ChibiOS/_FatFS/
${CMAKE_SOURCE_DIR}/targets/ChibiOS/_FatFs/
${fatfs_SOURCE_DIR}/source

CMAKE_FIND_ROOT_PATH_BOTH
Expand All @@ -47,7 +47,7 @@ if(NF_FEATURE_HAS_USB_MSD)
list(APPEND CHIBIOS_FATFS_SOURCES ${chibios-contrib_SOURCE_DIR}/os/various/fatfs_bindings/fatfs_diskio.c)
else()
# get it from the targets directory for fixing STM32F7 series Cache issues
list(APPEND CHIBIOS_FATFS_SOURCES ${CMAKE_SOURCE_DIR}/targets/ChibiOS/_FatFS/fatfs_diskio.c)
list(APPEND CHIBIOS_FATFS_SOURCES ${CMAKE_SOURCE_DIR}/targets/ChibiOS/_FatFs/fatfs_diskio.c)
endif()

include(FindPackageHandleStandardArgs)
Expand Down
52 changes: 52 additions & 0 deletions CMake/Modules/FindLITTLEFS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#

include(FetchContent)
FetchContent_GetProperties(littlefs)

# List of the required include paths
list(APPEND littlefs_INCLUDE_DIRS
${littlefs_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/targets/${RTOS}/_littlefs)

set(src_LITTLEFS

lfs.c
lfs_util.c

# HAL implementation specific to a platform
# has to be included at platform level
hal_littlefs.c

target_littlefs.c
)

foreach(SRC_FILE ${src_LITTLEFS})

set(LITTLEFS_SRC_FILE SRC_FILE -NOTFOUND)

find_file(LITTLEFS_SRC_FILE ${SRC_FILE}
PATHS

${littlefs_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/targets/${RTOS}/_littlefs
${TARGET_BASE_LOCATION}

CMAKE_FIND_ROOT_PATH_BOTH
)

if (BUILD_VERBOSE)
message("${SRC_FILE} >> ${LITTLEFS_SRC_FILE}")
endif()

list(APPEND littlefs_SOURCES ${LITTLEFS_SRC_FILE})

endforeach()

set_source_files_properties(${littlefs_SOURCE_DIR}/lfs.c PROPERTIES COMPILE_FLAGS -Wno-shadow)

include(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(littlefs DEFAULT_MSG littlefs_INCLUDE_DIRS littlefs_SOURCES)
150 changes: 77 additions & 73 deletions CMake/Modules/FindNF_CoreCLR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/PAL/Include)
list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/CLR/CorLib)

# CLR startup
list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/CLR/Startup)
list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/CLR/Startup)

# others
list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/targets/${RTOS}/_include)
Expand Down Expand Up @@ -134,7 +134,7 @@ set(NF_CoreCLR_SRCS
nf_rt_native_nanoFramework_Runtime_Native_Power.cpp
nf_rt_native_nanoFramework_Runtime_Native_Rtc_stubs.cpp
nf_rt_native_System_Environment.cpp

# Core stubs
RPC_stub.cpp

Expand All @@ -151,9 +151,10 @@ set(NF_CoreCLR_SRCS
nanoHAL_Time.cpp
nanoHAL_Watchdog.c
nanoHAL_SystemEvents.c

# PAL
nanoPAL_Events.cpp
nanoPAL_FileSystem_stubs.cpp
nanoPAL_NativeDouble.cpp
nanoPAL_Network_stubs.cpp
nanoPAL_PerformanceCounters_stubs.cpp
Expand Down Expand Up @@ -192,15 +193,15 @@ if(NF_FEATURE_SUPPORT_REFLECTION)

# should we include binary serialization support?
if(NF_FEATURE_BINARY_SERIALIZATION)
list(APPEND NF_CoreCLR_SRCS BinaryFormatter.cpp)
list(APPEND NF_CoreCLR_SRCS BinaryFormatter.cpp)
else()
# binary serialization stubs because we're not supporting reflection
list(APPEND NF_CoreCLR_SRCS BinaryFormatter_stub.cpp)
list(APPEND NF_CoreCLR_SRCS BinaryFormatter_stub.cpp)
endif()

else()
# binary serialization stubs because we're not supporting reflection
list(APPEND NF_CoreCLR_SRCS BinaryFormatter_stub.cpp)
list(APPEND NF_CoreCLR_SRCS BinaryFormatter_stub.cpp)
endif()

# include Collection support files depending on build option
Expand All @@ -209,7 +210,14 @@ if(API_nanoFramework.System.Collections)
list(APPEND NF_CoreCLR_SRCS CLR_RT_HeapBlock_Stack.cpp)
endif()

# need a conditional include because of ESP32 building network as a library
# file system support?
if(API_System.IO.FileSystem)
list(APPEND NF_CoreCLR_SRCS FileStream.cpp)
else()
list(APPEND NF_CoreCLR_SRCS FileStream_stub.cpp)
endif()

# need a conditional include because of ESP32 building network as a library
if(NOT USE_SECURITY_MBEDTLS_OPTION)
list(APPEND NF_CoreCLR_SRCS base64.c)
endif()
Expand All @@ -229,103 +237,100 @@ if(EXISTS ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.Runtime.Native/
endif()

foreach(SRC_FILE ${NF_CoreCLR_SRCS})

set(NF_CoreCLR_SRC_FILE SRC_FILE-NOTFOUND)

find_file(NF_CoreCLR_SRC_FILE ${SRC_FILE}
PATHS

# Core
${CMAKE_SOURCE_DIR}/src/CLR/Core

# CoreLib
${CMAKE_SOURCE_DIR}/src/CLR/CorLib

# CLR startup
${CMAKE_SOURCE_DIR}/src/CLR/Startup

# Runtime.Native
${CMAKE_SOURCE_DIR}/src/nanoFramework.Runtime.Native

# Core stubs
${CMAKE_SOURCE_DIR}/src/CLR/Core/Hardware
${CMAKE_SOURCE_DIR}/src/CLR/Core/InterruptHandler
${CMAKE_SOURCE_DIR}/src/CLR/Core/NativeEventDispatcher
${CMAKE_SOURCE_DIR}/src/CLR/Core/RPC
${CMAKE_SOURCE_DIR}/src/CLR/Core/Serialization

# CLR stubs
${CMAKE_SOURCE_DIR}/src/CLR/Debugger
${CMAKE_SOURCE_DIR}/src/CLR/Diagnostics
${CMAKE_SOURCE_DIR}/src/CLR/Messaging

# Helpers
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/nanoprintf
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/NanoRingBuffer
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/Base64
${CMAKE_SOURCE_DIR}/src/CLR/Diagnostics

# HAL
${CMAKE_SOURCE_DIR}/src/HAL

# PAL
${CMAKE_SOURCE_DIR}/src/PAL
${CMAKE_SOURCE_DIR}/src/PAL/BlockStorage
${CMAKE_SOURCE_DIR}/src/PAL/Double
${CMAKE_SOURCE_DIR}/src/PAL/Events

# PAL stubs
${CMAKE_SOURCE_DIR}/src/PAL/AsyncProcCall
${CMAKE_SOURCE_DIR}/src/PAL/COM
${CMAKE_SOURCE_DIR}/src/PAL/Profiler

# platform specific implementations
${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.Runtime.Native

# target
${TARGET_BASE_LOCATION}
PATHS

# Core
${CMAKE_SOURCE_DIR}/src/CLR/Core

# CoreLib
${CMAKE_SOURCE_DIR}/src/CLR/CorLib

# CLR startup
${CMAKE_SOURCE_DIR}/src/CLR/Startup

# Runtime.Native
${CMAKE_SOURCE_DIR}/src/nanoFramework.Runtime.Native

# Core stubs
${CMAKE_SOURCE_DIR}/src/CLR/Core/Hardware
${CMAKE_SOURCE_DIR}/src/CLR/Core/InterruptHandler
${CMAKE_SOURCE_DIR}/src/CLR/Core/NativeEventDispatcher
${CMAKE_SOURCE_DIR}/src/CLR/Core/RPC
${CMAKE_SOURCE_DIR}/src/CLR/Core/Serialization
${CMAKE_SOURCE_DIR}/src/CLR/Core/FileStream

# CLR stubs
${CMAKE_SOURCE_DIR}/src/CLR/Debugger
${CMAKE_SOURCE_DIR}/src/CLR/Diagnostics
${CMAKE_SOURCE_DIR}/src/CLR/Messaging

# Helpers
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/nanoprintf
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/NanoRingBuffer
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/Base64
${CMAKE_SOURCE_DIR}/src/CLR/Diagnostics

# HAL
${CMAKE_SOURCE_DIR}/src/HAL

# PAL
${CMAKE_SOURCE_DIR}/src/PAL
${CMAKE_SOURCE_DIR}/src/PAL/BlockStorage
${CMAKE_SOURCE_DIR}/src/PAL/Double
${CMAKE_SOURCE_DIR}/src/PAL/Events
${CMAKE_SOURCE_DIR}/src/PAL/FileSystem

# PAL stubs
${CMAKE_SOURCE_DIR}/src/PAL/AsyncProcCall
${CMAKE_SOURCE_DIR}/src/PAL/COM
${CMAKE_SOURCE_DIR}/src/PAL/Profiler

# platform specific implementations
${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.Runtime.Native

# target
${TARGET_BASE_LOCATION}

CMAKE_FIND_ROOT_PATH_BOTH
)

if (BUILD_VERBOSE)
if(BUILD_VERBOSE)
message("${SRC_FILE} >> ${NF_CoreCLR_SRC_FILE}")
endif()

list(APPEND NF_CoreCLR_SOURCES ${NF_CoreCLR_SRC_FILE})

endforeach()

include(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(NF_CoreCLR DEFAULT_MSG NF_CoreCLR_INCLUDE_DIRS NF_CoreCLR_SOURCES)


# macro to be called from binutils to add Core CLR library
# optional EXTRA_INCLUDES with include paths to be added to the library
# optional EXTRA_COMPILE_DEFINITIONS with compiler definitions to be added to the library
macro(nf_add_lib_coreclr)

# parse arguments
cmake_parse_arguments(NFALC "" "" "EXTRA_INCLUDES;EXTRA_COMPILE_DEFINITIONS" ${ARGN})

# add this has a library
set(LIB_NAME NF_CoreCLR)

add_library(
${LIB_NAME} STATIC
${NF_CoreCLR_SOURCES}
${NF_Diagnostics_SOURCES})
${LIB_NAME} STATIC
${NF_CoreCLR_SOURCES}
${NF_Diagnostics_SOURCES})

target_include_directories(
${LIB_NAME}
PUBLIC
${NF_CoreCLR_INCLUDE_DIRS}
${NFALC_EXTRA_INCLUDES})
${LIB_NAME}
PUBLIC
${NF_CoreCLR_INCLUDE_DIRS}
${NFALC_EXTRA_INCLUDES})

# TODO can be removed later
if(RTOS_ESP32_CHECK)

nf_common_compiler_definitions(TARGET ${LIB_NAME} BUILD_TARGET ${NANOCLR_PROJECT_NAME})

# this is the only one different
Expand All @@ -335,13 +340,12 @@ macro(nf_add_lib_coreclr)
${NFALC_EXTRA_COMPILER_DEFINITIONS}
)

else()
else()
nf_set_compile_options(TARGET ${LIB_NAME})
nf_set_compile_definitions(TARGET ${LIB_NAME} EXTRA_COMPILE_DEFINITIONS ${NFALC_EXTRA_COMPILE_DEFINITIONS} BUILD_TARGET ${NANOCLR_PROJECT_NAME})
nf_set_link_options(TARGET ${LIB_NAME})
endif()

# add alias
add_library("nano::${LIB_NAME}" ALIAS ${LIB_NAME})

endmacro()
Loading

0 comments on commit bf46e5d

Please sign in to comment.