8000 IPv6 on esp8266-nonos-sdk and arduino by d-a-v · Pull Request #5136 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

IPv6 on esp8266-nonos-sdk and arduino #5136

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

Merged
merged 127 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
6c64759
wip
d-a-v Aug 22, 2018
746ec81
cc wip
d-a-v Aug 22, 2018
53c9222
cc wip
d-a-v Aug 22, 2018
6de50d4
cc comments
d-a-v Aug 22, 2018
2dd152d
wip cc
d-a-v Aug 24, 2018
f87602a
+sync, get/set default nodelay, sync
d-a-v Aug 27, 2018
6be4b6f
default nodelay=1
d-a-v Aug 28, 2018
8f7fb1e
update flush()
d-a-v Aug 28, 2018
c0bea2b
fix return value
d-a-v Aug 28, 2018
d00ac35
ClientContext: put things together
d-a-v Aug 28, 2018
53a19a8
Merge branch 'master' into ClientContext
devyte Sep 5, 2018
a662bfc
use ip4_addr instead of ip_addr
d-a-v May 23, 2018
b751983
ip4* -> ipv4*
d-a-v Aug 30, 2018
fc1719e
ipv6 wip
d-a-v Aug 30, 2018
68c207c
wip ipv6
d-a-v Sep 5, 2018
e18c276
wip ipv6
d-a-v Sep 5, 2018
090c5d5
ipv6: now compiles and links
d-a-v Sep 6, 2018
2fcd96c
wip ipv6: simplification of IPAddress + fix nasty reinterpret_cast bug
d-a-v Sep 6, 2018
eb666fb
wip ipv6
d-a-v Sep 6, 2018
ad02962
wip ipv6
d-a-v Sep 7, 2018
6718fe6
wip ipv6 lwIP-2.1rc0, menus
d-a-v Sep 10, 2018
95e8afe
wip ipv6
d-a-v Sep 10, 2018
de36650
wip ipv6
d-a-v Sep 11, 2018
d21916d
use ip4_addr instead of ip_addr
d-a-v May 23, 2018
0b11b17
ip4* -> ipv4*
d-a-v Aug 30, 2018
537b4da
ipv6 wip
d-a-v Aug 30, 2018
8f2ad74
wip ipv6
d-a-v Sep 5, 2018
c398663
wip ipv6
d-a-v Sep 5, 2018
b26701a
ipv6: now compiles and links
d-a-v Sep 6, 2018
9903be1
wip ipv6: simplification of IPAddress + fix nasty reinterpret_cast bug
d-a-v Sep 6, 2018
20bbdb3
wip ipv6
d-a-v Sep 6, 2018
b05dd81
wip ipv6
d-a-v Sep 7, 2018
b96c1c0
Merge branch 'ipv6' of github.com:d-a-v/Arduino into ipv6
d-a-v Sep 13, 2018
643036f
wip ipv6: now tcp server is working too :)
d-a-v Sep 14, 2018
86ba377
Merge branch 'ClientContext' into ipv6-test
d-a-v Sep 14, 2018
347130e
Merge branch 'master' into ipv6-test
devyte Sep 14, 2018
3c6ecb7
ipv6 fixes from lwip2 (dhcp6 working, beware: your esp is now accessi…
d-a-v Sep 15, 2018
5799d7e
parse and show standard ipv6 + WiFi.localIP6Link()/localIP6Global()
d-a-v Sep 16, 2018
d93ff6f
IPv6 initial example sketch
d-a-v Sep 17, 2018
54a50e2
liblwip2.a -> liblwip2_536.a
d-a-v Sep 17, 2018
43c5c9f
getFullVersion: lwIP version was displayed twice
d-a-v Sep 17, 2018
a777aa3
udp with IPV6 fixes
d-a-v Sep 17, 2018
1f48ad7
fix generic ip type management
d-a-v Sep 17, 2018
e3da355
lwip2: disable debug
d-a-v Sep 17, 2018
22f5701
lwip2: disable debug
d-a-v Sep 17, 2018
389bf07
lwip2: disable debug
d-a-v Sep 17, 2018
402c35e
update example with UDP showing remote v4 or v6 address
d-a-v Sep 17, 2018
53931c5
wip
d-a-v Aug 22, 2018
81ec0f4
cc wip
d-a-v Aug 22, 2018
fbf1dd1
cc wip
d-a-v Aug 22, 2018
b4a918f
cc comments
d-a-v Aug 22, 2018
c14eeef
wip cc
d-a-v Aug 24, 2018
238610e
+sync, get/set default nodelay, sync
d-a-v Aug 27, 2018
d0036a1
default nodelay=1
d-a-v Aug 28, 2018
e4c187b
update flush()
d-a-v Aug 28, 2018
d31d6f2
fix return value
d-a-v Aug 28, 2018
5cf60b6
ClientContext: put things together
d-a-v Aug 28, 2018
a058506
Move SSLContext to its own header (#5121)
earlephilhower Sep 17, 2018
a7a5959
Fix connection options and update github pubkey (#5120)
earlephilhower Sep 17, 2018
d06cac2
ClientContext: fix debugging messages
d-a-v Sep 18, 2018
976b749
Merge branch 'ClientContext' into ipv6-test
d-a-v Sep 18, 2018
ad61dfc
Esp.getFullVersion: show when IPv6 is enabled
d-a-v Sep 18, 2018
ede6e44
fixes lwip-v2 compatibilities with lwip-1.4 (check IPAddress.h's begi…
d-a-v Sep 18, 2018
2693714
enable nagle by default
d-a-v Sep 18, 2018
1bc5bc8
minor update to IPv6 example
d-a-v Sep 18, 2018
e67b6f0
astyled example
d-a-v Sep 18, 2018
c7859ba
LLMNR: restore a removed test
d-a-v Sep 18, 2018
636aa28
mDNSlib porting (multicast api changes like for MMNR SSDP)
d-a-v Sep 18, 2018
17ba0f6
fix: IPAddress is now rich, and cast to uint32_t is sometimes ambiguo…
d-a-v Sep 18, 2018
afa747d
port OTA
d-a-v Sep 18, 2018
0bbd791
IPAddress cosmetic
d-a-v Sep 18, 2018
4708451
add const to Ethernet and friends
d-a-v Sep 18, 2018
e8c659e
Merge branch 'master' into ClientContext
earlephilhower Sep 18, 2018
63e1da7
fix DNS
d-a-v Sep 18, 2018
b9f79f5
Merge branch 'master' into ipv6-test
d-a-v Sep 18, 2018
f271b2a
WiFiClient: move static members out of the class, add comments
d-a-v Sep 18, 2018
7f57694
Merge branch 'ClientContext' of github.com:d-a-v/Arduino into ClientC…
d-a-v Sep 18, 2018
888bdb8
remove circular dependency
d-a-v Sep 19, 2018
9d31c78
Merge branch 'ClientContext' into ipv6-test
d-a-v Sep 19, 2018
15e7dfe
IPAddress needs to be copied
d-a-v Sep 19, 2018
c8a81e5
IPAddress needs to be copied
d-a-v Sep 19, 2018
254c252
IPaddress: fix nullptr
d-a-v Sep 19, 2018
c2b0b96
add missing files (due to update to lwIP-2.1rc1)
d-a-v Sep 19, 2018
8f53b52
ipv6 example: use ipv6.google.com, shows status in udp:23, show versions
d-a-v Sep 19, 2018
0b7456b
Merge branch 'master' into ipv6-test
devyte Sep 21, 2018
64802a0
interface list for c++
d-a-v Sep 22, 2018
b7cd735
Merge branch 'master' into ipv6-test
d-a-v Sep 22, 2018
ba4a4d0
Merge branch 'master' into ipv6-test
d-a-v Sep 24, 2018
0393171
Merge branch 'master' into ipv6-test
d-a-v Sep 25, 2018
f63d2c7
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Sep 25, 2018
0cde770
+ IfList: interface iterator
d-a-v Sep 26, 2018
e855977
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Sep 26, 2018
4f97603
rename ifList to addrList, more accessors, updated example
d-a-v Sep 26, 2018
a6faa9d
Merge branch 'master' into ipv6-test
d-a-v Sep 27, 2018
b1e9cb5
Merge branch 'master' into ipv6-test
d-a-v Sep 28, 2018
10638ba
Merge branch 'master' into ipv6-test
d-a-v Sep 29, 2018
5948b93
Merge branch 'master' into ipv6-test
d-a-v Oct 1, 2018
bd85431
update example & comments and AddrList API
d-a-v Oct 1, 2018
0de3365
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Oct 1, 2018
f986cfe
astyle
d-a-v Oct 1, 2018
190c016
Merge branch 'master' into ipv6-test
d-a-v Oct 2, 2018
94eef5f
Merge branch 'master' into ipv6-test2
d-a-v Oct 9, 2018
f4cb3a6
cleaning
d-a-v Oct 9, 2018
bc654a3
Merge branch 'master' into ipv6-test
d-a-v Nov 26, 2018
849f87a
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Nov 26, 2018
29618dc
use CONST in place of constv2
d-a-v Nov 26, 2018
38efc64
Merge branch 'master' into ipv6-test
d-a-v Nov 26, 2018
1d78618
+ IPAddress::fromString4()
d-a-v Nov 26, 2018
bcd8fcd
use StringStream:: for ::toString()
d-a-v Nov 26, 2018
53b099b
use periodic timeout
d-a-v Nov 26, 2018
366d3a7
minor updates on interface iterator
d-a-v Nov 26, 2018
2dcf863
check for IPv4 addresses for softAP intialization
d-a-v Nov 26, 2018
82eecf3
comment
d-a-v Nov 27, 2018
0d7cd7d
document preprocessing #error directive
d-a-v Nov 27, 2018
523aa05
remove lowpan*
d-a-v Nov 27, 2018
97d2032
fix example
d-a-v Nov 27, 2018
ece7393
pio build
d-a-v Nov 27, 2018
b526eef
remove ifList from ESP8266WiFi.cpp
d-a-v Nov 27, 2018
d377bad
fix boards.txt
d-a-v Nov 27, 2018
271e94f
cast return type
d-a-v Nov 27, 2018
326f705
Merge branch 'ipv6-test' of github.com:d-a-v/Arduino into ipv6-test
d-a-v Nov 27, 2018
d2bad35
rename IfList -> AddrList
d-a-v Nov 27, 2018
9ea8f0e
rename IfList to AddrList
d-a-v Nov 27, 2018
f530d84
fix example
d-a-v Nov 27, 2018
c16a111
check WiFi.config args for v4()
d-a-v Nov 27, 2018
72a64f0
remove tools/sdk/include/mesh.h
d-a-v Nov 27, 2018
fdcca1f
update lwIP to 2.1.2 stable, glue tagged 1.0 stable
d-a-v Nov 27, 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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sudo: false
language: bash
os: linux
dist: trusty
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and
# Contents
- Installing options:
- [Using Boards Manager](#installing-with-boards-manager)
- [Using git version](#using-git-version)
- [Using git version](#using-git-version-basic-instructions)
- [Using PlatformIO](#using-platformio)
- [Building with make](#building-with-make)
- [Documentation](#documentation)
Expand All @@ -30,15 +30,19 @@ Boards manager link: `http://arduino.esp8266.com/stable/package_esp8266com_index

Documentation: [https://arduino-esp8266.readthedocs.io/en/2.4.2/](https://arduino-esp8266.readthedocs.io/en/2.4.2/)

### Using git version
### Using git version (basic instructions)
[![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino)

- Install the current upstream Arduino IDE at the 1.8 level or later. The current version is at the [Arduino website](http://www.arduino.cc/en/main/software).
- Go to Arduino application directory
- Go to Arduino directory
- For Mac OS X, it is `Arduino.app` showing as the Arduino icon.
This location may be your `~/Downloads`, `~/Desktop` or even `/Applications`.
```bash
cd <application-directory>/Arduino.app/Contents/
cd <application-directory>/Arduino.app/Contents/Java
```
- For Linux, it is ~/arduino by default.
```bash
cd ~arduino
```
- Clone this repository into hardware/esp8266com/esp8266 directory (or clone it elsewhere and create a symlink)
```bash
Expand Down Expand Up @@ -124,3 +128,5 @@ ESP8266 core files are licensed under LGPL.
[umm_malloc](https://github.com/rhempel/umm_malloc) memory management library written by Ralph Hempel is used in this project. It is distributed under MIT license.

[axTLS](http://axtls.sourceforge.net/) library written by Cameron Rich, built from https://github.com/igrr/axtls-8266, is used in this project. It is distributed under [BSD license](https://github.com/igrr/axtls-8266/blob/master/LICENSE).

[BearSSL](https://bearssl.org) library written by Thomas Pornin, built from https://github.com/earlephilhower/bearssl-esp8266, is used in this project. It is distributed under the [MIT License](https://bearssl.org/#legal-details).
1,289 changes: 841 additions & 448 deletions boards.txt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion bootloaders/eboot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ AR := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-gcc
OBJDUMP := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-objdump


INC += -I../../tools/sdk/include
CFLAGS += -std=gnu99

CFLAGS += -O0 -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals

CFLAGS += $(INC)

LDFLAGS += -nostdlib -Wl,--no-check-sections -umain

LD_SCRIPT := -Teboot.ld
Expand Down
Binary file modified bootloaders/eboot/eboot.elf
Binary file not shown.
12 changes: 8 additions & 4 deletions bootloaders/eboot/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
#ifndef FLASH_H
#define FLASH_H


/* The geometry defines are placed in the sdk. The .h was factored out for reuse by eboot here.
* Beware: this means that eboot has an external dependency.
* The following .h is placed in tools/sdk/includes
*/
#include <spi_flash_geometry.h>

int SPIEraseBlock(uint32_t block);
int SPIEraseSector(uint32_t sector);
int SPIRead(uint32_t addr, void *dest, size_t size);
int SPIWrite(uint32_t addr, void *src, size_t size);
int SPIEraseAreaEx(const uint32_t start, const uint32_t size);

#define FLASH_SECTOR_SIZE 0x1000
#define FLASH_BLOCK_SIZE 0x10000
#define APP_START_OFFSET 0x1000

typedef struct {
unsigned char magic;
Expand All @@ -25,7 +29,7 @@ typedef struct {
/* SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) */
unsigned char flash_mode;

/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M,
/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, 8 = 8M, 9 = 16M
Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz */
unsigned char flash_size_freq;

Expand Down
2 changes: 1 addition & 1 deletion cores/esp8266/AddrList.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
delay(500);
}

can be replaced with:
can be replaced by:

for (bool configured = false; !configured; ) {
for (auto addr: addrList)
Expand Down
46 changes: 44 additions & 2 deletions cores/esp8266/Esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,43 @@ uint64_t EspClass::deepSleepMax()

}

/*
Layout of RTC Memory is as follows:
Ref: Espressif doc 2C-ESP8266_Non_OS_SDK_API_Reference, section 3.3.23 (system_rtc_mem_write)

|<------system data (256 bytes)------->|<-----------------user data (512 bytes)--------------->|

SDK function signature:
bool system_rtc_mem_read (
uint32 des_addr,
void * src_addr,
uint32 save_size
)

The system data section can't be used by the user, so:
des_addr must be >=64 (i.e.: 256/4) and <192 (i.e.: 768/4)
src_addr is a pointer to data
save_size is the number of bytes to write

For the method interface:
offset is the user block number (block size is 4 bytes) must be >= 0 and <128
data is a pointer to data, 4-byte aligned
size is number of bytes in the block pointed to by data

Same for write

Note: If the Updater class is in play, e.g.: the application uses OTA, the eboot
command will be stored into the first 128 bytes of user data, then it will be
retrieved by eboot on boot. That means that user data present there will be lost.
Ref:
- discussion in PR #5330.
- https://github.com/esp8266/esp8266-wiki/wiki/Memory-Map#memmory-mapped-io-registers
- Arduino/bootloaders/eboot/eboot_command.h RTC_MEM definition
*/

bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size)
{
if (size + offset > 512) {
if (offset * 4 + size > 512 || size == 0) {
return false;
} else {
return system_rtc_mem_read(64 + offset, data, size);
Expand All @@ -143,13 +177,15 @@ bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size)

bool EspClass::rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size)
{
if (size + offset > 512) {
if (offset * 4 + size > 512 || size == 0) {
return false;
} else {
return system_rtc_mem_write(64 + offset, data, size);
}
}



extern "C" void __real_system_restart_local();
void EspClass::reset(void)
{
Expand All @@ -165,6 +201,7 @@ void EspClass::restart(void)
uint16_t EspClass::getVcc(void)
{
InterruptLock lock;
(void)lock;
return system_get_vdd33();
}

Expand All @@ -183,6 +220,11 @@ uint32_t EspClass::getFreeContStack()
return cont_get_free_stack(g_pcont);
}

void EspClass::resetFreeContStack()
{
cont_repaint_stack(g_pcont);
}

uint32_t EspClass::getChipId(void)
{
return system_get_chip_id();
Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class EspClass {
void getHeapStats(uint32_t* free = nullptr, uint16_t* max = nullptr, uint8_t* frag = nullptr);

uint32_t getFreeContStack();
void resetFreeContStack();

const char * getSdkVersion();
String getCoreVersion();
Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/FSImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class DirImpl {

class FSImpl {
public:
virtual ~FSImpl () { }
virtual bool begin() = 0;
virtual void end() = 0;
virtual bool format() = 0;
Expand Down
5 changes: 4 additions & 1 deletion cores/esp8266/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
#endif

// A class to make it easier to handle and pass around IP addresses
// based on lwip's ip address (ipv4, limited compatibility with ipv6)
// IPv6 update:
// IPAddress is now a decorator class for lwIP's ip_addr_t
// fully backward compatible with legacy IPv4-only Arduino's
// with unchanged footprint when IPv6 is disabled

class IPAddress: public Printable {
private:
Expand Down
4 changes: 2 additions & 2 deletions cores/esp8266/MD5Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class MD5Builder {
void add(const uint8_t * data, const uint16_t len);
void add(const char * data){ add((const uint8_t*)data, strlen(data)); }
void add(char * data){ add((const char*)data); }
void add(const String data){ add(data.c_str()); }
void add(const String& data){ add(data.c_str()); }
void addHexString(const char * data);
void addHexString(char * data){ addHexString((const char*)data); }
void addHexString(const String data){ addHexString(data.c_str()); }
void addHexString(const String& data){ addHexString(data.c_str()); }
bool addStream(Stream & stream, const size_t maxLen);
void calculate(void);
void getBytes(uint8_t * output);
Expand Down
122 changes: 122 additions & 0 deletions cores/esp8266/StackThunk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
StackThunk.c - Allow use second stack for BearSSL calls

BearSSL uses a significant amount of stack space, much larger than
the default Arduino core stack. These routines handle swapping
between a secondary, user-allocated stack on the heap and the real
stack.

Copyright (c) 2017 Earle F. Philhower, III. All rights reserved.

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
Modified 8 May 2015 by Hristo Gochkov (proper post and file upload handling)
*/

#include <stdint.h>
#include <stdlib.h>
#include "StackThunk.h"

uint32_t *stack_thunk_ptr = NULL;
uint32_t *stack_thunk_top = NULL;
uint32_t *stack_thunk_save = NULL; /* Saved A1 while in BearSSL */
uint32_t stack_thunk_refcnt = 0;

#define _stackSize (5600/4)
#define _stackPaint 0xdeadbeef

/* Add a reference, and allocate the stack if necessary */
void stack_thunk_add_ref()
{
stack_thunk_refcnt++;
if (stack_thunk_refcnt == 1) {
stack_thunk_ptr = (uint32_t *)malloc(_stackSize * sizeof(uint32_t));
stack_thunk_top = stack_thunk_ptr + _stackSize - 1;
stack_thunk_save = NULL;
stack_thunk_repaint();
}
}

/* Drop a reference, and free stack if no more in use */
void stack_thunk_del_ref()
{
if (stack_thunk_refcnt == 0) {
/* Error! */
return;
}
stack_thunk_refcnt--;
if (!stack_thunk_refcnt) {
free(stack_thunk_ptr);
stack_thunk_ptr = NULL;
stack_thunk_top = NULL;
stack_thunk_save = NULL;
}
}

void stack_thunk_repaint()
{
for (int i=0; i < _stackSize; i++) {
stack_thunk_ptr[i] = _stackPaint;
}
}

/* Simple accessor functions used by postmortem */
uint32_t stack_thunk_get_refcnt() {
return stack_thunk_refcnt;
}

uint32_t stack_thunk_get_stack_top() {
return (uint32_t)stack_thunk_top;
}

uint32_t stack_thunk_get_stack_bot() {
return (uint32_t)stack_thunk_ptr;
}

uint32_t stack_thunk_get_cont_sp() {
return (uint32_t)stack_thunk_save;
}

/* Return the number of bytes ever used since the stack was created */
uint32_t stack_thunk_get_max_usage()
{
uint32_t cnt = 0;

/* No stack == no usage by definition! */
if (!stack_thunk_ptr) {
return 0;
}

for (cnt=0; (cnt < _stackSize) && (stack_thunk_ptr[cnt] == _stackPaint); cnt++) {
/* Noop, all work done in for() */
}
return 4 * (_stackSize - cnt);
}

/* Print the stack from the first used 16-byte chunk to the top, decodable by the exception decoder */
void stack_thunk_dump_stack()
{
uint32_t *pos = stack_thunk_top;
while (pos < stack_thunk_ptr) {
if ((pos[0] != _stackPaint) || (pos[1] != _stackPaint) || (pos[2] != _stackPaint) || (pos[3] != _stackPaint))
break;
pos += 4;
}
ets_printf(">>>stack>>>\n");
while (pos < stack_thunk_ptr) {
ets_printf("%08x: %08x %08x %08x %08x\n", pos, pos[0], pos[1], pos[2], pos[3]);
pos += 4;
}
ets_printf("<<<stack<<<\n");
}
Loading
0