Skip to content

Commit

Permalink
Merge commit 'fdf41a301df3f311da5ceb279603e4be0ecaeaf2' into develop
Browse files Browse the repository at this point in the history
* commit 'fdf41a301df3f311da5ceb279603e4be0ecaeaf2':
  Allow compilation of custom LWIP (SmingHub#878)
  Compile libsming(ssl) on demand (SmingHub#879)
  Fix websocket client key generation (SmingHub#871)
  Preparation for release 3.0.1. (SmingHub#869)
  Fixed compilation of Sming with custom heap enabled. (SmingHub#868)
  spiffs_mount() added (SmingHub#865)
  • Loading branch information
johndoe8967 committed Jan 22, 2017
2 parents a086ac2 + fdf41a3 commit 6ba8d77
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
path = Sming/third-party/umm_malloc
url = https://github.com/rhempel/umm_malloc.git
ignore = dirty
[submodule "Sming/third-party/esp-open-lwip"]
path = Sming/third-party/esp-open-lwip
url = https://github.com/pfalcon/esp-open-lwip.git
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ script:
- export ESP_HOME=$TRAVIS_BUILD_DIR/opt/esp-alt-sdk
- export PATH=$PATH:$TRAVIS_BUILD_DIR/opt/esp-alt-sdk/utils/
- cd $SMING_HOME
- make test
- make test
- cd $SMING_HOME/../
- export SMING_HAS_CHANGED=`for i in $CHANGED_FILES; do if [[ $i == Sming/* ]]; then echo 1; break; fi; done`
- if [ ! -z "$SMING_HAS_CHANGED" ]; then CHANGED_PROJECTS=`cd $SMING_HOME/../samples; ls -d *`; fi
- for i in $CHANGED_PROJECTS; do echo "Compiling $i"; make -C "samples/$i"; if [ $? -ne 0 ]; then exit 1; fi; done
- cd $SMING_HOME
- make clean
- make clean samples-clean
- make ENABLE_GDB=1
- make Basic_Debug
- make clean samples-clean
- make ENABLE_CUSTOM_HEAP=1
- make Basic_Blink ENABLE_CUSTOM_HEAP=1
- make clean samples-clean
- if [ "$SDK_VERSION" == "1.5.0" ]; then make ENABLE_CUSTOM_LWIP=1; make samples ENABLE_CUSTOM_LWIP=1; fi
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native develo
* Based on Espressif NONOS SDK. Tested with versions 1.4 and 1.5.

## Latest Release
- [Sming V3.0.0](https://github.com/SmingHub/Sming/releases/tag/3.0.0)
- [Sming V3.0.1](https://github.com/SmingHub/Sming/releases/tag/3.0.1)

## Getting started
- [Windows](https://github.com/SmingHub/Sming/wiki/Windows-Quickstart)
Expand Down
21 changes: 18 additions & 3 deletions Sming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,19 @@ ifeq ($(ENABLE_CUSTOM_HEAP), 1)
CUSTOM_TARGETS += $(USER_LIBDIR)/libmainmm.a
endif

# => Open Source LWIP
LIBLWIP = lwip
ENABLE_ESPCONN ?= 1
ifeq ($(ENABLE_CUSTOM_LWIP), 1)
THIRD_PARTY_DATA += third-party/esp-open-lwip/Makefile.open
EXTRA_INCDIR += third-party/esp-open-lwip/include
CUSTOM_TARGETS += $(USER_LIBDIR)/liblwip_open.a
LIBLWIP = lwip_open
endif

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = compiler/lib
LIBS = microc microgcc hal phy pp net80211 lwip wpa main

LIBS = microc microgcc hal phy pp net80211 $(LIBLWIP) wpa main
ifeq ($(ENABLE_CUSTOM_PWM), 1)
THIRD_PARTY_DATA += third-party/pwm/pwm.c
LIBS += pwm
Expand Down Expand Up @@ -296,6 +305,12 @@ $(USER_LIBDIR)/libmainmm.a: $(addprefix $(SDK_LIBDIR)/,libmain.a)
$(Q) $(AR) -d $@ mem_manager.o
endif

ifeq ($(ENABLE_CUSTOM_LWIP), 1)
$(USER_LIBDIR)/liblwip_open.a: third-party/esp-open-lwip/Makefile.open
$(Q) $(MAKE) -C third-party/esp-open-lwip/ -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) USER_LIBDIR=$(SMING_HOME)/$(USER_LIBDIR)/
endif


spiffy: spiffy/spiffy

spiffy/spiffy:
Expand Down Expand Up @@ -338,7 +353,7 @@ else
$(Q) $(MAKE) --no-print-directory -C spiffy clean V=$(V)
endif

test: all spiffy samples
test: Basic_Blink Basic_rBoot Basic_Ssl Basic_HwPWM

docs/wiki/Home.md:
$(vecho) "No Wiki submodule found. Using git to fetch it..."
Expand Down
32 changes: 27 additions & 5 deletions Sming/Makefile-project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,23 @@ TARGET = app

THIRD_PARTY_DIR = $(SMING_HOME)/third-party

SMING_FEATURES = none
LIBSMING = sming
ifeq ($(ENABLE_SSL),1)
LIBSMING = smingssl
SMING_FEATURES = SSL
endif

# which modules (subdirectories) of the project to include in compiling
# define your custom directories in the project's own Makefile before including this one
MODULES ?= app # default to app if not set by user
EXTRA_INCDIR ?= include # default to include if not set by user
EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(SMING_HOME)/system/include $(SMING_HOME)/Wiring $(SMING_HOME)/Libraries $(SMING_HOME)/SmingCore $(SMING_HOME)/Services/SpifFS $(SDK_BASE)/../include $(THIRD_PARTY_DIR)/rboot $(THIRD_PARTY_DIR)/rboot/appcode $(THIRD_PARTY_DIR)/spiffs/src

ifeq ($(ENABLE_CUSTOM_LWIP), 1)
LWIP_INCDIR = $(SMING_HOME)/third-party/esp-open-lwip
endif

EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME)/system/include $(SMING_HOME)/Wiring $(SMING_HOME)/Libraries $(SMING_HOME)/SmingCore $(SMING_HOME)/Services/SpifFS $(SDK_BASE)/../include $(THIRD_PARTY_DIR)/rboot $(THIRD_PARTY_DIR)/rboot/appcode $(THIRD_PARTY_DIR)/spiffs/src

ENABLE_CUSTOM_HEAP ?= 0

Expand All @@ -155,9 +162,14 @@ ifeq ($(ENABLE_CUSTOM_HEAP),1)
LIBMAIN = mainmm
endif

LIBLWIP = lwip
ifeq ($(ENABLE_CUSTOM_LWIP), 1)
LIBLWIP = lwip_open
endif

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMING_HOME)/compiler/lib/
LIBS = microc microgcc hal phy pp net80211 lwip wpa $(LIBMAIN) $(LIBSMING) crypto pwm smartconfig $(EXTRA_LIBS)
LIBS = microc microgcc hal phy pp net80211 $(LIBLWIP) wpa $(LIBMAIN) $(LIBSMING) crypto pwm smartconfig $(EXTRA_LIBS)

# compiler flags using during compilation of source files
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS)
Expand Down Expand Up @@ -185,11 +197,16 @@ ifeq ($(ENABLE_SSL),1)
AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1
endif

CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBSMING).a include/ssl/private_key.h
CUSTOM_TARGETS += include/ssl/private_key.h
CFLAGS += $(AXTLS_FLAGS)
CXXFLAGS += $(AXTLS_FLAGS)
endif

ifeq ($(ENABLE_CUSTOM_LWIP), 1)
CUSTOM_TARGETS += $(USER_LIBDIR)/liblwip_open.a
# EXTRA_INCDIR += third-party/esp-open-lwip/include
endif

# we will use global WiFi settings from Eclipse Environment Variables, if possible
WIFI_SSID ?= ""
WIFI_PWD ?= ""
Expand Down Expand Up @@ -313,7 +330,7 @@ endef

.PHONY: all checkdirs spiff_update spiff_clean clean

all: checkdirs $(TARGET_OUT) $(SPIFF_BIN_OUT) $(FW_FILE_1) $(FW_FILE_2)
all: $(USER_LIBDIR)/lib$(LIBSMING).a checkdirs $(TARGET_OUT) $(SPIFF_BIN_OUT) $(FW_FILE_1) $(FW_FILE_2)

spiff_update: spiff_clean $(SPIFF_BIN_OUT)

Expand Down Expand Up @@ -352,7 +369,7 @@ $(APP_AR): $(OBJ)
$(Q) $(AR) cru $@ $^

$(USER_LIBDIR)/lib$(LIBSMING).a:
$(vecho) "Recompiling Sming with SSL support. This may take some time"
$(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time"
$(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) SMING_HOME=$(SMING_HOME)
$(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) SMING_HOME=$(SMING_HOME)

Expand All @@ -366,6 +383,11 @@ $(USER_LIBDIR)/libpwm.a:
$(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/libpwm.a ENABLE_CUSTOM_PWM=1
endif

ifeq ($(ENABLE_CUSTOM_LWIP), 1)
$(USER_LIBDIR)/liblwip_open.a:
$(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/liblwip_open.a ENABLE_CUSTOM_LWIP=1
endif

checkdirs: $(BUILD_DIR) $(FW_BASE) $(CUSTOM_TARGETS)

$(BUILD_DIR):
Expand Down
27 changes: 22 additions & 5 deletions Sming/Makefile-rboot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,23 @@ TARGET = app
THIRD_PARTY_DIR = $(SMING_HOME)/third-party

LIBSMING = sming
SMING_FEATURES = none
ifeq ($(ENABLE_SSL),1)
LIBSMING = smingssl
SMING_FEATURES = SSL
endif

# which modules (subdirectories) of the project to include in compiling
# define your custom directories in the project's own Makefile before including this one
MODULES ?= app # default to app if not set by user
MODULES += $(THIRD_PARTY_DIR)/rboot/appcode
EXTRA_INCDIR ?= include # default to include if not set by user
EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(SMING_HOME)/system/include $(SMING_HOME)/Wiring $(SMING_HOME)/Libraries $(SMING_HOME)/SmingCore $(SMING_HOME)/Services/SpifFS $(SDK_BASE)/../include $(THIRD_PARTY_DIR)/rboot $(THIRD_PARTY_DIR)/rboot/appcode $(THIRD_PARTY_DIR)/spiffs/src

ifeq ($(ENABLE_CUSTOM_LWIP), 1)
LWIP_INCDIR = $(SMING_HOME)/third-party/esp-open-lwip
endif

EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME)/system/include $(SMING_HOME)/Wiring $(SMING_HOME)/Libraries $(SMING_HOME)/SmingCore $(SMING_HOME)/Services/SpifFS $(SDK_BASE)/../include $(THIRD_PARTY_DIR)/rboot $(THIRD_PARTY_DIR)/rboot/appcode $(THIRD_PARTY_DIR)/spiffs/src

USER_LIBDIR = $(SMING_HOME)/compiler/lib/

Expand Down Expand Up @@ -194,7 +201,12 @@ else
endif
# libraries used in this project, mainly provided by the SDK

LIBS = microc microgcc hal phy pp net80211 lwip wpa $(LIBMAIN) $(LIBSMING) crypto pwm smartconfig $(EXTRA_LIBS)
LIBLWIP = lwip
ifeq ($(ENABLE_CUSTOM_LWIP), 1)
LIBLWIP = lwip_open
endif

LIBS = microc microgcc hal phy pp net80211 $(LIBLWIP) wpa $(LIBMAIN) $(LIBSMING) crypto pwm smartconfig $(EXTRA_LIBS)

# SSL support using axTLS
ifeq ($(ENABLE_SSL),1)
Expand All @@ -205,11 +217,16 @@ ifeq ($(ENABLE_SSL),1)
AXTLS_FLAGS += -DSSL_DEBUG=1 -DDEBUG_TLS_MEM=1
endif

CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBSMING).a include/ssl/private_key.h
CUSTOM_TARGETS += include/ssl/private_key.h
CFLAGS += $(AXTLS_FLAGS)
CXXFLAGS += $(AXTLS_FLAGS)
endif

ifeq ($(ENABLE_CUSTOM_LWIP), 1)
EXTRA_INCDIR += third-party/esp-open-lwip/include
endif


# we will use global WiFi settings from Eclipse Environment Variables, if possible
WIFI_SSID ?= ""
WIFI_PWD ?= ""
Expand Down Expand Up @@ -357,7 +374,7 @@ endef

.PHONY: all checkdirs spiff_update spiff_clean clean

all: checkdirs $(LIBMAIN_DST) $(RBOOT_BIN) $(RBOOT_ROM_0) $(RBOOT_ROM_1) $(SPIFF_BIN_OUT) $(FW_FILE_1) $(FW_FILE_2)
all: $(USER_LIBDIR)/lib$(LIBSMING).a checkdirs $(LIBMAIN_DST) $(RBOOT_BIN) $(RBOOT_ROM_0) $(RBOOT_ROM_1) $(SPIFF_BIN_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(RBOOT_BIN):
$(MAKE) -C $(THIRD_PARTY_DIR)/rboot
Expand Down Expand Up @@ -392,7 +409,7 @@ $(APP_AR): $(OBJ)
$(Q) $(AR) cru $@ $^

$(USER_LIBDIR)/lib$(LIBSMING).a:
$(vecho) "Recompiling Sming with SSL support. This may take some time"
$(vecho) "(Re)compiling Sming. Enabled features: $(SMING_FEATURES). This may take some time"
$(Q) $(MAKE) -C $(SMING_HOME) clean V=$(V) ENABLE_SSL=$(ENABLE_SSL) SMING_HOME=$(SMING_HOME)
$(Q) $(MAKE) -C $(SMING_HOME) V=$(V) ENABLE_SSL=$(ENABLE_SSL) SMING_HOME=$(SMING_HOME)

Expand Down
8 changes: 3 additions & 5 deletions Sming/SmingCore/Network/WebsocketClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool WebsocketClient::connect(String url, uint32_t sslOptions /* = 0 */)
char b64Key[25];
_mode = wsMode::Connecting; // Server Connected / WS Upgrade request sent

randomSeed(analogRead(0));
randomSeed(os_random());

for (int i = 0; i < 16; ++i)
{
Expand All @@ -56,10 +56,8 @@ bool WebsocketClient::connect(String url, uint32_t sslOptions /* = 0 */)

base64_encode(16, (const unsigned char*) keyStart, 24, (char*) b64Key);

for (int i = 0; i < 24; ++i)
{
_key[i] = b64Key[i];
}
_key.setString(b64Key, 24);

String protocol = "chat";
sendString("GET ");
if (_uri.Path != "")
Expand Down
2 changes: 1 addition & 1 deletion Sming/SmingCore/SmingCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef _NET_WIRING_
#define _NET_WIRING_

#define SMING_VERSION "3.0.0" // Major Minor Sub
#define SMING_VERSION "3.0.1" // Major Minor Sub

#include "../Wiring/WiringFrameworkIncludes.h"

Expand Down
51 changes: 51 additions & 0 deletions Sming/custom_heap/heap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* heap.c - overrides of SDK heap handling functions
* Copyright (c) 2016 Ivan Grokhotkov. All rights reserved.
* This file is distributed under MIT license.
*/

#include <stdlib.h>
#include <c_types.h>
#include "umm_malloc_cfg.h"
#include "umm_malloc.h"

#define IRAM_ATTR __attribute__((section(".iram.text")))

void* IRAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
{
return malloc(size);
}

void IRAM_ATTR vPortFree(void *ptr, const char* file, int line)
{
free(ptr);
}

void* IRAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int line)
{
return calloc(count, size);
}

void* IRAM_ATTR pvPortRealloc(void *ptr, size_t size, const char* file, int line)
{
return realloc(ptr, size);
}

void* IRAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
{
return calloc(1, size);
}

size_t xPortGetFreeHeapSize(void)
{
return umm_free_heap_size();
}

size_t IRAM_ATTR xPortWantedSizeAlign(size_t size)
{
return (size + 3) & ~((size_t) 3);
}

void system_show_malloc(void)
{
umm_info(NULL, 1);
}
69 changes: 69 additions & 0 deletions Sming/third-party/.patches/esp-open-lwip.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
diff --git a/include/user_config.h b/include/user_config.h
index e69de29..1db5073 100644
--- a/include/user_config.h
+++ b/include/user_config.h
@@ -0,0 +1,34 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef signed short sint16_t;
+
+void *ets_bzero(void *block, size_t size);
+bool ets_post(uint32_t prio, ETSSignal sig, ETSParam par);
+void ets_task(ETSTask task, uint32_t prio, ETSEvent * queue, uint8 qlen);
+
+void system_pp_recycle_rx_pkt(void *eb);
+
+#ifndef MEMLEAK_DEBUG
+ extern void *pvPortMalloc( size_t xWantedSize );
+ extern void vPortFree( void *pv );
+ extern void *pvPortZalloc(size_t size);
+#else
+ extern void *pvPortMalloc(size_t xWantedSize, const char *file, uint32 line);
+ extern void *pvPortZalloc(size_t xWantedSize, const char *file, uint32 line);
+ extern void vPortFree(void *ptr, const char *file, uint32 line);
+
+ extern void pvPortFree(void *ptr);
+ extern void *vPortMalloc(size_t xWantedSize);
+#endif /*MEMLEAK_DEBUG*/
+
+
+ extern void *pvPortCalloc(unsigned int n, unsigned int count);
+ extern void *pvPortRealloc(void * p, size_t size);
+ extern size_t xPortGetFreeHeapSize(void);
+// extern void prvHeapInit(void) ICACHE_FLASH_ATTR ;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/Makefile.open b/Makefile.open
index 1bc584f..493275b 100644
--- a/Makefile.open
+++ b/Makefile.open
@@ -36,11 +36,21 @@ lwip/core/ipv4/ip.o \
lwip/core/ipv4/ip_frag.o \
lwip/netif/etharp.o \
\
-lwip/app/dhcpserver.o \
-\
-espconn_dummy.o \
+lwip/app/dhcpserver.o
+
+
+ifneq ($(ENABLE_ESPCONN),1)
+ OBJS += espconn_dummy.o
+else
+ OBJS += lwip/app/espconn.o \
+lwip/app/espconn_tcp.o \
+lwip/app/espconn_udp.o \
+lwip/app/espconn_mdns.o \
+lwip/core/mdns.o
+
+endif

-LIB = liblwip_open.a
+LIB = $(USER_LIBDIR)liblwip_open.a

all: $(LIB)

1 change: 1 addition & 0 deletions Sming/third-party/esp-open-lwip
Submodule esp-open-lwip added at b9a23a
Loading

0 comments on commit 6ba8d77

Please sign in to comment.