1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-29 16:03:14 +03:00

Automatic stack location selection (SYS or HEAP), enable per library AR-chive in arduino build system (#5018)

Automatic stack location selection (SYS or HEAP), enable per library AR-chive in arduino build system 

* enable dot_a_linkage on internal libraries
* add device tests
* boards generator: deprecate --noextra4k/--allowWPS and fix documentation
This commit is contained in:
david gauchard
2018-08-20 14:35:52 +02:00
committed by GitHub
parent 9f67d83907
commit 85e68093e9
37 changed files with 268 additions and 151 deletions

View File

@ -0,0 +1,111 @@
/*
ESP8266WiFiSTA-WPS.cpp - WiFi library for esp8266
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Reworked on 28 Dec 2015 by Markus Sattler
*/
#include "ESP8266WiFi.h"
#include "ESP8266WiFiGeneric.h"
#include "ESP8266WiFiSTA.h"
#include "coredecls.h" // disable_extra4k_at_link_time()
static void wifi_wps_status_cb(wps_cb_status status);
/**
* WPS config
* so far only WPS_TYPE_PBC is supported (SDK 1.2.0)
* @return ok
*/
bool ESP8266WiFiSTAClass::beginWPSConfig(void) {
// SYS ram is used by WPS, let's configure user stack inside user's HEAP
disable_extra4k_at_link_time();
if(!WiFi.enableSTA(true)) {
// enable STA failed
return false;
}
disconnect();
DEBUGV("wps begin\n");
if(!wifi_wps_disable()) {
DEBUGV("wps disable failed\n");
return false;
}
// so far only WPS_TYPE_PBC is supported (SDK 1.2.0)
if(!wifi_wps_enable(WPS_TYPE_PBC)) {
DEBUGV("wps enable failed\n");
return false;
}
if(!wifi_set_wps_cb((wps_st_cb_t) &wifi_wps_status_cb)) {
DEBUGV("wps cb failed\n");
return false;
}
if(!wifi_wps_start()) {
DEBUGV("wps start failed\n");
return false;
}
esp_yield();
// will return here when wifi_wps_status_cb fires
return true;
}
/**
* WPS callback
* @param status wps_cb_status
*/
void wifi_wps_status_cb(wps_cb_status status) {
DEBUGV("wps cb status: %d\r\n", status);
switch(status) {
case WPS_CB_ST_SUCCESS:
if(!wifi_wps_disable()) {
DEBUGV("wps disable failed\n");
}
wifi_station_connect();
break;
case WPS_CB_ST_FAILED:
DEBUGV("wps FAILED\n");
break;
case WPS_CB_ST_TIMEOUT:
DEBUGV("wps TIMEOUT\n");
break;
case WPS_CB_ST_WEP:
DEBUGV("wps WEP\n");
break;
case WPS_CB_ST_UNK:
DEBUGV("wps UNKNOWN\n");
if(!wifi_wps_disable()) {
DEBUGV("wps disable failed\n");
}
break;
}
// TODO user function to get status
esp_schedule(); // resume the beginWPSConfig function
}

View File

@ -571,90 +571,6 @@ int32_t ESP8266WiFiSTAClass::RSSI(void) {
// -------------------------------------------------- STA remote configure -----------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------
#ifdef NO_EXTRA_4K_HEAP
/* NO_EXTRA_4K_HEAP's description in cores/esp8266/core_esp8266_main.cpp */
void wifi_wps_status_cb(wps_cb_status status);
/**
* WPS config
* so far only WPS_TYPE_PBC is supported (SDK 1.2.0)
* @return ok
*/
bool ESP8266WiFiSTAClass::beginWPSConfig(void) {
if(!WiFi.enableSTA(true)) {
// enable STA failed
return false;
}
disconnect();
DEBUGV("wps begin\n");
if(!wifi_wps_disable()) {
DEBUGV("wps disable failed\n");
return false;
}
// so far only WPS_TYPE_PBC is supported (SDK 1.2.0)
if(!wifi_wps_enable(WPS_TYPE_PBC)) {
DEBUGV("wps enable failed\n");
return false;
}
if(!wifi_set_wps_cb((wps_st_cb_t) &wifi_wps_status_cb)) {
DEBUGV("wps cb failed\n");
return false;
}
if(!wifi_wps_start()) {
DEBUGV("wps start failed\n");
return false;
}
esp_yield();
// will return here when wifi_wps_status_cb fires
return true;
}
/**
* WPS callback
* @param status wps_cb_status
*/
void wifi_wps_status_cb(wps_cb_status status) {
DEBUGV("wps cb status: %d\r\n", status);
switch(status) {
case WPS_CB_ST_SUCCESS:
if(!wifi_wps_disable()) {
DEBUGV("wps disable failed\n");
}
wifi_station_connect();
break;
case WPS_CB_ST_FAILED:
DEBUGV("wps FAILED\n");
break;
case WPS_CB_ST_TIMEOUT:
DEBUGV("wps TIMEOUT\n");
break;
case WPS_CB_ST_WEP:
DEBUGV("wps WEP\n");
break;
case WPS_CB_ST_UNK:
DEBUGV("wps UNKNOWN\n");
if(!wifi_wps_disable()) {
DEBUGV("wps disable failed\n");
}
break;
}
// TODO user function to get status
esp_schedule(); // resume the beginWPSConfig function
}
#endif // NO_EXTRA_4K_HEAP
bool ESP8266WiFiSTAClass::_smartConfigStarted = false;
bool ESP8266WiFiSTAClass::_smartConfigDone = false;

View File

@ -85,7 +85,7 @@ class ESP8266WiFiSTAClass {
protected:
static bool _useStaticIp;
static bool _useStaticIp;
// ----------------------------------------------------------------------------------------------
// ------------------------------------ STA remote configure -----------------------------------
@ -93,14 +93,7 @@ class ESP8266WiFiSTAClass {
public:
#ifdef NO_EXTRA_4K_HEAP
bool beginWPSConfig(void);
#else
inline bool beginWPSConfig(void) __attribute__((always_inline)) {
return WPS_is_unavailable_in_this_configuration__Please_check_FAQ_or_board_generator_tool();
}
#endif
bool beginSmartConfig();
bool stopSmartConfig();
bool smartConfigDone();

View File

@ -41,6 +41,7 @@ extern "C" {
#include "lwip/netif.h"
#include "include/ClientContext.h"
#include "c_types.h"
#include "coredecls.h"
namespace BearSSL {
@ -1259,14 +1260,12 @@ bool WiFiClientSecure::loadPrivateKey(Stream& stream, size_t size) {
// SSL debugging which should focus on the WiFiClientBearSSL objects.
extern "C" {
#include <cont.h>
extern cont_t g_cont;
extern size_t br_esp8266_stack_proxy_usage();
void _BearSSLCheckStack(const char *fcn, const char *file, int line) {
static int cnt = 0;
register uint32_t *sp asm("a1");
int freestack = 4 * (sp - g_cont.stack);
int freestack = 4 * (sp - g_pcont->stack);
int freeheap = ESP.getFreeHeap();
static int laststack, lastheap, laststack2;
if ((laststack != freestack) || (lastheap != freeheap) || (laststack2 != (int)br_esp8266_stack_proxy_usage())) {