Skip to content

Blockdevice config changes to make it possible to run littlefs filesystem tests #12143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
#include "drivers/SPI.h"
#include "drivers/DigitalOut.h"

#ifndef MBED_CONF_DATAFLASH_SPI_MOSI
#define MBED_CONF_DATAFLASH_SPI_MOSI NC
#endif
#ifndef MBED_CONF_DATAFLASH_SPI_MISO
#define MBED_CONF_DATAFLASH_SPI_MISO NC
#endif
#ifndef MBED_CONF_DATAFLASH_SPI_CLK
#define MBED_CONF_DATAFLASH_SPI_CLK NC
#endif
#ifndef MBED_CONF_DATAFLASH_SPI_CS
#define MBED_CONF_DATAFLASH_SPI_CS NC
#endif
#ifndef MBED_CONF_DATAFLASH_SPI_FREQ
#define MBED_CONF_DATAFLASH_SPI_FREQ 40000000
#endif

/** BlockDevice for DataFlash flash devices
*
Expand Down Expand Up @@ -72,13 +87,14 @@ class DataFlashBlockDevice : public mbed::BlockDevice {
* @param csel SPI chip select pin
* @param nowp GPIO not-write-protect
* @param freq Clock speed of the SPI bus (defaults to 40MHz)
* @param nwp Not-write-protected pin
*/
DataFlashBlockDevice(PinName mosi,
PinName miso,
PinName sclk,
PinName csel,
DataFlashBlockDevice(PinName mosi = MBED_CONF_DATAFLASH_SPI_MOSI,
PinName miso = MBED_CONF_DATAFLASH_SPI_MISO,
PinName sclk = MBED_CONF_DATAFLASH_SPI_CLK,
PinName csel = MBED_CONF_DATAFLASH_SPI_CS,
int freq = MBED_CONF_DATAFLASH_SPI_FREQ,
PinName nowp = NC);
PinName nwp = NC);

/** Initialize a block device
*
Expand Down
36 changes: 33 additions & 3 deletions components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@
#include "drivers/QSPI.h"
#include "features/storage/blockdevice/BlockDevice.h"

#ifndef MBED_CONF_QSPIF_QSPI_IO0
#define MBED_CONF_QSPIF_QSPI_IO0 NC
#endif
#ifndef MBED_CONF_QSPIF_QSPI_IO1
#define MBED_CONF_QSPIF_QSPI_IO1 NC
#endif
#ifndef MBED_CONF_QSPIF_QSPI_IO2
#define MBED_CONF_QSPIF_QSPI_IO2 NC
#endif
#ifndef MBED_CONF_QSPIF_QSPI_IO3
#define MBED_CONF_QSPIF_QSPI_IO3 NC
#endif
#ifndef MBED_CONF_QSPIF_QSPI_SCK
#define MBED_CONF_QSPIF_QSPI_SCK NC
#endif
#ifndef MBED_CONF_QSPIF_QSPI_CSN
#define MBED_CONF_QSPIF_QSPI_CSN NC
#endif
#ifndef MBED_CONF_QSPIF_QSPI_POLARITY_MODE
#define MBED_CONF_QSPIF_QSPI_POLARITY_MODE 0
#endif
#ifndef MBED_CONF_QSPIF_QSPI_FREQ
#define MBED_CONF_QSPIF_QSPI_FREQ 40000000
#endif

/** Enum qspif standard error codes
*
* @enum qspif_bd_error
Expand Down Expand Up @@ -98,10 +123,15 @@ class QSPIFBlockDevice : public mbed::BlockDevice {
* @param clock_mode specifies the QSPI Clock Polarity mode (QSPIF_POLARITY_MODE_0/QSPIF_POLARITY_MODE_1)
* default value = 0
* @param freq Clock frequency of the QSPI bus (defaults to 40MHz)
*
*/
QSPIFBlockDevice(PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, PinName csel,
int clock_mode, int freq = MBED_CONF_QSPIF_QSPI_FREQ);
QSPIFBlockDevice(PinName io0 = MBED_CONF_QSPIF_QSPI_IO0,
PinName io1 = MBED_CONF_QSPIF_QSPI_IO1,
PinName io2 = MBED_CONF_QSPIF_QSPI_IO2,
PinName io3 = MBED_CONF_QSPIF_QSPI_IO3,
PinName sclk = MBED_CONF_QSPIF_QSPI_SCK,
PinName csel = MBED_CONF_QSPIF_QSPI_CSN,
int clock_mode = MBED_CONF_QSPIF_QSPI_POLARITY_MODE,
int freq = MBED_CONF_QSPIF_QSPI_FREQ);

