Skip to content

Commit

Permalink
Merge remote-tracking branch 'esporigin/esp8266' into SPIFFS-OTA
Browse files Browse the repository at this point in the history
  • Loading branch information
pgollor committed Sep 28, 2015
2 parents f54386e + 55d992e commit 98d2468
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
16 changes: 11 additions & 5 deletions cores/esp8266/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ ICACHE_FLASH_ATTR String::String(double value, unsigned char decimalPlaces) {
}

ICACHE_FLASH_ATTR String::~String() {
os_free(buffer);
free(buffer);
}

// /*********************************************/
Expand All @@ -133,7 +133,7 @@ inline void String::init(void) {

void ICACHE_FLASH_ATTR String::invalidate(void) {
if(buffer)
os_free(buffer);
free(buffer);
buffer = NULL;
capacity = len = 0;
}
Expand All @@ -150,12 +150,18 @@ unsigned char ICACHE_FLASH_ATTR String::reserve(unsigned int size) {
}

unsigned char ICACHE_FLASH_ATTR String::changeBuffer(unsigned int maxStrLen) {
char *newbuffer = (char *) os_realloc(buffer, maxStrLen + 1);
size_t newSize = (maxStrLen + 16) & (~0xf);
char *newbuffer = (char *) malloc(newSize);
if(newbuffer) {
memset(newbuffer, 0, newSize);
memcpy(newbuffer, buffer, len);
if (buffer)
free(buffer);
capacity = newSize - 1;
buffer = newbuffer;
capacity = maxStrLen;
return 1;
}
buffer = newbuffer;
return 0;
}

Expand Down Expand Up @@ -192,7 +198,7 @@ void ICACHE_FLASH_ATTR String::move(String &rhs) {
rhs.len = 0;
return;
} else {
os_free(buffer);
free(buffer);
}
}
buffer = rhs.buffer;
Expand Down
25 changes: 14 additions & 11 deletions cores/esp8266/core_esp8266_postmortem.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
/*
postmortem.c - output of debug info on sketch crash
Copyright (c) 2015 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
Expand Down Expand Up @@ -42,25 +42,28 @@ void __wrap_system_restart_local() {

struct rst_info rst_info = {0};
system_rtc_mem_read(0, &rst_info, sizeof(rst_info));
if (rst_info.reason != REASON_SOFT_WDT_RST &&
if (rst_info.reason != REASON_SOFT_WDT_RST &&
rst_info.reason != REASON_EXCEPTION_RST &&
rst_info.reason != REASON_WDT_RST)
rst_info.reason != REASON_WDT_RST)
{
return;
}

ets_install_putc1(&uart_write_char_d);

if (rst_info.reason == REASON_EXCEPTION_RST) {
ets_printf("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n",
ets_printf("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n",
rst_info.exccause, rst_info.epc1, rst_info.epc2, rst_info.epc3, rst_info.excvaddr, rst_info.depc);
}
else if (rst_info.reason == REASON_SOFT_WDT_RST) {
ets_printf("\nSoft WDT reset\n");
}

uint32_t cont_stack_start = (uint32_t) &(g_cont.stack);
uint32_t cont_stack_end = (uint32_t) g_cont.stack_end;
uint32_t stack_end;

// amount of stack taken by interrupt or exception handler
// amount of stack taken by interrupt or exception handler
// and everything up to __wrap_system_restart_local
// (determined empirically, might break)
uint32_t offset = 0;
Expand All @@ -80,13 +83,13 @@ void __wrap_system_restart_local() {
}
else {
ets_printf("\nctx: sys \n");
stack_end = 0x3fffffb0;
// it's actually 0x3ffffff0, but the stuff below ets_run
stack_end = 0x3fffffb0;
// it's actually 0x3ffffff0, but the stuff below ets_run
// is likely not really relevant to the crash
}

ets_printf("sp: %08x end: %08x offset: %04x\n", sp, stack_end, offset);

// print_pcs(sp + offset, stack_end);
print_stack(sp + offset, stack_end);
delayMicroseconds(10000);
Expand All @@ -102,7 +105,7 @@ static void print_stack(uint32_t start, uint32_t end) {
// rough indicator: stack frames usually have SP saved as the second word
bool looksLikeStackFrame = (values[2] == pos + 0x10);

ets_printf("%08x: %08x %08x %08x %08x %c\n",
ets_printf("%08x: %08x %08x %08x %08x %c\n",
pos, values[0], values[1], values[2], values[3], (looksLikeStackFrame)?'<':' ');
}
ets_printf("<<<stack<<<\n");
Expand Down
4 changes: 2 additions & 2 deletions doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ title: Reference
* [size](#size)
* [name](#name)
* [close](#close)
* [WiFi(ESP8266WiFi library)](#wifiesp8266wifi-library)
* [WiFi(ESP8266WiFi library)](#wifiesp8266wifi-library)
* [Ticker](#ticker)
* [EEPROM](#eeprom)
* [I2C (Wire library)](#i2c-wire-library)
Expand Down Expand Up @@ -382,7 +382,7 @@ Size can be anywhere between 4 and 4096 bytes.
whenever you wish to save changes to flash. `EEPROM.end()` will also commit, and will
release the RAM copy of EEPROM contents.

EEPROM library uses one sector of flash located at 0x7b000 for storage.
EEPROM library uses one sector of flash located just after the SPIFFS.

Three examples included.

Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WebServer/src/ESP8266WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ void ESP8266WebServer::_prepareHeader(String& response, int code, const char* co

sendHeader("Content-Type", content_type, true);
if (_contentLength != CONTENT_LENGTH_UNKNOWN && _contentLength != CONTENT_LENGTH_NOT_SET) {
sendHeader("Content-Length", String(_contentLength).c_str());
sendHeader("Content-Length", String(_contentLength));
}
else if (contentLength > 0){
sendHeader("Content-Length", String(contentLength).c_str());
sendHeader("Content-Length", String(contentLength));
}
sendHeader("Connection", "close");
sendHeader("Access-Control-Allow-Origin", "*");
Expand Down
Binary file modified tools/sdk/lib/libaxtls.a
Binary file not shown.
Binary file modified tools/sdk/lib/liblwip.a
Binary file not shown.

0 comments on commit 98d2468

Please sign in to comment.