diff --git a/features/filesystem/littlefs/littlefs/lfs_util.h b/features/filesystem/littlefs/littlefs/lfs_util.h index b05d118f4b..e5175064fe 100644 --- a/features/filesystem/littlefs/littlefs/lfs_util.h +++ b/features/filesystem/littlefs/littlefs/lfs_util.h @@ -37,16 +37,18 @@ // macros must not have side-effects as the macros can be removed for a smaller // code footprint -// Logging functions #ifdef __MBED__ #include "mbed_debug.h" +#include "mbed_assert.h" #else -#define MBED_LFS_ENABLE_INFO false -#define MBED_LFS_ENABLE_DEBUG true -#define MBED_LFS_ENABLE_WARN true -#define MBED_LFS_ENABLE_ERROR true +#define MBED_LFS_ENABLE_INFO false +#define MBED_LFS_ENABLE_DEBUG true +#define MBED_LFS_ENABLE_WARN true +#define MBED_LFS_ENABLE_ERROR true +#define MBED_LFS_ENABLE_ASSERT true #endif +// Logging functions #if !defined(LFS_NO_INFO) && MBED_LFS_ENABLE_INFO #define LFS_INFO(fmt, ...) printf("lfs info:%d: " fmt "\n", __LINE__, __VA_ARGS__) #elif !defined(LFS_NO_INFO) && !defined(MBED_LFS_ENABLE_INFO) @@ -80,8 +82,10 @@ #endif // Runtime assertions -#ifndef LFS_NO_ASSERT +#if !defined(LFS_NO_ASSERT) && MBED_LFS_ENABLE_ASSERT #define LFS_ASSERT(test) assert(test) +#elif !defined(LFS_NO_ASSERT) && !defined(MBED_LFS_ENABLE_ASSERT) +#define LFS_ASSERT(test) MBED_ASSERT(test) #else #define LFS_ASSERT(test) #endif diff --git a/features/filesystem/littlefs/mbed_lib.json b/features/filesystem/littlefs/mbed_lib.json index bafc549f5c..0924d8aa4e 100644 --- a/features/filesystem/littlefs/mbed_lib.json +++ b/features/filesystem/littlefs/mbed_lib.json @@ -40,6 +40,11 @@ "macro_name": "MBED_LFS_ENABLE_ERROR", "value": null, "help": "Enables error logging, true = enabled, false = disabled, null = disabled only in release builds" + }, + "enable_assert": { + "macro_name": "MBED_LFS_ENABLE_ASSERT", + "value": null, + "help": "Enables asserts, true = enabled, false = disabled, null = disabled only in release builds" } } }