Skip to content
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

updates for lwip2 #1147

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@
path = Sming/Libraries/Adafruit_SSD1306
url = https://github.com/adafruit/Adafruit_SSD1306.git
ignore = dirty
[submodule "Sming/third-party/lwip2"]
path = Sming/third-party/lwip2
url = https://github.com/d-a-v/esp82xx-nonos-linklayer.git
ignore = dirty
20 changes: 18 additions & 2 deletions Sming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,18 @@ ENABLE_CUSTOM_LWIP ?= 1
ENABLE_ESPCONN ?= 0
ifeq ($(ENABLE_CUSTOM_LWIP), 1)
THIRD_PARTY_DATA += third-party/esp-open-lwip/Makefile.open
EXTRA_INCDIR += system/esp-lwip
EXTRA_INCDIR += third-party/esp-open-lwip/include
LIBLWIP = lwip_open
lwip_extra = 1
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
THIRD_PARTY_DATA += third-party/lwip2/Makefile.sming
EXTRA_INCDIR += third-party/lwip2/include
LIBLWIP = lwip2
lwip_extra = 1
endif
ifeq ($(lwip_extra),1)
EXTRA_CFLAGS_LWIP = -I../../system/include -I../../Wiring
ENABLE_LWIPDEBUG ?= 0
ifeq ($(ENABLE_LWIPDEBUG), 1)
Expand All @@ -210,8 +221,6 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1)

ifeq ($(ENABLE_ESPCONN), 1)
LIBLWIP = lwip_full
else
LIBLWIP = lwip_open
endif
CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a
endif
Expand Down Expand Up @@ -384,6 +393,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1)
$(USER_LIBDIR)/liblwip_%.a: third-party/esp-open-lwip/Makefile.open
$(Q) $(MAKE) -C third-party/esp-open-lwip/ -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" all
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
$(USER_LIBDIR)/liblwip%.a: third-party/lwip2/Makefile.sming
$(Q) $(MAKE) -C third-party/lwip2/ -f Makefile.sming ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" all
endif

spiffy: spiffy/spiffy

Expand Down Expand Up @@ -429,6 +442,9 @@ endif
ifeq ($(ENABLE_CUSTOM_LWIP), 1)
$(Q) -$(MAKE) -C third-party/esp-open-lwip/ -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" clean
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
$(Q) -$(MAKE) -C third-party/lwip2/ -f Makefile.sming ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" clean
endif

test: Basic_Blink Basic_rBoot Basic_Ssl Basic_HwPWM

Expand Down
11 changes: 11 additions & 0 deletions Sming/Makefile-project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ ENABLE_CUSTOM_LWIP ?= 1
ifeq ($(ENABLE_CUSTOM_LWIP), 1)
LWIP_INCDIR = $(SMING_HOME)/third-party/esp-open-lwip/include
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
LWIP_INCDIR = $(SMING_HOME)/third-party/lwip2/include
endif

EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME)/system/include \
$(SMING_HOME)/Wiring $(SMING_HOME)/Libraries $(SMING_HOME)/Libraries/Adafruit_GFX \
Expand All @@ -200,6 +203,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1)
endif
CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
LIBLWIP = lwip2
CUSTOM_TARGETS += $(USER_LIBDIR)/liblwip2.a
endif

LIBPWM = pwm

Expand Down Expand Up @@ -461,6 +468,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1)
$(USER_LIBDIR)/liblwip_%.a:
$(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) ENABLE_CUSTOM_LWIP=1 ENABLE_ESPCONN=$(ENABLE_ESPCONN)
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
$(USER_LIBDIR)/liblwip%.a:
$(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) ENABLE_CUSTOM_LWIP=2 ENABLE_ESPCONN=$(ENABLE_ESPCONN)
endif

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

