Skip to content

Commit

Permalink
Merge pull request #12372 from ARMmbed/release-candidate
Browse files Browse the repository at this point in the history
Release candidate for mbed-os-5.15.1
  • Loading branch information
0xc0170 authored Feb 7, 2020
2 parents 64853b3 + 7b398c0 commit e642a7d
Show file tree
Hide file tree
Showing 903 changed files with 509,649 additions and 14,124 deletions.
67 changes: 59 additions & 8 deletions UNITTESTS/events/equeue/test_equeue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,64 @@ static void *multithread_thread(void *p)
return 0;
}

class ecount {
mutable pthread_mutex_t mutex;
pthread_cond_t cond;
uint8_t count;
public:
ecount() : count(0)
{
int err = pthread_mutex_init(&mutex, NULL);
EXPECT_EQ(0, err);
err = pthread_cond_init(&cond, NULL);
EXPECT_EQ(0, err);
}

~ecount()
{
int err = pthread_mutex_destroy(&mutex);
EXPECT_EQ(0, err);
err = pthread_cond_destroy(&cond);
EXPECT_EQ(0, err);
}

void lock() const
{
int err = pthread_mutex_lock(&mutex);
EXPECT_EQ(0, err);
}

void unlock() const
{
int err = pthread_mutex_unlock(&mutex);
EXPECT_EQ(0, err);
}

void touch()
{
lock();
if (count < 200) {
count++;
}
unlock();
int err = pthread_cond_broadcast(&cond);
EXPECT_EQ(0, err);
}

void wait_for_touches(uint8_t n)
{
lock();
while (count < n) {
int err = pthread_cond_wait(&cond, &mutex);
EXPECT_EQ(0, err);
}
unlock();
}
};

static void multithread_func(void *p)
{
if ((*(reinterpret_cast<uint8_t *>(p))) < 200) {
(*(reinterpret_cast<uint8_t *>(p)))++;
}
static_cast<ecount *>(p)->touch();
}

static void background_func(void *p, int ms)
Expand Down Expand Up @@ -665,20 +718,18 @@ TEST_F(TestEqueue, test_equeue_multithread)
int err = equeue_create(&q, TEST_EQUEUE_SIZE);
ASSERT_EQ(0, err);

uint8_t touched = 0;
equeue_call_every(&q, 1, multithread_func, &touched);
ecount t;
equeue_call_every(&q, 1, multithread_func, &t);

pthread_t thread;
err = pthread_create(&thread, 0, multithread_thread, &q);
ASSERT_EQ(0, err);

usleep(10000);
t.wait_for_touches(1);
equeue_break(&q);
err = pthread_join(thread, 0);
ASSERT_EQ(0, err);

EXPECT_TRUE(touched > 1);

