Skip to content

Commit 67027c0

Browse files
authored
Merge pull request #2340 from nodemcu/dev
2.2 master snap
2 parents 5073c19 + 18f33f5 commit 67027c0

File tree

294 files changed

+240623
-7851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+240623
-7851
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
sdk/
22
cache/
3+
.ccache/
34
user_config.h
45
server-ca.crt
56

Makefile

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22
#
33
.NOTPARALLEL:
44

5-
# SDK version NodeMCU is locked to
6-
SDK_VER:=2.1.0
5+
# SDK base version, as released by Espressif
6+
SDK_BASE_VER:=2.2.0
77

8-
# no patch: SDK_BASE_VER equals SDK_VER and sdk dir depends on sdk_extracted
9-
SDK_BASE_VER:=$(SDK_VER)
10-
SDK_DIR_DEPENDS:=sdk_extracted
11-
# with patch: SDK_BASE_VER differs from SDK_VER and sdk dir depends on sdk_patched
12-
#SDK_BASE_VER:=1.5.4
13-
#SDK_DIR_DEPENDS:=sdk_patched
8+
# no patch: SDK_VER equals SDK_BASE_VER and sdk dir depends on sdk_extracted
9+
#SDK_VER:=$(SDK_BASE_VER)
10+
#SDK_DIR_DEPENDS:=sdk_extracted
11+
12+
# with patch: SDK_VER differs from SDK_BASE_VER and sdk dir depends on sdk_patched
13+
SDK_PATCH_VER:=f8f27ce
14+
SDK_VER:=$(SDK_BASE_VER)-$(SDK_PATCH_VER)
15+
SDK_DIR_DEPENDS:=sdk_patched
1416

1517
SDK_FILE_VER:=$(SDK_BASE_VER)
16-
SDK_FILE_SHA1:=66a4272894dc1bcec19f5f8bf79fee80f60a021b
17-
#SDK_PATCH_VER:=$(SDK_VER)_patch_20160704
18-
#SDK_PATCH_SHA1:=388d9e91df74e3b49fca126da482cf822cf1ebf1
18+
SDK_FILE_SHA1:=8b63f1066d3560ff77f119e8ba30a9c39e7baaad
19+
SDK_PATCH_SHA1:=0bc21ec77b08488f04d3e1c9d161b711d07201a8
1920
# Ensure we search "our" SDK before the tool-chain's SDK (if any)
2021
TOP_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
21-
SDK_DIR:=$(TOP_DIR)/sdk/esp_iot_sdk_v$(SDK_VER)
22-
CCFLAGS:= -I$(TOP_DIR)/sdk-overrides/include -I$(SDK_DIR)/include
22+
SDK_REL_DIR=sdk/esp_iot_sdk_v$(SDK_VER)
23+
SDK_DIR:=$(TOP_DIR)/$(SDK_REL_DIR)
24+
CCFLAGS:= -I$(TOP_DIR)/sdk-overrides/include -I$(TOP_DIR)/app/include/lwip/app -I$(SDK_DIR)/include
2325
LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)
2426

2527
ifdef DEBUG
@@ -39,6 +41,7 @@ ifeq ($(OS),Windows_NT)
3941
# It is xcc
4042
AR = xt-ar
4143
CC = xt-xcc
44+
CXX = xt-xcc
4245
NM = xt-nm
4346
CPP = xt-cpp
4447
OBJCOPY = xt-objcopy
@@ -50,6 +53,7 @@ ifeq ($(OS),Windows_NT)
5053
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
5154
AR = xtensa-lx106-elf-ar
5255
CC = xtensa-lx106-elf-gcc
56+
CXX = xtensa-lx106-elf-g++
5357
NM = xtensa-lx106-elf-nm
5458
CPP = xtensa-lx106-elf-cpp
5559
OBJCOPY = xtensa-lx106-elf-objcopy
@@ -77,6 +81,7 @@ else
7781
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
7882
AR = xtensa-lx106-elf-ar
7983
CC = $(WRAPCC) xtensa-lx106-elf-gcc
84+
CXX = $(WRAPCC) xtensa-lx106-elf-g++
8085
NM = xtensa-lx106-elf-nm
8186
CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E
8287
OBJCOPY = xtensa-lx106-elf-objcopy
@@ -104,6 +109,7 @@ ESPTOOL ?= ../tools/esptool.py
104109

