summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2024-05-07 00:23:50 +0200
committerHiFiPhile <[email protected]>2024-05-07 00:23:50 +0200
commit0f4ea8e9182c3f1f526e2ff5447ca31c5c7d8709 (patch)
treea771bfede97ec89797fd39f6e48555e58f9c916b
parent63d5103f42f5da11e08566a107c85b358e3d11aa (diff)
Enable NCM + iperf for MCU with bigger RAM.
-rw-r--r--examples/device/net_lwip_webserver/CMakeLists.txt1
-rw-r--r--examples/device/net_lwip_webserver/Makefile1
-rw-r--r--examples/device/net_lwip_webserver/src/main.c8
-rw-r--r--examples/device/net_lwip_webserver/src/tusb_config.h14
4 files changed, 23 insertions, 1 deletions
diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt
index a16b8bd71..c39fd32c5 100644
--- a/examples/device/net_lwip_webserver/CMakeLists.txt
+++ b/examples/device/net_lwip_webserver/CMakeLists.txt
@@ -74,6 +74,7 @@ target_sources(${PROJECT} PUBLIC
${LWIP}/src/netif/slipif.c
${LWIP}/src/apps/http/httpd.c
${LWIP}/src/apps/http/fs.c
+ ${LWIP}/src/apps/lwiperf/lwiperf.c
)
# due to warnings from other net source, we need to prevent error from some of the warnings options
diff --git a/examples/device/net_lwip_webserver/Makefile b/examples/device/net_lwip_webserver/Makefile
index 22426ba0d..141532466 100644
--- a/examples/device/net_lwip_webserver/Makefile
+++ b/examples/device/net_lwip_webserver/Makefile
@@ -63,6 +63,7 @@ SRC_C += \
lib/lwip/src/netif/slipif.c \
lib/lwip/src/apps/http/httpd.c \
lib/lwip/src/apps/http/fs.c \
+ lib/lwip/src/apps/lwiperf/lwiperf.c \
lib/networking/dhserver.c \
lib/networking/dnserver.c \
lib/networking/rndis_reports.c
diff --git a/examples/device/net_lwip_webserver/src/main.c b/examples/device/net_lwip_webserver/src/main.c
index e6f5faeb6..791e09b4f 100644
--- a/examples/device/net_lwip_webserver/src/main.c
+++ b/examples/device/net_lwip_webserver/src/main.c
@@ -53,6 +53,10 @@ try changing the first byte of tud_network_mac_address[] below from 0x02 to 0x00
#include "lwip/init.h"
#include "lwip/timeouts.h"
+#ifdef INCLUDE_IPERF
+ #include "lwip/apps/lwiperf.h"
+#endif
+
#define INIT_IP4(a, b, c, d) \
{ PP_HTONL(LWIP_MAKEU32(a, b, c, d)) }
@@ -225,6 +229,10 @@ int main(void) {
while (dnserv_init(IP_ADDR_ANY, 53, dns_query_proc) != ERR_OK);
httpd_init();
+#ifdef INCLUDE_IPERF
+ // test with: iperf -c 192.168.7.1 -e -i 1 -M 5000 -l 8192 -r
+ lwiperf_start_tcp_server_default(NULL, NULL);
+#endif
while (1) {
tud_task();
diff --git a/examples/device/net_lwip_webserver/src/tusb_config.h b/examples/device/net_lwip_webserver/src/tusb_config.h
index e0db3113c..ae5e67513 100644
--- a/examples/device/net_lwip_webserver/src/tusb_config.h
+++ b/examples/device/net_lwip_webserver/src/tusb_config.h
@@ -84,6 +84,18 @@ extern "C" {
#define CFG_TUSB_MEM_ALIGN __attribute__((aligned(4)))
#endif
+// Use different configurations to test all net devices (also due to resource limitations)
+#if TU_CHECK_MCU(OPT_MCU_LPC15XX, OPT_MCU_LPC40XX, OPT_MCU_LPC51UXX, OPT_MCU_LPC54)
+ #define USE_ECM 1
+#elif TU_CHECK_MCU(OPT_MCU_SAMD21, OPT_MCU_SAML21, OPT_MCU_SAML22)
+ #define USE_ECM 1
+#elif TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32F1)
+ #define USE_ECM 1
+#else
+ #define USE_ECM 0
+ #define INCLUDE_IPERF
+#endif
+
//--------------------------------------------------------------------
// NCM CLASS CONFIGURATION, SEE "ncm.h" FOR PERFORMANCE TUNNING
//--------------------------------------------------------------------
@@ -118,7 +130,7 @@ extern "C" {
// Network class has 2 drivers: ECM/RNDIS and NCM.
// Only one of the drivers can be enabled
-#define CFG_TUD_ECM_RNDIS 1
+#define CFG_TUD_ECM_RNDIS USE_ECM
#define CFG_TUD_NCM (1 - CFG_TUD_ECM_RNDIS)
#ifdef __cplusplus