Removing nvstore. adding back the option for configuration as in the external repo

pull/8317/head
Yossi Levy 2018-10-10 17:05:16 +03:00
parent 473f8d3f94
commit b84f377b73
4 changed files with 36 additions and 20 deletions

View File

@ -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)
{

View File

@ -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

View File

@ -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"
}
}
}

View File

@ -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;