105110

106111
CSRCS ?= $(wildcard *.c)
112+
CXXSRCS ?= $(wildcard *.cpp)
107113
ASRCs ?= $(wildcard *.s)
108114
ASRCS ?= $(wildcard *.S)
109115
SUBDIRS ?= $(patsubst %/,%,$(dir $(filter-out tools/Makefile,$(wildcard */Makefile))))
@@ -112,10 +118,12 @@ ODIR := .output
112118
OBJODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/obj
113119

114120
OBJS := $(CSRCS:%.c=$(OBJODIR)/%.o) \
121+
$(CXXSRCS:%.cpp=$(OBJODIR)/%.o) \
115122
$(ASRCs:%.s=$(OBJODIR)/%.o) \
116123
$(ASRCS:%.S=$(OBJODIR)/%.o)
117124

118125
DEPS := $(CSRCS:%.c=$(OBJODIR)/%.d) \
126+
$(CXXSCRS:%.cpp=$(OBJODIR)/%.d) \
119127
$(ASRCs:%.s=$(OBJODIR)/%.d) \
120128
$(ASRCS:%.S=$(OBJODIR)/%.d)
121129

@@ -196,36 +204,41 @@ $(BINODIR)/%.bin: $(IMAGEODIR)/%.out
196204
# Should be done in top-level makefile only
197205
#
198206

199-
all: $(SDK_DIR_DEPENDS) pre_build .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
207+
all: sdk_pruned pre_build .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
200208

201209
.PHONY: sdk_extracted
202210
.PHONY: sdk_patched
211+
.PHONY: sdk_pruned
203212

204213
sdk_extracted: $(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER)
205214
sdk_patched: sdk_extracted $(TOP_DIR)/sdk/.patched-$(SDK_VER)
215+
sdk_pruned: $(SDK_DIR_DEPENDS) $(TOP_DIR)/sdk/.pruned-$(SDK_VER)
206216

