Skip to content

Commit

Permalink
Simplify LWIP build
Browse files Browse the repository at this point in the history
* Make copy of `lwip/contrib/ports/unix/lib/` in `Linux` ($UNAME) directory, rather than attempting to patch it

lwipopts.h

* Put simplified lwipopts.h into root directory, but don't #include directly - it's added via lwip/opts.h
* Add default DNS server
* Add debug flags

Testing with `SystemClock_NTP` sample with DNS/UDP debugging enabled shows UDP requests are being sent out but no responses received. Further investigation required.
  • Loading branch information
mikee47 committed May 25, 2019
1 parent 9746217 commit 01ad266
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 2,785 deletions.
1 change: 0 additions & 1 deletion Sming/Arch/Host/Components/hostlib/host_lwip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "hostlib.h"

extern "C" {
#include "lwipopts.h"
#include <lwip/init.h>
#include <lwip/ip_addr.h>
#include <lwip/timeouts.h>
Expand Down
33 changes: 33 additions & 0 deletions Sming/Arch/Host/Components/lwip/Linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.8)

project(lwip C)

set (BUILD_SHARED_LIBS OFF)

if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_SYSTEM_NAME STREQUAL "GNU")
message(FATAL_ERROR "Lwip shared library is only working on Linux or the Hurd")
endif()

set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lwip)
include(${LWIP_DIR}/contrib/ports/CMakeCommon.cmake)

set (LWIP_DEFINITIONS -DLWIP_DEBUG)
set (LWIP_INCLUDE_DIRS
"${LWIP_DIR}/.."
"${LWIP_DIR}/src/include"
"${LWIP_CONTRIB_DIR}/"
"${LWIP_CONTRIB_DIR}/ports/unix/port/include"
"${CMAKE_CURRENT_SOURCE_DIR}/"
)

include(${LWIP_CONTRIB_DIR}/ports/unix/Filelists.cmake)
include(${LWIP_DIR}/src/Filelists.cmake)

add_library(lwip ${lwipnoapps_SRCS} ${lwipcontribportunix_SRCS} ${lwipcontribportunixnetifs_SRCS})
target_compile_options(lwip PRIVATE ${LWIP_COMPILER_FLAGS} -m32)
target_compile_definitions(lwip PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwip PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})
target_link_libraries(lwip ${LWIP_SANITIZER_LIBS})

find_library(LIBPTHREAD pthread)
target_link_libraries(lwip ${LIBPTHREAD})
4 changes: 4 additions & 0 deletions Sming/Arch/Host/Components/lwip/Linux/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

all:
cd $(BUILD_DIR); cmake $(CURDIR)
make -C $(BUILD_DIR)
8 changes: 0 additions & 8 deletions Sming/Arch/Host/Components/lwip/Makefile

This file was deleted.

106 changes: 0 additions & 106 deletions Sming/Arch/Host/Components/lwip/lwip.patch
Original file line number Diff line number Diff line change
@@ -1,109 +1,3 @@
diff --git a/contrib/ports/unix/lib/CMakeLists.txt b/contrib/ports/unix/lib/CMakeLists.txt
index 93d17bd0..d38cf5ff 100644
--- a/contrib/ports/unix/lib/CMakeLists.txt
+++ b/contrib/ports/unix/lib/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8)

project(lwip C)

-set (BUILD_SHARED_LIBS ON)
+set (BUILD_SHARED_LIBS OFF)

if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_SYSTEM_NAME STREQUAL "GNU")
message(FATAL_ERROR "Lwip shared library is only working on Linux or the Hurd")
@@ -23,7 +23,7 @@ include(${LWIP_CONTRIB_DIR}/ports/unix/Filelists.cmake)
include(${LWIP_DIR}/src/Filelists.cmake)

add_library(lwip ${lwipnoapps_SRCS} ${lwipcontribportunix_SRCS} ${lwipcontribportunixnetifs_SRCS})
-target_compile_options(lwip PRIVATE ${LWIP_COMPILER_FLAGS})
+target_compile_options(lwip PRIVATE ${LWIP_COMPILER_FLAGS} -m32)
target_compile_definitions(lwip PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwip PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})
target_link_libraries(lwip ${LWIP_SANITIZER_LIBS})
diff --git a/contrib/ports/unix/lib/lwipopts.h b/contrib/ports/unix/lib/lwipopts.h
index 660f7f70..94400b99 100644
--- a/contrib/ports/unix/lib/lwipopts.h
+++ b/contrib/ports/unix/lib/lwipopts.h
@@ -319,5 +319,5 @@
* LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
* transport.
*/
-#define LWIP_DNS 0
+#define LWIP_DNS 0

diff --git a/contrib/ports/unix/lib/lwipopts.h b/contrib/ports/unix/lib/lwipopts.h
index 660f7f70..c0affbdd 100644
--- a/contrib/ports/unix/lib/lwipopts.h
+++ b/contrib/ports/unix/lib/lwipopts.h
@@ -62,7 +62,7 @@
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
* use lwIP facilities.
*/
-#define NO_SYS 0
+#define NO_SYS 1

/*
------------------------------------
@@ -150,27 +150,27 @@
* MEMP_NUM_NETBUF: the number of struct netbufs.
* (only needed if you use the sequential API, like api_lib.c)
*/
-#define MEMP_NUM_NETBUF 2
+#define MEMP_NUM_NETBUF 0

/**
* MEMP_NUM_NETCONN: the number of struct netconns.
* (only needed if you use the sequential API, like api_lib.c)
*/
-#define MEMP_NUM_NETCONN 32
+#define MEMP_NUM_NETCONN 0

/**
* MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used
* for callback/timeout API communication.
* (only needed if you use tcpip.c)
*/
-#define MEMP_NUM_TCPIP_MSG_API 8
+#define MEMP_NUM_TCPIP_MSG_API 4

/**
* MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used
* for incoming packets.
* (only needed if you use tcpip.c)
*/
-#define MEMP_NUM_TCPIP_MSG_INPKT 8
+#define MEMP_NUM_TCPIP_MSG_INPKT 4

/**
* PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
@@ -319,7 +319,7 @@
* LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
* transport.
*/
-#define LWIP_DNS 0
+#define LWIP_DNS 1

/*
---------------------------------
@@ -382,7 +382,7 @@
/**
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
*/
-#define LWIP_NETCONN 1
+#define LWIP_NETCONN 0

/*
------------------------------------
@@ -392,7 +392,7 @@
/**
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
*/
-#define LWIP_SOCKET 1
+#define LWIP_SOCKET 0

/**
* SO_REUSE==1: Enable SO_REUSEADDR

diff --git a/contrib/ports/unix/port/sys_arch.c b/contrib/ports/unix/port/sys_arch.c
index a56d7de1..dd3f16e1 100644
--- a/contrib/ports/unix/port/sys_arch.c
Expand Down
Loading

0 comments on commit 01ad266

Please sign in to comment.