Skip to content

Commit c0585c3

Browse files
authored
Merge pull request #3080 from ARMmbed/release-candidate
Release candidate for mbed-os-5.2-rc4
2 parents 873686c + 457aef7 commit c0585c3

File tree

47 files changed

+562
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+562
-258
lines changed

TESTS/mbed_drivers/lp_timeout/main.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,18 @@ void lp_timeout_1s_deepsleep(void)
4343
{
4444
complete = false;
4545

46-
/*
47-
* We use here lp_ticker_read() instead of us_ticker_read() for start and
46+
/*
47+
* Since deepsleep() may shut down the UART peripheral, we wait for 10ms
48+
* to allow for hardware serial buffers to completely flush.
49+
50+
* This should be replaced with a better function that checks if the
51+
* hardware buffers are empty. However, such an API does not exist now,
52+
* so we'll use the wait_ms() function for now.
53+
*/
54+
wait_ms(10);
55+
56+
/*
57+
* We use here lp_ticker_read() instead of us_ticker_read() for start and
4858
* end because the microseconds timer might be disable during deepsleep.
4959
*/
5060
timestamp_t start = lp_ticker_read();

TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,22 @@ void lp_ticker_1s_deepsleep()
6565
complete = false;
6666
uint32_t delay_ts;
6767

68+
/*
69+
* Since deepsleep() may shut down the UART peripheral, we wait for 10ms
70+
* to allow for hardware serial buffers to completely flush.
71+
72+
* This should be replaced with a better function that checks if the
73+
* hardware buffers are empty. However, such an API does not exist now,
74+
* so we'll use the wait_ms() function for now.
75+
*/
76+
wait_ms(10);
77+
6878
ticker_set_handler(lp_ticker_data, cb_done);
6979
ticker_remove_event(lp_ticker_data, &delay_event);
7080
delay_ts = lp_ticker_read() + 1000000;
7181

72-
/*
73-
* We use here lp_ticker_read() instead of us_ticker_read() for start and
82+
/*
83+
* We use here lp_ticker_read() instead of us_ticker_read() for start and
7484
* end because the microseconds timer might be disable during deepsleep.
7585
*/
7686
timestamp_t start = lp_ticker_read();

features/FEATURE_LWIP/lwip-interface/lwip_stack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,9 @@ static int mbed_lwip_socket_accept(nsapi_stack_t *stack, nsapi_socket_t server,
698698
netconn_set_recvtimeout(ns->conn, 1);
699699
*(struct lwip_socket **)handle = ns;
700700

701-
(void) netconn_peer(ns->conn, (ip_addr_t *)addr->bytes, port);
702-
addr->version = NSAPI_IPv4;
701+
ip_addr_t peer_addr;
702+
(void) netconn_peer(ns->conn, &peer_addr, port);
703+
convert_lwip_addr_to_mbed(addr, &peer_addr);
703704

704705
return 0;
705706
}

features/mbedtls/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8e004104020dd4328434e8a207245b0327bbb9b1
1+
mbedtls-2.4.0

features/mbedtls/importer/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
#
2828

2929
# Set the mbed TLS release to import (this can/should be edited before import)
30-
MBED_TLS_RELEASE ?= a592dcc1c6277bb191269e709cdd3d5593e593ed
30+
MBED_TLS_RELEASE ?= mbedtls-2.4.0
3131

3232
# Translate between mbed TLS namespace and mbed namespace
3333
TARGET_PREFIX:=../
3434
TARGET_SRC:=$(TARGET_PREFIX)src
3535
TARGET_INC:=$(TARGET_PREFIX)inc
3636

3737
# mbed TLS source directory - hidden from mbed via TARGET_IGNORE
38-
MBED_TLS_URL:=https://github.com/ARMmbed/mbedtls.git
38+
MBED_TLS_URL:=https://github.com/ARMmbed/mbedtls-restricted.git
3939
MBED_TLS_DIR:=TARGET_IGNORE/mbedtls
4040
MBED_TLS_API:=$(MBED_TLS_DIR)/include/mbedtls
4141
MBED_TLS_GIT_CFG=$(MBED_TLS_DIR)/.git/config

features/mbedtls/inc/mbedtls/version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@
3838
* Major, Minor, Patchlevel
3939
*/
4040
#define MBEDTLS_VERSION_MAJOR 2
41-
#define MBEDTLS_VERSION_MINOR 3
41+
#define MBEDTLS_VERSION_MINOR 4
4242
#define MBEDTLS_VERSION_PATCH 0
4343

4444
/**
4545
* The single version number has the following structure:
4646
* MMNNPP00
4747
* Major version | Minor version | Patch version
4848
*/
49-
#define MBEDTLS_VERSION_NUMBER 0x02030000
50-
#define MBEDTLS_VERSION_STRING "2.3.0"
51-
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.3.0"
49+
#define MBEDTLS_VERSION_NUMBER 0x02040000
50+
#define MBEDTLS_VERSION_STRING "2.4.0"
51+
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.4.0"
5252

5353
#if defined(MBEDTLS_VERSION_C)
5454

features/nanostack/FEATURE_NANOSTACK/clone_nanostack.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ clean() {
5858
rm -rf $dir
5959
done
6060
clean_nanostack_binaries
61+
clean_nanostack_licenses
6162
}
6263

6364
clone() {
@@ -80,12 +81,23 @@ export_repos() {
8081
}
8182

8283
copy_nanostack_binaries() {
83-
mkdir -p ../nanostack-binaries
84-
mv sal-stack-nanostack/FEATURE_* ../nanostack-binaries/
84+
mv sal-stack-nanostack/FEATURE_* ../
8585
}
8686

8787
clean_nanostack_binaries() {
88-
rm -rf ../nanostack-binaries
88+
for binaries in ../FEATURE_*; do
89+
if [ "$binaries" != "../FEATURE_NANOSTACK" ]; then
90+
rm -rf $binaries
91+
fi
92+
done
93+
}
94+
95+
copy_nanostack_licenses() {
96+
mv sal-stack-nanostack/LICENSE* ../
97+
}
98+
99+
clean_nanostack_licenses() {
100+
rm -rf ../LICENSE*
89101
}
90102

91103
case "${1-}" in
@@ -99,6 +111,7 @@ case "${1-}" in
99111
export)
100112
export_repos
101113
copy_nanostack_binaries
114+
copy_nanostack_licenses
102115
;;
103116
*)
104117
print_usage