/** Initialize a block device
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@
#include "drivers/DigitalOut.h"
#include "features/storage/blockdevice/BlockDevice.h"

#ifndef MBED_CONF_RSPIF_DRIVER_SPI_MOSI
#define MBED_CONF_RSPIF_DRIVER_SPI_MOSI NC
#endif
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_MISO
#define MBED_CONF_RSPIF_DRIVER_SPI_MISO NC
#endif
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_CLK
#define MBED_CONF_RSPIF_DRIVER_SPI_CLK NC
#endif
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_CS
#define MBED_CONF_RSPIF_DRIVER_SPI_CS NC
#endif
#ifndef MBED_CONF_RSPIF_DRIVER_SPI_FREQ
#define MBED_CONF_RSPIF_DRIVER_SPI_FREQ 40000000
#endif

/** Reduced BlockDevice for SPI based flash devices
* *Should only be used by Boot Loader*
*
Expand Down Expand Up @@ -66,7 +82,11 @@ class SPIFReducedBlockDevice : public mbed::BlockDevice {
* @param csel SPI chip select pin
* @param freq Clock speed of the SPI bus (defaults to 40MHz)
*/
SPIFReducedBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName csel, int freq = 40000000);
SPIFReducedBlockDevice(PinName mosi = MBED_CONF_RSPIF_DRIVER_SPI_MOSI,
PinName miso = MBED_CONF_RSPIF_DRIVER_SPI_MISO,
PinName sclk = MBED_CONF_RSPIF_DRIVER_SPI_CLK,
PinName csel = MBED_CONF_RSPIF_DRIVER_SPI_CS,
int freq = MBED_CONF_RSPIF_DRIVER_SPI_FREQ);

/** Initialize a block device
*
Expand Down
10 changes: 5 additions & 5 deletions components/storage/blockdevice/COMPONENT_RSPIF/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "rspif-driver",
"config": {
"SPI_MOSI": "NC",
"SPI_MISO": "NC",
"SPI_CLK": "NC",
"SPI_CS": "NC",
"SPI_FREQ": "40000000"
"SPI_MOSI": "SPI_MOSI",
"SPI_MISO": "SPI_MISO",
"SPI_CLK": "SPI_SCK",
"SPI_CS": "SPI_CS",
"SPI_FREQ":"40000000"
},
"target_overrides": {
"K82F": {
Expand Down
34 changes: 32 additions & 2 deletions components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@
#include "platform/PlatformMutex.h"
#include "hal/static_pinmap.h"

#ifndef MBED_CONF_SD_SPI_MOSI
#define MBED_CONF_SD_SPI_MOSI NC
#endif
#ifndef MBED_CONF_SD_SPI_MISO
#define MBED_CONF_SD_SPI_MISO NC
#endif
#ifndef MBED_CONF_SD_SPI_CLK
#define MBED_CONF_SD_SPI_CLK NC
#endif
#ifndef MBED_CONF_SD_SPI_CS
#define MBED_CONF_SD_SPI_CS NC
#endif
#ifndef MBED_CONF_SD_INIT_FREQUENCY
#define MBED_CONF_SD_INIT_FREQUENCY 100000
#endif
#ifndef MBED_CONF_SD_TRX_FREQUENCY
#define MBED_CONF_SD_TRX_FREQUENCY 1000000
#endif
#ifndef MBED_CONF_SD_CRC_ENABLED
#define MBED_CONF_SD_CRC_ENABLED 0
#endif

/** SDBlockDevice class
*
* Access an SD Card using SPI bus
Expand All @@ -44,15 +66,23 @@ class SDBlockDevice : public mbed::BlockDevice {
* @param hz Clock speed of the SPI bus (defaults to 1MHz)
* @param crc_on Enable cyclic redundancy check (defaults to disabled)
*/
SDBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName cs, uint64_t hz = 1000000, bool crc_on = 0);
SDBlockDevice(PinName mosi = MBED_CONF_SD_SPI_MOSI,
PinName miso = MBED_CONF_SD_SPI_MISO,
PinName sclk = MBED_CONF_SD_SPI_CLK,
PinName cs = MBED_CONF_SD_SPI_CS,
uint64_t hz = MBED_CONF_SD_TRX_FREQUENCY,
bool crc_on = MBED_CONF_SD_CRC_ENABLED);

