Skip to content

Commit

Permalink
Merge pull request #6818 from ARMmbed/release-candidate
Browse files Browse the repository at this point in the history
Release candidate for mbed-os-5.8.4
  • Loading branch information
Cruz Monrreal committed May 7, 2018
2 parents c05d72c + 09132ce commit ae6c7c6
Show file tree
Hide file tree
Showing 271 changed files with 21,704 additions and 15,633 deletions.
18 changes: 7 additions & 11 deletions .github/pull_request_template.md
Expand Up @@ -3,26 +3,22 @@
<!--
Required
Add here detailed changes summary, testing results, dependencies
Good example: https://os.mbed.com/docs/latest/reference/guidelines.html#workflow (Pull request template)
Good example: https://os.mbed.com/docs/latest/reference/workflow.html (Pull request template)
-->


### Pull request type

<!--
Required
Please add only one X to one of the following types. Do not fill multiple types (split the pull request otherwise) or
change the layout.
[X] Fix
Please add only one X to one of the following types. Do not fill multiple types (split the pull request otherwise).
Please note this is not a GitHub task list, indenting the boxes or changing the format to add a '.' or '*' in front
of them would change the meaning incorrectly. The only changes to be made are to add a description text under the
description heading and to add a 'x' to the correct box.
-->
[ ] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change
-->

[ ] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change
32 changes: 32 additions & 0 deletions TESTS/host_tests/device_echo.py
@@ -0,0 +1,32 @@
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""


import uuid
from mbed_host_tests import BaseHostTest

class Device_Echo(BaseHostTest):

def _callback_repeat(self, key, value, _):
self.send_kv(key, value)

def setup(self):
self.register_callback("echo", self._callback_repeat)
self.register_callback("echo_count", self._callback_repeat)

def teardown(self):
pass
39 changes: 30 additions & 9 deletions TESTS/mbed_drivers/echo/main.cpp
Expand Up @@ -21,28 +21,49 @@
#include "unity/unity.h"
#include "utest/utest.h"

#define PAYLOAD_LENGTH 36

using namespace utest::v1;

// Fill a buffer with a slice of the ASCII alphabet.
void fill_buffer(char* buffer, unsigned int length, unsigned int index) {
unsigned int start = length * index;
for (int i = 0; i < length - 1; i++) {
buffer[i] = 'a' + ((start + i) % 26);
}
buffer[length - 1] = '\0';
}

// Echo server (echo payload to host)
template<int N>
void test_case_echo_server_x() {
char _key[11] = {};
char _value[128] = {};
char _tx_value[PAYLOAD_LENGTH + 1] = {};
char _rx_value[PAYLOAD_LENGTH + 1] = {};
const int echo_count = N;
const char _key_const[] = "echo_count";
const char _echo_count_key_const[] = "echo_count";
const char _echo_key_const[] = "echo";
int expected_key = 1;

greentea_send_kv(_key_const, echo_count);
// Send up the echo count
greentea_send_kv(_echo_count_key_const, echo_count);
// Handshake with host
do {
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
expected_key = strcmp(_key_const, _key);
greentea_parse_kv(_key, _rx_value, sizeof(_key), sizeof(_rx_value));
// Ensure the key received is "echo_count" and not some old data
expected_key = strcmp(_echo_count_key_const, _key);
} while (expected_key);
TEST_ASSERT_EQUAL_INT(echo_count, atoi(_value));
TEST_ASSERT_EQUAL_INT(echo_count, atoi(_rx_value));

for (int i=0; i < echo_count; ++i) {
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
greentea_send_kv(_key, _value);
fill_buffer(_tx_value, PAYLOAD_LENGTH, i);
greentea_send_kv(_echo_key_const, _tx_value);
do {
greentea_parse_kv(_key, _rx_value, sizeof(_key), sizeof(_rx_value));
// Ensure the key received is "echo" and not some old data
expected_key = strcmp(_echo_key_const, _key);
} while (expected_key);
TEST_ASSERT(strncmp(_tx_value, _rx_value, PAYLOAD_LENGTH) == 0);
}
}

Expand All @@ -56,7 +77,7 @@ Case cases[] = {
};

utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
GREENTEA_SETUP(30, "echo");
GREENTEA_SETUP(30, "device_echo");
return greentea_test_setup_handler(number_of_cases);
}

Expand Down
8 changes: 6 additions & 2 deletions TESTS/mbed_hal/flash/functional_tests/main.cpp
Expand Up @@ -28,7 +28,13 @@
using namespace utest::v1;

#define TEST_CYCLES 10000000

#ifdef TARGET_NRF52
/* The increased tolerance is to account for the imprecise timers on the NRF52. */
#define ALLOWED_DRIFT_PPM (1000000/50000) //5.0%
#else
#define ALLOWED_DRIFT_PPM (1000000/5000) //0.5%
#endif

