[FL-2794] Lib: update LFS to v2.5.0, lower update free page limit (#1706)
* Lib: update lfs to v2.5.0 * Storage: set minimum free pages for update on internal storage to 3 * Updater: lower min int free space limit * lfs: disabled debug and trace logs by default Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
		| @@ -9,7 +9,7 @@ | |||||||
|  |  | ||||||
| /* When less than LFS_RESERVED_PAGES_COUNT are left free, creation &  | /* When less than LFS_RESERVED_PAGES_COUNT are left free, creation &  | ||||||
|  * modification of non-dot files is restricted */ |  * modification of non-dot files is restricted */ | ||||||
| #define LFS_RESERVED_PAGES_COUNT 5 | #define LFS_RESERVED_PAGES_COUNT 3 | ||||||
|  |  | ||||||
| typedef struct { | typedef struct { | ||||||
|     const size_t start_address; |     const size_t start_address; | ||||||
|   | |||||||
| @@ -11,15 +11,20 @@ | |||||||
|  |  | ||||||
| #define LFS_TAG "Lfs" | #define LFS_TAG "Lfs" | ||||||
|  |  | ||||||
|  | #ifdef FURI_LFS_DEBUG | ||||||
| #define LFS_TRACE(...) FURI_LOG_T(LFS_TAG, __VA_ARGS__); | #define LFS_TRACE(...) FURI_LOG_T(LFS_TAG, __VA_ARGS__); | ||||||
|  |  | ||||||
| #define LFS_DEBUG(...) FURI_LOG_D(LFS_TAG, __VA_ARGS__); | #define LFS_DEBUG(...) FURI_LOG_D(LFS_TAG, __VA_ARGS__); | ||||||
|  | #else | ||||||
|  | #define LFS_TRACE(...) | ||||||
|  |  | ||||||
|  | #define LFS_DEBUG(...) | ||||||
|  | #endif // FURI_LFS_DEBUG | ||||||
|  |  | ||||||
| #define LFS_WARN(...) FURI_LOG_W(LFS_TAG, __VA_ARGS__); | #define LFS_WARN(...) FURI_LOG_W(LFS_TAG, __VA_ARGS__); | ||||||
|  |  | ||||||
| #define LFS_ERROR(...) FURI_LOG_E(LFS_TAG, __VA_ARGS__); | #define LFS_ERROR(...) FURI_LOG_E(LFS_TAG, __VA_ARGS__); | ||||||
|  |  | ||||||
|  |  | ||||||
| // Because crc | // Because crc | ||||||
| #undef LFS_CONFIG | #undef LFS_CONFIG | ||||||
|  |  | ||||||
| @@ -35,16 +40,13 @@ | |||||||
| #ifndef LFS_NO_ASSERT | #ifndef LFS_NO_ASSERT | ||||||
| #include <assert.h> | #include <assert.h> | ||||||
| #endif | #endif | ||||||
| #if !defined(LFS_NO_DEBUG) || \ | #if !defined(LFS_NO_DEBUG) || !defined(LFS_NO_WARN) || !defined(LFS_NO_ERROR) || \ | ||||||
|         !defined(LFS_NO_WARN) || \ |  | ||||||
|         !defined(LFS_NO_ERROR) || \ |  | ||||||
|     defined(LFS_YES_TRACE) |     defined(LFS_YES_TRACE) | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| extern "C" | extern "C" { | ||||||
| { |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| // Builtin functions, these may be replaced by more efficient | // Builtin functions, these may be replaced by more efficient | ||||||
| @@ -77,10 +79,18 @@ static inline uint32_t lfs_npw2(uint32_t a) { | |||||||
|     uint32_t r = 0; |     uint32_t r = 0; | ||||||
|     uint32_t s; |     uint32_t s; | ||||||
|     a -= 1; |     a -= 1; | ||||||
|     s = (a > 0xffff) << 4; a >>= s; r |= s; |     s = (a > 0xffff) << 4; | ||||||
|     s = (a > 0xff  ) << 3; a >>= s; r |= s; |     a >>= s; | ||||||
|     s = (a > 0xf   ) << 2; a >>= s; r |= s; |     r |= s; | ||||||
|     s = (a > 0x3   ) << 1; a >>= s; r |= s; |     s = (a > 0xff) << 3; | ||||||
|  |     a >>= s; | ||||||
|  |     r |= s; | ||||||
|  |     s = (a > 0xf) << 2; | ||||||
|  |     a >>= s; | ||||||
|  |     r |= s; | ||||||
|  |     s = (a > 0x3) << 1; | ||||||
|  |     a >>= s; | ||||||
|  |     r |= s; | ||||||
|     return (r | (a >> 1)) + 1; |     return (r | (a >> 1)) + 1; | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| @@ -114,20 +124,23 @@ static inline int lfs_scmp(uint32_t a, uint32_t b) { | |||||||
|  |  | ||||||
| // Convert between 32-bit little-endian and native order | // Convert between 32-bit little-endian and native order | ||||||
| static inline uint32_t lfs_fromle32(uint32_t a) { | static inline uint32_t lfs_fromle32(uint32_t a) { | ||||||
| #if !defined(LFS_NO_INTRINSICS) && ( \ | #if !defined(LFS_NO_INTRINSICS) &&                                   \ | ||||||
|     (defined(  BYTE_ORDER  ) && defined(  ORDER_LITTLE_ENDIAN  ) &&   BYTE_ORDER   ==   ORDER_LITTLE_ENDIAN  ) || \ |     ((defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) &&         \ | ||||||
|     (defined(__BYTE_ORDER  ) && defined(__ORDER_LITTLE_ENDIAN  ) && __BYTE_ORDER   == __ORDER_LITTLE_ENDIAN  ) || \ |       BYTE_ORDER == ORDER_LITTLE_ENDIAN) ||                          \ | ||||||
|     (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) |      (defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) &&     \ | ||||||
|  |       __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) ||                      \ | ||||||
|  |      (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ | ||||||
|  |       __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) | ||||||
|     return a; |     return a; | ||||||
| #elif !defined(LFS_NO_INTRINSICS) && ( \ | #elif !defined(LFS_NO_INTRINSICS) &&                                                         \ | ||||||
|     (defined(  BYTE_ORDER  ) && defined(  ORDER_BIG_ENDIAN  ) &&   BYTE_ORDER   ==   ORDER_BIG_ENDIAN  ) || \ |     ((defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && BYTE_ORDER == ORDER_BIG_ENDIAN) || \ | ||||||
|     (defined(__BYTE_ORDER  ) && defined(__ORDER_BIG_ENDIAN  ) && __BYTE_ORDER   == __ORDER_BIG_ENDIAN  ) || \ |      (defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) &&                                \ | ||||||
|     (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) |       __BYTE_ORDER == __ORDER_BIG_ENDIAN) ||                                                 \ | ||||||
|  |      (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) &&                            \ | ||||||
|  |       __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) | ||||||
|     return __builtin_bswap32(a); |     return __builtin_bswap32(a); | ||||||
| #else | #else | ||||||
|     return (((uint8_t*)&a)[0] <<  0) | |     return (((uint8_t*)&a)[0] << 0) | (((uint8_t*)&a)[1] << 8) | (((uint8_t*)&a)[2] << 16) | | ||||||
|            (((uint8_t*)&a)[1] <<  8) | |  | ||||||
|            (((uint8_t*)&a)[2] << 16) | |  | ||||||
|            (((uint8_t*)&a)[3] << 24); |            (((uint8_t*)&a)[3] << 24); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| @@ -138,20 +151,23 @@ static inline uint32_t lfs_tole32(uint32_t a) { | |||||||
|  |  | ||||||
| // Convert between 32-bit big-endian and native order | // Convert between 32-bit big-endian and native order | ||||||
| static inline uint32_t lfs_frombe32(uint32_t a) { | static inline uint32_t lfs_frombe32(uint32_t a) { | ||||||
| #if !defined(LFS_NO_INTRINSICS) && ( \ | #if !defined(LFS_NO_INTRINSICS) &&                                   \ | ||||||
|     (defined(  BYTE_ORDER  ) && defined(  ORDER_LITTLE_ENDIAN  ) &&   BYTE_ORDER   ==   ORDER_LITTLE_ENDIAN  ) || \ |     ((defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) &&         \ | ||||||
|     (defined(__BYTE_ORDER  ) && defined(__ORDER_LITTLE_ENDIAN  ) && __BYTE_ORDER   == __ORDER_LITTLE_ENDIAN  ) || \ |       BYTE_ORDER == ORDER_LITTLE_ENDIAN) ||                          \ | ||||||
|     (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) |      (defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) &&     \ | ||||||
|  |       __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) ||                      \ | ||||||
|  |      (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ | ||||||
|  |       __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) | ||||||
|     return __builtin_bswap32(a); |     return __builtin_bswap32(a); | ||||||
| #elif !defined(LFS_NO_INTRINSICS) && ( \ | #elif !defined(LFS_NO_INTRINSICS) &&                                                         \ | ||||||
|     (defined(  BYTE_ORDER  ) && defined(  ORDER_BIG_ENDIAN  ) &&   BYTE_ORDER   ==   ORDER_BIG_ENDIAN  ) || \ |     ((defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && BYTE_ORDER == ORDER_BIG_ENDIAN) || \ | ||||||
|     (defined(__BYTE_ORDER  ) && defined(__ORDER_BIG_ENDIAN  ) && __BYTE_ORDER   == __ORDER_BIG_ENDIAN  ) || \ |      (defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) &&                                \ | ||||||
|     (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) |       __BYTE_ORDER == __ORDER_BIG_ENDIAN) ||                                                 \ | ||||||
|  |      (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) &&                            \ | ||||||
|  |       __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) | ||||||
|     return a; |     return a; | ||||||
| #else | #else | ||||||
|     return (((uint8_t*)&a)[0] << 24) | |     return (((uint8_t*)&a)[0] << 24) | (((uint8_t*)&a)[1] << 16) | (((uint8_t*)&a)[2] << 8) | | ||||||
|            (((uint8_t*)&a)[1] << 16) | |  | ||||||
|            (((uint8_t*)&a)[2] <<  8) | |  | ||||||
|            (((uint8_t*)&a)[3] << 0); |            (((uint8_t*)&a)[3] << 0); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| @@ -183,7 +199,6 @@ static inline void lfs_free(void *p) { | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } /* extern "C" */ | } /* extern "C" */ | ||||||
| #endif | #endif | ||||||
|   | |||||||
 Submodule lib/littlefs updated: 1863dc7883...40dba4a556
									
								
							| @@ -12,7 +12,7 @@ | |||||||
| #define UPDATE_ROOT_DIR EXT_PATH("update") | #define UPDATE_ROOT_DIR EXT_PATH("update") | ||||||
|  |  | ||||||
| /* Need at least 4 free LFS pages before update */ | /* Need at least 4 free LFS pages before update */ | ||||||
| #define UPDATE_MIN_INT_FREE_SPACE 4 * 4 * 1024 | #define UPDATE_MIN_INT_FREE_SPACE 2 * 4 * 1024 | ||||||
|  |  | ||||||
| static const char* update_prepare_result_descr[] = { | static const char* update_prepare_result_descr[] = { | ||||||
|     [UpdatePrepareResultOK] = "OK", |     [UpdatePrepareResultOK] = "OK", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user