/** Creates an SDBlockDevice on a SPI bus specified by pins (using static pin-map)
*
* @param spi_pinmap Static SPI pin-map
* @param hz Clock speed of the SPI bus (defaults to 1MHz)
* @param crc_on Enable cyclic redundancy check (defaults to disabled)
*/
SDBlockDevice(const spi_pinmap_t &spi_pinmap, PinName cs, uint64_t hz = 1000000, bool crc_on = 0);
SDBlockDevice(const spi_pinmap_t &spi_pinmap,
PinName cs = MBED_CONF_SD_SPI_CS,
uint64_t hz = MBED_CONF_SD_TRX_FREQUENCY,
bool crc_on = MBED_CONF_SD_CRC_ENABLED);

virtual ~SDBlockDevice();

Expand Down
3 changes: 2 additions & 1 deletion components/storage/blockdevice/COMPONENT_SD/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"CMD_TIMEOUT": 10000,
"CMD0_IDLE_STATE_RETRIES": 5,
"INIT_FREQUENCY": 100000,
"CRC_ENABLED": 1,
"TRX_FREQUENCY": 1000000,
"CRC_ENABLED": 0,
"TEST_BUFFER": 8192
},
"target_overrides": {
Expand Down
24 changes: 23 additions & 1 deletion components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@
#include "drivers/DigitalOut.h"
#include "features/storage/blockdevice/BlockDevice.h"

#ifndef MBED_CONF_SPIF_DRIVER_SPI_MOSI
#define MBED_CONF_SPIF_DRIVER_SPI_MOSI NC
#endif
#ifndef MBED_CONF_SPIF_DRIVER_SPI_MISO
#define MBED_CONF_SPIF_DRIVER_SPI_MISO NC
#endif
#ifndef MBED_CONF_SPIF_DRIVER_SPI_CLK
#define MBED_CONF_SPIF_DRIVER_SPI_CLK NC
#endif
#ifndef MBED_CONF_SPIF_DRIVER_SPI_CS
#define MBED_CONF_SPIF_DRIVER_SPI_CS NC
#endif
#ifndef MBED_CONF_SPIF_DRIVER_SPI_FREQ
#define MBED_CONF_SPIF_DRIVER_SPI_FREQ 40000000
#endif

/** Enum spif standard error codes
*
* @enum spif_bd_error
Expand Down Expand Up @@ -82,8 +98,14 @@ class SPIFBlockDevice : public mbed::BlockDevice {
* @param sclk SPI clock pin
* @param csel SPI chip select pin
* @param freq Clock speed of the SPI bus (defaults to 40MHz)
*
*
*/
SPIFBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName csel, int freq = 40000000);
SPIFBlockDevice(PinName mosi = MBED_CONF_SPIF_DRIVER_SPI_MOSI,
PinName miso = MBED_CONF_SPIF_DRIVER_SPI_MISO,
PinName sclk = MBED_CONF_SPIF_DRIVER_SPI_CLK,
PinName csel = MBED_CONF_SPIF_DRIVER_SPI_CS,
int freq = MBED_CONF_SPIF_DRIVER_SPI_FREQ);

