Skip to content

Implement SecureStore class #20

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

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ad88218
Kernel.h doxygen update
SenRamakri Oct 15, 2018
4cdcdc1
Updated attach_thread_terminate_hook doxygen comments
SenRamakri Oct 29, 2018
2418d9c
Edit Kernel.h
Oct 30, 2018
b01c857
exclude vendor's EMAC driver from doxy
Oct 31, 2018
60cc0c2
fixed NetworkInterface Class missing in doxy
Oct 31, 2018
e3623b9
Increase EMAC test timeout to 1400 seconds
Oct 31, 2018
74f7259
Fix off-by-one-error in BusIn/Out
pea-pod Oct 31, 2018
a7c777d
Make examples commands return a failure
adbridge Oct 31, 2018
ebef79a
Add generic BlockDevice test for contiguous erase/write/read.
Oct 24, 2018
c3e0e3e
Add generic BlockDevice test for get_erase_value().
Oct 24, 2018
7614055
Added mutex to DataFlash for thread safety
geky Oct 29, 2018
0d04f03
Added missing mutex to DataFlash for thread safety.
Oct 30, 2018
56a12ce
feat: Name cellular FSM queue thread
jdbruijn Nov 1, 2018
1f4f623
feat: Name PPP thread
jdbruijn Nov 1, 2018
b28d081
Fix up subprocess calls
adbridge Nov 1, 2018
f92108c
Make sure that close() is called before the transport is destroyed.
Nov 1, 2018
766359c
Typo fixes in Doxygen for Platform
kegilbert Nov 1, 2018
07eb6bd
Add missing include for TLSSocket
Nov 1, 2018
ae673d6
Fix typos in Events doxygen
kegilbert Nov 1, 2018
3008de5
Fix typos in RTOS doxygen.
kegilbert Nov 1, 2018
3f635ef
fix: Update thread names
jdbruijn Nov 2, 2018
467a7b6
feat: Add name to shared queue threads
jdbruijn Nov 2, 2018
440905a
fix: Change cellular FSM thread name
jdbruijn Nov 2, 2018
2ef82e1
fix: Remove rtx from main thread name
jdbruijn Nov 3, 2018
c7afb91
Fix compile warning about initializing and variable order
KariHaapalehto Nov 5, 2018
2df7258
Add get_erase_value() support
Nov 5, 2018
09ee5f9
readme: add license section
0xc0170 Oct 25, 2018
8ec69e6
readme: add note about 3rd party code licenses
0xc0170 Oct 25, 2018
f8fc0b3
contributing: update the text
0xc0170 Oct 25, 2018
97cb833
Readme: add license guide doc page
0xc0170 Oct 25, 2018
4aaf013
Fix memory leak
KariHaapalehto Nov 5, 2018
dfadcda
readme: fix apache license
0xc0170 Nov 5, 2018
36f1fa0
Remove extra _deselect to prevent possible hard fault
Oct 30, 2018
73cc54e
Merge pull request #8524 from korjaa/more_blockdevice_tests
0xc0170 Nov 5, 2018
909c11b
Merge pull request #8605 from adbridge/master
0xc0170 Nov 5, 2018
d55c0da
Merge pull request #8613 from SeppoTakalo/tls_fix
0xc0170 Nov 5, 2018
cb49241
Merge pull request #8621 from marcuschangarm/fix_include
0xc0170 Nov 5, 2018
1ea2897
TOOLS : Add missing M33 and M33F in python scripts
jeromecoutant Oct 16, 2018
ba86a53
Update tools/toolchains/gcc.py
Nov 5, 2018
8060a53
Comma, editorial changes
Nov 6, 2018
86153dd
Commas and other small editorial changes
Nov 6, 2018
4cbcd64
Merge branch 'doxy_refactor' of https://github.com/jamesbeyond/mbed-o…
0xc0170 Nov 6, 2018
2ae9981
Merge branch 'platform-doxy-typo-fix' of https://github.com/kegilbert…
0xc0170 Nov 6, 2018
0db51e6
Merge branch 'events-doxy-typo-fix' of https://github.com/kegilbert/m…
0xc0170 Nov 6, 2018
9d1aa73
Merge branch 'rtos-doxy-typo-fix' of https://github.com/kegilbert/mbe…
0xc0170 Nov 6, 2018
5549c52
Merge pull request #8606 from pea-pod/fix-bus-oboe
Nov 6, 2018
64ef110
Edits in README.md
Nov 6, 2018
819f002
Remove comma in CONTRIBUTING.md
Nov 6, 2018
44aaad4
Remove comma in CONTRIBUTING.md
Nov 6, 2018
9072b55
Merge pull request #8604 from SeppoTakalo/emac_timeout
Nov 6, 2018
6042ea3
Merge pull request #8639 from offirko/offir-mbed-qspif3
Nov 6, 2018
0c2d35f
Merge pull request #8612 from vidavidorra/master
Nov 6, 2018
c792d33
Merge pull request #8652 from 0xc0170/dev_rollup
Nov 7, 2018
ddd82a9
Merge branch 'fix_possible_memory_leak' of ssh://github.com/KariHaapa…
Nov 7, 2018
f7eb135
Merge branch 'fix_licensing' of ssh://github.com/0xc0170/mbed-os into…
Nov 7, 2018
7536876
Merge branch 'fix_compile_warning' of ssh://github.com/KariHaapalehto…
Nov 7, 2018
fd744e7
Merge branch 'sdblockdevice_deselect' of ssh://github.com/jarlamsa/mb…
Nov 7, 2018
edb6d9d
Merge branch 'PR_M33' of ssh://github.com/jeromecoutant/mbed into rollup
Nov 7, 2018
0a8f5e0
Merge branch 'sen_KernelDoxyUpdate' of ssh://github.com/SenRamakri/mb…
Nov 7, 2018
96191e2
Merge pull request #8663 from cmonr/rollup
0xc0170 Nov 7, 2018
4bf4ac1
Support erase value in Flash HAL drivers, FlashIAP and block devices
Oct 30, 2018
9f2bbbc
Add a Unity macro to assert on platform error code difference
Nov 5, 2018
d616a5b
KVStore & derived classes: design docs & implementation
Oct 9, 2018
5a4f1d1
Implement TDBStore class
Nov 7, 2018
4b6a2fe
Implement SecureStore class
Nov 7, 2018
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Mbed OS is an open-source, device software platform for the Internet of Things. Contributions are an important part of the platform, and our goal is to make it as simple as possible to become a contributor.