207217
$(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER): $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip
208218
mkdir -p "$(dir $@)"
209-
(cd "$(dir $@)" && rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK-$(SDK_VER) && unzip $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip ESP8266_NONOS_SDK-$(SDK_VER)/lib/* ESP8266_NONOS_SDK-$(SDK_VER)/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK-$(SDK_VER)/include/* ESP8266_NONOS_SDK-$(SDK_VER)/bin/esp_init_data_default.bin)
210-
mv $(dir $@)/ESP8266_NONOS_SDK-$(SDK_VER) $(dir $@)/esp_iot_sdk_v$(SDK_VER)
211-
rm -f $(SDK_DIR)/lib/liblwip.a
219+
(cd "$(dir $@)" && rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK-$(SDK_BASE_VER) && unzip $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip ESP8266_NONOS_SDK-$(SDK_BASE_VER)/lib/* ESP8266_NONOS_SDK-$(SDK_BASE_VER)/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK-$(SDK_BASE_VER)/include/* ESP8266_NONOS_SDK-$(SDK_BASE_VER)/bin/esp_init_data_default_v05.bin)
220+
mv $(dir $@)/ESP8266_NONOS_SDK-$(SDK_BASE_VER) $(dir $@)/esp_iot_sdk_v$(SDK_BASE_VER)
221+
touch $@
222+
223+
$(TOP_DIR)/sdk/.patched-$(SDK_VER): $(TOP_DIR)/cache/$(SDK_PATCH_VER).patch
224+
mv $(dir $@)/esp_iot_sdk_v$(SDK_BASE_VER) $(dir $@)/esp_iot_sdk_v$(SDK_VER)
225+
git apply --verbose -p1 --exclude='*VERSION' --exclude='*bin/at*' --directory=$(SDK_REL_DIR) $<
212226
touch $@
213227

214-
$(TOP_DIR)/sdk/.patched-$(SDK_VER): $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip
215-
mkdir -p "$(dir $@)/patch"
216-
(cd "$(dir $@)/patch" && unzip $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER)*.zip *.a esp_init_data_default.bin && mv *.a $(SDK_DIR)/lib/ && mv esp_init_data_default.bin $(SDK_DIR)/bin/)
217-
rmdir $(dir $@)/patch
218-
rm -f $(SDK_DIR)/lib/liblwip.a
228+
$(TOP_DIR)/sdk/.pruned-$(SDK_VER):
229+
rm -f $(SDK_DIR)/lib/liblwip.a $(SDK_DIR)/lib/libssl.a $(SDK_DIR)/lib/libmbedtls.a
230+
ar d $(SDK_DIR)/lib/libmain.a time.o
231+
ar d $(SDK_DIR)/lib/libc.a lib_a-time.o
219232
touch $@
220233

221234
$(TOP_DIR)/cache/v$(SDK_FILE_VER).zip:
222235
mkdir -p "$(dir $@)"
223236
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused https://github.com/espressif/ESP8266_NONOS_SDK/archive/v$(SDK_FILE_VER).zip -O $@ || { rm -f "$@"; exit 1; }
224237
(echo "$(SDK_FILE_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; }
225238

226-
$(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip:
239+
$(TOP_DIR)/cache/$(SDK_PATCH_VER).patch:
227240
mkdir -p "$(dir $@)"
228-
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused http://espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v$(SDK_PATCH_VER).zip -O $@ || { rm -f "$@"; exit 1; }
241+
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused "https://github.com/espressif/ESP8266_NONOS_SDK/compare/v$(SDK_BASE_VER)...$(SDK_PATCH_VER).patch" -O $@ || { rm -f "$@"; exit 1; }
229242
(echo "$(SDK_PATCH_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; }
230243

231244
clean:
@@ -306,6 +319,17 @@ $(OBJODIR)/%.d: %.c
306319
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
307320
rm -f $@.$$$$
308321

322+
$(OBJODIR)/%.o: %.cpp
323+
@mkdir -p $(OBJODIR);
324+
$(CXX) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
325+
326+
$(OBJODIR)/%.d: %.cpp
327+
@mkdir -p $(OBJODIR);
328+
@echo DEPEND: $(CXX) -M $(CFLAGS) $<
329+
@set -e; rm -f $@; \
330+
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
331+
rm -f $@.$$$$
332+
309333
$(OBJODIR)/%.o: %.s
310334
@mkdir -p $(OBJODIR);
311335
$(CC) $(CFLAGS) -o $@ -c $<

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# **NodeMCU 2.1.0** #
1+
# **NodeMCU 2.2.0** #
22

33
[![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://img.shields.io/gitter/room/badges/shields.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44
[![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware)
@@ -7,7 +7,7 @@
77

88
### A Lua based firmware for ESP8266 WiFi SOC
99

10-
NodeMCU is an [eLua](http://www.eluaproject.net/) based firmware for the [ESP8266 WiFi SOC from Espressif](http://espressif.com/en/products/esp8266/). The firmware is based on the [Espressif NON-OS SDK 2.1.0](https://github.com/espressif/ESP8266_NONOS_SDK/releases/tag/v2.1.0) and uses a file system based on [spiffs](https://github.com/pellepl/spiffs). The code repository consists of 98.1% C-code that glues the thin Lua veneer to the SDK.
10+
NodeMCU is an [eLua](http://www.eluaproject.net/) based firmware for the [ESP8266 WiFi SOC from Espressif](http://espressif.com/en/products/esp8266/). The firmware is based on the [Espressif NON-OS SDK 2.2.0](https://github.com/espressif/ESP8266_NONOS_SDK/releases/tag/v2.2.0) and uses a file system based on [spiffs](https://github.com/pellepl/spiffs). The code repository consists of 98.1% C-code that glues the thin Lua veneer to the SDK.
1111

1212
The NodeMCU *firmware* is a companion project to the popular [NodeMCU dev kits](https://github.com/nodemcu/nodemcu-devkit-v1.0), ready-made open source development boards with ESP8266-12E chips.
1313

@@ -16,7 +16,7 @@ The NodeMCU *firmware* is a companion project to the popular [NodeMCU dev kits](
1616
- Easy to program wireless node and/or access point
1717
- Based on Lua 5.1.4 (without *debug, os* modules)
1818
- Asynchronous event-driven programming model
19-
- 55+ built-in modules
19+
- more than 65 built-in modules
2020
- Firmware available with or without floating point support (integer-only uses less memory)
2121
- Up-to-date documentation at [https://nodemcu.readthedocs.io](https://nodemcu.readthedocs.io)
2222

@@ -38,7 +38,7 @@ end)
3838
```lua
3939
-- connect to WiFi access point
4040
wifi.setmode(wifi.STATION)
41-
wifi.sta.config("SSID", "password")
41+
wifi.sta.config{ssid="SSID", pwd="password"}
4242
```
4343

4444
# Documentation

app/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ SUBDIRS= \
5050
misc \
5151
pm \
5252
sjson \
53+
sqlite3 \
5354

5455

5556
endif # } PDIR
@@ -104,6 +105,7 @@ COMPONENTS_eagle.app.v6 = \
104105
swTimer/libswtimer.a \
105106
misc/libmisc.a \
106107
sjson/libsjson.a \
108+
sqlite3/libsqlite3.a \
107109

108110

109111
# Inspect the modules library and work out which modules need to be linked.
@@ -164,6 +166,7 @@ CONFIGURATION_DEFINES = -D__ets__ \
164166
-DLWIP_OPEN_SRC \
165167
-DPBUF_RSV_FOR_WLAN \
166168
-DEBUF_LWIP \
169+
-DUSE_OPTIMIZE_PRINTF \
167170
-DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \
168171

169172
DEFINES += \

app/coap/coap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ void coap_setup(void)
549549
message_id = (unsigned short)os_random(); // calculate only once
550550
}
551551

552-
inline int
552+
int
553553
check_token(coap_packet_t *pkt) {
554554
return pkt->tok.len == the_token.len && c_memcmp(pkt->tok.p, the_token.p, the_token.len) == 0;
555555
}

app/driver/key.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ key_50ms_cb(struct single_key_param *single_key)
132132
LOCAL void
133133
key_intr_handler(void *arg)
134134
{
135-
struct keys_param *keys = arg;
136135
uint8 i;
137136
uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
137+
struct keys_param *keys = arg;
138138

139139
for (i = 0; i < keys->key_num; i++) {
140140
if (gpio_status & BIT(keys->single_key[i]->gpio_id)) {

app/fatfs/myfatfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ struct myvfs_dir {
112112
// ---------------------------------------------------------------------------
113113
// exported helper functions for FatFS
114114
//
115-
inline void *ff_memalloc( UINT size )
115+
void *ff_memalloc( UINT size )
116116
{
117117
return c_malloc( size );
118118
}
119119

120-
inline void ff_memfree( void *mblock )
120+
void ff_memfree( void *mblock )
121121
{
122122
c_free( mblock );
123123
}

app/http/httpclient.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,20 +215,23 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
215215
ua_len = strlen(ua_header);
216216
}
217217

218-
char host_header[32] = "";
218+
char * host_header = "";
219219
int host_len = 0;
220220
if ( os_strstr( req->headers, "Host:" ) == NULL && os_strstr( req->headers, "host:" ) == NULL)
221221
{
222+
int max_header_len = 9 + strlen(req->hostname); // 9 is fixed size of "Host:[space][cr][lf]\0"
222223
if ((req->port == 80)
223224
#ifdef CLIENT_SSL_ENABLE
224225
|| ((req->port == 443) && ( req->secure ))
225226
#endif
226227
)
227228
{
229+
host_header = alloca(max_header_len);
228230
os_sprintf( host_header, "Host: %s\r\n", req->hostname );
229231
}
230232
else
231233
{
234+
host_header = alloca(max_header_len + 6); // 6 is worst case of ":port" where port is maximum 5 digits
232235
os_sprintf( host_header, "Host: %s:%d\r\n", req->hostname, req->port );
233236
}
234237
host_len = strlen(host_header);

app/include/arch/cc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ typedef uint32_t mem_ptr_t;
6565
#define U32_F "d"
6666
#define X32_F "x"
6767

68-
68+
#define LWIP_ERR_T s32_t
6969

7070
//#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
7171
#define PACK_STRUCT_FIELD(x) x

0 commit comments

Comments
 (0)