@@ -40,8 +40,8 @@ __asm__(
40
40
"init_data_end:\n"
41
41
);
42
42
extern const char _irom0_text_start [], _irom0_text_end [], _flash_used_end [];
43
- #define IROM0_SIZE (_irom0_text_end - _irom0_text_start)
44
43
44
+ #define IROM0_SIZE (_irom0_text_end - _irom0_text_start)
45
45
46
46
#define PRE_INIT_TEXT_ATTR __attribute__((section(".p3.pre_init")))
47
47
#define IROM_PTABLE_ATTR __attribute__((section(".irom0.ptable")))
@@ -60,9 +60,14 @@ extern const char _irom0_text_start[], _irom0_text_end[], _flash_used_end[];
60
60
#define NODEMCU_PARTITION_LFS PLATFORM_PARTITION(NODEMCU_LFS0_PARTITION)
61
61
#define NODEMCU_PARTITION_SPIFFS PLATFORM_PARTITION(NODEMCU_SPIFFS0_PARTITION)
62
62
63
+ #define RF_CAL_SIZE 0x1000
64
+ #define PHY_DATA_SIZE 0x1000
65
+ #define SYSTEM_PARAMETER_SIZE 0x3000
66
+
63
67
#define MAX_PARTITIONS 20
64
68
#define WORDSIZE sizeof(uint32_t)
65
69
#define PTABLE_SIZE 7 /** THIS MUST BE MATCHED TO NO OF PT ENTRIES BELOW **/
70
+
66
71
struct defaultpt {
67
72
platform_rcr_t hdr ;
68
73
partition_item_t pt [PTABLE_SIZE + 1 ]; // the +! is for the endmarker
@@ -78,12 +83,12 @@ static const struct defaultpt rompt IROM_PTABLE_ATTR USED_ATTR = {
78
83
.id = PLATFORM_RCR_PT },
79
84
.pt = {
80
85
{ NODEMCU_PARTITION_EAGLEROM , 0x00000 , 0x0B000 },
81
- { SYSTEM_PARTITION_RF_CAL , 0x0B000 , 0x1000 },
82
- { SYSTEM_PARTITION_PHY_DATA , 0x0C000 , 0x1000 },
83
- { SYSTEM_PARTITION_SYSTEM_PARAMETER , 0x0D000 , 0x3000 },
84
- { NODEMCU_PARTITION_IROM0TEXT , 0x10000 , 0x0000 },
85
- { NODEMCU_PARTITION_LFS , 0x0 , LUA_FLASH_STORE },
86
- { NODEMCU_PARTITION_SPIFFS , 0x0 , SPIFFS_MAX_FILESYSTEM_SIZE },
86
+ { SYSTEM_PARTITION_RF_CAL , 0x0D000 , RF_CAL_SIZE },
87
+ { SYSTEM_PARTITION_PHY_DATA , 0x0F000 , PHY_DATA_SIZE },
88
+ { NODEMCU_PARTITION_IROM0TEXT , 0x10000 , 0x0000 },
89
+ { NODEMCU_PARTITION_LFS , 0x0 , LUA_FLASH_STORE },
90
+ { NODEMCU_PARTITION_SPIFFS , 0x0 , SPIFFS_MAX_FILESYSTEM_SIZE },
91
+ { SYSTEM_PARTITION_SYSTEM_PARAMETER , 0x0 , SYSTEM_PARAMETER_SIZE },
87
92
{0 ,(uint32_t ) & _irom0_text_end ,0 }
88
93
}
89
94
};
@@ -161,7 +166,6 @@ void user_pre_init(void) {
161
166
}
162
167
163
168
// Now register the partition and return
164
- // for (i=0;i<n;i++) os_printf("P%d: %3d %06x %06x\n", i, pt[i].type, pt[i].addr, pt[i].size);
165
169
if ( fs_size_code > 1 && system_partition_table_regist (pt , n , fs_size_code )) {
166
170
return ;
167
171
}
@@ -230,26 +234,41 @@ static uint32_t first_time_setup(partition_item_t *pt, uint32_t n, uint32_t flas
230
234
p -> addr = last ;
231
235
break ;
232
236
237
+ /*
238
+ * Set up the SPIFFS partition based on some sensible defaults:
239
+ * size == 0 mean no SPIFFS partition.
240
+ * size == ~0 means use all of the available flash for SPIFFS (resp the addr if set).
241
+ * if size > 0 then float the default boundary to 1M if the SPIFFS will fit.
242
+ */
233
243
case NODEMCU_PARTITION_SPIFFS :
234
- if (p -> size == ~0x0 && p -> addr == 0 ) {
235
- // This allocate all the remaining flash to SPIFFS
236
- p -> addr = last ;
237
- p -> size = flash_size - last ;
238
- } else if (p -> size == ~0x0 ) {
239
- p -> size = flash_size - p -> addr ;
240
- } else if (p -> addr == 0 ) {
241
- // if the is addr not specified then start SPIFFS at 1Mb
242
- // boundary if the size will fit otherwise make it consecutive
243
- // to the previous partition.
244
- p -> addr = (p -> size <= flash_size - 0x100000 ) ? 0x100000 : last ;
244
+ if (p -> size == ~0x0 ) { /* Maximum SPIFFS partition */
245
+ if (p -> addr == 0 )
246
+ p -> addr = last ;
247
+ p -> size = flash_size - SYSTEM_PARAMETER_SIZE - last ;
248
+ } else if (p -> size > 0x0 ) { /* Explicit SPIFFS size */
249
+ if (p -> addr < last ) // SPIFFS can't overlap the previous region;
250
+ p -> addr = 0 ;
251
+ if (p -> addr == 0 )
252
+ p -> addr = (p -> size <= flash_size - SYSTEM_PARAMETER_SIZE - 0x100000 ) ?
253
+ 0x100000 : last ;
245
254
}
255
+ /* else p->size == 0 No SPIFFS partition */
256
+ break ;
257
+
258
+ case SYSTEM_PARTITION_SYSTEM_PARAMETER :
259
+ p -> addr = flash_size - SYSTEM_PARAMETER_SIZE ;
260
+ p -> size = SYSTEM_PARAMETER_SIZE ;
246
261
}
247
262
248
263
if (p -> size == 0 ) {
249
264
// Delete 0-sized partitions as the SDK barfs on these
250
265
newn -- ;
251
266
} else {
252
- // Do consistency tests on the partition
267
+ /*
268
+ * Do consistency tests on the partition. The address and size must
269
+ * be flash sector aligned. Partitions can't overlap, and the last
270
+ * patition must fit within the flash size.
271
+ */
253
272
if (p -> addr & (INTERNAL_FLASH_SECTOR_SIZE - 1 ) ||
254
273
p -> size & (INTERNAL_FLASH_SECTOR_SIZE - 1 ) ||
255
274
p -> addr < last ||
@@ -259,7 +278,6 @@ static uint32_t first_time_setup(partition_item_t *pt, uint32_t n, uint32_t flas
259
278
}
260
279
if (j < i ) // shift the partition down if we have any deleted slots
261
280
pt [j ] = * p ;
262
- //os_printf("Partition %d: %04x %06x %06x\n", j, p->type, p->addr, p->size);
263
281
j ++ ;
264
282
last = p -> addr + p -> size ;
265
283
}
0 commit comments