@@ -44,11 +44,6 @@ const spi_pinmap_t static_spi_pinmap = get_spi_pinmap(MBED_CONF_SD_SPI_MOSI, MBE
44
44
#endif
45
45
#endif
46
46
47
- #if MCUBOOT_AS_ENVIE
48
- static BlockDevice *default_bd = NULL ;
49
- static MBRBlockDevice *logical_bd = NULL ;
50
- #endif
51
-
52
47
/*
53
48
* MCUBOOT_AS_ENVIE -> Secondary Block device defined by getOTAData [SDCARD, QSPI] Internal flash not supported
54
49
* -> !!WARNING!! Scratch Block device by default on QSPI + MBR + FAT
@@ -66,35 +61,36 @@ BlockDevice *BlockDevice::get_default_instance()
66
61
storageType storage_type;
67
62
uint32_t data_offset;
68
63
uint32_t update_size;
69
- BlockDevice *raw_bd = NULL ;
70
64
71
65
getOTAData (&storage_type, &data_offset, &update_size);
72
66
73
67
// if (storage_type & INTERNAL_FLASH_FLAG) {
74
68
// if (storage_type & (FATFS_FLAG | LITTLEFS_FLAG)) {
75
69
// // have a filesystem, use offset as partition start
76
70
// static FlashIAPBlockDevice flashIAP_bd(0x8000000 + data_offset, 2 * 1024 * 1024 - data_offset);
77
- // raw_bd = &flashIAP_bd;
71
+ // return &flashIAP_bd;
78
72
// } else {
79
73
// // raw device, no offset
80
74
// static FlashIAPBlockDevice flashIAP_bd(0x8000000, 2 * 1024 * 1024);
81
- // raw_bd = &flashIAP_bd;
75
+ // return &flashIAP_bd;
82
76
// }
83
77
// }
84
78
85
79
#if MCUBOOT_ENVIE_SDCARD
86
80
if (storage_type & SDCARD_FLAG) {
87
81
static SDMMCBlockDevice SDMMC_bd;
88
- raw_bd = &SDMMC_bd;
82
+ BOOT_LOG_INF (" SDMMCBlockDevice" );
83
+ return &SDMMC_bd;
89
84
}
90
85
#endif
91
86
92
87
if (storage_type & QSPI_FLASH_FLAG) {
93
88
static QSPIFBlockDevice QSPIF_bd (PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000 );
94
- raw_bd = &QSPIF_bd;
89
+ BOOT_LOG_INF (" QSPIFBlockDevice" );
90
+ return &QSPIF_bd;
95
91
}
96
92
97
- return raw_bd ;
93
+ return NULL ;
98
94
#else // MCUBOOT_AS_ENVIE
99
95
#if COMPONENT_SPIF
100
96
@@ -144,7 +140,8 @@ mbed::BlockDevice* get_secondary_bd(void) {
144
140
// In this case, our flash is much larger than a single image so
145
141
// slice it into the size of an image slot
146
142
#if MCUBOOT_AS_ENVIE
147
- default_bd = mbed::BlockDevice::get_default_instance ();
143
+ mbed::BlockDevice* default_bd = mbed::BlockDevice::get_default_instance ();
144
+ mbed::BlockDevice* logical_bd;
148
145
storageType storage_type;
149
146
uint32_t data_offset;
150
147
uint32_t update_size;
@@ -175,7 +172,7 @@ mbed::BlockDevice* get_secondary_bd(void) {
175
172
}
176
173
#endif
177
174
178
- static mbed::FileBlockDevice file_bd (logical_bd, " /secondary/update.bin" , " rb+" , update_size);
175
+ static mbed::FileBlockDevice file_bd (" /secondary/update.bin" , " rb+" , update_size);
179
176
return &file_bd;
180
177
} else {
181
178
int err = default_bd->init ();
@@ -200,7 +197,7 @@ mbed::BlockDevice* get_secondary_bd(void) {
200
197
}
201
198
#endif
202
199
203
- static mbed::FileBlockDevice file_bd (default_bd, " /secondary/update.bin" , " rb+" , update_size);
200
+ static mbed::FileBlockDevice file_bd (" /secondary/update.bin" , " rb+" , update_size);
204
201
return &file_bd;
205
202
}
206
203
@@ -223,7 +220,7 @@ mbed::BlockDevice* get_secondary_bd(void) {
223
220
if (err) {
224
221
BOOT_LOG_ERR (" Error mounting fatfs on secondary mbr device" );
225
222
}
226
- static mbed::FileBlockDevice file_bd (&mbr_bd, " /secondary/update.bin" , " rb+" , MCUBOOT_SLOT_SIZE);
223
+ static mbed::FileBlockDevice file_bd (" /secondary/update.bin" , " rb+" , MCUBOOT_SLOT_SIZE);
227
224
return &file_bd;
228
225
#endif
229
226
#endif // MCUBOOT_AS_ENVIE
@@ -248,9 +245,9 @@ mbed::BlockDevice* get_scratch_bd(void) {
248
245
*
249
246
*/
250
247
251
- if (!(storage_type & QSPI_FLASH_FLAG)) {
252
- default_bd = new QSPIFBlockDevice (PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000 );
253
- logical_bd = new MBRBlockDevice (default_bd, 2 );
248
+ // if(!(storage_type & QSPI_FLASH_FLAG)) {
249
+ mbed::BlockDevice* default_bd = new QSPIFBlockDevice (PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000 );
250
+ mbed::BlockDevice* logical_bd = new MBRBlockDevice (default_bd, 2 );
254
251
255
252
int err = logical_bd->init ();
256
253
if (err) {
@@ -262,9 +259,9 @@ mbed::BlockDevice* get_scratch_bd(void) {
262
259
if (err) {
263
260
BOOT_LOG_ERR (" Error mounting fatfs on scratch mbr device" );
264
261
}
265
- }
262
+ // }
266
263
267
- static mbed::FileBlockDevice file_bd (logical_bd, " /scratch/scratch.bin" , " rb+" , MCUBOOT_SCRATCH_SIZE);
264
+ static mbed::FileBlockDevice file_bd (" /scratch/scratch.bin" , " rb+" , MCUBOOT_SCRATCH_SIZE);
268
265
return &file_bd;
269
266
#else
270
267
#if !defined MCUBOOT_USE_FILE_BD
@@ -284,7 +281,7 @@ mbed::BlockDevice* get_scratch_bd(void) {
284
281
if (err) {
285
282
BOOT_LOG_ERR (" Error mounting fatfs on scratch mbr device" );
286
283
}
287
- static mbed::FileBlockDevice file_bd (&mbr_bd, " /scratch/scratch.bin" , " rb+" , MCUBOOT_SCRATCH_SIZE);
284
+ static mbed::FileBlockDevice file_bd (" /scratch/scratch.bin" , " rb+" , MCUBOOT_SCRATCH_SIZE);
288
285
return &file_bd;
289
286
#endif
290
287
#endif // MCUBOOT_AS_ENVIE
0 commit comments