diff --git a/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.cpp index 0a84163465..020964ec3f 100644 --- a/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.cpp @@ -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) { diff --git a/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h b/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h index 4865e70630..20279658fb 100644 --- a/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h +++ b/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h @@ -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 diff --git a/components/storage/blockdevice/COMPONENT_FLASHIAP/mbed_lib.json b/components/storage/blockdevice/COMPONENT_FLASHIAP/mbed_lib.json new file mode 100644 index 0000000000..49b4cdb7b9 --- /dev/null +++ b/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" + } + } +} diff --git a/features/storage/system_storage/SystemStorage.cpp b/features/storage/system_storage/SystemStorage.cpp index 963916a49b..04bec9e63f 100644 --- a/features/storage/system_storage/SystemStorage.cpp +++ b/features/storage/system_storage/SystemStorage.cpp @@ -31,7 +31,6 @@ #endif #if COMPONENT_FLASHIAP -#include "nvstore.h" #include "FlashIAPBlockDevice.h" #endif @@ -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) { @@ -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;