You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also reset the board to see the data persist across boots:
120
120
121
-
```
121
+
```commandline
122
122
--- Block device geometry ---
123
123
read_size: 1 B
124
124
program_size: 1 B
@@ -153,12 +153,12 @@ If you have problems, you can review the [documentation](https://os.mbed.com/doc
153
153
for suggestions on what could be wrong and how to fix it.
154
154
155
155
## Changing the block device
156
+
Mbed-OS supports a variety of block device types, more information on supported devices can be found [here](https://os.mbed.com/docs/mbed-os/latest/apis/data-storage.html#Default-BlockDevice-configuration).
156
157
157
-
In Mbed OS, a C++ classes that inherits from the [BlockDevice](https://os.mbed.com/docs/latest/reference/storage.html#block-devices)
158
-
interface represents each block device. You can change the filesystem in the
159
-
example by changing the class declared in main.cpp.
158
+
Each device is represented by a C++ class that inherits from the interface class [BlockDevice](https://os.mbed.com/docs/mbed-os/latest/apis/blockdevice-apis.html). These classes take their default configuration from the component configuration file. This may be found in `/mbed-os/storage/blockdevice/` under the path corresponding to the block device type—for example [mbed_lib.json](https://github.com/ARMmbed/mbed-os/blob/master/storage/blockdevice/COMPONENT_SPIF/mbed_lib.json).
160
159
161
-
```diff
160
+
In this example, you can determine which block device is used by modifying the type of `bd` in main.cpp. For instance, if instead you wanted to use a SPIF block device you would declare `bd` as an SPIFBlockDevice instance.
161
+
```diff
162
162
-SPIFBlockDevice bd(
163
163
- MBED_CONF_SPIF_DRIVER_SPI_MOSI,
164
164
- MBED_CONF_SPIF_DRIVER_SPI_MISO,
@@ -170,133 +170,28 @@ example by changing the class declared in main.cpp.
170
170
+ MBED_CONF_SD_SPI_CLK,
171
171
+ MBED_CONF_SD_SPI_CS);
172
172
```
173
-
174
-
**Note:** Most block devices require pin assignments. Double check that the
175
-
pins in `<driver>/mbed_lib.json` are correct. For example, to change the pins for the SD driver, open `sd-driver/config/mbed_lib.json`, and change your target platform to the correct pin-out in the `target_overrides` configuration.
176
-
177
-
Starting mbed-os 5.10 the SD, SPIF, DATAFLASH and QSPIF block devices are components under mbed-os. In order to add a component to the application use the "components_add" `target_overrides` configuration:
178
-
173
+
You may need to make modifications to the application configuration file if you're using a physical storage device that isn't included in your target's default configuration (check in `targets.json` for this). To do this, add your physical storage device as a component in `mbed_app.json` as follows:
174
+
```json
175
+
"target_overrides": {
176
+
"K64F": {
177
+
"target.components_add": ["SPIF"],
178
+
}
179
+
}
179
180
```
181
+
You can also modify the pin assignments for your component as follows:
182
+
```json
180
183
"target_overrides": {
181
-
...
182
-
"NUCLEO_F429ZI": {
183
-
"components_add": ["SPIF"],
184
-
"SPI_MOSI": "PC_12",
185
-
"SPI_MISO": "PC_11",
186
-
"SPI_CLK": "PC_10",
187
-
"SPI_CS": "PA_15"
188
-
},
189
-
...
184
+
"K64F": {
185
+
"target.components_add": ["SPIF"],
186
+
"spif-driver.SPI_MOSI": "PC_12",
187
+
"spif-driver.SPI_MISO": "PC_11",
188
+
"spif-driver.SPI_CLK": "PC_10",
189
+
"spif-driver.SPI_CS": "PA_15"
190
+
}
190
191
}
191
192
```
192
-
193
-
The components_add param can be "SPIF", "SD" , "DATAFLASH" or "QSPIF" depends on the block devices you need.
194
-
195
-
Mbed OS has several options for the block device:
196
-
197
-
-**SPIFBlockDevice** - Block device driver for NOR-based SPI flash devices that
198
-
support SFDP. NOR-based SPI flash supports byte-sized read and writes, with an
199
-
erase size of about 4kbytes. An erase sets a block to all 1s, with successive
200
-
writes clearing set bits.
201
-
202
-
```cpp
203
-
SPIFBlockDevice bd(
204
-
MBED_CONF_SPIF_DRIVER_SPI_MOSI,
205
-
MBED_CONF_SPIF_DRIVER_SPI_MISO,
206
-
MBED_CONF_SPIF_DRIVER_SPI_CLK,
207
-
MBED_CONF_SPIF_DRIVER_SPI_CS);
208
-
```
209
-
210
-
- **QSPIFBlockDevice** - Block device driver for NOR-based Quad SPI flash devices that
211
-
support SFDP, with QUAD SPI bus support for 4 bits per cycle (4 times the speed of standard SPI)
212
-
213
-
``` cpp
214
-
QSPIFBlockDevice bd(
215
-
QSPI_FLASH1_IO0,
216
-
QSPI_FLASH1_IO1,
217
-
QSPI_FLASH1_IO2,
218
-
QSPI_FLASH1_IO3,
219
-
QSPI_FLASH1_SCK,
220
-
QSPI_FLASH1_CSN,
221
-
QSPIF_POLARITY_MODE_0,
222
-
MBED_CONF_QSPIF_QSPI_FREQ);
223
-
```
224
-
225
-
-**DataFlashBlockDevice** - Block device driver for NOR-based SPI flash devices
226
-
that support the DataFlash protocol, such as the Adesto AT45DB series of
227
-
devices. DataFlash is a memory protocol that combines flash with SRAM buffers
228
-
for a programming interface. DataFlash supports byte-sized read and writes, with
229
-
an erase size of about 528 bytes or sometimes 1056 bytes. DataFlash provides
230
-
erase sizes with an extra 16 bytes for error correction codes (ECC), so a flash
231
-
translation layer (FTL) may still present 512 byte erase sizes.
232
-
233
-
```cpp
234
-
DataFlashBlockDevice bd(
235
-
MBED_CONF_DATAFLASH_SPI_MOSI,
236
-
MBED_CONF_DATAFLASH_SPI_MISO,
237
-
MBED_CONF_DATAFLASH_SPI_CLK,
238
-
MBED_CONF_DATAFLASH_SPI_CS);
239
-
```
240
-
241
-
- **SDBlockDevice** - Block device driver for SD cards and eMMC memory chips. SD
242
-
cards or eMMC chips offer a full FTL layer on top of NAND flash. This makes the
243
-
storage well-suited for systems that require a about 1GB of memory.
244
-
Additionally, SD cards are a popular form of portable storage. They are useful
245
-
if you want to store data that you can access from a PC.
Mbed OS comes with support for storing partitions on disk with a Master Boot
278
-
Record (MBR). The MBRBlockDevice provides this functionality and supports
279
-
creating partitions at runtime or using preformatted partitions configured
280
-
separately from outside the application.
281
-
282
-
- **ReadOnlyBlockDevice** - With the read-only block device, you can wrap a
283
-
block device in a read-only layer, ensuring that user of the block device does
284
-
not modify the storage.
285
-
286
-
- **ProfilingBlockDevice** - With the profiling block device, you can profile
287
-
the quantity of erase, program and read operations that are incurred on a
288
-
block device.
289
-
290
-
- **ObservingBlockDevice** - The observing block device grants the user the
291
-
ability to register a callback on block device operations. You can use this to
292
-
inspect the state of the block device, log different metrics or perform some
293
-
other operation.
294
-
295
-
- **ExhaustibleBlockDevice** - Useful for evaluating how file systems respond to
296
-
wear, the exhaustible block device simulates wear on another form of storage.
297
-
You can configure it to expire blocks as necessary.
298
-
299
-
## Tested configurations
193
+
Alternatively, you may use the system's default block device `BlockDevice *bd = BlockDevice::get_default_instance()` but this will require more code changes to the example.
0 commit comments