Expand Down
14 changes: 14 additions & 0 deletions Sming/Makefile-rboot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ ENABLE_CUSTOM_LWIP ?= 1
ifeq ($(ENABLE_CUSTOM_LWIP), 1)
LWIP_INCDIR = $(SMING_HOME)/third-party/esp-open-lwip/include
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
LWIP_INCDIR = $(SMING_HOME)/third-party/lwip2/include
endif

EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME)/system/include \
$(SMING_HOME)/Wiring $(SMING_HOME)/Libraries $(SMING_HOME)/Libraries/Adafruit_GFX \
Expand Down Expand Up @@ -249,6 +252,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1)
endif
CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
LIBLWIP = lwip2
CUSTOM_TARGETS += $(USER_LIBDIR)/liblwip2.a
endif

LIBPWM = pwm

Expand Down Expand Up @@ -280,6 +287,9 @@ endif
ifeq ($(ENABLE_CUSTOM_LWIP), 1)
EXTRA_INCDIR += third-party/esp-open-lwip/include
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
EXTRA_INCDIR += third-party/lwip2/include
endif


# we will use global WiFi settings from Eclipse Environment Variables, if possible
Expand Down Expand Up @@ -511,6 +521,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1)
$(USER_LIBDIR)/liblwip_%.a:
$(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) ENABLE_CUSTOM_LWIP=1 ENABLE_ESPCONN=$(ENABLE_ESPCONN)
endif
ifeq ($(ENABLE_CUSTOM_LWIP), 2)
$(USER_LIBDIR)/liblwip%.a:
$(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) ENABLE_CUSTOM_LWIP=2 ENABLE_ESPCONN=$(ENABLE_ESPCONN)
endif

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

Expand Down
5 changes: 5 additions & 0 deletions Sming/Services/CommandProcessing/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "CommandHandler.h"
#include "CommandDelegate.h"

#ifndef LWIP_HASH_STR
#define LWIP_HASH_STR ""
#endif

CommandHandler::CommandHandler()
{
registeredCommands = new HashMap<String, CommandDelegate>;
Expand Down Expand Up @@ -138,6 +142,7 @@ void CommandHandler::procesStatusCommand(String commandLine, CommandOutput* comm
commandOutput->printf("ESP SDK version : ");
commandOutput->print(system_get_sdk_version());
commandOutput->printf("\r\n");
commandOutput->printf("lwIP version : %d.%d.%d(%s)\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION, LWIP_HASH_STR);
commandOutput->printf("Time = ");
commandOutput->printf(SystemClock.getSystemTimeString().c_str());
commandOutput->printf("\r\n");
Expand Down
8 changes: 8 additions & 0 deletions Sming/SmingCore/Network/NtpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ void NtpClient::requestTime()
return;
}

#if LWIP_VERSION_MAJOR == 1
struct ip_addr resolvedIp;
#else
ip_addr_t resolvedIp;
#endif
int result = dns_gethostbyname(this->server.c_str(), &resolvedIp,
staticDnsResponse, (void*) this);

Expand Down Expand Up @@ -174,7 +178,11 @@ void NtpClient::onReceive(pbuf *buf, IPAddress remoteIP, uint16_t remotePort)
}
}

#if LWIP_VERSION_MAJOR == 1
void NtpClient::staticDnsResponse(const char *name, struct ip_addr *ip, void *arg)
#else
void NtpClient::staticDnsResponse(const char *name, const ip_addr_t *ip, void *arg)
#endif
{
// DNS has been resolved

Expand Down
4 changes: 4 additions & 0 deletions Sming/SmingCore/Network/NtpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ class NtpClient : protected UdpConnection
* @param arg Pointer to the NTP client object that made the DNS request
* @note This function is called when a DNS query is serviced
*/
#if LWIP_VERSION_MAJOR == 1
static void staticDnsResponse(const char *name, struct ip_addr *ip, void *arg);
#else
static void staticDnsResponse(const char *name, const ip_addr_t *ip, void *arg);
#endif
};

