Skip to content

Commit

Permalink
Removing nvstore. adding back the option for configuration as in the …
Browse files Browse the repository at this point in the history
…external repo
  • Loading branch information
Yossi Levy authored and Yossi Levy committed Oct 10, 2018
1 parent 473f8d3 commit b84f377
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
Expand Up @@ -36,12 +36,6 @@
#define DEBUG_PRINTF(...)
#endif

FlashIAPBlockDevice::FlashIAPBlockDevice()
: _flash(), _base(0), _size(0), _is_initialized(false), _init_ref_count(0)
{
DEBUG_PRINTF("FlashIAPBlockDevice: %" PRIX32 " %" PRIX32 "\r\n", address, size);
}

FlashIAPBlockDevice::FlashIAPBlockDevice(uint32_t address, uint32_t size)
: _flash(), _base(address), _size(size), _is_initialized(false), _init_ref_count(0)
{
Expand Down
Expand Up @@ -28,16 +28,15 @@
*/
class FlashIAPBlockDevice : public BlockDevice {
public:
/** Creates a FlashIAPBlockDevice **/
FlashIAPBlockDevice();

/** Creates a FlashIAPBlockDevice
*
* @param address Physical address where the block device start
* @param size The block device size
*/
FlashIAPBlockDevice(uint32_t address, uint32_t size = 0);

FlashIAPBlockDevice(uint32_t address = MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS,
uint32_t size = MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE);

virtual ~FlashIAPBlockDevice();

/** Initialize a block device
Expand Down
19 changes: 19 additions & 0 deletions components/storage/blockdevice/COMPONENT_FLASHIAP/mbed_lib.json
@@ -0,0 +1,19 @@
{
"name": "flashiap-block-device",
"config": {
"base-address": {
"help": "Base address for the block device on the external flash.",
"value": "0xFFFFFFFF"
},
"size": {
"help": "Memory allocated for block device.",
"value": "0"
}
},
"target_overrides": {
"REALTEK_RTL8195AM": {
"base-address": "0x1C0000",
"size": "0x40000"
}
}
}
24 changes: 14 additions & 10 deletions features/storage/system_storage/SystemStorage.cpp
Expand Up @@ -31,7 +31,6 @@
#endif

#if COMPONENT_FLASHIAP
#include "nvstore.h"
#include "FlashIAPBlockDevice.h"
#endif

Expand Down Expand Up @@ -85,12 +84,12 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()

#elif COMPONENT_FLASHIAP

uint32_t top_address;
#if (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE == 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS == 0xFFFFFFFF)

size_t flash_size;
uint32_t start_address;
uint32_t bottom_address;
size_t area_size;
FlashIAP flash;
NVStore &nvstore = NVStore::get_instance();
nvstore.get_area_params(0, top_address, area_size); //Find where nvstore begins

int ret = flash.init();
if (ret != 0) {
Expand All @@ -99,16 +98,21 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()

//Find the start of first sector after text area
bottom_address = align_up(FLASHIAP_ROM_END, flash.get_sector_size(FLASHIAP_ROM_END));

if (top_address <= bottom_address) {
return 0;
}
start_address = flash.get_flash_start();
flash_size = flash.get_flash_size();

ret = flash.deinit();

static FlashIAPBlockDevice default_bd(bottom_address, top_address - bottom_address);
static FlashIAPBlockDevice default_bd(bottom_address, start_address + flash_size - bottom_address);

#else

static FlashIAPBlockDevice default_bd;

#endif

return &default_bd;

#else

return NULL;
Expand Down

0 comments on commit b84f377

Please sign in to comment.