features/storage/FEATURE_STORAGE/TESTS/cfstore/create/create.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include "mbed.h"
28+
#include "mbed_stats.h"
2829
#include "cfstore_config.h"
2930
#include "cfstore_debug.h"
3031
#include "cfstore_test.h"
@@ -507,11 +508,10 @@ control_t cfstore_create_test_04_end(const size_t call_count)
507508
*
508509
* Create enough KV's to consume the whole of available memory
509510
*/
510-
int32_t cfstore_create_test_05_core(const size_t call_count, uint32_t* bytes_stored_ex)
511+
int32_t cfstore_create_test_05_core(const size_t call_count)
511512
{
512513
int32_t ret = ARM_DRIVER_ERROR;
513514
uint32_t i = 0;
514-
uint32_t bytes_stored = 0;
515515
const uint32_t max_num_kvs_create = 200;
516516
const size_t kv_name_tag_len = 3;
517517
const size_t kv_name_min_len = 10;
@@ -535,9 +535,6 @@ int32_t cfstore_create_test_05_core(const size_t call_count, uint32_t* bytes_sto
535535
memset(value_buf, 0, max_value_buf_size);
536536
snprintf(kv_name_tag_buf, kv_name_tag_len+1, "%0d", (int) i);
537537
ret = cfstore_create_kv_create(kv_name_min_len, kv_name_tag_buf, value_buf, kv_value_min_len/64 * (i+1));
538-
bytes_stored += kv_name_min_len + i + strlen(kv_name_tag_buf); /* kv_name */
539-
bytes_stored += kv_value_min_len/64 * (i+1); /* kv value blob */
540-
bytes_stored += 8; /* kv overhead */
541538
if(ret == ARM_CFSTORE_DRIVER_ERROR_OUT_OF_MEMORY){
542539
CFSTORE_ERRLOG("Out of memory on %d-th KV, trying to allocate memory totalling %d.\n", (int) i, (int) bytes_stored);
543540
break;
@@ -551,9 +548,6 @@ int32_t cfstore_create_test_05_core(const size_t call_count, uint32_t* bytes_sto
551548
free(value_buf);
552549
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
553550
TEST_ASSERT_MESSAGE(drv->Uninitialize() >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
554-
if(bytes_stored_ex){
555-
*bytes_stored_ex = bytes_stored;
556-
}
557551
return ret;
558552
}
559553

@@ -576,22 +570,25 @@ control_t cfstore_create_test_05(const size_t call_count)
576570
{
577571
uint32_t i = 0;
578572
int32_t ret = ARM_DRIVER_ERROR;
579-
uint32_t bytes_stored = 0;
580-
uint32_t bytes_stored_prev = 0;
581573
const uint32_t max_loops = 50;
574+
mbed_stats_heap_t stats_before;
575+
mbed_stats_heap_t stats_after;
576+
577+
mbed_stats_heap_get(&stats_before);
582578

583579
CFSTORE_FENTRYLOG("%s:entered\n", __func__);
584580
for(i = 0; i < max_loops; i++) {
585-
ret = cfstore_create_test_05_core(call_count, &bytes_stored);
581+
ret = cfstore_create_test_05_core(call_count);
586582
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: cfstore_create_test_05_core() failed (ret = %d.\n", __func__, (int) ret);
587583
TEST_ASSERT_MESSAGE(ret >= ARM_DRIVER_OK, cfstore_create_utest_msg_g);
588584

585+
mbed_stats_heap_get(&stats_after);
589586
if(i > 1) {
590-
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: memory leak: stored %d bytes on loop %d, but %d bytes on loop %d .\n", __func__, (int) bytes_stored, (int) i, (int) bytes_stored_prev, (int) i-1);
591-
TEST_ASSERT_MESSAGE(bytes_stored == bytes_stored_prev, cfstore_create_utest_msg_g);
592-
587+
CFSTORE_TEST_UTEST_MESSAGE(cfstore_create_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: memory leak: stored %d bytes on loop %d, but %d bytes on loop %d .\n", __func__, (int) stats_after.current_size, (int) i, (int) stats_before.current_size, (int) i-1);
588+
TEST_ASSERT_MESSAGE(stats_after.current_size == stats_before.current_size, cfstore_create_utest_msg_g);
589+
TEST_ASSERT(stats_after.alloc_fail_cnt > stats_before.alloc_fail_cnt);
593590
}
594-
bytes_stored_prev = bytes_stored;
591+
stats_before = stats_after;
595592
}
596593
return CaseNext;
597594
}
@@ -828,7 +825,9 @@ Case cases[] = {
828825
Case("CREATE_test_03_end", cfstore_create_test_03_end),
829826
Case("CREATE_test_04_start", cfstore_utest_default_start),
830827
Case("CREATE_test_04_end", cfstore_create_test_04_end),
828+
#if defined(MBED_HEAP_STATS_ENABLED) && MBED_HEAP_STATS_ENABLED && !defined(__ICCARM__)
831829
Case("CREATE_test_05", cfstore_create_test_05),
830+
#endif
832831
Case("CREATE_test_06_start", cfstore_utest_default_start),
833832
Case("CREATE_test_06_end", cfstore_create_test_06_end),
834833
Case("CREATE_test_07_start", cfstore_utest_default_start),

features/storage/FEATURE_STORAGE/cfstore/source/configuration_store.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,7 @@ static int32_t cfstore_get_next_hkvt(cfstore_area_hkvt_t* prev, cfstore_area_hkv
12941294

12951295
CFSTORE_ASSERT(prev != NULL);
12961296
CFSTORE_ASSERT(next != NULL);
1297+
CFSTORE_ASSERT(prev->tail <= ctx->area_0_tail);
12971298

12981299
if(prev->tail == ctx->area_0_tail){
12991300
CFSTORE_TP(CFSTORE_TP_VERBOSE1, "%s:reached the end of the list. return NULL entry\n", __func__);
@@ -1433,6 +1434,14 @@ static int32_t cfstore_realloc_ex(ARM_CFSTORE_SIZE size, uint64_t *allocated_siz
14331434
}
14341435

14351436
ptr = (uint8_t*) CFSTORE_REALLOC((void*) ctx->area_0_head, size);
1437+
if (ptr == NULL) {
1438+
if (total_kv_size <= ctx->area_0_len) {
1439+
/* Size is shrinking so a realloc failure is recoverable.
1440+
* Update ptr so it matches the previous head.
1441+
*/
1442+
ptr = ctx->area_0_head;
1443+
}
1444+
}
14361445
if(ptr == NULL){
14371446
CFSTORE_ERRLOG("%s:Error: unable to allocate memory (size=%d)\n", __func__, (int) size);
14381447
/* realloc() has failed to allocate the required memory object. If previously
@@ -2449,11 +2458,11 @@ static int32_t cfstore_file_destroy(cfstore_file_t* file)
24492458
if(cfstore_hkvt_get_flags_delete(&hkvt)){
24502459
ret = cfstore_delete_ex(&hkvt);
24512460
}
2452-
/* reset client buffer to empty ready for reuse */
2453-
/* delete the file even if not deleting the KV*/
2454-
cfstore_listDel(&file->node);
2455-
memset(file, 0, sizeof(cfstore_file_t));
24562461
}
2462+
/* reset client buffer to empty ready for reuse */
2463+
/* delete the file even if not deleting the KV*/
2464+
cfstore_listDel(&file->node);
2465+
memset(file, 0, sizeof(cfstore_file_t));
24572466
}
24582467
return ret;
24592468
}
@@ -4045,6 +4054,7 @@ static int32_t cfstore_uninitialise(void)
40454054
CFSTORE_FREE(ctx->area_0_head);
40464055
ctx->area_0_head = NULL;
40474056
ctx->area_0_tail = NULL;
4057+
ctx->area_0_len = 0;
40484058
}
40494059
}
40504060
out:

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ requests
99
mbed-ls>=0.2.13
1010
mbed-host-tests>=1.1.2
1111
mbed-greentea>=0.2.24
12-
pyxdg>=0.25
1312
pycurl>=4
1413
beautifulsoup4>=4
1514
fuzzywuzzy>=0.11

targets/TARGET_ONSEMI/TARGET_NCS36510/swversion.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* $Rev: 2199 $
88
* $Date: 2013-08-07 12:17:27 +0200 (Wed, 07 Aug 2013) $
99
******************************************************************************
10-
* Copyright 2016 Semiconductor Components Industries LLC (d/b/a ON Semiconductor).
10+
* Copyright 2016 Semiconductor Components Industries LLC (d/b/a "ON Semiconductor").
1111
* All rights reserved. This software and/or documentation is licensed by ON Semiconductor
1212
* under limited terms and conditions. The terms and conditions pertaining to the software
1313
* and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf
14-
* (ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software) and
14+
* ("ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software") and
1515
* if applicable the software license agreement. Do not use this software and/or
1616
* documentation unless you have carefully read and you agree to the limited terms and
1717
* conditions. By using this software and/or documentation, you agree to the limited
@@ -37,7 +37,7 @@
3737
* *
3838
*************************************************************************************************/
3939

40-
#ifdef IAR
40+
#ifdef __ICCARM__
4141
/** Define a fib table constant region, to be located at fixed offset in the binary
4242
* such that flash loader knows where to find it and gets the build dependent data
4343
* it needs for programming the new fib.

targets/TARGET_RENESAS/TARGET_RZ_A1H/device/cmsis_nvic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#ifndef MBED_CMSIS_NVIC_H
3333
#define MBED_CMSIS_NVIC_H
3434

35+
#include "cmsis.h"
36+
3537
#ifdef __cplusplus
3638
extern "C" {
3739
#endif

targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/device/cmsis_nvic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#ifndef MBED_CMSIS_NVIC_H
3333
#define MBED_CMSIS_NVIC_H
3434

35+
#include "cmsis.h"
36+
3537
#ifdef __cplusplus
3638
extern "C" {
3739
#endif

targets/TARGET_STM/TARGET_STM32F0/gpio_irq_api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static void gpio_irq2(void) {
127127
}
128128

129129
extern uint32_t Set_GPIO_Clock(uint32_t port_idx);
130+
extern void pin_function_gpiomode(PinName pin, uint32_t gpiomode);
130131

131132
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) {
132133
IRQn_Type irq_n = (IRQn_Type)0;
@@ -196,8 +197,8 @@ void gpio_irq_free(gpio_irq_t *obj) {
196197
gpio_channel->channel_gpio[gpio_idx] = 0;
197198
gpio_channel->channel_pin[gpio_idx] = 0;
198199

199-
// Disable EXTI line
200-
pin_function(obj->pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
200+
// Disable EXTI line, but don't change pull-up config
201+
pin_function_gpiomode(obj->pin, STM_MODE_INPUT);
201202
obj->event = EDGE_NONE;
202203
}
203204

@@ -245,7 +246,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) {
245246
}
246247
}
247248

248-
pin_function(obj->pin, STM_PIN_DATA(mode, pull, 0));
249+
pin_function_gpiomode(obj->pin, mode);
249250
}
250251

251252
void gpio_irq_enable(gpio_irq_t *obj) {

targets/TARGET_STM/TARGET_STM32F0/pinmap.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,20 @@ void pin_mode(PinName pin, PinMode mode) {
138138
if (pupd > 2) pupd = 0; // Open-drain = No pull-up/No pull-down
139139
gpio->PUPDR &= (uint32_t)(~(GPIO_PUPDR_PUPDR0 << (pin_index * 2)));
140140
gpio->PUPDR |= (uint32_t)(pupd << (pin_index * 2));
141+
}
142+
143+
/* Internal function for setting the gpiomode/function
144+
* without changing Pull mode
145+
*/
146+
void pin_function_gpiomode(PinName pin, uint32_t gpiomode) {
147+
148+
/* Read current pull state from HW to avoid over-write*/
149+
uint32_t port_index = STM_PORT(pin);
150+
uint32_t pin_index = STM_PIN(pin);
151+
GPIO_TypeDef *gpio = (GPIO_TypeDef *) Set_GPIO_Clock(port_index);
152+
uint32_t temp = gpio->PUPDR;
153+
uint32_t pull = (temp >> (pin_index * 2U)) & GPIO_PUPDR_PUPDR0;
141154

155+
/* Then re-use global function for updating the mode part*/
156+
pin_function(pin, STM_PIN_DATA(gpiomode, pull, 0));
142157
}

0 commit comments

Comments
 (0)