Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use LFS_DEFINES if available #15150

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CONFIG_EXAMPLES_ALARM=y
CONFIG_EXAMPLES_ALARM_STACKSIZE=2048
CONFIG_FS_LITTLEFS=y
CONFIG_FS_LITTLEFS_MULTI_VERSION=y
CONFIG_FS_LITTLEFS_VERSION="v2.9.3"
CONFIG_FS_LITTLEFS_VERSION="v2.10.0"
xiaoxiang781216 marked this conversation as resolved.
Show resolved Hide resolved
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBM=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CONFIG_EXAMPLES_RANDOM=y
CONFIG_FS_LARGEFILE=y
CONFIG_FS_LITTLEFS=y
CONFIG_FS_LITTLEFS_MULTI_VERSION=y
CONFIG_FS_LITTLEFS_VERSION="v2.9.3"
CONFIG_FS_LITTLEFS_VERSION="v2.10.0"
CONFIG_FS_PROCFS=y
CONFIG_HOST_MACOS=y
CONFIG_IDLETHREAD_STACKSIZE=3072
Expand Down
22 changes: 12 additions & 10 deletions fs/littlefs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ if(CONFIG_FS_LITTLEFS)

target_compile_definitions(
fs
PRIVATE -DLFS_TRACE=finfo
-DLFS_DEBUG=finfo
-DLFS_WARN=fwarn
-DLFS_ERROR=ferr
-DLFS_ASSERT=DEBUGASSERT
-DLFS_CONFIG=${CMAKE_CURRENT_LIST_DIR}/lfs_vfs.h
-DLFS_NAME_MAX=${CONFIG_FS_LITTLEFS_NAME_MAX}
-DLFS_FILE_MAX=${CONFIG_FS_LITTLEFS_FILE_MAX}
-DLFS_ATTR_MAX=${CONFIG_FS_LITTLEFS_ATTR_MAX}
$<$<BOOL:${CONFIG_FS_LITTLEFS_MULTI_VERSION}>:-DLFS_MULTIVERSION>)
PRIVATE
xiaoxiang781216 marked this conversation as resolved.
Show resolved Hide resolved
$<$<NOT:$<BOOL:${CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES}>>:-DLFS_TRACE=finfo>
$<$<NOT:$<BOOL:${CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES}>>:-DLFS_DEBUG=finfo>
$<$<NOT:$<BOOL:${CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES}>>:-DLFS_WARN=fwarn>
$<$<NOT:$<BOOL:${CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES}>>:-DLFS_ERROR=ferr>
$<$<NOT:$<BOOL:${CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES}>>:-DLFS_ASSERT=DEBUGASSERT>
$<$<NOT:$<BOOL:${CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES}>>:-DLFS_CONFIG=${CMAKE_CURRENT_LIST_DIR}/lfs_vfs.h>
$<$<BOOL:${CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES}>:-DLFS_DEFINES=${CMAKE_CURRENT_LIST_DIR}/lfs_nuttx_defines.h>
-DLFS_NAME_MAX=${CONFIG_FS_LITTLEFS_NAME_MAX}
-DLFS_FILE_MAX=${CONFIG_FS_LITTLEFS_FILE_MAX}
-DLFS_ATTR_MAX=${CONFIG_FS_LITTLEFS_ATTR_MAX}
$<$<BOOL:${CONFIG_FS_LITTLEFS_MULTI_VERSION}>:-DLFS_MULTIVERSION>)

# Note: the littlefs upstream doesn't seems to care -Wshadow cf.
# https://github.com/littlefs-project/littlefs/pull/873
Expand Down
12 changes: 12 additions & 0 deletions fs/littlefs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ config FS_LITTLEFS_LOCAL_PATCHES
patches for LITTLEFS.
This is NOT expected to be tweaked directly by users.

config FS_LITTLEFS_HAS_LFS_DEFINES
xiaoxiang781216 marked this conversation as resolved.
Show resolved Hide resolved
bool "Use LFS_DEFINES (available for littlefs >=2.10.0)"
depends on !FS_LITTLEFS_LOCAL_PATCHES
default y
---help---
Set this y if you are using littlefs versions which supports
LFS_DEFINES. (that is, 2.10.0 and later)
Otherwise, set this n.

See the littlefs 2.10.0 release notes about what LFS_DEFINES is.
https://github.com/littlefs-project/littlefs/releases/tag/v2.10.0

config FS_LITTLEFS_ATTR_UPDATE
bool "LITTLEFS update attributes"
depends on FS_LITTLEFS_ATTR_MAX > 0
Expand Down
5 changes: 5 additions & 0 deletions fs/littlefs/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ VPATH += :littlefs/littlefs
# cf. https://github.com/littlefs-project/littlefs/pull/873
CFLAGS += -Wno-shadow

ifeq ($(CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES),y)
CFLAGS += -DLFS_DEFINES=../lfs_nuttx_defines.h
else
CFLAGS += -DLFS_TRACE=finfo
CFLAGS += -DLFS_DEBUG=finfo
CFLAGS += -DLFS_WARN=fwarn
CFLAGS += -DLFS_ERROR=ferr
CFLAGS += -DLFS_ASSERT=DEBUGASSERT
CFLAGS += -DLFS_CONFIG=../lfs_vfs.h
endif

CFLAGS += -DLFS_NAME_MAX=$(CONFIG_FS_LITTLEFS_NAME_MAX)
CFLAGS += -DLFS_FILE_MAX=$(CONFIG_FS_LITTLEFS_FILE_MAX)
CFLAGS += -DLFS_ATTR_MAX=$(CONFIG_FS_LITTLEFS_ATTR_MAX)
Expand Down
43 changes: 43 additions & 0 deletions fs/littlefs/lfs_nuttx_defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/****************************************************************************
* fs/littlefs/lfs_nuttx_defines.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

xiaoxiang781216 marked this conversation as resolved.
Show resolved Hide resolved
/****************************************************************************
* Included Files
****************************************************************************/

#include <debug.h>

#include "fs_heap.h"

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define LFS_TRACE finfo
#define LFS_DEBUG finfo
#define LFS_WARN fwarn
#define LFS_ERROR ferr

#define LFS_ASSERT DEBUGASSERT

#define LFS_MALLOC(sz) fs_heap_malloc(sz)
#define LFS_FREE(p) fs_heap_free(p)
Loading