Skip to content

Commit bf46e5d

Browse files
authored
Add littlefs file system and update Sys.IO.FileSystem (#2911)
1 parent 828e15b commit bf46e5d

File tree

229 files changed

+16172
-13362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+16172
-13362
lines changed

.devcontainer/All/Dockerfile.All

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM ghcr.io/nanoframework/dev-container-all:v2.47
1+
FROM ghcr.io/nanoframework/dev-container-all:v2.48

.devcontainer/All/Dockerfile.All.SRC

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ RUN git clone --branch nf-build https://github.com/nanoframework/STM32CubeL4.git
7777
RUN git clone --branch v6.4.0_rel --recursive https://github.com/eclipse-threadx/threadx.git --depth 1 ./sources/AzureRTOS \
7878
&& git clone --branch v6.3.0_rel --recursive https://github.com/eclipse-threadx/netxduo.git --depth 1 ./sources/NetxDuo
7979

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

8585
# Clone FreeRTOS and what is needed for ESP32
8686
RUN git clone --branch V10.4.1-kernel-only https://github.com/FreeRTOS/FreeRTOS-Kernel.git --depth 1 ./sources/FreeRTOS \

.devcontainer/All/scripts/git-pull-repos.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ cd /sources/CMSIS_5
2424
git pull origin 5.5.1
2525
cd /sources/lwip
2626
git pull origin STABLE-2_1_3_RELEASE
27-
cd /sources/spiffs
28-
git pull origin nf-build
27+
cd /sources/littlefs
28+
git pull origin v2.9.3
2929
cd /sources/SimpleLinkCC32
3030
git pull origin 4.10.00.07
3131
cd /sources/SimpleLinkCC13
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM ghcr.io/nanoframework/dev-container-azure-rtos:v1.26
1+
FROM ghcr.io/nanoframework/dev-container-azure-rtos:v1.27

.devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ RUN git clone --branch nf-build https://github.com/nanoframework/STM32CubeL4.git
6666
RUN git clone --branch v6.4.0_rel --recursive https://github.com/eclipse-threadx/threadx.git --depth 1 ./sources/AzureRTOS \
6767
&& git clone --branch v6.4.0_rel --recursive https://github.com/eclipse-threadx/netxduo.git --depth 1 ./sources/NetxDuo
6868

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

7474
# set gcc location
7575
ARG TMP_GCC_PATH=/usr/local/bin/gcc
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM ghcr.io/nanoframework/dev-container-chibios:v1.27
1+
FROM ghcr.io/nanoframework/dev-container-chibios:v1.28

.devcontainer/ChibiOS/Dockerfile.ChibiOS.SRC

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ RUN git clone --branch nf-build https://github.com/nanoframework/STM32CubeL4.git
6464
&& git clone --branch nf-build https://github.com/nanoframework/STM32CubeH7.git --depth 1 ./sources/STM32CubeH7 \
6565
&& git clone --branch chibios-21.11.x https://github.com/ChibiOS/ChibiOS-Contrib.git --depth 1 ./sources/ChibiOs-Contrib
6666

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

7373
# set gcc location

.devcontainer/TI/Dockerfile.TI

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM ghcr.io/nanoframework/dev-container-ti:v1.22
1+
FROM ghcr.io/nanoframework/dev-container-ti:v1.23

.devcontainer/TI/Dockerfile.TI.SRC

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ RUN mkdir -p /tmp/dc-extracted/titools \
3232
&& curl -o /tmp/dc-downloads/titools.zip $TI_TOOL_URL -L \
3333
&& unzip -d /tmp/dc-extracted/titools /tmp/dc-downloads/titools.zip
3434

35-
3635
FROM ubuntu:latest AS devcontainer
3736

3837
# Avoid warnings by switching to noninteractive

CMake/Modules/FindCHIBIOS_FATFS.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ foreach(SRC_FILE ${FATFS_SRCS})
2727

2828
find_file(FATFS_SRC_FILE ${SRC_FILE}
2929
PATHS
30-
${CMAKE_SOURCE_DIR}/targets/ChibiOS/_FatFS/
30+
${CMAKE_SOURCE_DIR}/targets/ChibiOS/_FatFs/
3131
${fatfs_SOURCE_DIR}/source
3232

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

5353
include(FindPackageHandleStandardArgs)

CMake/Modules/FindLITTLEFS.cmake

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# Copyright (c) .NET Foundation and Contributors
3+
# See LICENSE file in the project root for full license information.
4+
#
5+
6+
include(FetchContent)
7+
FetchContent_GetProperties(littlefs)
8+
9+
# List of the required include paths
10+
list(APPEND littlefs_INCLUDE_DIRS
11+
${littlefs_SOURCE_DIR}
12+
${CMAKE_SOURCE_DIR}/targets/${RTOS}/_littlefs)
13+
14+
set(src_LITTLEFS
15+
16+
lfs.c
17+
lfs_util.c
18+
19+
# HAL implementation specific to a platform
20+
# has to be included at platform level
21+
hal_littlefs.c
22+
23+
target_littlefs.c
24+
)
25+
26+
foreach(SRC_FILE ${src_LITTLEFS})
27+
28+
set(LITTLEFS_SRC_FILE SRC_FILE -NOTFOUND)
29+
30+
find_file(LITTLEFS_SRC_FILE ${SRC_FILE}
31+
PATHS
32+
33+
${littlefs_SOURCE_DIR}
34+
${CMAKE_SOURCE_DIR}/targets/${RTOS}/_littlefs
35+
${TARGET_BASE_LOCATION}
36+
37+
CMAKE_FIND_ROOT_PATH_BOTH
38+
)
39+
40+
if (BUILD_VERBOSE)
41+
message("${SRC_FILE} >> ${LITTLEFS_SRC_FILE}")
42+
endif()
43+
44+
list(APPEND littlefs_SOURCES ${LITTLEFS_SRC_FILE})
45+
46+
endforeach()
47+
48+
set_source_files_properties(${littlefs_SOURCE_DIR}/lfs.c PROPERTIES COMPILE_FLAGS -Wno-shadow)
49+
50+
include(FindPackageHandleStandardArgs)
51+
52+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(littlefs DEFAULT_MSG littlefs_INCLUDE_DIRS littlefs_SOURCES)

CMake/Modules/FindNF_CoreCLR.cmake

+77-73
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/PAL/Include)
1515
list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/CLR/CorLib)
1616