equeue_destroy(&q);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"FVP_MPS2": {
"base-address": "0x00200000",
"size": "0x200000"
},
"S5JS100": {
"base-address": "0x40EF5000",
"size": "0x80000"
}
}
}
6 changes: 6 additions & 0 deletions components/storage/blockdevice/COMPONENT_SPIF/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
}
},
"target_overrides": {
"HANI_IOT": {
"SPI_MOSI": "P0_26",
"SPI_MISO": "P1_3",
"SPI_CLK": "P1_2",
"SPI_CS": "P0_20"
},
"LPC54114": {
"SPI_MOSI": "P0_20",
"SPI_MISO": "P0_18",
Expand Down
16 changes: 6 additions & 10 deletions components/wifi/esp8266-driver/ESP8266/ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_PRESENT)
#if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_API_PRESENT)
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
Expand Down Expand Up @@ -57,7 +57,6 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
_closed(false),
_error(false),
_busy(false),
_reset_check(_rmutex),
_reset_done(false),
_conn_status(NSAPI_STATUS_DISCONNECTED)
{
Expand Down Expand Up @@ -272,14 +271,15 @@ bool ESP8266::reset(void)
continue;
}

_rmutex.lock();
while ((rtos::Kernel::get_ms_count() - start_time < ESP8266_BOOTTIME) && !_reset_done) {
while (!_reset_done) {
_process_oob(ESP8266_RECV_TIMEOUT, true); // UART mutex claimed -> need to check for OOBs ourselves
_reset_check.wait_for(100); // Arbitrary relatively short delay
if (_reset_done || (rtos::Kernel::get_ms_count() - start_time >= ESP8266_BOOTTIME)) {
break;
}
rtos::ThisThread::sleep_for(100);
}

done = _reset_done;
_rmutex.unlock();
if (done) {
break;
}
Expand Down Expand Up @@ -1040,11 +1040,7 @@ void ESP8266::_oob_watchdog_reset()

void ESP8266::_oob_ready()
{

_rmutex.lock();
_reset_done = true;
_reset_check.notify_all();
_rmutex.unlock();

for (int i = 0; i < SOCKET_COUNT; i++) {
_sock_i[i].open = false;
Expand Down
6 changes: 2 additions & 4 deletions components/wifi/esp8266-driver/ESP8266/ESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef ESP8266_H
#define ESP8266_H

#if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_PRESENT)
#if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_API_PRESENT)
#include <stdint.h>

#include "drivers/UARTSerial.h"
Expand All @@ -27,8 +27,8 @@
#include "platform/ATCmdParser.h"
#include "platform/Callback.h"
#include "platform/mbed_error.h"
#include "rtos/ConditionVariable.h"
#include "rtos/Mutex.h"
#include "rtos/ThisThread.h"

// Various timeouts for different ESP8266 operations
#ifndef ESP8266_CONNECT_TIMEOUT
Expand Down Expand Up @@ -428,7 +428,6 @@ class ESP8266 {
PinName _serial_rts;
PinName _serial_cts;
rtos::Mutex _smutex; // Protect serial port access
rtos::Mutex _rmutex; // Reset protection

// AT Command Parser
mbed::ATCmdParser _parser;
Expand Down Expand Up @@ -479,7 +478,6 @@ class ESP8266 {
bool _closed;
bool _error;
bool _busy;
rtos::ConditionVariable _reset_check;
bool _reset_done;

// Modem's address info
Expand Down
14 changes: 13 additions & 1 deletion components/wifi/esp8266-driver/ESP8266Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_PRESENT)
#if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_API_PRESENT)

#include <string.h>
#include <stdint.h>
Expand Down Expand Up @@ -64,7 +64,9 @@ ESP8266Interface::ESP8266Interface()
_pwr_pin(MBED_CONF_ESP8266_PWR),
_ap_sec(NSAPI_SECURITY_UNKNOWN),
_if_blocking(true),
#if MBED_CONF_RTOS_PRESENT
_if_connected(_cmutex),
#endif
_initialized(false),
_connect_retval(NSAPI_ERROR_OK),
_disconnect_retval(NSAPI_ERROR_OK),
Expand Down Expand Up @@ -104,7 +106,9 @@ ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName r
_pwr_pin(pwr),
_ap_sec(NSAPI_SECURITY_UNKNOWN),
_if_blocking(true),
#if MBED_CONF_RTOS_PRESENT
_if_connected(_cmutex),
#endif
_initialized(false),
_connect_retval(NSAPI_ERROR_OK),
_disconnect_retval(NSAPI_ERROR_OK),
Expand Down Expand Up @@ -267,7 +271,9 @@ void ESP8266Interface::_connect_async()
_esp.uart_enable_input(false);
_software_conn_stat = IFACE_STATUS_DISCONNECTED;
}
#if MBED_CONF_RTOS_PRESENT
_if_connected.notify_all();
#endif
} else {
// Postpone to give other stuff time to run
_connect_event_id = _global_event_queue->call_in(ESP8266_INTERFACE_CONNECT_INTERVAL_MS,
Expand Down Expand Up @@ -329,10 +335,12 @@ int ESP8266Interface::connect()
"connect(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
}

#if MBED_CONF_RTOS_PRESENT
while (_if_blocking && (_conn_status_to_error() != NSAPI_ERROR_IS_CONNECTED)
&& (_connect_retval == NSAPI_ERROR_NO_CONNECTION)) {
_if_connected.wait();
}
#endif

_cmutex.unlock();

Expand Down Expand Up @@ -418,7 +426,9 @@ void ESP8266Interface::_disconnect_async()

_power_off();
_software_conn_stat = IFACE_STATUS_DISCONNECTED;
#if MBED_CONF_RTOS_PRESENT
_if_connected.notify_all();
#endif

} else {
// Postpone to give other stuff time to run
Expand Down Expand Up @@ -479,11 +489,13 @@ int ESP8266Interface::disconnect()
"disconnect(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
}

#if MBED_CONF_RTOS_PRESENT
while (_if_blocking
&& (_conn_status_to_error() != NSAPI_ERROR_NO_CONNECTION)
&& (_disconnect_retval != NSAPI_ERROR_OK)) {
_if_connected.wait();
}
#endif

_cmutex.unlock();
if (!_if_blocking) {
Expand Down
6 changes: 5 additions & 1 deletion components/wifi/esp8266-driver/ESP8266Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef ESP8266_INTERFACE_H
#define ESP8266_INTERFACE_H

#if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_PRESENT)
#if DEVICE_SERIAL && DEVICE_INTERRUPTIN && defined(MBED_CONF_EVENTS_PRESENT) && defined(MBED_CONF_NSAPI_PRESENT) && defined(MBED_CONF_RTOS_API_PRESENT)
#include "drivers/DigitalOut.h"
#include "drivers/Timer.h"
#include "ESP8266/ESP8266.h"
Expand All @@ -30,7 +30,9 @@
#include "features/netsocket/WiFiAccessPoint.h"
#include "features/netsocket/WiFiInterface.h"
#include "platform/Callback.h"
#if MBED_CONF_RTOS_PRESENT
#include "rtos/ConditionVariable.h"
#endif
#include "rtos/Mutex.h"

#define ESP8266_SOCKET_COUNT 5
Expand Down Expand Up @@ -452,7 +454,9 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface {
struct _channel_info _ch_info;

bool _if_blocking; // NetworkInterface, blocking or not
#if MBED_CONF_RTOS_PRESENT
rtos::ConditionVariable _if_connected;
#endif

// connect status reporting
nsapi_error_t _conn_status_to_error();
Expand Down
Loading

0 comments on commit e642a7d

Please sign in to comment.