To encourage productive collaboration, as well as robust, consistent and maintainable code, we have a set ofguidelines for contributing toMbed OS. Please see: [contributing guidelines](https://os.mbed.com/docs/latest/reference/contributing.html).
To encourage productive collaboration, as well as robust, consistent and maintainable code, we have a set of guidelines for [contributing to Mbed OS](https://os.mbed.com/docs/latest/reference/contributing.html).
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@
Arm Mbed OS is an open source embedded operating system designed specifically for the "things" in the Internet of Things. It includes all the features you need to develop a connected product based on an Arm Cortex-M microcontroller, including security, connectivity, an RTOS and drivers for sensors and I/O devices.

Mbed OS provides a platform that includes:
* Security foundations.
* Cloud management services.
* Drivers for sensors, I/O devices and connectivity.

- Security foundations.
- Cloud management services.
- Drivers for sensors, I/O devices and connectivity.

## Release notes
The [release notes](https://os.mbed.com/releases) detail the current release. You can also find information about previous versions.

## License and contributions

The software is provided under [Apache-2.0 license](LICENSE). Contributions to this project are accepted under the same license. Please see [contributing.md](CONTRIBUTING.md) for more info.

This project contains code from other projects. The original license text is included in those source files. They must comply with our [license guide](https://os.mbed.com/docs/latest/reference/license.html)

## Getting started for developers

We have a [developer website](https://os.mbed.com) for asking questions, engaging with others, finding information on boards and components, using an online IDE and compiler, reading the documentation and learning about what's new and what's coming next in Mbed OS.
Expand All @@ -36,6 +43,7 @@ We also have a [contributing and publishing guide](https://os.mbed.com/contribut

## Documentation

For more information about Mbed OS, please see [our published documentation](https://os.mbed.com/docs/latest). It includes published Doxygen for our APIs, step-by-step tutorials, porting information and background reference materials about our architecture and tools.
For more information about Mbed OS, please see [our published documentation](https://os.mbed.com/docs/latest). It includes Doxygen for our APIs, step-by-step tutorials, porting information and background reference materials about our architecture and tools.

To contribute to this documentation, please see the [mbed-os-5-docs repository](https://github.com/ARMmbed/mbed-os-5-docs).

To contribute to this documentation, please see the [mbed-os-5-docs repo](https://github.com/ARMmbed/mbed-os-5-docs).
18 changes: 14 additions & 4 deletions TESTS/mbed_drivers/flashiap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ void flashiap_program_test()
TEST_ASSERT_TRUE(sector_size % page_size == 0);
uint32_t prog_size = std::max(page_size, (uint32_t)8);
uint8_t *data = new uint8_t[prog_size + 2];
for (uint32_t i = 0; i < prog_size + 2; i++) {
data[i] = i;
}

// the one before the last sector in the system
uint32_t address = (flash_device.get_flash_start() + flash_device.get_flash_size()) - (sector_size);
Expand All @@ -68,14 +65,27 @@ void flashiap_program_test()
ret = flash_device.erase(address, sector_size);
TEST_ASSERT_EQUAL_INT32(0, ret);

uint8_t erase_val = flash_device.get_erase_value();
memset(data, erase_val, prog_size);

uint8_t *data_flashed = new uint8_t[prog_size];
for (uint32_t i = 0; i < sector_size / prog_size; i++) {
uint32_t page_addr = address + i * prog_size;
ret = flash_device.read(data_flashed, page_addr, prog_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, data_flashed, prog_size);
}

for (uint32_t i = 0; i < prog_size + 2; i++) {
data[i] = i;
}

for (uint32_t i = 0; i < sector_size / prog_size; i++) {
uint32_t prog_addr = address + i * prog_size;
ret = flash_device.program(data, prog_addr, prog_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
}

uint8_t *data_flashed = new uint8_t[prog_size];
for (uint32_t i = 0; i < sector_size / prog_size; i++) {
uint32_t page_addr = address + i * prog_size;
ret = flash_device.read(data_flashed, page_addr, prog_size);
Expand Down
2 changes: 1 addition & 1 deletion TESTS/network/emac/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ using namespace utest::v1;
utest::v1::status_t test_setup(const size_t number_of_cases)
{
#if !MBED_CONF_APP_ECHO_SERVER
GREENTEA_SETUP(1200, "default_auto");
GREENTEA_SETUP(1400, "default_auto");
#endif
return verbose_test_setup_handler(number_of_cases);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ DataFlashBlockDevice::DataFlashBlockDevice(PinName mosi,

int DataFlashBlockDevice::init()
{
_mutex.lock();
DEBUG_PRINTF("init\r\n");

if (!_is_initialized) {
Expand All @@ -173,6 +174,7 @@ int DataFlashBlockDevice::init()
uint32_t val = core_util_atomic_incr_u32(&_init_ref_count, 1);

if (val != 1) {
_mutex.unlock();
return BD_ERROR_OK;
}

Expand Down Expand Up @@ -281,33 +283,40 @@ int DataFlashBlockDevice::init()
_is_initialized = true;
}

_mutex.unlock();
return result;
}

int DataFlashBlockDevice::deinit()
{
_mutex.lock();
DEBUG_PRINTF("deinit\r\n");

if (!_is_initialized) {
_init_ref_count = 0;
_mutex.unlock();
return BD_ERROR_OK;
}

uint32_t val = core_util_atomic_decr_u32(&_init_ref_count, 1);

if (val) {
_mutex.unlock();
return BD_ERROR_OK;
}

_is_initialized = false;
_mutex.unlock();
return BD_ERROR_OK;
}

int DataFlashBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
{
_mutex.lock();
DEBUG_PRINTF("read: %p %" PRIX64 " %" PRIX64 "\r\n", buffer, addr, size);

if (!_is_initialized) {
_mutex.unlock();
return BD_ERROR_DEVICE_ERROR;
}

Expand Down Expand Up @@ -345,14 +354,17 @@ int DataFlashBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
result = BD_ERROR_OK;
}

_mutex.unlock();
return result;
}

int DataFlashBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size)
{
_mutex.lock();
DEBUG_PRINTF("program: %p %" PRIX64 " %" PRIX64 "\r\n", buffer, addr, size);

if (!_is_initialized) {
_mutex.unlock();
return BD_ERROR_DEVICE_ERROR;
}

Expand Down Expand Up @@ -411,14 +423,17 @@ int DataFlashBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t
_write_enable(false);
}

_mutex.unlock();
return result;
}

int DataFlashBlockDevice::erase(bd_addr_t addr, bd_size_t size)
{
_mutex.lock();
DEBUG_PRINTF("erase: %" PRIX64 " %" PRIX64 "\r\n", addr, size);

if (!_is_initialized) {
_mutex.unlock();
return BD_ERROR_DEVICE_ERROR;
}

Expand Down Expand Up @@ -465,6 +480,7 @@ int DataFlashBlockDevice::erase(bd_addr_t addr, bd_size_t size)
_write_enable(false);
}

_mutex.unlock();
return result;
}

Expand All @@ -484,23 +500,29 @@ bd_size_t DataFlashBlockDevice::get_program_size() const

bd_size_t DataFlashBlockDevice::get_erase_size() const
{
_mutex.lock();
DEBUG_PRINTF("erase size: %" PRIX16 "\r\n", _block_size);

return _block_size;
bd_size_t block_size = _block_size;
_mutex.unlock();
return block_size;
}

bd_size_t DataFlashBlockDevice::get_erase_size(bd_addr_t addr) const
{
_mutex.lock();
DEBUG_PRINTF("erase size: %" PRIX16 "\r\n", _block_size);

return _block_size;
bd_size_t block_size = _block_size;
_mutex.unlock();
return block_size;
}

bd_size_t DataFlashBlockDevice::size() const
{
_mutex.lock();
DEBUG_PRINTF("device size: %" PRIX32 "\r\n", _device_size);

return _device_size;
bd_size_t device_size = _device_size;
_mutex.unlock();
return device_size;
}

/**
Expand All @@ -512,6 +534,7 @@ bd_size_t DataFlashBlockDevice::size() const
*/
uint16_t DataFlashBlockDevice::_get_register(uint8_t opcode)
{
_mutex.lock();
DEBUG_PRINTF("_get_register: %" PRIX8 "\r\n", opcode);

/* activate device */
Expand All @@ -527,6 +550,7 @@ uint16_t DataFlashBlockDevice::_get_register(uint8_t opcode)
/* deactivate device */
_cs = 1;

_mutex.unlock();
return status;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ class DataFlashBlockDevice : public BlockDevice {
int _sync(void);
int _write_page(const uint8_t *buffer, uint32_t addr, uint32_t offset, uint32_t size);
uint32_t _translate_address(bd_addr_t addr);

// Mutex for thread safety
mutable PlatformMutex _mutex;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,20 @@ bd_size_t FlashIAPBlockDevice::get_erase_size(bd_addr_t addr) const
return erase_size;
}

int FlashIAPBlockDevice::get_erase_value() const
{
if (!_is_initialized) {
return -1;
}

uint8_t erase_val = _flash.get_erase_value();

DEBUG_PRINTF("get_erase_value: %" PRIX8 "\r\n", erase_val);

return erase_val;
}


bd_size_t FlashIAPBlockDevice::size() const
{
DEBUG_PRINTF("size: %" PRIX64 "\r\n", _size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ class FlashIAPBlockDevice : public BlockDevice {
*/
virtual bd_size_t get_erase_size(bd_addr_t addr) const;

/** Get the value of storage when erased
*
* @return The value of storage when erased
*/
virtual int get_erase_value() const;

/** Get the total size of the underlying device
*
* @return Size of the underlying device in bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ bd_size_t QSPIFBlockDevice::size() const
return _device_size_bytes;
}

int QSPIFBlockDevice::get_erase_value() const
{
return 0xFF;
}

/********************************/
/* Different Device Csel Mgmt */
/********************************/
Expand Down
11 changes: 11 additions & 0 deletions components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ class QSPIFBlockDevice : public BlockDevice {
*/
virtual bd_size_t get_erase_size(bd_addr_t addr);

/** Get the value of storage byte after it was erased
*
* If get_erase_value returns a non-negative byte value, the underlying
* storage is set to that value when erased, and storage containing
* that value can be programmed without another erase.
*
* @return The value of storage when erased, or -1 if you can't
* rely on the value of erased storage
*/
virtual int get_erase_value() const;

/** Get the total size of the underlying device
*
* @return Size of the underlying device in bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,6 @@ int SDBlockDevice::_read(uint8_t *buffer, uint32_t length)
// read until start byte (0xFE)
if (false == _wait_token(SPI_START_BLOCK)) {
debug_if(SD_DBG, "Read timeout\n");
_deselect();
return SD_BLOCK_DEVICE_ERROR_NO_RESPONSE;
}

Expand Down
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.md.html

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0" version="9.1.6" editor="www.draw.io" type="device"><diagram id="03139726-0aa5-5ee2-a4e8-af4a44b6180b" name="Page-1">7VfbbtswDP0aP3bwJU7zmjRNCwwDBgS7PSo2bQuVLU9WEmdfP8qm41u8ZsDWbkDzEFuHFEUe8ZJY3l1aPiiWJx9kCMJy7bC0vLXluo7vz/BhkFON3C4IiBUPSakFtvwHEGgTuuchFD1FLaXQPO+DgcwyCHQPY0rJY18tkqJ/as5iGAHbgIkx+oWHOqnRhW+3+CPwOGlOdmyS7FjwFCu5z+g8y/Wi6lOLU9bYIv0iYaE8diDv3vLulJS6fkvLOxCG24a2et9mQnr2W0Gmr9pAfhyY2EPj8lzg3lVu3NMnomT+fW98WqVMxTyzvCVK7bzEbwSryAx+o2Vey2YdmYZS3zDBY9oXoHOgWpv4FtOzOnnXABsuYHsqNKRbLRU0cgxnN9yDWD7EEmVCaJKrOc2ZPjjkh4tBJ3TXxnnXBDZlAL2obDSo2zPnHkBpjlm2rLlYV2ytiJm1gMjskqgViSopIo6X5a0imWmqEcel9YalXJjqegRxAGPV+KlTYZTOZ3cTgXLD+ABlB6LEeACZglYnVCGp61FyUBG7M1of25JwGizplMOCMEZVGJ9Nt5mIL5SME4npjBLzUwEjRiELl6becSVzQBZXiHS5ClmRQEikXMMPhL3WMGanG/2cIlUgmOaHfve4FD6Z+yg5Hntm2rsdMD1ksJB7FQDt6pbzwJBvP2NIY5mCHhmqbuMc43UX5P4fneNXTWOn3trIX28jo5x80TYy+5ez9P3nt7n2+nNt8ZL56F/Ix+mZthMyeBpOMZRvKgLX9njedahChtTpq1F75zfLb8/RWA+IfvG8ykic6hq/OxJn84Eh70+NRFy2P9Rr9fbfkHf/Ew==</diagram></mxfile>
Loading