Skip to content

Commit 48691b2

Browse files
committed
Merge branch 'fz-dev' into dev
2 parents 1a4d928 + 3a767c9 commit 48691b2

File tree

4 files changed

+59
-44
lines changed

4 files changed

+59
-44
lines changed

applications/storage/storages/storage_int.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/* When less than LFS_RESERVED_PAGES_COUNT are left free, creation &
1111
* modification of non-dot files is restricted */
12-
#define LFS_RESERVED_PAGES_COUNT 5
12+
#define LFS_RESERVED_PAGES_COUNT 3
1313

1414
typedef struct {
1515
const size_t start_address;

lib/lfs_config.h

+56-41
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@
55
#ifdef FURI_NDEBUG
66
#define LFS_NO_ASSERT
77
#define LFS_ASSERT(x)
8-
#else
8+
#else
99
#define LFS_ASSERT furi_assert
1010
#endif
1111

1212
#define LFS_TAG "Lfs"
1313

14+
#ifdef FURI_LFS_DEBUG
1415
#define LFS_TRACE(...) FURI_LOG_T(LFS_TAG, __VA_ARGS__);
1516

1617
#define LFS_DEBUG(...) FURI_LOG_D(LFS_TAG, __VA_ARGS__);
18+
#else
19+
#define LFS_TRACE(...)
20+
21+
#define LFS_DEBUG(...)
22+
#endif // FURI_LFS_DEBUG
1723

1824
#define LFS_WARN(...) FURI_LOG_W(LFS_TAG, __VA_ARGS__);
1925

2026
#define LFS_ERROR(...) FURI_LOG_E(LFS_TAG, __VA_ARGS__);
2127

22-
2328
// Because crc
2429
#undef LFS_CONFIG
2530

@@ -35,16 +40,13 @@
3540
#ifndef LFS_NO_ASSERT
3641
#include <assert.h>
3742
#endif
38-
#if !defined(LFS_NO_DEBUG) || \
39-
!defined(LFS_NO_WARN) || \
40-
!defined(LFS_NO_ERROR) || \
41-
defined(LFS_YES_TRACE)
43+
#if !defined(LFS_NO_DEBUG) || !defined(LFS_NO_WARN) || !defined(LFS_NO_ERROR) || \
44+
defined(LFS_YES_TRACE)
4245
#include <stdio.h>
4346
#endif
4447

4548
#ifdef __cplusplus
46-
extern "C"
47-
{
49+
extern "C" {
4850
#endif
4951

5052
// Builtin functions, these may be replaced by more efficient
@@ -66,21 +68,29 @@ static inline uint32_t lfs_aligndown(uint32_t a, uint32_t alignment) {
6668
}
6769

6870
static inline uint32_t lfs_alignup(uint32_t a, uint32_t alignment) {
69-
return lfs_aligndown(a + alignment-1, alignment);
71+
return lfs_aligndown(a + alignment - 1, alignment);
7072
}
7173

7274
// Find the smallest power of 2 greater than or equal to a
7375
static inline uint32_t lfs_npw2(uint32_t a) {
7476
#if !defined(LFS_NO_INTRINSICS) && (defined(__GNUC__) || defined(__CC_ARM))
75-
return 32 - __builtin_clz(a-1);
77+
return 32 - __builtin_clz(a - 1);
7678
#else
7779
uint32_t r = 0;
7880
uint32_t s;
7981
a -= 1;
80-
s = (a > 0xffff) << 4; a >>= s; r |= s;
81-
s = (a > 0xff ) << 3; a >>= s; r |= s;
82-
s = (a > 0xf ) << 2; a >>= s; r |= s;
83-
s = (a > 0x3 ) << 1; a >>= s; r |= s;
82+
s = (a > 0xffff) << 4;
83+
a >>= s;
84+
r |= s;
85+
s = (a > 0xff) << 3;
86+
a >>= s;
87+
r |= s;
88+
s = (a > 0xf) << 2;
89+
a >>= s;
90+
r |= s;
91+
s = (a > 0x3) << 1;
92+
a >>= s;
93+
r |= s;
8494
return (r | (a >> 1)) + 1;
8595
#endif
8696
}
@@ -114,20 +124,23 @@ static inline int lfs_scmp(uint32_t a, uint32_t b) {
114124

115125
// Convert between 32-bit little-endian and native order
116126
static inline uint32_t lfs_fromle32(uint32_t a) {
117-
#if !defined(LFS_NO_INTRINSICS) && ( \
118-
(defined( BYTE_ORDER ) && defined( ORDER_LITTLE_ENDIAN ) && BYTE_ORDER == ORDER_LITTLE_ENDIAN ) || \
119-
(defined(__BYTE_ORDER ) && defined(__ORDER_LITTLE_ENDIAN ) && __BYTE_ORDER == __ORDER_LITTLE_ENDIAN ) || \
120-
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
127+
#if !defined(LFS_NO_INTRINSICS) && \
128+
((defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \
129+
BYTE_ORDER == ORDER_LITTLE_ENDIAN) || \
130+
(defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) && \
131+
__BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \
132+
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
133+
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
121134
return a;
122-
#elif !defined(LFS_NO_INTRINSICS) && ( \
123-
(defined( BYTE_ORDER ) && defined( ORDER_BIG_ENDIAN ) && BYTE_ORDER == ORDER_BIG_ENDIAN ) || \
124-
(defined(__BYTE_ORDER ) && defined(__ORDER_BIG_ENDIAN ) && __BYTE_ORDER == __ORDER_BIG_ENDIAN ) || \
125-
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
135+
#elif !defined(LFS_NO_INTRINSICS) && \
136+
((defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && BYTE_ORDER == ORDER_BIG_ENDIAN) || \
137+
(defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) && \
138+
__BYTE_ORDER == __ORDER_BIG_ENDIAN) || \
139+
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
140+
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
126141
return __builtin_bswap32(a);
127142
#else
128-
return (((uint8_t*)&a)[0] << 0) |
129-
(((uint8_t*)&a)[1] << 8) |
130-
(((uint8_t*)&a)[2] << 16) |
143+
return (((uint8_t*)&a)[0] << 0) | (((uint8_t*)&a)[1] << 8) | (((uint8_t*)&a)[2] << 16) |
131144
(((uint8_t*)&a)[3] << 24);
132145
#endif
133146
}
@@ -138,21 +151,24 @@ static inline uint32_t lfs_tole32(uint32_t a) {
138151

139152
// Convert between 32-bit big-endian and native order
140153
static inline uint32_t lfs_frombe32(uint32_t a) {
141-
#if !defined(LFS_NO_INTRINSICS) && ( \
142-
(defined( BYTE_ORDER ) && defined( ORDER_LITTLE_ENDIAN ) && BYTE_ORDER == ORDER_LITTLE_ENDIAN ) || \
143-
(defined(__BYTE_ORDER ) && defined(__ORDER_LITTLE_ENDIAN ) && __BYTE_ORDER == __ORDER_LITTLE_ENDIAN ) || \
144-
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
154+
#if !defined(LFS_NO_INTRINSICS) && \
155+
((defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \
156+
BYTE_ORDER == ORDER_LITTLE_ENDIAN) || \
157+
(defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) && \
158+
__BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \
159+
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
160+
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
145161
return __builtin_bswap32(a);
146-
#elif !defined(LFS_NO_INTRINSICS) && ( \
147-
(defined( BYTE_ORDER ) && defined( ORDER_BIG_ENDIAN ) && BYTE_ORDER == ORDER_BIG_ENDIAN ) || \
148-
(defined(__BYTE_ORDER ) && defined(__ORDER_BIG_ENDIAN ) && __BYTE_ORDER == __ORDER_BIG_ENDIAN ) || \
149-
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
162+
#elif !defined(LFS_NO_INTRINSICS) && \
163+
((defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && BYTE_ORDER == ORDER_BIG_ENDIAN) || \
164+
(defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) && \
165+
__BYTE_ORDER == __ORDER_BIG_ENDIAN) || \
166+
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
167+
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
150168
return a;
151169
#else
152-
return (((uint8_t*)&a)[0] << 24) |
153-
(((uint8_t*)&a)[1] << 16) |
154-
(((uint8_t*)&a)[2] << 8) |
155-
(((uint8_t*)&a)[3] << 0);
170+
return (((uint8_t*)&a)[0] << 24) | (((uint8_t*)&a)[1] << 16) | (((uint8_t*)&a)[2] << 8) |
171+
(((uint8_t*)&a)[3] << 0);
156172
#endif
157173
}
158174

@@ -161,11 +177,11 @@ static inline uint32_t lfs_tobe32(uint32_t a) {
161177
}
162178

163179
// Calculate CRC-32 with polynomial = 0x04c11db7
164-
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size);
180+
uint32_t lfs_crc(uint32_t crc, const void* buffer, size_t size);
165181

166182
// Allocate memory, only used if buffers are not provided to littlefs
167183
// Note, memory must be 64-bit aligned
168-
static inline void *lfs_malloc(size_t size) {
184+
static inline void* lfs_malloc(size_t size) {
169185
#ifndef LFS_NO_MALLOC
170186
return malloc(size);
171187
#else
@@ -175,15 +191,14 @@ static inline void *lfs_malloc(size_t size) {
175191
}
176192

177193
// Deallocate memory, only used if buffers are not provided to littlefs
178-
static inline void lfs_free(void *p) {
194+
static inline void lfs_free(void* p) {
179195
#ifndef LFS_NO_MALLOC
180196
free(p);
181197
#else
182198
(void)p;
183199
#endif
184200
}
185201

186-
187202
#ifdef __cplusplus
188203
} /* extern "C" */
189204
#endif

lib/update_util/update_operation.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define UPDATE_ROOT_DIR EXT_PATH("update")
1313

1414
/* Need at least 4 free LFS pages before update */
15-
#define UPDATE_MIN_INT_FREE_SPACE 4 * 4 * 1024
15+
#define UPDATE_MIN_INT_FREE_SPACE 2 * 4 * 1024
1616

1717
static const char* update_prepare_result_descr[] = {
1818
[UpdatePrepareResultOK] = "OK",

0 commit comments

Comments
 (0)