mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #8317 from yossi2le/add-flashiap-bd-as-default
Add FlashIAP block device as default block device for WISE 1570pull/8222/merge
commit
a6651b868b
|
@ -36,14 +36,8 @@
|
||||||
#define DEBUG_PRINTF(...)
|
#define DEBUG_PRINTF(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FlashIAPBlockDevice::FlashIAPBlockDevice()
|
FlashIAPBlockDevice::FlashIAPBlockDevice(uint32_t address, uint32_t size)
|
||||||
: _flash(), _base(0), _size(0), _is_initialized(false), _init_ref_count(0)
|
: _flash(), _base(address), _size(size), _is_initialized(false), _init_ref_count(0)
|
||||||
{
|
|
||||||
DEBUG_PRINTF("FlashIAPBlockDevice: %" PRIX32 " %" PRIX32 "\r\n", address, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
FlashIAPBlockDevice::FlashIAPBlockDevice(uint32_t address, uint32_t)
|
|
||||||
: _flash(), _base(0), _size(0), _is_initialized(false), _init_ref_count(0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,11 +64,27 @@ int FlashIAPBlockDevice::init()
|
||||||
int ret = _flash.init();
|
int ret = _flash.init();
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
core_util_atomic_decr_u32(&_init_ref_count, 1);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
_base = _flash.get_flash_start();
|
if (_size + _base > _flash.get_flash_size() + _flash.get_flash_start()) {
|
||||||
_size = _flash.get_flash_size();
|
core_util_atomic_decr_u32(&_init_ref_count, 1);
|
||||||
|
return BD_ERROR_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_base < _flash.get_flash_start()) {
|
||||||
|
core_util_atomic_decr_u32(&_init_ref_count, 1);
|
||||||
|
return BD_ERROR_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_base) {
|
||||||
|
_base = _flash.get_flash_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_size) {
|
||||||
|
_size = _flash.get_flash_size() - (_base - _flash.get_flash_start());
|
||||||
|
}
|
||||||
|
|
||||||
_is_initialized = true;
|
_is_initialized = true;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -28,12 +28,15 @@
|
||||||
*/
|
*/
|
||||||
class FlashIAPBlockDevice : public BlockDevice {
|
class FlashIAPBlockDevice : public BlockDevice {
|
||||||
public:
|
public:
|
||||||
/** Creates a FlashIAPBlockDevice **/
|
|
||||||
FlashIAPBlockDevice();
|
|
||||||
|
|
||||||
MBED_DEPRECATED("Please use default constructor instead")
|
|
||||||
FlashIAPBlockDevice(uint32_t address, uint32_t size = 0);
|
|
||||||
|
|
||||||
|
/** Creates a FlashIAPBlockDevice
|
||||||
|
*
|
||||||
|
* @param address Physical address where the block device start
|
||||||
|
* @param size The block device size
|
||||||
|
*/
|
||||||
|
FlashIAPBlockDevice(uint32_t address = MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS,
|
||||||
|
uint32_t size = MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE);
|
||||||
|
|
||||||
virtual ~FlashIAPBlockDevice();
|
virtual ~FlashIAPBlockDevice();
|
||||||
|
|
||||||
/** Initialize a block device
|
/** Initialize a block device
|
||||||
|
|
|
@ -680,7 +680,7 @@ control_t fslittle_fopen_test_05(const size_t call_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char fslittle_fopen_ascii_illegal_buf_g[] = "\"<EFBFBD>'*+,./:;<=>?[\\]|";
|
static const char fslittle_fopen_ascii_illegal_buf_g[] = "\"?'*+,./:;<=>?[\\]|";
|
||||||
|
|
||||||
/** @brief test to call fopen() with filename that in includes
|
/** @brief test to call fopen() with filename that in includes
|
||||||
* illegal characters
|
* illegal characters
|
||||||
|
|
|
@ -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,6 +24,9 @@
|
||||||
#elif COMPONENT_SD
|
#elif COMPONENT_SD
|
||||||
#include "SDBlockDevice.h"
|
#include "SDBlockDevice.h"
|
||||||
#include "FATFileSystem.h"
|
#include "FATFileSystem.h"
|
||||||
|
#elif COMPONENT_FLASHIAP
|
||||||
|
#include "FlashIAPBlockDevice.h"
|
||||||
|
#include "LittleFileSystem.h"
|
||||||
#else
|
#else
|
||||||
#error [NOT_SUPPORTED] storage test not supported on this platform
|
#error [NOT_SUPPORTED] storage test not supported on this platform
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,8 +30,22 @@
|
||||||
#include "SDBlockDevice.h"
|
#include "SDBlockDevice.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if COMPONENT_FLASHIAP
|
||||||
|
#include "FlashIAPBlockDevice.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace mbed;
|
using namespace mbed;
|
||||||
|
|
||||||
|
// Align a value to a specified size.
|
||||||
|
// Parameters :
|
||||||
|
// val - [IN] Value.
|
||||||
|
// size - [IN] Size.
|
||||||
|
// Return : Aligned value.
|
||||||
|
static inline uint32_t align_up(uint32_t val, uint32_t size)
|
||||||
|
{
|
||||||
|
return (((val - 1) / size) + 1) * size;
|
||||||
|
}
|
||||||
|
|
||||||
MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
|
MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
|
||||||
{
|
{
|
||||||
#if COMPONENT_SPIF
|
#if COMPONENT_SPIF
|
||||||
|
@ -68,6 +82,37 @@ MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
|
||||||
|
|
||||||
return &default_bd;
|
return &default_bd;
|
||||||
|
|
||||||
|
#elif COMPONENT_FLASHIAP
|
||||||
|
|
||||||
|
#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;
|
||||||
|
FlashIAP flash;
|
||||||
|
|
||||||
|
int ret = flash.init();
|
||||||
|
if (ret != 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Find the start of first sector after text area
|
||||||
|
bottom_address = align_up(FLASHIAP_ROM_END, flash.get_sector_size(FLASHIAP_ROM_END));
|
||||||
|
start_address = flash.get_flash_start();
|
||||||
|
flash_size = flash.get_flash_size();
|
||||||
|
|
||||||
|
ret = flash.deinit();
|
||||||
|
|
||||||
|
static FlashIAPBlockDevice default_bd(bottom_address, start_address + flash_size - bottom_address);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static FlashIAPBlockDevice default_bd;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return &default_bd;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -92,6 +137,13 @@ MBED_WEAK FileSystem *FileSystem::get_default_instance()
|
||||||
|
|
||||||
return &sdcard;
|
return &sdcard;
|
||||||
|
|
||||||
|
#elif COMPONENT_FLASHIAP
|
||||||
|
|
||||||
|
static LittleFileSystem flash("flash", BlockDevice::get_default_instance());
|
||||||
|
flash.set_as_default();
|
||||||
|
|
||||||
|
return &flash;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1745,6 +1745,7 @@
|
||||||
"device_name": "STM32L486RG"
|
"device_name": "STM32L486RG"
|
||||||
},
|
},
|
||||||
"MTB_ADV_WISE_1570": {
|
"MTB_ADV_WISE_1570": {
|
||||||
|
"components": ["FLASHIAP"],
|
||||||
"inherits": ["FAMILY_STM32"],
|
"inherits": ["FAMILY_STM32"],
|
||||||
"core": "Cortex-M4F",
|
"core": "Cortex-M4F",
|
||||||
"extra_labels_add": ["STM32L4", "STM32L486RG", "STM32L486xG", "WISE_1570"],
|
"extra_labels_add": ["STM32L4", "STM32L486RG", "STM32L486xG", "WISE_1570"],
|
||||||
|
|
Loading…
Reference in New Issue