1717
# CLR startup
18-
list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/CLR/Startup)
18+
list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/CLR/Startup)
1919

2020
# others
2121
list(APPEND NF_CoreCLR_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/targets/${RTOS}/_include)
@@ -134,7 +134,7 @@ set(NF_CoreCLR_SRCS
134134
nf_rt_native_nanoFramework_Runtime_Native_Power.cpp
135135
nf_rt_native_nanoFramework_Runtime_Native_Rtc_stubs.cpp
136136
nf_rt_native_System_Environment.cpp
137-
137+
138138
# Core stubs
139139
RPC_stub.cpp
140140

@@ -151,9 +151,10 @@ set(NF_CoreCLR_SRCS
151151
nanoHAL_Time.cpp
152152
nanoHAL_Watchdog.c
153153
nanoHAL_SystemEvents.c
154-
154+
155155
# PAL
156156
nanoPAL_Events.cpp
157+
nanoPAL_FileSystem_stubs.cpp
157158
nanoPAL_NativeDouble.cpp
158159
nanoPAL_Network_stubs.cpp
159160
nanoPAL_PerformanceCounters_stubs.cpp
@@ -192,15 +193,15 @@ if(NF_FEATURE_SUPPORT_REFLECTION)
192193

193194
# should we include binary serialization support?
194195
if(NF_FEATURE_BINARY_SERIALIZATION)
195-
list(APPEND NF_CoreCLR_SRCS BinaryFormatter.cpp)
196+
list(APPEND NF_CoreCLR_SRCS BinaryFormatter.cpp)
196197
else()
197198
# binary serialization stubs because we're not supporting reflection
198-
list(APPEND NF_CoreCLR_SRCS BinaryFormatter_stub.cpp)
199+
list(APPEND NF_CoreCLR_SRCS BinaryFormatter_stub.cpp)
199200
endif()
200201

201202
else()
202203
# binary serialization stubs because we're not supporting reflection
203-
list(APPEND NF_CoreCLR_SRCS BinaryFormatter_stub.cpp)
204+
list(APPEND NF_CoreCLR_SRCS BinaryFormatter_stub.cpp)
204205
endif()
205206

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

212-
# need a conditional include because of ESP32 building network as a library
213+
# file system support?
214+
if(API_System.IO.FileSystem)
215+
list(APPEND NF_CoreCLR_SRCS FileStream.cpp)
216+
else()
217+
list(APPEND NF_CoreCLR_SRCS FileStream_stub.cpp)
218+
endif()
219+
220+
# need a conditional include because of ESP32 building network as a library
213221
if(NOT USE_SECURITY_MBEDTLS_OPTION)
214222
list(APPEND NF_CoreCLR_SRCS base64.c)
215223
endif()
@@ -229,103 +237,100 @@ if(EXISTS ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.Runtime.Native/
229237
endif()
230238

231239
foreach(SRC_FILE ${NF_CoreCLR_SRCS})
232-
233240
set(NF_CoreCLR_SRC_FILE SRC_FILE-NOTFOUND)
234241

235242
find_file(NF_CoreCLR_SRC_FILE ${SRC_FILE}
236-
PATHS
237-
238-
# Core
239-
${CMAKE_SOURCE_DIR}/src/CLR/Core
240-
241-
# CoreLib
242-
${CMAKE_SOURCE_DIR}/src/CLR/CorLib
243-
244-
# CLR startup
245-
${CMAKE_SOURCE_DIR}/src/CLR/Startup
246-
247-
# Runtime.Native
248-
${CMAKE_SOURCE_DIR}/src/nanoFramework.Runtime.Native
249-
250-
# Core stubs
251-
${CMAKE_SOURCE_DIR}/src/CLR/Core/Hardware
252-
${CMAKE_SOURCE_DIR}/src/CLR/Core/InterruptHandler
253-
${CMAKE_SOURCE_DIR}/src/CLR/Core/NativeEventDispatcher
254-
${CMAKE_SOURCE_DIR}/src/CLR/Core/RPC
255-
${CMAKE_SOURCE_DIR}/src/CLR/Core/Serialization
256-
257-
# CLR stubs
258-
${CMAKE_SOURCE_DIR}/src/CLR/Debugger
259-
${CMAKE_SOURCE_DIR}/src/CLR/Diagnostics
260-
${CMAKE_SOURCE_DIR}/src/CLR/Messaging
261-
262-
# Helpers
263-
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/nanoprintf
264-
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/NanoRingBuffer
265-
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/Base64
266-
${CMAKE_SOURCE_DIR}/src/CLR/Diagnostics
267-
268-
# HAL
269-
${CMAKE_SOURCE_DIR}/src/HAL
270-
271-
# PAL
272-
${CMAKE_SOURCE_DIR}/src/PAL
273-
${CMAKE_SOURCE_DIR}/src/PAL/BlockStorage
274-
${CMAKE_SOURCE_DIR}/src/PAL/Double
275-
${CMAKE_SOURCE_DIR}/src/PAL/Events
276-
277-
# PAL stubs
278-
${CMAKE_SOURCE_DIR}/src/PAL/AsyncProcCall
279-
${CMAKE_SOURCE_DIR}/src/PAL/COM
280-
${CMAKE_SOURCE_DIR}/src/PAL/Profiler
281-
282-
# platform specific implementations
283-
${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.Runtime.Native
284-
285-
# target
286-
${TARGET_BASE_LOCATION}
243+
PATHS
244+
245+
# Core
246+
${CMAKE_SOURCE_DIR}/src/CLR/Core
247+
248+
# CoreLib
249+
${CMAKE_SOURCE_DIR}/src/CLR/CorLib
250+
251+
# CLR startup
252+
${CMAKE_SOURCE_DIR}/src/CLR/Startup
253+
254+
# Runtime.Native
255+
${CMAKE_SOURCE_DIR}/src/nanoFramework.Runtime.Native
256+
257+
# Core stubs
258+
${CMAKE_SOURCE_DIR}/src/CLR/Core/Hardware
259+
${CMAKE_SOURCE_DIR}/src/CLR/Core/InterruptHandler
260+
${CMAKE_SOURCE_DIR}/src/CLR/Core/NativeEventDispatcher
261+
${CMAKE_SOURCE_DIR}/src/CLR/Core/RPC
262+
${CMAKE_SOURCE_DIR}/src/CLR/Core/Serialization
263+
${CMAKE_SOURCE_DIR}/src/CLR/Core/FileStream
264+
265+
# CLR stubs
266+
${CMAKE_SOURCE_DIR}/src/CLR/Debugger
267+
${CMAKE_SOURCE_DIR}/src/CLR/Diagnostics
268+
${CMAKE_SOURCE_DIR}/src/CLR/Messaging
269+
270+
# Helpers
271+
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/nanoprintf
272+
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/NanoRingBuffer
273+
${CMAKE_SOURCE_DIR}/src/CLR/Helpers/Base64
274+
${CMAKE_SOURCE_DIR}/src/CLR/Diagnostics
275+
276+
# HAL
277+
${CMAKE_SOURCE_DIR}/src/HAL
278+
279+
# PAL
280+
${CMAKE_SOURCE_DIR}/src/PAL
281+
${CMAKE_SOURCE_DIR}/src/PAL/BlockStorage
282+
${CMAKE_SOURCE_DIR}/src/PAL/Double
283+
${CMAKE_SOURCE_DIR}/src/PAL/Events
284+
${CMAKE_SOURCE_DIR}/src/PAL/FileSystem
285+
286+
# PAL stubs
287+
${CMAKE_SOURCE_DIR}/src/PAL/AsyncProcCall
288+
${CMAKE_SOURCE_DIR}/src/PAL/COM
289+
${CMAKE_SOURCE_DIR}/src/PAL/Profiler
290+
291+
# platform specific implementations
292+
${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.Runtime.Native
293+
294+
# target
295+
${TARGET_BASE_LOCATION}
287296

288297
CMAKE_FIND_ROOT_PATH_BOTH
289298
)
290299

291-
if (BUILD_VERBOSE)
300+
if(BUILD_VERBOSE)
292301
message("${SRC_FILE} >> ${NF_CoreCLR_SRC_FILE}")
293302
endif()
294303

295304
list(APPEND NF_CoreCLR_SOURCES ${NF_CoreCLR_SRC_FILE})
296-
297305
endforeach()
298306

299307
include(FindPackageHandleStandardArgs)
300308

301309
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NF_CoreCLR DEFAULT_MSG NF_CoreCLR_INCLUDE_DIRS NF_CoreCLR_SOURCES)
302310

303-
304311
# macro to be called from binutils to add Core CLR library
305312
# optional EXTRA_INCLUDES with include paths to be added to the library
306313
# optional EXTRA_COMPILE_DEFINITIONS with compiler definitions to be added to the library
307314
macro(nf_add_lib_coreclr)
308-
309315
# parse arguments
310316
cmake_parse_arguments(NFALC "" "" "EXTRA_INCLUDES;EXTRA_COMPILE_DEFINITIONS" ${ARGN})
311317

312318
# add this has a library
313319
set(LIB_NAME NF_CoreCLR)
314320

315321
add_library(
316-
${LIB_NAME} STATIC
317-
${NF_CoreCLR_SOURCES}
318-
${NF_Diagnostics_SOURCES})
322+
${LIB_NAME} STATIC
323+
${NF_CoreCLR_SOURCES}
324+
${NF_Diagnostics_SOURCES})
319325

320326
target_include_directories(
321-
${LIB_NAME}
322-
PUBLIC
323-
${NF_CoreCLR_INCLUDE_DIRS}
324-
${NFALC_EXTRA_INCLUDES})
327+
${LIB_NAME}
328+
PUBLIC
329+
${NF_CoreCLR_INCLUDE_DIRS}
330+
${NFALC_EXTRA_INCLUDES})
325331

326332
# TODO can be removed later
327333
if(RTOS_ESP32_CHECK)
328-
329334
nf_common_compiler_definitions(TARGET ${LIB_NAME} BUILD_TARGET ${NANOCLR_PROJECT_NAME})
330335

331336
# this is the only one different
@@ -335,13 +340,12 @@ macro(nf_add_lib_coreclr)
335340
${NFALC_EXTRA_COMPILER_DEFINITIONS}
336341
)
337342

338-
else()
343+
else()
339344
nf_set_compile_options(TARGET ${LIB_NAME})
340345
nf_set_compile_definitions(TARGET ${LIB_NAME} EXTRA_COMPILE_DEFINITIONS ${NFALC_EXTRA_COMPILE_DEFINITIONS} BUILD_TARGET ${NANOCLR_PROJECT_NAME})
341346
nf_set_link_options(TARGET ${LIB_NAME})
342347
endif()
343348

344349
# add alias
345350
add_library("nano::${LIB_NAME}" ALIAS ${LIB_NAME})
346-
347351
endmacro()

0 commit comments

Comments
 (0)