/*
return values to be checked are documented at:
Expand Down Expand Up @@ -279,9 +285,7 @@ Case cases[] = {
Case("Flash - erase sector", flash_erase_sector_test),
Case("Flash - program page", flash_program_page_test),
Case("Flash - buffer alignment test", flash_buffer_alignment_test),
#ifndef MCU_NRF52
Case("Flash - clock and cache test", flash_clock_and_cache_test),
#endif
};

utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions doxygen_options.json
Expand Up @@ -9,5 +9,6 @@
"PREDEFINED": "DOXYGEN_ONLY DEVICE_ANALOGIN DEVICE_ANALOGOUT DEVICE_CAN DEVICE_ETHERNET DEVICE_EMAC DEVICE_FLASH DEVICE_I2C DEVICE_I2CSLAVE DEVICE_I2C_ASYNCH DEVICE_INTERRUPTIN DEVICE_ITM DEVICE_LOWPOWERTIMER DEVICE_PORTIN DEVICE_PORTINOUT DEVICE_PORTOUT DEVICE_PWMOUT DEVICE_RTC DEVICE_TRNG DEVICE_SERIAL DEVICE_SERIAL_ASYNCH DEVICE_SERIAL_FC DEVICE_SLEEP DEVICE_SPI DEVICE_SPI_ASYNCH DEVICE_SPISLAVE DEVICE_STORAGE \"MBED_DEPRECATED_SINCE(f, g)=\" \"MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, M)=\" \"MBED_DEPRECATED(s)=\"",
"EXPAND_AS_DEFINED": "",
"SKIP_FUNCTION_MACROS": "NO",
"STRIP_CODE_COMMENTS": "NO",
"EXCLUDE_PATTERNS": "*/tools/* */targets/* */features/mbedtls/* */features/storage/* */features/unsupported/* */BUILD/* */rtos/TARGET_CORTEX/rtx*/* */cmsis/* */features/FEATURE_COMMON_PAL/* */features/FEATURE_LWIP/* */features/FEATURE_UVISOR/* */features/nanostack/FEATURE_NANOSTACK/sal-stack-nanostack/* */features/nanostack/FEATURE_NANOSTACK/coap-service/* */ble/generic/* */ble/pal/*"
}
5 changes: 2 additions & 3 deletions drivers/UARTSerial.cpp
Expand Up @@ -305,12 +305,11 @@ void UARTSerial::rx_irq(void)
void UARTSerial::tx_irq(void)
{
bool was_full = _txbuf.full();
char data;

/* Write to the peripheral if there is something to write
* and if the peripheral is available to write. */
while (!_txbuf.empty() && SerialBase::writeable()) {
char data;
_txbuf.pop(data);
while (SerialBase::writeable() && _txbuf.pop(data)) {
SerialBase::_base_putc(data);
}

Expand Down
Expand Up @@ -6,7 +6,7 @@
"value": false
},
"event_loop_thread_stack_size": {
"help": "Define event-loop thread stack size.",
"help": "Define event-loop thread stack size. [bytes]",
"value": 6144
},
"critical-section-usable-from-interrupt": {
Expand Down
Expand Up @@ -611,7 +611,7 @@ static err_t lpc_low_level_output(struct netif *netif, struct pbuf *p)
/* Wait until enough descriptors are available for the transfer. */
/* THIS WILL BLOCK UNTIL THERE ARE ENOUGH DESCRIPTORS AVAILABLE */
#if NO_SYS == 0
for (idx = 0; idx < dn; idx++) {
for (s32_t count = 0; count < dn; count++) {
osSemaphoreAcquire(lpc_enetif->xTXDCountSem.id, osWaitForever);
}
MBED_ASSERT(dn <= lpc_tx_ready(netif));
Expand Down
100 changes: 30 additions & 70 deletions features/filesystem/littlefs/littlefs/lfs.c
Expand Up @@ -783,26 +783,19 @@ static int lfs_dir_find(lfs_t *lfs, lfs_dir_t *dir,
lfs_entry_t *entry, const char **path) {
const char *pathname = *path;
size_t pathlen;
entry->d.type = LFS_TYPE_DIR;
entry->d.elen = sizeof(entry->d) - 4;
entry->d.alen = 0;
entry->d.nlen = 0;
entry->d.u.dir[0] = lfs->root[0];
entry->d.u.dir[1] = lfs->root[1];

while (true) {
nextname:
nextname:
// skip slashes
pathname += strspn(pathname, "/");
pathlen = strcspn(pathname, "/");

// special case for root dir
if (pathname[0] == '\0') {
*entry = (lfs_entry_t){
.d.type = LFS_TYPE_DIR,
.d.elen = sizeof(entry->d) - 4,
.d.alen = 0,
.d.nlen = 0,
.d.u.dir[0] = lfs->root[0],
.d.u.dir[1] = lfs->root[1],
};
return 0;
}

// skip '.' and root '..'
if ((pathlen == 1 && memcmp(pathname, ".", 1) == 0) ||
(pathlen == 2 && memcmp(pathname, "..", 2) == 0)) {
Expand Down Expand Up @@ -834,10 +827,25 @@ static int lfs_dir_find(lfs_t *lfs, lfs_dir_t *dir,
suffix += sufflen;
}

// found path
if (pathname[0] == '\0') {
return 0;
}

// update what we've found
*path = pathname;

// find path
// continue on if we hit a directory
if (entry->d.type != LFS_TYPE_DIR) {
return LFS_ERR_NOTDIR;
}

int err = lfs_dir_fetch(lfs, dir, entry->d.u.dir);
if (err) {
return err;
}

// find entry matching name
while (true) {
int err = lfs_dir_next(lfs, dir, entry);
if (err) {
Expand Down Expand Up @@ -873,21 +881,8 @@ static int lfs_dir_find(lfs_t *lfs, lfs_dir_t *dir,
entry->d.type &= ~0x80;
}

// to next name
pathname += pathlen;
pathname += strspn(pathname, "/");
if (pathname[0] == '\0') {
return 0;
}

// continue on if we hit a directory
if (entry->d.type != LFS_TYPE_DIR) {
return LFS_ERR_NOTDIR;
}

int err = lfs_dir_fetch(lfs, dir, entry->d.u.dir);
if (err) {
return err;
}
}
}

Expand All @@ -904,13 +899,8 @@ int lfs_mkdir(lfs_t *lfs, const char *path) {

// fetch parent directory
lfs_dir_t cwd;
int err = lfs_dir_fetch(lfs, &cwd, lfs->root);
if (err) {
return err;
}

lfs_entry_t entry;
err = lfs_dir_find(lfs, &cwd, &entry, &path);
int err = lfs_dir_find(lfs, &cwd, &entry, &path);
if (err != LFS_ERR_NOENT || strchr(path, '/') != NULL) {
return err ? err : LFS_ERR_EXIST;
}
Expand Down Expand Up @@ -954,13 +944,8 @@ int lfs_dir_open(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
dir->pair[0] = lfs->root[0];
dir->pair[1] = lfs->root[1];

int err = lfs_dir_fetch(lfs, dir, dir->pair);
if (err) {
return err;
}

lfs_entry_t entry;
err = lfs_dir_find(lfs, dir, &entry, &path);
int err = lfs_dir_find(lfs, dir, &entry, &path);
if (err) {
return err;
} else if (entry.d.type != LFS_TYPE_DIR) {
Expand Down Expand Up @@ -1302,13 +1287,8 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file,

// allocate entry for file if it doesn't exist
lfs_dir_t cwd;
int err = lfs_dir_fetch(lfs, &cwd, lfs->root);
if (err) {
return err;
}

lfs_entry_t entry;
err = lfs_dir_find(lfs, &cwd, &entry, &path);
int err = lfs_dir_find(lfs, &cwd, &entry, &path);
if (err && (err != LFS_ERR_NOENT || strchr(path, '/') != NULL)) {
return err;
}
Expand Down Expand Up @@ -1814,13 +1794,8 @@ lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file) {
/// General fs operations ///
int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info) {
lfs_dir_t cwd;
int err = lfs_dir_fetch(lfs, &cwd, lfs->root);
if (err) {
return err;
}

lfs_entry_t entry;
err = lfs_dir_find(lfs, &cwd, &entry, &path);
int err = lfs_dir_find(lfs, &cwd, &entry, &path);
if (err) {
return err;
}
Expand Down Expand Up @@ -1855,13 +1830,8 @@ int lfs_remove(lfs_t *lfs, const char *path) {
}

lfs_dir_t cwd;
int err = lfs_dir_fetch(lfs, &cwd, lfs->root);
if (err) {
return err;
}

lfs_entry_t entry;
err = lfs_dir_find(lfs, &cwd, &entry, &path);
int err = lfs_dir_find(lfs, &cwd, &entry, &path);
if (err) {
return err;
}
Expand Down Expand Up @@ -1916,24 +1886,14 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {

// find old entry
lfs_dir_t oldcwd;
int err = lfs_dir_fetch(lfs, &oldcwd, lfs->root);
if (err) {
return err;
}

lfs_entry_t oldentry;
err = lfs_dir_find(lfs, &oldcwd, &oldentry, &oldpath);
int err = lfs_dir_find(lfs, &oldcwd, &oldentry, &oldpath);
if (err) {
return err;
}

// allocate new entry
lfs_dir_t newcwd;
err = lfs_dir_fetch(lfs, &newcwd, lfs->root);
if (err) {
return err;
}

lfs_entry_t preventry;
err = lfs_dir_find(lfs, &newcwd, &preventry, &newpath);
if (err && (err != LFS_ERR_NOENT || strchr(newpath, '/') != NULL)) {
Expand Down

0 comments on commit ae6c7c6

Please sign in to comment.