/** Initialize a block device
*
Expand Down
41 changes: 5 additions & 36 deletions features/storage/system_storage/SystemStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,51 +64,25 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
{
#if COMPONENT_SPIF

static SPIFBlockDevice default_bd(
MBED_CONF_SPIF_DRIVER_SPI_MOSI,
MBED_CONF_SPIF_DRIVER_SPI_MISO,
MBED_CONF_SPIF_DRIVER_SPI_CLK,
MBED_CONF_SPIF_DRIVER_SPI_CS,
MBED_CONF_SPIF_DRIVER_SPI_FREQ
);
static SPIFBlockDevice default_bd;

return &default_bd;

#elif COMPONENT_RSPIF

static SPIFReducedBlockDevice default_bd(
MBED_CONF_RSPIF_DRIVER_SPI_MOSI,
MBED_CONF_RSPIF_DRIVER_SPI_MISO,
MBED_CONF_RSPIF_DRIVER_SPI_CLK,
MBED_CONF_RSPIF_DRIVER_SPI_CS,
MBED_CONF_RSPIF_DRIVER_SPI_FREQ
);
static SPIFReducedBlockDevice default_bd;

return &default_bd;

#elif COMPONENT_QSPIF

static QSPIFBlockDevice default_bd(
MBED_CONF_QSPIF_QSPI_IO0,
MBED_CONF_QSPIF_QSPI_IO1,
MBED_CONF_QSPIF_QSPI_IO2,
MBED_CONF_QSPIF_QSPI_IO3,
MBED_CONF_QSPIF_QSPI_SCK,
MBED_CONF_QSPIF_QSPI_CSN,
MBED_CONF_QSPIF_QSPI_POLARITY_MODE,
MBED_CONF_QSPIF_QSPI_FREQ
);
static QSPIFBlockDevice default_bd;

return &default_bd;

#elif COMPONENT_DATAFLASH

static DataFlashBlockDevice default_bd(
MBED_CONF_DATAFLASH_SPI_MOSI,
MBED_CONF_DATAFLASH_SPI_MISO,
MBED_CONF_DATAFLASH_SPI_CLK,
MBED_CONF_DATAFLASH_SPI_CS
);
static DataFlashBlockDevice default_bd;

return &default_bd;

Expand All @@ -120,12 +94,7 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
MBED_CONF_SD_SPI_CS
);
#else
static SDBlockDevice default_bd(
MBED_CONF_SD_SPI_MOSI,
MBED_CONF_SD_SPI_MISO,
MBED_CONF_SD_SPI_CLK,
MBED_CONF_SD_SPI_CS
);
static SDBlockDevice default_bd;
#endif

return &default_bd;
Expand Down
19 changes: 19 additions & 0 deletions tools/test_configs/QSPIFBlockDeviceAndHeapBlockDevice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"config": {
"sim-blockdevice": {
"help": "Simulated block device, requires sufficient heap",
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
"value": "HeapBlockDevice"
},
"test-blockdevice": {
"help": "Used blockdevice",
"macro_name": "MBED_TEST_BLOCKDEVICE",
"value": "QSPIFBlockDevice"
},
"test-filesystem": {
"help": "Used filesystem",
"macro_name": "MBED_TEST_FILESYSTEM",
"value": "LittleFileSystem"
}
}
}
25 changes: 25 additions & 0 deletions tools/test_configs/RSPIFBlockDeviceAndHeapBlockDevice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"config": {
"sim-blockdevice": {
"help": "Simulated block device, requires sufficient heap",
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
"value": "HeapBlockDevice"
},
"test-blockdevice": {
"help": "Used blockdevice",
"macro_name": "MBED_TEST_BLOCKDEVICE",
"value": "SPIFReducedBlockDevice"
},
"test-filesystem": {
"help": "Used filesystem",
"macro_name": "MBED_TEST_FILESYSTEM",
"value": "LittleFileSystem"
}
},
"target_overrides": {
"NRF52840_DK": {
"target.components_remove": ["QSPI", "QSPIF"],
"target.components_add" : ["SPI", "RSPIF"]
}
}
}
19 changes: 19 additions & 0 deletions tools/test_configs/SDBlockDeviceAndHeapBlockDevice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"config": {
"sim-blockdevice": {
"help": "Simulated block device, requires sufficient heap",
"macro_name": "MBED_TEST_SIM_BLOCKDEVICE",
"value": "HeapBlockDevice"
},
"test-blockdevice": {
"help": "Used blockdevice",
"macro_name": "MBED_TEST_BLOCKDEVICE",
"value": "SDBlockDevice"
},
"test-filesystem": {
"help": "Used filesystem",
"macro_name": "MBED_TEST_FILESYSTEM",
"value": "LittleFileSystem"
}
}
}
Loading