Skip to content

Commit 54aa2f3

Browse files
authored
Merge branch 'master' into bugfix/urlparams
2 parents e800cd0 + 1bd1de0 commit 54aa2f3

File tree

15 files changed

+274
-82
lines changed

15 files changed

+274
-82
lines changed

cores/esp8266/core_esp8266_postmortem.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
#include "user_interface.h"
2828
#include "esp8266_peri.h"
2929
#include "cont.h"
30+
#include "pgmspace.h"
3031

3132
extern void __real_system_restart_local();
3233
extern void gdb_do_break();
3334

3435
extern cont_t g_cont;
3536

37+
// These will be pointers to PROGMEM const strings
3638
static const char* s_panic_file = 0;
3739
static int s_panic_line = 0;
3840
static const char* s_panic_func = 0;
@@ -55,6 +57,14 @@ extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack,
5557

5658
extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
5759

60+
static void ets_puts_P(const char *romString) {
61+
char c = pgm_read_byte(romString++);
62+
while (c) {
63+
ets_putc(c);
64+
c = pgm_read_byte(romString++);
65+
}
66+
}
67+
5868
void __wrap_system_restart_local() {
5969
if (crash_for_gdb) *((int*)0) = 0;
6070
register uint32_t sp asm("a1");
@@ -71,17 +81,21 @@ void __wrap_system_restart_local() {
7181
ets_install_putc1(&uart_write_char_d);
7282

7383
if (s_panic_line) {
74-
ets_printf("\nPanic %s:%d %s\n", s_panic_file, s_panic_line, s_panic_func);
84+
ets_puts_P(PSTR("\nPanic "));
85+
ets_puts_P(s_panic_file);
86+
ets_printf(":%d ", s_panic_line);
87+
ets_puts_P(s_panic_func);
88+
ets_puts_P(PSTR("\n"));
7589
}
7690
else if (s_abort_called) {
77-
ets_printf("Abort called\n");
91+
ets_puts_P(PSTR("Abort called\n"));
7892
}
7993
else if (rst_info.reason == REASON_EXCEPTION_RST) {
8094
ets_printf("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n",
8195
rst_info.exccause, rst_info.epc1, rst_info.epc2, rst_info.epc3, rst_info.excvaddr, rst_info.depc);
8296
}
8397
else if (rst_info.reason == REASON_SOFT_WDT_RST) {
84-
ets_printf("\nSoft WDT reset\n");
98+
ets_puts_P(PSTR("\nSoft WDT reset\n"));
8599
}
86100

87101
uint32_t cont_stack_start = (uint32_t) &(g_cont.stack);
@@ -103,11 +117,11 @@ void __wrap_system_restart_local() {
103117
}
104118

105119
if (sp > cont_stack_start && sp < cont_stack_end) {
106-
ets_printf("\nctx: cont \n");
120+
ets_puts_P(PSTR("\nctx: cont \n"));
107121
stack_end = cont_stack_end;
108122
}
109123
else {
110-
ets_printf("\nctx: sys \n");
124+
ets_puts_P(("\nctx: sys \n"));
111125
stack_end = 0x3fffffb0;
112126
// it's actually 0x3ffffff0, but the stuff below ets_run
113127
// is likely not really relevant to the crash
@@ -126,7 +140,7 @@ void __wrap_system_restart_local() {
126140

127141

128142
static void print_stack(uint32_t start, uint32_t end) {
129-
ets_printf("\n>>>stack>>>\n");
143+
ets_puts_P(PSTR("\n>>>stack>>>\n"));
130144
for (uint32_t pos = start; pos < end; pos += 0x10) {
131145
uint32_t* values = (uint32_t*)(pos);
132146

@@ -136,7 +150,7 @@ static void print_stack(uint32_t start, uint32_t end) {
136150
ets_printf("%08x: %08x %08x %08x %08x %c\n",
137151
pos, values[0], values[1], values[2], values[3], (looksLikeStackFrame)?'<':' ');
138152
}
139-
ets_printf("<<<stack<<<\n");
153+
ets_puts_P(PSTR("<<<stack<<<\n"));
140154
}
141155

142156
/*

cores/esp8266/umm_malloc/umm_malloc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@
493493

494494
#include <stdio.h>
495495
#include <string.h>
496+
#include <pgmspace.h>
496497

497498
#include "umm_malloc.h"
498499

@@ -512,6 +513,9 @@
512513
# define DBG_LOG_LEVEL DBG_LOG_LEVEL
513514
#endif
514515

516+
// Macro to place constant strings into PROGMEM and print them properly
517+
#define printf(fmt, ...) do { static const char fstr[] PROGMEM = fmt; char rstr[sizeof(fmt)]; for (size_t i=0; i<sizeof(rstr); i++) rstr[i] = fstr[i]; printf(rstr, ##__VA_ARGS__); } while (0)
518+
515519
/* -- dbglog {{{ */
516520

517521
/* ----------------------------------------------------------------------------

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static const char serverIndex[] PROGMEM =
1212
<input type='file' name='update'>
1313
<input type='submit' value='Update'>
1414
</form>
15-
</body></html>\n)";
15+
</body></html>)";
1616
static const char successResponse[] PROGMEM =
1717
"<META http-equiv=\"refresh\" content=\"15;URL=\">Update Success! Rebooting...\n";
1818

libraries/ESP8266WebServer/src/Parsing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
9191
String searchStr = "";
9292
int hasSearch = url.indexOf('?');
9393
if (hasSearch != -1){
94-
searchStr = urlDecode(url.substring(hasSearch + 1));
94+
searchStr = url.substring(hasSearch + 1);
9595
url = url.substring(0, hasSearch);
9696
}
9797
_currentUri = url;
@@ -321,7 +321,7 @@ void ESP8266WebServer::_parseArguments(String data) {
321321
}
322322
RequestArgument& arg = _currentArgs[iarg];
323323
arg.key = data.substring(pos, equal_sign_index);
324-
arg.value = data.substring(equal_sign_index + 1, next_arg_index);
324+
arg.value = urlDecode(data.substring(equal_sign_index + 1, next_arg_index));
325325
#ifdef DEBUG_ESP_HTTP_SERVER
326326
DEBUG_OUTPUT.print("arg ");
327327
DEBUG_OUTPUT.print(iarg);

libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@
33

44
#include "RequestHandler.h"
55

6+
// Table of extension->MIME strings stored in PROGMEM, needs to be global due to GCC section typing rules
7+
static const struct {const char endsWith[16]; const char mimeType[32];} mimeTable[] ICACHE_RODATA_ATTR = {
8+
{ ".html", "text/html" },
9+
{ ".htm", "text/html" },
10+
{ ".css", "text/css" },
11+
{ ".txt", "text/plain" },
12+
{ ".js", "application/javascript" },
13+
{ ".json", "application/json" },
14+
{ ".png", "image/png" },
15+
{ ".gif", "image/gif" },
16+
{ ".jpg", "image/jpeg" },
17+
{ ".ico", "image/x-icon" },
18+
{ ".svg", "image/svg+xml" },
19+
{ ".ttf", "application/x-font-ttf" },
20+
{ ".otf", "application/x-font-opentype" },
21+
{ ".woff", "application/font-woff" },
22+
{ ".woff2", "application/font-woff2" },
23+
{ ".eot", "application/vnd.ms-fontobject" },
24+
{ ".sfnt", "application/font-sfnt" },
25+
{ ".xml", "text/xml" },
26+
{ ".pdf", "application/pdf" },
27+
{ ".zip", "application/zip" },
28+
{ ".gz", "application/x-gzip" },
29+
{ ".appcache", "text/cache-manifest" },
30+
{ "", "application/octet-stream" } };
31+
632
class FunctionRequestHandler : public RequestHandler {
733
public:
834
FunctionRequestHandler(ESP8266WebServer::THandlerFunction fn, ESP8266WebServer::THandlerFunction ufn, const String &uri, HTTPMethod method)
@@ -116,29 +142,18 @@ class StaticRequestHandler : public RequestHandler {
116142
}
117143

118144
static String getContentType(const String& path) {
119-
if (path.endsWith(".html")) return "text/html";
120-
else if (path.endsWith(".htm")) return "text/html";
121-
else if (path.endsWith(".css")) return "text/css";
122-
else if (path.endsWith(".txt")) return "text/plain";
123-
else if (path.endsWith(".js")) return "application/javascript";
124-
else if (path.endsWith(".json")) return "application/json";
125-
else if (path.endsWith(".png")) return "image/png";
126-
else if (path.endsWith(".gif")) return "image/gif";
127-
else if (path.endsWith(".jpg")) return "image/jpeg";
128-
else if (path.endsWith(".ico")) return "image/x-icon";
129-
else if (path.endsWith(".svg")) return "image/svg+xml";
130-
else if (path.endsWith(".ttf")) return "application/x-font-ttf";
131-
else if (path.endsWith(".otf")) return "application/x-font-opentype";
132-
else if (path.endsWith(".woff")) return "application/font-woff";
133-
else if (path.endsWith(".woff2")) return "application/font-woff2";
134-
else if (path.endsWith(".eot")) return "application/vnd.ms-fontobject";
135-
else if (path.endsWith(".sfnt")) return "application/font-sfnt";
136-
else if (path.endsWith(".xml")) return "text/xml";
137-
else if (path.endsWith(".pdf")) return "application/pdf";
138-
else if (path.endsWith(".zip")) return "application/zip";
139-
else if(path.endsWith(".gz")) return "application/x-gzip";
140-
else if (path.endsWith(".appcache")) return "text/cache-manifest";
141-
return "application/octet-stream";
145+
char buff[sizeof(mimeTable[0].mimeType)];
146+
// Check all entries but last one for match, return if found
147+
for (size_t i=0; i < sizeof(mimeTable)/sizeof(mimeTable[0])-1; i++) {
148+
strcpy_P(buff, mimeTable[i].endsWith);
149+
if (path.endsWith(buff)) {
150+
strcpy_P(buff, mimeTable[i].mimeType);
151+
return String(buff);
152+
}
153+
}
154+
// Fall-through and just return default type
155+
strcpy_P(buff, mimeTable[sizeof(mimeTable)/sizeof(mimeTable[0])-1].mimeType);
156+
return String(buff);
142157
}
143158

144159
protected:

libraries/ESP8266WiFi/src/WiFiClientSecure.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -657,53 +657,6 @@ extern "C" int __ax_get_file(const char *filename, uint8_t **buf)
657657
}
658658
extern "C" void ax_get_file() __attribute__ ((weak, alias("__ax_get_file")));
659659

660-
661-
#ifdef DEBUG_TLS_MEM
662-
#define DEBUG_TLS_MEM_PRINT(...) DEBUGV(__VA_ARGS__)
663-
#else
664-
#define DEBUG_TLS_MEM_PRINT(...)
665-
#endif
666-
667-
extern "C" void* ax_port_malloc(size_t size, const char* file, int line)
668-
{
669-
(void) file;
670-
(void) line;
671-
void* result = malloc(size);
672-
if (result == nullptr) {
673-
DEBUG_TLS_MEM_PRINT("%s:%d malloc %d failed, left %d\r\n", file, line, size, ESP.getFreeHeap());
674-
}
675-
if (size >= 1024) {
676-
DEBUG_TLS_MEM_PRINT("%s:%d malloc %d, left %d\r\n", file, line, size, ESP.getFreeHeap());
677-
}
678-
return result;
679-
}
680-
681-
extern "C" void* ax_port_calloc(size_t size, size_t count, const char* file, int line)
682-
{
683-
void* result = ax_port_malloc(size * count, file, line);
684-
memset(result, 0, size * count);
685-
return result;
686-
}
687-
688-
extern "C" void* ax_port_realloc(void* ptr, size_t size, const char* file, int line)
689-
{
690-
(void) file;
691-
(void) line;
692-
void* result = realloc(ptr, size);
693-
if (result == nullptr) {
694-
DEBUG_TLS_MEM_PRINT("%s:%d realloc %d failed, left %d\r\n", file, line, size, ESP.getFreeHeap());
695-
}
696-
if (size >= 1024) {
697-
DEBUG_TLS_MEM_PRINT("%s:%d realloc %d, left %d\r\n", file, line, size, ESP.getFreeHeap());
698-
}
699-
return result;
700-
}
701-
702-
extern "C" void ax_port_free(void* ptr)
703-
{
704-
free(ptr);
705-
}
706-
707660
extern "C" void __ax_wdt_feed()
708661
{
709662
optimistic_yield(10000);

libraries/GDBStub/library.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "GDBStub",
3+
"version": "0.2",
4+
"keywords": "gdb, debug",
5+
"description": "GDB server stub helps debug crashes when JTAG isn't an option.",
6+
"repository":
7+
{
8+
"type": "git",
9+
"url": "https://github.com/esp8266/Arduino.git"
10+
},
11+
"export": {
12+
"include": "libraries/GDBStub"
13+
},
14+
"authors":
15+
[
16+
{
17+
"name": "Jeroen Domburg"
18+
},
19+
{
20+
"name": "Ivan Grokhotkov",
21+
"email": "[email protected]",
22+
"maintainer": true
23+
}
24+
],
25+
"frameworks": "arduino",
26+
"platforms": "espressif8266",
27+
"build": {
28+
"libArchive": false
29+
}
30+
}

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "framework-arduinoespressif8266",
3+
"description": "Arduino Wiring-based Framework (ESP8266 Core)",
4+
"url": "https://github.com/esp8266/Arduino",
5+
"version": "2.4.0-rc.1"
6+
}

tests/common.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,53 @@ function build_package()
122122
./build_boards_manager_package.sh
123123
}
124124

125+
126+
function install_platformio()
127+
{
128+
pip install -U https://github.com/platformio/platformio/archive/develop.zip
129+
platformio platform install https://github.com/platformio/platform-espressif8266.git#feature/stage
130+
sed -i 's/https:\/\/github\.com\/esp8266\/Arduino\.git/*/' ~/.platformio/platforms/espressif8266_stage/platform.json
131+
ln -s $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif8266
132+
# Install dependencies:
133+
# - esp8266/examples/ConfigFile
134+
pio lib install ArduinoJson
135+
}
136+
137+
function build_sketches_with_platformio()
138+
{
139+
set +e
140+
local srcpath=$1
141+
local build_arg=$2
142+
local sketches=$(find $srcpath -name *.ino)
143+
for sketch in $sketches; do
144+
local sketchdir=$(dirname $sketch)
145+
local sketchdirname=$(basename $sketchdir)
146+
local sketchname=$(basename $sketch)
147+
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
148+
echo "Skipping $sketch, beacause it is not the main sketch file";
149+
continue
150+
fi;
151+
if [[ -f "$sketchdir/.test.skip" ]]; then
152+
echo -e "\n ------------ Skipping $sketch ------------ \n";
153+
continue
154+
fi
155+
local build_cmd="pio ci $sketchdir $build_arg"
156+
echo -e "\n ------------ Building $sketch ------------ \n";
157+
echo "$build_cmd"
158+
time ($build_cmd >build.log)
159+
local result=$?
160+
if [ $result -ne 0 ]; then
161+
echo "Build failed ($1)"
162+
echo "Build log:"
163+
cat build.log
164+
set -e
165+
return $result
166+
fi
167+
rm build.log
168+
done
169+
set -e
170+
}
171+
125172
function run_travis_ci_build()
126173
{
127174
# Build documentation using Sphinx
@@ -165,6 +212,15 @@ function run_travis_ci_build()
165212
echo -e "travis_fold:start:size_report"
166213
cat size.log
167214
echo -e "travis_fold:end:size_report"
215+
216+
# PlatformIO
217+
echo -e "travis_fold:start:install_platformio"
218+
install_platformio
219+
echo -e "travis_fold:end:install_platformio"
220+
221+
echo -e "travis_fold:start:build_sketches_with_platformio"
222+
build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose"
223+
echo -e "travis_fold:end:build_sketches_with_platformio"
168224
}
169225

170226
set -e

0 commit comments

Comments
 (0)