Skip to content

lwIP-v2 ready to use #3783

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

Merged
merged 3 commits into from
Nov 3, 2017
Merged
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lwip2"]
path = tools/sdk/lwip2/builder
url = https://github.com/d-a-v/esp82xx-nonos-linklayer.git
3,899 changes: 2,520 additions & 1,379 deletions boards.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra

build.lwip_lib=-llwip_gcc
build.lwip_include=lwip/include
build.lwip_flags=-DLWIP_OPEN_SRC

compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/
compiler.sdk.path={runtime.platform.path}/tools/sdk
compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/lwip/include" "-I{compiler.libc.path}/include" "-I{build.path}/core"
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/{build.lwip_include}" "-I{compiler.libc.path}/include" "-I{build.path}/core"

compiler.c.cmd=xtensa-lx106-elf-gcc
compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections
Expand Down
1 change: 1 addition & 0 deletions tools/sdk/ld/eagle.app.v6.common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ SECTIONS
*libstdc++.a:(.literal .text .literal.* .text.*)
*liblwip_gcc.a:(.literal .text .literal.* .text.*)
*liblwip_src.a:(.literal .text .literal.* .text.*)
*liblwip2.a:(.literal .text .literal.* .text.*)
*libaxtls.a:(.literal .text .literal.* .text.*)
*libat.a:(.literal.* .text.*)
*libcrypto.a:(.literal.* .text.*)
Expand Down
Binary file added tools/sdk/lib/liblwip2.a
Binary file not shown.
6 changes: 6 additions & 0 deletions tools/sdk/lwip2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

all install clean: builder/lwip2-src/README
make -C builder -f Makefile.arduino $@

builder/lwip2-src/README:
git submodule update --init --recursive builder
1 change: 1 addition & 0 deletions tools/sdk/lwip2/builder
Submodule builder added at 9b6966
1 change: 1 addition & 0 deletions tools/sdk/lwip2/include/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
warning: this directory is re/over/written from lwip2 builder upon lwip2 rebuild
145 changes: 145 additions & 0 deletions tools/sdk/lwip2/include/arch/cc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@

/*

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

author: d. gauchard

*/

// version for esp8266 sdk-2.0.0(656edbf)

#ifndef LWIP2_ARCH_CC_H
#define LWIP2_ARCH_CC_H

#include "stdint.h"

#include "lwip-err-t.h"

#ifdef LWIP_BUILD

// define LWIP_BUILD only when building LWIP
// otherwise include files below would conflict
// with standard headers like atoi()
#ifdef __cplusplus
extern "C"
{
#endif
#include "ets_sys.h"
#include "osapi.h"
#include "esp-missing.h"
#ifdef __cplusplus
}
#endif

void sntp_set_system_time (uint32_t t);

#endif // defined(LWIP_BUILD)

#include "mem.h" // useful for os_malloc used in esp-arduino's mDNS

typedef uint32_t sys_prot_t; // not really used
#define SYS_ARCH_DECL_PROTECT(lev)
#define SYS_ARCH_PROTECT(lev) os_intr_lock()
#define SYS_ARCH_UNPROTECT(lev) os_intr_unlock()

///////////////////////////////
//// DEBUG
#include "gluedebug.h"

#if ULWIPDEBUG // debug 1:on or 0
#define LWIP_DEBUG 1
#define LWIP_PLATFORM_DIAG(x) do { os_printf x; } while(0)
#define LWIP_PLATFORM_ASSERT(x) do { os_printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); *(int*)0=0; } while(0)
//#define LWIP_PLATFORM_ASSERT(x) do { os_printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); while(1); } while(0)
#endif // ULWIPDEBUG

#if !ULWIPASSERT
#define LWIP_NOASSERT 1
#endif

///////////////////////////////
//// MISSING

#define sys_now millis // arduino wire millis() definition returns 32 bits like sys_now() does
#define LWIP_RAND r_rand // old lwip uses this useful undocumented function
#define IPSTR "%d.%d.%d.%d"
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \
ip4_addr2_16(ipaddr), \
ip4_addr3_16(ipaddr), \
ip4_addr4_16(ipaddr)

// ip_addr / ip_info: do not exist in lwip2 (only in lwip1.4)
struct ip_addr {
uint32_t addr;
};
struct ip_info {
struct ip_addr ip;
struct ip_addr netmask;
struct ip_addr gw;
};

///////////////////////////////
//// PROVIDED TO USER

typedef struct ip4_addr ip4_addr_t;
extern int ntp_servers_number;
extern ip4_addr_t* ntp_servers;

///////////////////////////////
//// STUBS

// these symbols must be renamed in the new implementation
// because they are known/used in blobs

#define dhcp_cleanup dhcp_cleanup_LWIP2
#define dhcp_release dhcp_release_LWIP2
#define dhcp_start dhcp_start_LWIP2
#define dhcp_stop dhcp_stop_LWIP2
#define dhcps_start dhcps_start_LWIP2
//#define dhcps_stop dhcps_stop_LWIP2 // void(void)
#define espconn_init espconn_init_LWIP2
#define etharp_output etharp_output_LWIP2
#define ethbroadcast ethbroadcast_LWIP2
#define ethernet_input ethernet_input_LWIP2
#define lwip_init lwip_init_LWIP2
#define netif_add netif_add_LWIP2
#define netif_default netif_default_LWIP2
#define netif_remove netif_remove_LWIP2
#define netif_set_addr netif_set_addr_LWIP2
#define netif_set_default netif_set_default_LWIP2
#define netif_set_down netif_set_down_LWIP2
#define netif_set_up netif_set_up_LWIP2
#define pbuf_alloc pbuf_alloc_LWIP2
#define pbuf_free pbuf_free_LWIP2
#define pbuf_ref pbuf_ref_LWIP2
//#define sys_check_timeouts sys_check_timeouts_LWIP2 // void(void)