/** @} */
Expand Down
4 changes: 4 additions & 0 deletions Sming/SmingCore/Network/TcpConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,11 @@ void TcpConnection::staticOnError(void *arg, err_t err)
//debugf("<staticOnError");
}

#if LWIP_VERSION_MAJOR == 1
void TcpConnection::staticDnsResponse(const char *name, ip_addr_t *ipaddr, void *arg)
#else
void TcpConnection::staticDnsResponse(const char *name, const ip_addr_t *ipaddr, void *arg)
#endif
{
DnsLookup* dlook = (DnsLookup*)arg;
if (dlook == NULL) return;
Expand Down
4 changes: 4 additions & 0 deletions Sming/SmingCore/Network/TcpConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ class TcpConnection
static err_t staticOnSent(void *arg, tcp_pcb *tcp, uint16_t len);
static err_t staticOnPoll(void *arg, tcp_pcb *tcp);
static void staticOnError(void *arg, err_t err);
#if LWIP_VERSION_MAJOR == 1
static void staticDnsResponse(const char *name, ip_addr_t *ipaddr, void *arg);
#else
static void staticDnsResponse(const char *name, const ip_addr_t *ipaddr, void *arg);
#endif

static void closeTcpConnection(tcp_pcb *tpcb);
void initialize(tcp_pcb* pcb);
Expand Down
4 changes: 4 additions & 0 deletions Sming/SmingCore/Network/UdpConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ void UdpConnection::onReceive(pbuf* buf, IPAddress remoteIP, uint16_t remotePort
}
}

#if LWIP_VERSION_MAJOR == 1
void UdpConnection::staticOnReceive(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
#else
void UdpConnection::staticOnReceive(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
#endif
{
UdpConnection *self = (UdpConnection*)arg;
if (self == NULL) return;
Expand Down
4 changes: 4 additions & 0 deletions Sming/SmingCore/Network/UdpConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class UdpConnection

protected:
void initialize(udp_pcb* pcb = NULL);
#if LWIP_VERSION_MAJOR == 1
static void staticOnReceive(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);
#else
static void staticOnReceive(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
#endif

protected:
udp_pcb* udp;
Expand Down
7 changes: 7 additions & 0 deletions Sming/Wiring/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ IPAddress::IPAddress(ip_addr address)
memcpy(_address, &address.addr, sizeof(_address));
}

#if LWIP_VERSION_MAJOR == 2
IPAddress::IPAddress(ip_addr_t address)
{
memcpy(_address, &address.addr, sizeof(_address));
}
#endif

IPAddress::IPAddress(const uint8_t *address)
{
memcpy(_address, address, sizeof(_address));
Expand Down
6 changes: 6 additions & 0 deletions Sming/Wiring/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class IPAddress : public Printable
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
IPAddress(uint32_t address);
IPAddress(ip_addr address);
#if LWIP_VERSION_MAJOR == 2
IPAddress(ip_addr_t address);
#endif
IPAddress(const uint8_t *address);
IPAddress(const String address);

Expand All @@ -55,6 +58,9 @@ class IPAddress : public Printable
operator uint32_t() { return *((uint32_t*)_address); };
operator ip_addr() { ip_addr ret; ret.addr = *((uint32_t*)_address); return ret; };
operator ip_addr*() { return (ip_addr*)_address; };
#if LWIP_VERSION_MAJOR == 2
operator ip_addr_t*() { return (ip_addr_t*)_address; };
#endif
bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
bool operator==(const uint8_t* addr);

Expand Down
1 change: 1 addition & 0 deletions Sming/compiler/ld/common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ SECTIONS
out/build/app_app.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.* .irom.debug.*)
*libsming.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.* .irom.debug.*)
*libsmingssl.a:*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.* .irom.debug.*)
*liblwip2.a:(.literal .text .literal.* .text.*)
_irom0_text_end = ABSOLUTE(.);
_flash_code_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Sming/third-party/lwip2
Submodule lwip2 added at 80c63d