diff --git a/builder/family/realtek-ambz2.py b/builder/family/realtek-ambz2.py index 1fa5026..b3e2fd4 100644 --- a/builder/family/realtek-ambz2.py +++ b/builder/family/realtek-ambz2.py @@ -189,6 +189,9 @@ env.Replace(FREERTOS_PORT=env["FAMILY_NAME"], FREERTOS_PORT_DEFINE="REALTEK_AMBZ queue.AddExternalLibrary("freertos") queue.AddExternalLibrary("freertos-port") +# Sources - lwIP +queue.AddExternalLibrary("lwip", port="ambz2") + # Sources - network utilities queue.AddLibrary( name="ambz2_net", @@ -216,7 +219,6 @@ queue.AddLibrary( "+", # network "+", - "+", # network - websocket "+", # network - mdns @@ -301,34 +303,6 @@ queue.AddLibrary( ), ) - -# Sources - lwIP 2.0.2 -queue.AddLibrary( - name="ambz2_lwip", - base_dir=join(COMPONENT_DIR, "common", "network", "lwip", "lwip_v2.0.2"), - srcs=[ - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - ], - includes=[ - "+", - "+", - "+", - "+", - ], - options=dict( - CFLAGS=[ - "-Wno-implicit-function-declaration", - ], - ), -) - # Sources - mbedTLS queue.AddLibrary( name="ambz2_mbedtls", diff --git a/cores/realtek-amb/base/config/lwipopts.h b/cores/realtek-amb/base/config/lwipopts.h index 326f60d..fae78d4 100644 --- a/cores/realtek-amb/base/config/lwipopts.h +++ b/cores/realtek-amb/base/config/lwipopts.h @@ -4,8 +4,14 @@ #include_next "lwipopts.h" -#define ip_addr ip4_addr // LwIP 2.0.x compatibility -#define ip_addr_t ip4_addr_t // LwIP 2.0.x compatibility +#if (!defined(LWIP_IPV4) || LWIP_IPV4) && !LWIP_IPV6 +#define ip_addr ip4_addr // LwIP 2.0.x compatibility +#define ip_addr_t ip4_addr_t // LwIP 2.0.x compatibility +#endif +#if !LWIP_IPV4 && LWIP_IPV6 +#define ip_addr ip6_addr // LwIP 2.0.x compatibility +#define ip_addr_t ip6_addr_t // LwIP 2.0.x compatibility +#endif #define in_addr_t u32_t #define IN_ADDR_T_DEFINED 1 diff --git a/cores/realtek-ambz2/base/config/lwipopts.h b/cores/realtek-ambz2/base/config/lwipopts.h new file mode 100644 index 0000000..642ba35 --- /dev/null +++ b/cores/realtek-ambz2/base/config/lwipopts.h @@ -0,0 +1,10 @@ +/* Copyright (c) Kuba SzczodrzyƄski 2023-05-27. */ + +#pragma once + +// lwipopts.h defines `unsigned int sys_now()`, while lwip/sys.h defines `u32_t sys_now()` +// since u32_t is unsigned long, these are incompatible +#define sys_now sys_now_dummy +#include_next "lwipopts.h" +#undef sys_now +extern unsigned long sys_now(void); diff --git a/cores/realtek-ambz2/base/fixups/wireless.h b/cores/realtek-ambz2/base/fixups/wireless.h new file mode 100644 index 0000000..c991585 --- /dev/null +++ b/cores/realtek-ambz2/base/fixups/wireless.h @@ -0,0 +1,5 @@ +/* Copyright (c) Kuba SzczodrzyƄski 2023-05-27. */ + +#undef IFNAMSIZ + +#include_next "wireless.h" diff --git a/external-libs.json b/external-libs.json index 4cb871b..9b3ff07 100644 --- a/external-libs.json +++ b/external-libs.json @@ -121,5 +121,25 @@ "+", "+" ] + }, + "lwip-ambz2": { + "package": "library-lwip", + "sources": [ + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+" + ], + "includes": [ + "+", + "+", + "+", + "+" + ] } } diff --git a/platform.json b/platform.json index dad8560..eeea980 100644 --- a/platform.json +++ b/platform.json @@ -45,7 +45,12 @@ "any": "gccarmnoneeabi@~1.100301.0" }, "libraries": { - "freertos": "10.0.1" + "freertos": "10.0.1", + "lwip": { + "2.0.3": "2.0.3-ambz2", + "2.1.3": "2.1.3-ambz2", + "default": "2.1.3-ambz2" + } } }, "framework-beken-bdk": {