#if !defined(LWIP_DEBUG) || !SYS_DEBUG
#define sys_timeout sys_timeout_LWIP2
#endif

#define sys_untimeout sys_untimeout_LWIP2

///////////////////////////////
#endif // LWIP2_ARCH_CC_H
5 changes: 5 additions & 0 deletions tools/sdk/lwip2/include/arch/sys_arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#ifndef MYSYSARCH_H
#define MYSYSARCH_H

#endif // MYSYSARCH_H
Empty file.
89 changes: 89 additions & 0 deletions tools/sdk/lwip2/include/gluedebug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

#ifndef __GLUE_DEBUG_H
#define __GLUE_DEBUG_H

/////////////////////////////////////////////////////////////////////////////
// user-definable

// this is needed separately from lwipopts.h
// because it is shared by both sides of glue

#define UDEBUG 0 // 0 or 1 (glue debug)
#define UDUMP 0 // 0 or 1 (glue / dump packet)
#define UDEBUGINDEX 0 // 0 or 1 (show debug line number)
#define UDEBUGSTORE 0 // 0 or 1 (store debug into buffer until doprint_allow=1=serial-available)

#define ULWIPDEBUG 0 // 0 or 1 (trigger lwip debug)
#define ULWIPASSERT 0 // 0 or 1 (trigger lwip self-check, 0 saves flash)

#define STRING_IN_FLASH 0 // *print("fmt is stored in flash")

#define ROTBUFLEN_BIT 11 // (UDEBUGSTORE=1) doprint()'s buffer: 11=2048B

#if ULWIPDEBUG
//#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
//#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH)
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON)
#endif

/////////////////////////////////////////////////////////////////////////////

#if UDEBUG && UDEBUGSTORE
#warning use 'doprint_allow=1' right after Serial is enabled
extern int doprint_allow;
#endif

// print definitions:
// uprint(): always used by glue, defined as doprint() in debug mode or nothing()
// os_printf(): can be redefined as doprint()
// doprint(): always print, can be os_printf_plus() or defined in doprint.c (buffered)
// in buffered mode: doprint_allow=1 is needed after Serial.begin

#if STRING_IN_FLASH && !defined(USE_OPTIMIZE_PRINTF)
#define USE_OPTIMIZE_PRINTF // at least used in arduino/esp8266
#endif
// os_printf_plus() missing in osapi.h (fixed in arduino's sdk-2.1):
extern int os_printf_plus (const char * format, ...) __attribute__ ((format (printf, 1, 2)));

#include <osapi.h> // os_printf* definitions + ICACHE_RODATA_ATTR

#if UDEBUG && (UDEBUGINDEX || UDEBUGSTORE)
// doprint() is used

#undef os_printf
#define os_printf(x...) do { doprint(x); } while (0)

#if STRING_IN_FLASH

#define doprint(fmt, ...) \
do { \
static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
doprint_minus(flash_str, ##__VA_ARGS__); \
} while(0)

#else // !STRING_IN_FLASH

#define doprint(fmt, ...) doprint_minus(fmt, ##__VA_ARGS__)

#endif // !STRING_IN_FLASH

int doprint_minus (const char* format, ...) __attribute__ ((format (printf, 1, 2))); // format in flash

#else // !( UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) )

#define doprint(x...) do { os_printf(x); } while (0)

#endif // !( UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) )

#if UDEBUG
#define uprint(x...) do { doprint(x); } while (0)
#else
#define uprint(x...) do { (void)0; } while (0)
#endif

#define uerror(x...) do { doprint(x); } while (0)
#define uassert(assertion...) do { if ((assertion) == 0) { os_printf_plus("assert fail: " #assertion " @%s:%d\n", __FILE__, __LINE__); uhalt(); } } while (0)
#define uhalt() do { *((int*)0) = 0; /* this triggers gdb */ } while (0)
#define nl() do { uprint("\n"); } while (0)

#endif
10 changes: 10 additions & 0 deletions tools/sdk/lwip2/include/lwip-err-t.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// script-generated, extracted from espressif SDK's lwIP arch/cc.h
#define LWIP_NO_STDINT_H 1
typedef unsigned char u8_t;
typedef signed char s8_t;
typedef unsigned short u16_t;
typedef signed short s16_t;
typedef unsigned long u32_t;
typedef signed long s32_t;
typedef unsigned long mem_ptr_t;
#define LWIP_ERR_T s32_t
6 changes: 6 additions & 0 deletions tools/sdk/lwip2/include/lwip-git-hash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// generated by makefiles/make-lwip2-hash
#ifndef LWIP_HASH_H
#define LWIP_HASH_H
#define LWIP_HASH 0x92f23d6
#define LWIP_HASH_STR "92f23d6(tag:STABLE-2_0_3_RELEASE)"
#endif // LWIP_HASH_H
Loading