From e131a9cce8b65fe08771ed0699ffc9db73fd6861 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 2 Nov 2024 21:25:21 +0100 Subject: [PATCH 01/22] Ethernet: Reject additonal connection instead of looping on OVERFLOW --- EthernetInterface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index f8306cb..1e49a21 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -144,7 +144,9 @@ void EthernetInterface::acceptClient() { // STM32 version return; } } - DIAG(F("Ethernet OVERFLOW")); + // reached here only if more than MAX_SOCK_NUM clients want to connect + DIAG(F("Ethernet more than %d clients, not accepting new connection"), MAX_SOCK_NUM); + client.stop(); } #else void EthernetInterface::acceptClient() { // non-STM32 version From 657fb7009c7c32ff32fcba6a8bc6f0bb7275fd41 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 4 Nov 2024 17:27:34 +0100 Subject: [PATCH 02/22] tag --- GITHUB_SHA.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index f1dae0d..46f45ee 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202409300806Z" +#define GITHUB_SHA "devel-202411041626Z" From 701f4e852f385c0004d4f6ad9618b4bf4e5b2d3c Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 4 Nov 2024 17:28:51 +0100 Subject: [PATCH 03/22] Variable number of TCP clients --- CommandDistributor.cpp | 3 +-- CommandDistributor.h | 4 ++-- EthernetInterface.h | 2 +- config.example.h | 7 +++++++ defines.h | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index e889f62..924e0af 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -56,8 +56,7 @@ template void CommandDistributor::broadcastReply(clientType t #ifdef CD_HANDLE_RING // wifi or ethernet ring streams with multiple client types RingStream * CommandDistributor::ring=0; - CommandDistributor::clientType CommandDistributor::clients[8]={ - NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE}; +CommandDistributor::clientType CommandDistributor::clients[MAX_NUM_TCP_CLIENTS]={ NONE_TYPE }; // 0 is and must be NONE_TYPE // Parse is called by Withrottle or Ethernet interface to determine which // protocol the client is using and call the appropriate part of dcc++Ex diff --git a/CommandDistributor.h b/CommandDistributor.h index d86b87f..c1bb7f3 100644 --- a/CommandDistributor.h +++ b/CommandDistributor.h @@ -36,13 +36,13 @@ class CommandDistributor { public: - enum clientType: byte {NONE_TYPE,COMMAND_TYPE,WITHROTTLE_TYPE}; + enum clientType: byte {NONE_TYPE=0,COMMAND_TYPE,WITHROTTLE_TYPE}; private: static void broadcastToClients(clientType type); static StringBuffer * broadcastBufferWriter; #ifdef CD_HANDLE_RING static RingStream * ring; - static clientType clients[8]; + static clientType clients[MAX_NUM_TCP_CLIENTS]; #endif public : static void parse(byte clientId,byte* buffer, RingStream * ring); diff --git a/EthernetInterface.h b/EthernetInterface.h index 16156fa..6cea6e8 100644 --- a/EthernetInterface.h +++ b/EthernetInterface.h @@ -45,7 +45,7 @@ #include extern "C" struct netif gnetif; #define STM32_ETHERNET - #define MAX_SOCK_NUM 8 + #define MAX_SOCK_NUM MAX_NUM_TCP_CLIENTS #else #include "Ethernet.h" #endif diff --git a/config.example.h b/config.example.h index d7dab5e..ff4652f 100644 --- a/config.example.h +++ b/config.example.h @@ -137,6 +137,13 @@ The configuration file for DCC-EX Command Station // //#define ENABLE_ETHERNET true +///////////////////////////////////////////////////////////////////////////////////// +// +// MAX_NUM_TCP_CLIENTS: If you on STM32 Ethernet (and only there) want more than +// 10 TCP clients, enable this here **AND** follow the instructions in STM32lwiopts.h +// +//#define MAX_NUM_TCP_CLIENTS 20 + ///////////////////////////////////////////////////////////////////////////////////// // diff --git a/defines.h b/defines.h index 2c3ee55..0cd891f 100644 --- a/defines.h +++ b/defines.h @@ -239,4 +239,19 @@ #endif #endif +#if defined(ARDUINO_ARCH_STM32) +// Allow override of MAX_NUM_TCP_CLIENTS but default is 10 + #ifndef MAX_NUM_TCP_CLIENTS + #define MAX_NUM_TCP_CLIENTS 10 + #endif +#else + #if defined(ARDUINO_ARCH_ESP32) +// Espressif LWIP stack + #define MAX_NUM_TCP_CLIENTS 10 + #else +// Wifi shields etc + #define MAX_NUM_TCP_CLIENTS 8 + #endif #endif + +#endif //DEFINES_H From bcdf9cb1c5eebaeaed752672ac59832e422f4bf2 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 4 Nov 2024 17:35:34 +0100 Subject: [PATCH 04/22] Add STM32lwipopts.h --- STM32lwipopts.h | 261 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 STM32lwipopts.h diff --git a/STM32lwipopts.h b/STM32lwipopts.h new file mode 100644 index 0000000..68cb992 --- /dev/null +++ b/STM32lwipopts.h @@ -0,0 +1,261 @@ +/** + ****************************************************************************** + * @file STM32lwipopts_default.h + * @author MCD Application Team + * @brief lwIP Options Configuration. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +#ifndef __STM32LWIPOPTS_H__ +#define __STM32LWIPOPTS_H__ + +// we can not include that here so we +// need to duplicate that.define +// #include "defines.h" +#define MAX_NUM_TCP_CLIENTS 20 + +// increase ARP cache +#define MEMP_NUM_ARP_QUEUE MAX_NUM_TCP_CLIENTS+3 // one for each client (all on different HW) and a few extra + +// Example for debug +//#define LWIP_DEBUG 1 +//#define TCP_DEBUG LWIP_DBG_ON + +/** + * NO_SYS==1: Provides VERY minimal functionality. Otherwise, + * use lwIP facilities. + */ +#define NO_SYS 1 + +/** + * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain + * critical regions during buffer allocation, deallocation and memory + * allocation and deallocation. + */ +#define SYS_LIGHTWEIGHT_PROT 0 + +#define LWIP_NOASSERT + +/* ---------- Memory options ---------- */ +/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which + lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 + byte alignment -> define MEM_ALIGNMENT to 2. */ +#define MEM_ALIGNMENT 4 + +/* MEM_SIZE: the size of the heap memory. If the application will send +a lot of data that needs to be copied, this should be set high. */ +#define MEM_SIZE (10*1024) + +// Could be better or worse, needs more tests +//#define MEM_LIBC_MALLOC 1 +//#define MEMP_MEM_MALLOC 1 + +/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application + sends a lot of data out of ROM (or other static memory), this + should be set high. */ +#define MEMP_NUM_PBUF 10 +/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One + per active UDP "connection". */ +#define MEMP_NUM_UDP_PCB 6 +/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP + connections. */ +#define MEMP_NUM_TCP_PCB MAX_NUM_TCP_CLIENTS+1 // one extra so we can reject number N+1 from our code +/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP + connections. */ +#define MEMP_NUM_TCP_PCB_LISTEN 6 +/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP + segments. */ +#define MEMP_NUM_TCP_SEG MAX_NUM_TCP_CLIENTS +/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active + timeouts. */ +#define MEMP_NUM_SYS_TIMEOUT MAX_NUM_TCP_CLIENTS+2 + + +/* ---------- Pbuf options ---------- */ +/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ +#define PBUF_POOL_SIZE MAX_NUM_TCP_CLIENTS + +/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ +#define PBUF_POOL_BUFSIZE 1524 + + +/* ---------- TCP options ---------- */ +#define LWIP_TCP 1 +#define TCP_TTL 255 +#define LWIP_SO_RCVTIMEO 1 +#define LWIP_SO_RCVRCVTIMEO_NONSTANDARD 1 /* Pass an integer number of ms instead of a timeval struct. */ +#define LWIP_SO_SNDTIMEO 1 +#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 1 /* Pass an integer number of ms instead of a timeval struct. */ + +/* Controls if TCP should queue segments that arrive out of + order. Define to 0 if your device is low on memory and you are not scared by TCP congestion and latencies. */ +#define TCP_QUEUE_OOSEQ 0 + +/* TCP Maximum segment size. */ +#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */ + +/* TCP sender buffer space (bytes). */ +#define TCP_SND_BUF (4*TCP_MSS) + +/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least + as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */ + +#define TCP_SND_QUEUELEN (2* TCP_SND_BUF/TCP_MSS) + +/* TCP receive window. */ +#define TCP_WND (3*TCP_MSS) + +#define LWIP_TCP_KEEPALIVE 1 /* Keep the TCP link active. Important for MQTT/TLS */ +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 /* Prevent the same port to be used after reset. + Otherwise, the remote host may be confused if the port was not explicitly closed before the reset. */ + + +/* ---------- ICMP options ---------- */ +#define LWIP_ICMP 1 +#define LWIP_RAW 1 /* PING changed to 1 */ +#define DEFAULT_RAW_RECVMBOX_SIZE 3 /* for ICMP PING */ + + +/* ---------- DHCP options ---------- */ +/* Define LWIP_DHCP to 1 if you want DHCP configuration of + interfaces. DHCP is not implemented in lwIP 0.5.1, however, so + turning this on does currently not work. */ +#define LWIP_DHCP 1 + + +/* ---------- UDP options ---------- */ +#define LWIP_UDP 1 +#define UDP_TTL 255 + + +/* ---------- Statistics options ---------- */ +#define LWIP_STATS 0 +#define LWIP_PROVIDE_ERRNO + +/* ---------- link callback options ---------- */ +/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface + * whenever the link changes (i.e., link down) + */ +// need for building net_ip.c +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 +#define LWIP_DHCP_CHECK_LINK_UP 1 + +/* + -------------------------------------- + ---------- Checksum options ---------- + -------------------------------------- +*/ + +/* +The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware: + - To use this feature let the following define uncommented. + - To disable it and process by CPU comment the the checksum. +*/ +#define CHECKSUM_BY_HARDWARE + + +#ifdef CHECKSUM_BY_HARDWARE + /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/ + #define CHECKSUM_GEN_IP 0 + /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/ + #define CHECKSUM_GEN_UDP 0 + /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/ + #define CHECKSUM_GEN_TCP 0 + /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/ + #define CHECKSUM_CHECK_IP 0 + /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/ + #define CHECKSUM_CHECK_UDP 0 + /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/ + #define CHECKSUM_CHECK_TCP 0 + /* CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/ + #define CHECKSUM_GEN_ICMP 0 +#else + /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/ + #define CHECKSUM_GEN_IP 1 + /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/ + #define CHECKSUM_GEN_UDP 1 + /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/ + #define CHECKSUM_GEN_TCP 1 + /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/ + #define CHECKSUM_CHECK_IP 1 + /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/ + #define CHECKSUM_CHECK_UDP 1 + /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/ + #define CHECKSUM_CHECK_TCP 1 + /* CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/ + #define CHECKSUM_GEN_ICMP 1 +#endif + + +/* + ---------------------------------------------- + ---------- Sequential layer options ---------- + ---------------------------------------------- +*/ +/** + * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) + */ +#define LWIP_NETCONN 0 + +/* + ------------------------------------ + ---------- Socket options ---------- + ------------------------------------ +*/ +/** + * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) + */ +#define LWIP_SOCKET 0 +#define LWIP_DNS 1 + +/* + ------------------------------------ + ---------- httpd options ---------- + ------------------------------------ +*/ + +/** Set this to 1 to support CGI */ +#define LWIP_HTTPD_CGI 1 + +/** Set this to 1 to support SSI (Server-Side-Includes) */ +#define LWIP_HTTPD_SSI 1 + +/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the + * file system (to prevent changing the file included in CVS) */ +#define HTTPD_USE_CUSTOM_FSDATA 1 + +/* + ------------------------------------ + ---------- Custom options ---------- + ------------------------------------ +*/ + +/** Enables the Ethernet peripheral in RMII mode. If not defined, MII mode will + be enabled. Pin mapping must be configured for the selected mode + (see PinMap_Ethernet in PeripheralPins.c). */ +#define ETHERNET_RMII_MODE_CONFIGURATION 1 + +/** Uncomment this line to use the ethernet input in interrupt mode. + * NOTE: LwIP stack documentation recommends to use the polling mode without + * an operating system. */ +//#define ETH_INPUT_USE_IT 1 + +#define LWIP_MDNS_RESPONDER 1 +#define LWIP_IGMP 1 +#warning testing this + +#endif /* __STM32LWIPOPTS_H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 19f486940121871297ca618fd88192aa284c5e45 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 9 Nov 2024 12:57:49 +0100 Subject: [PATCH 05/22] multicast receive tests --- EthernetInterface.cpp | 13 ++++++++++++- STM32lwipopts.h | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index 1e49a21..2acb92f 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -36,9 +36,17 @@ #define DO_MDNS EthernetUDP udp; MDNS mdns(udp); +void serviceFound(const char* type, MDNSServiceProtocol /*proto*/, const char* name, IPAddress ip, + unsigned short port, const char* txtContent) +{ + if (name == NULL) { + DIAG("End service discovery of %s", type); + return; + } + DIAG("Got %s of type %s", name, type); +} #endif - //extern void looptimer(unsigned long timeout, const FSH* message); #define looptimer(a,b) @@ -117,7 +125,10 @@ void EthernetInterface::setup() outboundRing=new RingStream(OUTBOUND_RING_SIZE); #ifdef DO_MDNS mdns.begin(Ethernet.localIP(), WIFI_HOSTNAME); // hostname + udp.begin(IPAddress(224, 0, 0, 251), 5353, true); mdns.addServiceRecord(WIFI_HOSTNAME "._withrottle", IP_PORT, MDNSServiceTCP); +// mdns.setServiceFoundCallback(serviceFound); +// mdns.startDiscoveringService("_withrottle", MDNSServiceTCP, 0); // Not sure if we need to run it once, but just in case! mdns.run(); #endif diff --git a/STM32lwipopts.h b/STM32lwipopts.h index 68cb992..d4053e8 100644 --- a/STM32lwipopts.h +++ b/STM32lwipopts.h @@ -252,8 +252,12 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums * an operating system. */ //#define ETH_INPUT_USE_IT 1 -#define LWIP_MDNS_RESPONDER 1 +// We don't need this as we do not need to respond - we only announce +//#define LWIP_MDNS_RESPONDER 1 +//#define LWIP_NUM_NETIF_CLIENT_DATA 1 // MDNS needs at least one #define LWIP_IGMP 1 +#define SO_REUSE 1 +#define SO_REUSE_RXTOALL 1 #warning testing this #endif /* __STM32LWIPOPTS_H__ */ From 64a34b3a32a7cda963fa3eb5752430dca0142264 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 11:31:14 +0100 Subject: [PATCH 06/22] proto works --- EthernetInterface.cpp | 16 ++++++++++------ STM32lwipopts.h | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index 2acb92f..a2e292d 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -31,7 +31,13 @@ #include "CommandDistributor.h" #include "WiThrottle.h" #include "DCCTimer.h" -#if __has_include ( "MDNS_Generic.h") + +#include "EXmDNS.h" +#define DO_MDNS +EthernetUDP udp; +MDNS mdns(udp); + +#if 0 //#if __has_include ( "MDNS_Generic.h") #include "MDNS_Generic.h" #define DO_MDNS EthernetUDP udp; @@ -124,11 +130,9 @@ void EthernetInterface::setup() outboundRing=new RingStream(OUTBOUND_RING_SIZE); #ifdef DO_MDNS - mdns.begin(Ethernet.localIP(), WIFI_HOSTNAME); // hostname - udp.begin(IPAddress(224, 0, 0, 251), 5353, true); - mdns.addServiceRecord(WIFI_HOSTNAME "._withrottle", IP_PORT, MDNSServiceTCP); -// mdns.setServiceFoundCallback(serviceFound); -// mdns.startDiscoveringService("_withrottle", MDNSServiceTCP, 0); + if (!mdns.begin(Ethernet.localIP(), WIFI_HOSTNAME)) + DIAG("mdns.begin fail"); // hostname + mdns.addServiceRecord(WIFI_HOSTNAME, IP_PORT, MDNSServiceTCP); // Not sure if we need to run it once, but just in case! mdns.run(); #endif diff --git a/STM32lwipopts.h b/STM32lwipopts.h index d4053e8..24a3fae 100644 --- a/STM32lwipopts.h +++ b/STM32lwipopts.h @@ -57,8 +57,8 @@ a lot of data that needs to be copied, this should be set high. */ #define MEM_SIZE (10*1024) // Could be better or worse, needs more tests -//#define MEM_LIBC_MALLOC 1 -//#define MEMP_MEM_MALLOC 1 +#define MEM_LIBC_MALLOC 1 // critical, fixes heap trashing +#define MEMP_MEM_MALLOC 1 // uses malloc which means no pools which means slower but not mean 32KB up front /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application sends a lot of data out of ROM (or other static memory), this From 9a6e1707e7f7b51c7f0c09ba977d0ab4ef6f6b0c Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 11:31:49 +0100 Subject: [PATCH 07/22] add own mDNS files --- EXmDNS.cpp | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++ EXmDNS.h | 20 ++++++++ 2 files changed, 159 insertions(+) create mode 100644 EXmDNS.cpp create mode 100644 EXmDNS.h diff --git a/EXmDNS.cpp b/EXmDNS.cpp new file mode 100644 index 0000000..559f09c --- /dev/null +++ b/EXmDNS.cpp @@ -0,0 +1,139 @@ + +#include +#include "EthernetInterface.h" +#include "EXmDNS.h" +#include "DIAG.h" +static IPAddress mdnsMulticastIPAddr = IPAddress(224, 0, 0, 251); +#define MDNS_SERVER_PORT 5353 + +MDNS::MDNS(EthernetUDP& udp) { + _udp = &udp; +} +MDNS::~MDNS() { + _udp->stop(); +} +int MDNS::begin(const IPAddress& ip, char* name) { + // if we were called very soon after the board was booted, we need to give the + // EthernetShield (WIZnet) some time to come up. Hence, we delay until millis() is at + // least 3000. This is necessary, so that if we need to add a service record directly + // after begin, the announce packet does not get lost in the bowels of the WIZnet chip. + //while (millis() < 3000) + // delay(100); + + _ipAddress = ip; + _name = name; + return _udp->beginMulticast(mdnsMulticastIPAddr, MDNS_SERVER_PORT); +} +int MDNS::addServiceRecord(const char* name, uint16_t port, MDNSServiceProtocol_t proto) { + // we ignore proto, assume TCP + _serviceName = (char *)malloc(strlen(name +2)); + DIAG("name %d %s", strlen(name), name); + byte n; + for(n = 0; n 10000)) { + return; + } + lastrun = now; + DNSHeader_t dnsHeader = { 0 }; + + _udp->beginPacket(mdnsMulticastIPAddr, MDNS_SERVER_PORT); + + // dns header + dnsHeader.flags = lwip_htons(0x8400); // Response, authorative + dnsHeader.answerCount = lwip_htons(4 /*5*/); + _udp->write((uint8_t*)&dnsHeader, sizeof(DNSHeader_t)); + // rr #1 + _udp->write((uint8_t*)dns_rr_services, sizeof(dns_rr_services)); + byte buf[10]; + buf[0] = 0x00; + buf[1] = 0x0c; //PTR + buf[2] = 0x00; + buf[3] = 0x01; //IN + *((uint32_t*)(buf+4)) = lwip_htonl(120); //TTL in sec + *((uint16_t*)(buf+8)) = lwip_htons(sizeof(dns_rr_withrottle)); + _udp->write(buf, 10); + _udp->write(dns_rr_withrottle, sizeof(dns_rr_withrottle)); + // rr #2 + _udp->write(dns_rr_withrottle, sizeof(dns_rr_withrottle)); + *((uint16_t*)(buf+8)) = lwip_htons(strlen(_serviceName) + sizeof(dns_rr_withrottle)); // recycle most of buf + _udp->write(buf, 10); + + _udp->write(_serviceName, _serviceName[0]+1); + _udp->write(dns_rr_withrottle, sizeof(dns_rr_withrottle)); + // rr #3 + _udp->write(_serviceName, _serviceName[0]+1); + _udp->write(dns_rr_withrottle, sizeof(dns_rr_withrottle)); + + buf[1] = 0x21; // recycle most of buf but here SRV + buf[2] = 0x80; // cache flush + *((uint16_t*)(buf+8)) = lwip_htons(strlen(_serviceName) + strlen(dns_rr_local) + 1 + 6); + _udp->write(buf, 10); + + byte srv[6]; + // priority and weight + srv[0] = srv[1] = srv[2] = srv[3] = 0; + // port + *((uint16_t*)(srv+4)) = lwip_htons(_servicePort); + _udp->write(srv, 6); + // target + _udp->write(_serviceName, _serviceName[0]+1); + _udp->write(dns_rr_local, strlen(dns_rr_local)+1); + + // rr #4 + _udp->write(_serviceName, _serviceName[0]+1); + _udp->write(dns_rr_local, strlen(dns_rr_local)+1); + + buf[1] = 0x01; // recycle most of buf but here A + *((uint16_t*)(buf+8)) = lwip_htons(4); + _udp->write(buf, 10); + byte ip[4]; + ip[0] = _ipAddress[0]; + ip[1] = _ipAddress[1]; + ip[2] = _ipAddress[2]; + ip[3] = _ipAddress[3]; + _udp->write(ip, 4); + + _udp->endPacket(); + _udp->flush(); + // +} diff --git a/EXmDNS.h b/EXmDNS.h new file mode 100644 index 0000000..769a055 --- /dev/null +++ b/EXmDNS.h @@ -0,0 +1,20 @@ +typedef enum _MDNSServiceProtocol_t +{ + MDNSServiceTCP, + MDNSServiceUDP +} MDNSServiceProtocol_t; + +class MDNS { +public: + MDNS(EthernetUDP& udp); + ~MDNS(); + int begin(const IPAddress& ip, char* name); + int addServiceRecord(const char* name, uint16_t port, MDNSServiceProtocol_t proto); + void run(); +private: + EthernetUDP *_udp; + IPAddress _ipAddress; + char* _name; + char* _serviceName; + int _servicePort; +}; From 0a96320fd0e491fcdcc449f0df748b39f417bc48 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 19:48:52 +0100 Subject: [PATCH 08/22] tidy up values into name, serviceName, serviceProto and packet generation --- EXmDNS.cpp | 119 +++++++++++++++++++++++++++--------------- EXmDNS.h | 4 ++ EthernetInterface.cpp | 5 +- 3 files changed, 84 insertions(+), 44 deletions(-) diff --git a/EXmDNS.cpp b/EXmDNS.cpp index 559f09c..b4fc200 100644 --- a/EXmDNS.cpp +++ b/EXmDNS.cpp @@ -2,15 +2,49 @@ #include #include "EthernetInterface.h" #include "EXmDNS.h" -#include "DIAG.h" + +// fixed values for mDNS static IPAddress mdnsMulticastIPAddr = IPAddress(224, 0, 0, 251); #define MDNS_SERVER_PORT 5353 +// dotToLen() +// converts stings of form ".foo.barbar.x" to a string with the +// dots replaced with lenght. So string above would result in +// "\x03foo\x06barbar\x01x" in C notation. If not NULL, *substr +// will point to the beginning of the last component, in this +// example that would be "\x01x". +// +static void dotToLen(char *str, char **substr) { + char *dotplace = NULL; + char *s; + byte charcount = 0; + for (s = str;/*see break*/ ; s++) { + if (*s == '.' || *s == '\0') { + // take care of accumulated + if (dotplace != NULL && charcount != 0) { + *dotplace = charcount; + } + if (*s == '\0') + break; + if (substr && *s == '.') + *substr = s; + // set new values + dotplace = s; + charcount = 0; + } else { + charcount++; + } + } +} + MDNS::MDNS(EthernetUDP& udp) { _udp = &udp; } MDNS::~MDNS() { _udp->stop(); + if (_name) free(_name); + if (_serviceName) free(_serviceName); + if (_serviceProto) free(_serviceProto); } int MDNS::begin(const IPAddress& ip, char* name) { // if we were called very soon after the board was booted, we need to give the @@ -21,56 +55,53 @@ int MDNS::begin(const IPAddress& ip, char* name) { // delay(100); _ipAddress = ip; - _name = name; + _name = (char *)malloc(strlen(name +2)); + byte n; + for(n = 0; nbeginMulticast(mdnsMulticastIPAddr, MDNS_SERVER_PORT); } + int MDNS::addServiceRecord(const char* name, uint16_t port, MDNSServiceProtocol_t proto) { // we ignore proto, assume TCP _serviceName = (char *)malloc(strlen(name +2)); - DIAG("name %d %s", strlen(name), name); byte n; for(n = 0; n 10000)) { + if (!(now - lastrun > BROADCASTTIME * 1000UL)) { return; } lastrun = now; @@ -80,33 +111,39 @@ void MDNS::run() { // dns header dnsHeader.flags = lwip_htons(0x8400); // Response, authorative - dnsHeader.answerCount = lwip_htons(4 /*5*/); + dnsHeader.answerCount = lwip_htons(4 /*5 if TXT but we do not do that */); _udp->write((uint8_t*)&dnsHeader, sizeof(DNSHeader_t)); - // rr #1 + + // rr #1, the PTR record from generic _services.x.local to service.x.local _udp->write((uint8_t*)dns_rr_services, sizeof(dns_rr_services)); + byte buf[10]; buf[0] = 0x00; buf[1] = 0x0c; //PTR buf[2] = 0x00; buf[3] = 0x01; //IN *((uint32_t*)(buf+4)) = lwip_htonl(120); //TTL in sec - *((uint16_t*)(buf+8)) = lwip_htons(sizeof(dns_rr_withrottle)); - _udp->write(buf, 10); - _udp->write(dns_rr_withrottle, sizeof(dns_rr_withrottle)); - // rr #2 - _udp->write(dns_rr_withrottle, sizeof(dns_rr_withrottle)); - *((uint16_t*)(buf+8)) = lwip_htons(strlen(_serviceName) + sizeof(dns_rr_withrottle)); // recycle most of buf + *((uint16_t*)(buf+8)) = lwip_htons( _serviceProto[0] + 1 + strlen(dns_rr_tcplocal) + 1); _udp->write(buf, 10); - _udp->write(_serviceName, _serviceName[0]+1); - _udp->write(dns_rr_withrottle, sizeof(dns_rr_withrottle)); - // rr #3 - _udp->write(_serviceName, _serviceName[0]+1); - _udp->write(dns_rr_withrottle, sizeof(dns_rr_withrottle)); + _udp->write(_serviceProto,_serviceProto[0]+1); + _udp->write(dns_rr_tcplocal, strlen(dns_rr_tcplocal)+1); + + // rr #2, the PTR record from proto.x to name.proto.x + _udp->write(_serviceProto,_serviceProto[0]+1); + _udp->write(dns_rr_tcplocal, strlen(dns_rr_tcplocal)+1); + *((uint16_t*)(buf+8)) = lwip_htons(strlen(_serviceName) + strlen(dns_rr_tcplocal) + 1); // recycle most of buf + _udp->write(buf, 10); + + _udp->write(_serviceName, strlen(_serviceName)); + _udp->write(dns_rr_tcplocal, strlen(dns_rr_tcplocal)+1); + // rr #3, the SRV record for the service that points to local name + _udp->write(_serviceName, strlen(_serviceName)); + _udp->write(dns_rr_tcplocal, strlen(dns_rr_tcplocal)+1); buf[1] = 0x21; // recycle most of buf but here SRV buf[2] = 0x80; // cache flush - *((uint16_t*)(buf+8)) = lwip_htons(strlen(_serviceName) + strlen(dns_rr_local) + 1 + 6); + *((uint16_t*)(buf+8)) = lwip_htons(strlen(_name) + strlen(dns_rr_local) + 1 + 6); _udp->write(buf, 10); byte srv[6]; @@ -116,11 +153,11 @@ void MDNS::run() { *((uint16_t*)(srv+4)) = lwip_htons(_servicePort); _udp->write(srv, 6); // target - _udp->write(_serviceName, _serviceName[0]+1); + _udp->write(_name, _name[0]+1); _udp->write(dns_rr_local, strlen(dns_rr_local)+1); - // rr #4 - _udp->write(_serviceName, _serviceName[0]+1); + // rr #4, the A record for the name.local + _udp->write(_name, _name[0]+1); _udp->write(dns_rr_local, strlen(dns_rr_local)+1); buf[1] = 0x01; // recycle most of buf but here A diff --git a/EXmDNS.h b/EXmDNS.h index 769a055..fd50a2a 100644 --- a/EXmDNS.h +++ b/EXmDNS.h @@ -1,3 +1,6 @@ + +#define BROADCASTTIME 15 //seconds + typedef enum _MDNSServiceProtocol_t { MDNSServiceTCP, @@ -16,5 +19,6 @@ private: IPAddress _ipAddress; char* _name; char* _serviceName; + char* _serviceProto; int _servicePort; }; diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index a2e292d..26be378 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -132,9 +132,8 @@ void EthernetInterface::setup() #ifdef DO_MDNS if (!mdns.begin(Ethernet.localIP(), WIFI_HOSTNAME)) DIAG("mdns.begin fail"); // hostname - mdns.addServiceRecord(WIFI_HOSTNAME, IP_PORT, MDNSServiceTCP); - // Not sure if we need to run it once, but just in case! - mdns.run(); + mdns.addServiceRecord(WIFI_HOSTNAME "._withrottle", IP_PORT, MDNSServiceTCP); + mdns.run(); // run it right away to get out info ASAP #endif connected=true; } From b9ce166028cfc9ff0db81f127e9a575ef4ea921e Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 20:13:40 +0100 Subject: [PATCH 09/22] remove everything that are not our changes --- STM32lwipopts.h | 253 ++++++------------------------------------------ 1 file changed, 28 insertions(+), 225 deletions(-) diff --git a/STM32lwipopts.h b/STM32lwipopts.h index 24a3fae..9f6e0c5 100644 --- a/STM32lwipopts.h +++ b/STM32lwipopts.h @@ -1,265 +1,68 @@ -/** - ****************************************************************************** - * @file STM32lwipopts_default.h - * @author MCD Application Team - * @brief lwIP Options Configuration. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics International N.V. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ + + #ifndef __STM32LWIPOPTS_H__ #define __STM32LWIPOPTS_H__ -// we can not include that here so we -// need to duplicate that.define -// #include "defines.h" +// include this here and then override things we do differnet +#include "lwipopts_default.h" + +// we can not include our "defines.h" here +// so we need to duplicate that define #define MAX_NUM_TCP_CLIENTS 20 // increase ARP cache +#undef MEMP_NUM_APR_QUEUE #define MEMP_NUM_ARP_QUEUE MAX_NUM_TCP_CLIENTS+3 // one for each client (all on different HW) and a few extra // Example for debug //#define LWIP_DEBUG 1 //#define TCP_DEBUG LWIP_DBG_ON -/** - * NO_SYS==1: Provides VERY minimal functionality. Otherwise, - * use lwIP facilities. - */ -#define NO_SYS 1 - -/** - * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain - * critical regions during buffer allocation, deallocation and memory - * allocation and deallocation. - */ -#define SYS_LIGHTWEIGHT_PROT 0 - -#define LWIP_NOASSERT - -/* ---------- Memory options ---------- */ -/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which - lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 - byte alignment -> define MEM_ALIGNMENT to 2. */ -#define MEM_ALIGNMENT 4 - -/* MEM_SIZE: the size of the heap memory. If the application will send -a lot of data that needs to be copied, this should be set high. */ -#define MEM_SIZE (10*1024) - -// Could be better or worse, needs more tests +// IMPORTANT CHANGE THE FIRST ONE +#undef MEM_LIBC_MALLOC #define MEM_LIBC_MALLOC 1 // critical, fixes heap trashing +#undef MEMP_MEM_MALLOC #define MEMP_MEM_MALLOC 1 // uses malloc which means no pools which means slower but not mean 32KB up front -/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application - sends a lot of data out of ROM (or other static memory), this - should be set high. */ -#define MEMP_NUM_PBUF 10 -/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One - per active UDP "connection". */ -#define MEMP_NUM_UDP_PCB 6 -/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP - connections. */ +#undef MEMP_NUM_TCP_PCB #define MEMP_NUM_TCP_PCB MAX_NUM_TCP_CLIENTS+1 // one extra so we can reject number N+1 from our code -/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP - connections. */ #define MEMP_NUM_TCP_PCB_LISTEN 6 -/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP - segments. */ + +#undef MEMP_NUM_TCP_SEG #define MEMP_NUM_TCP_SEG MAX_NUM_TCP_CLIENTS -/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active - timeouts. */ + +#undef MEMP_NUM_SYS_TIMEOUT #define MEMP_NUM_SYS_TIMEOUT MAX_NUM_TCP_CLIENTS+2 - -/* ---------- Pbuf options ---------- */ -/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ +#undef PBUF_POOL_SIZE #define PBUF_POOL_SIZE MAX_NUM_TCP_CLIENTS -/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ -#define PBUF_POOL_BUFSIZE 1524 - - -/* ---------- TCP options ---------- */ -#define LWIP_TCP 1 -#define TCP_TTL 255 -#define LWIP_SO_RCVTIMEO 1 -#define LWIP_SO_RCVRCVTIMEO_NONSTANDARD 1 /* Pass an integer number of ms instead of a timeval struct. */ -#define LWIP_SO_SNDTIMEO 1 -#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 1 /* Pass an integer number of ms instead of a timeval struct. */ - -/* Controls if TCP should queue segments that arrive out of - order. Define to 0 if your device is low on memory and you are not scared by TCP congestion and latencies. */ -#define TCP_QUEUE_OOSEQ 0 - -/* TCP Maximum segment size. */ -#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */ - -/* TCP sender buffer space (bytes). */ -#define TCP_SND_BUF (4*TCP_MSS) - -/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least - as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */ - -#define TCP_SND_QUEUELEN (2* TCP_SND_BUF/TCP_MSS) - -/* TCP receive window. */ -#define TCP_WND (3*TCP_MSS) - -#define LWIP_TCP_KEEPALIVE 1 /* Keep the TCP link active. Important for MQTT/TLS */ -#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 /* Prevent the same port to be used after reset. - Otherwise, the remote host may be confused if the port was not explicitly closed before the reset. */ - - -/* ---------- ICMP options ---------- */ +#undef LWIO_ICMP #define LWIP_ICMP 1 +#undef LWIP_RAW #define LWIP_RAW 1 /* PING changed to 1 */ +#undef DEFAULT_RAW_RECVMBOX_SIZE #define DEFAULT_RAW_RECVMBOX_SIZE 3 /* for ICMP PING */ - -/* ---------- DHCP options ---------- */ -/* Define LWIP_DHCP to 1 if you want DHCP configuration of - interfaces. DHCP is not implemented in lwIP 0.5.1, however, so - turning this on does currently not work. */ +#undef LWIP_DHCP #define LWIP_DHCP 1 - - -/* ---------- UDP options ---------- */ +#undef LWIP_UDP #define LWIP_UDP 1 -#define UDP_TTL 255 - - -/* ---------- Statistics options ---------- */ -#define LWIP_STATS 0 -#define LWIP_PROVIDE_ERRNO - -/* ---------- link callback options ---------- */ -/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface - * whenever the link changes (i.e., link down) - */ -// need for building net_ip.c -#define LWIP_NETIF_HOSTNAME 1 -#define LWIP_NETIF_STATUS_CALLBACK 1 -#define LWIP_NETIF_LINK_CALLBACK 1 -#define LWIP_DHCP_CHECK_LINK_UP 1 - -/* - -------------------------------------- - ---------- Checksum options ---------- - -------------------------------------- -*/ /* The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware: - To use this feature let the following define uncommented. - To disable it and process by CPU comment the the checksum. */ -#define CHECKSUM_BY_HARDWARE - -#ifdef CHECKSUM_BY_HARDWARE - /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/ - #define CHECKSUM_GEN_IP 0 - /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/ - #define CHECKSUM_GEN_UDP 0 - /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/ - #define CHECKSUM_GEN_TCP 0 - /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/ - #define CHECKSUM_CHECK_IP 0 - /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/ - #define CHECKSUM_CHECK_UDP 0 - /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/ - #define CHECKSUM_CHECK_TCP 0 - /* CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/ - #define CHECKSUM_GEN_ICMP 0 -#else - /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/ - #define CHECKSUM_GEN_IP 1 - /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/ - #define CHECKSUM_GEN_UDP 1 - /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/ - #define CHECKSUM_GEN_TCP 1 - /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/ - #define CHECKSUM_CHECK_IP 1 - /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/ - #define CHECKSUM_CHECK_UDP 1 - /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/ - #define CHECKSUM_CHECK_TCP 1 - /* CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/ - #define CHECKSUM_GEN_ICMP 1 +#if CHECKSUM_GEN_TCP == 1 +#error On STM32 TCP checksum should be in HW #endif +#undef LWIP_IGMP +#define LWIP_IGMP 1 -/* - ---------------------------------------------- - ---------- Sequential layer options ---------- - ---------------------------------------------- -*/ -/** - * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) - */ -#define LWIP_NETCONN 0 - -/* - ------------------------------------ - ---------- Socket options ---------- - ------------------------------------ -*/ -/** - * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) - */ -#define LWIP_SOCKET 0 -#define LWIP_DNS 1 - -/* - ------------------------------------ - ---------- httpd options ---------- - ------------------------------------ -*/ - -/** Set this to 1 to support CGI */ -#define LWIP_HTTPD_CGI 1 - -/** Set this to 1 to support SSI (Server-Side-Includes) */ -#define LWIP_HTTPD_SSI 1 - -/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the - * file system (to prevent changing the file included in CVS) */ -#define HTTPD_USE_CUSTOM_FSDATA 1 - -/* - ------------------------------------ - ---------- Custom options ---------- - ------------------------------------ -*/ - -/** Enables the Ethernet peripheral in RMII mode. If not defined, MII mode will - be enabled. Pin mapping must be configured for the selected mode - (see PinMap_Ethernet in PeripheralPins.c). */ -#define ETHERNET_RMII_MODE_CONFIGURATION 1 - -/** Uncomment this line to use the ethernet input in interrupt mode. - * NOTE: LwIP stack documentation recommends to use the polling mode without - * an operating system. */ -//#define ETH_INPUT_USE_IT 1 - -// We don't need this as we do not need to respond - we only announce -//#define LWIP_MDNS_RESPONDER 1 -//#define LWIP_NUM_NETIF_CLIENT_DATA 1 // MDNS needs at least one -#define LWIP_IGMP 1 -#define SO_REUSE 1 -#define SO_REUSE_RXTOALL 1 -#warning testing this +//#define SO_REUSE 1 +//#define SO_REUSE_RXTOALL 1 #endif /* __STM32LWIPOPTS_H__ */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From afff10df28009ee0f622c8002ca098914ba7addc Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 20:15:45 +0100 Subject: [PATCH 10/22] add copyright notices --- EXmDNS.cpp | 19 +++++++++++++++++++ EXmDNS.h | 19 +++++++++++++++++++ STM32lwipopts.h | 25 +++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/EXmDNS.cpp b/EXmDNS.cpp index b4fc200..6cc1090 100644 --- a/EXmDNS.cpp +++ b/EXmDNS.cpp @@ -1,3 +1,22 @@ +/* + * © 2024 Harald Barth + * All rights reserved. + * + * This file is part of CommandStation-EX + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * It is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CommandStation. If not, see . + */ #include #include "EthernetInterface.h" diff --git a/EXmDNS.h b/EXmDNS.h index fd50a2a..d8b24d2 100644 --- a/EXmDNS.h +++ b/EXmDNS.h @@ -1,3 +1,22 @@ +/* + * © 2024 Harald Barth + * All rights reserved. + * + * This file is part of CommandStation-EX + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * It is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CommandStation. If not, see . + */ #define BROADCASTTIME 15 //seconds diff --git a/STM32lwipopts.h b/STM32lwipopts.h index 9f6e0c5..8efc641 100644 --- a/STM32lwipopts.h +++ b/STM32lwipopts.h @@ -1,5 +1,26 @@ - - +/* + * © 2024 Harald Barth + * All rights reserved. + * + * This file is part of CommandStation-EX + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * It is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CommandStation. If not, see . + */ +// +// Rewrite of the STM32lwipopts.h file from STM +// To be copied into where lwipopts_default.h resides +// #ifndef __STM32LWIPOPTS_H__ #define __STM32LWIPOPTS_H__ From 6a35daab6b5ed3188bb1072a48a75bbfc65e6ff5 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 20:20:25 +0100 Subject: [PATCH 11/22] remove dead code --- EthernetInterface.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index 26be378..ecdfefb 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -37,22 +37,6 @@ EthernetUDP udp; MDNS mdns(udp); -#if 0 //#if __has_include ( "MDNS_Generic.h") - #include "MDNS_Generic.h" - #define DO_MDNS - EthernetUDP udp; - MDNS mdns(udp); -void serviceFound(const char* type, MDNSServiceProtocol /*proto*/, const char* name, IPAddress ip, - unsigned short port, const char* txtContent) -{ - if (name == NULL) { - DIAG("End service discovery of %s", type); - return; - } - DIAG("Got %s of type %s", name, type); -} -#endif - //extern void looptimer(unsigned long timeout, const FSH* message); #define looptimer(a,b) From 9786ea9b3a412df08d97cdaa23da491f2e6176cd Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 20:25:20 +0100 Subject: [PATCH 12/22] fix compiler warnings --- EXmDNS.cpp | 2 +- EthernetInterface.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EXmDNS.cpp b/EXmDNS.cpp index 6cc1090..62511a2 100644 --- a/EXmDNS.cpp +++ b/EXmDNS.cpp @@ -99,7 +99,7 @@ int MDNS::addServiceRecord(const char* name, uint16_t port, MDNSServiceProtocol_ } static char dns_rr_services[] = "\x09_services\x07_dns-sd\x04_udp\x05local"; -static char *dns_rr_tcplocal = "\x04_tcp\x05local"; +static char dns_rr_tcplocal[] = "\x04_tcp\x05local"; static char *dns_rr_local = dns_rr_tcplocal + dns_rr_tcplocal[0] + 1; typedef struct _DNSHeader_t diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index ecdfefb..cd89c0e 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -114,7 +114,7 @@ void EthernetInterface::setup() outboundRing=new RingStream(OUTBOUND_RING_SIZE); #ifdef DO_MDNS - if (!mdns.begin(Ethernet.localIP(), WIFI_HOSTNAME)) + if (!mdns.begin(Ethernet.localIP(), (char *)WIFI_HOSTNAME)) DIAG("mdns.begin fail"); // hostname mdns.addServiceRecord(WIFI_HOSTNAME "._withrottle", IP_PORT, MDNSServiceTCP); mdns.run(); // run it right away to get out info ASAP From 001c4664c12eae48adf555106cb48c830cf9f6ab Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 20:32:06 +0100 Subject: [PATCH 13/22] as MDNS_Generic does not work and we now have our own, remove it --- platformio.ini | 4 ---- 1 file changed, 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 6317372..1bc6e60 100644 --- a/platformio.ini +++ b/platformio.ini @@ -104,7 +104,6 @@ lib_deps = ${env.lib_deps} arduino-libraries/Ethernet SPI - MDNS_Generic lib_ignore = WiFi101 WiFi101_Generic @@ -123,7 +122,6 @@ framework = arduino lib_deps = ${env.lib_deps} arduino-libraries/Ethernet - MDNS_Generic SPI lib_ignore = WiFi101 WiFi101_Generic @@ -278,7 +276,6 @@ framework = arduino lib_deps = ${env.lib_deps} stm32duino/STM32Ethernet @ ^1.4.0 stm32duino/STM32duino LwIP @ ^2.1.3 - MDNS_Generic lib_ignore = WiFi101 WiFi101_Generic WiFiEspAT @@ -302,7 +299,6 @@ framework = arduino lib_deps = ${env.lib_deps} stm32duino/STM32Ethernet @ ^1.4.0 stm32duino/STM32duino LwIP @ ^2.1.3 - MDNS_Generic lib_ignore = WiFi101 WiFi101_Generic WiFiEspAT From 1235c288dc795cedd433bca3abd2842556a6aefe Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 10 Nov 2024 21:11:40 +0100 Subject: [PATCH 14/22] make it compile on all default platforms --- EXmDNS.cpp | 2 ++ EXmDNS.h | 3 ++- EthernetInterface.cpp | 3 ++- EthernetInterface.h | 6 +++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/EXmDNS.cpp b/EXmDNS.cpp index 62511a2..09a3391 100644 --- a/EXmDNS.cpp +++ b/EXmDNS.cpp @@ -20,6 +20,7 @@ #include #include "EthernetInterface.h" +#ifdef DO_MDNS #include "EXmDNS.h" // fixed values for mDNS @@ -193,3 +194,4 @@ void MDNS::run() { _udp->flush(); // } +#endif //DO_MDNS diff --git a/EXmDNS.h b/EXmDNS.h index d8b24d2..676dbe3 100644 --- a/EXmDNS.h +++ b/EXmDNS.h @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with CommandStation. If not, see . */ - +#ifdef DO_MDNS #define BROADCASTTIME 15 //seconds typedef enum _MDNSServiceProtocol_t @@ -41,3 +41,4 @@ private: char* _serviceProto; int _servicePort; }; +#endif //DO_MDNS diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index cd89c0e..f8a43f2 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -32,10 +32,11 @@ #include "WiThrottle.h" #include "DCCTimer.h" +#ifdef DO_MDNS #include "EXmDNS.h" -#define DO_MDNS EthernetUDP udp; MDNS mdns(udp); +#endif //extern void looptimer(unsigned long timeout, const FSH* message); #define looptimer(a,b) diff --git a/EthernetInterface.h b/EthernetInterface.h index 6cea6e8..13a8b10 100644 --- a/EthernetInterface.h +++ b/EthernetInterface.h @@ -31,13 +31,16 @@ #define EthernetInterface_h #include "defines.h" +#if ETHERNET_ON == true #include "DCCEXParser.h" #include //#include #if defined (ARDUINO_TEENSY41) #include //TEENSY Ethernet Treiber #include + #ifndef MAX_SOCK_NUM #define MAX_SOCK_NUM 4 + #endif #elif defined (ARDUINO_NUCLEO_F429ZI) || defined (ARDUINO_NUCLEO_F439ZI) || defined (ARDUINO_NUCLEO_F4X9ZI) #include // #include "STM32lwipopts.h" @@ -46,6 +49,7 @@ extern "C" struct netif gnetif; #define STM32_ETHERNET #define MAX_SOCK_NUM MAX_NUM_TCP_CLIENTS + #define DO_MDNS #else #include "Ethernet.h" #endif @@ -77,5 +81,5 @@ class EthernetInterface { static void dropClient(byte socketnum); }; - +#endif // ETHERNET_ON #endif From 9602c32ea72b92c71f74a8b92943ed088c940297 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 16 Nov 2024 20:50:25 +0100 Subject: [PATCH 15/22] mDNS malloc error fix --- EXmDNS.cpp | 4 ++-- STM32lwipopts.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/EXmDNS.cpp b/EXmDNS.cpp index 09a3391..14e824b 100644 --- a/EXmDNS.cpp +++ b/EXmDNS.cpp @@ -75,7 +75,7 @@ int MDNS::begin(const IPAddress& ip, char* name) { // delay(100); _ipAddress = ip; - _name = (char *)malloc(strlen(name +2)); + _name = (char *)malloc(strlen(name)+2); byte n; for(n = 0; n Date: Wed, 27 Nov 2024 19:59:15 +0800 Subject: [PATCH 16/22] Fixes for Mega, HTONS/L macro --- EXmDNS.cpp | 23 +++++++++++++---------- EXmDNS.h | 6 ++++++ EthernetInterface.cpp | 2 +- EthernetInterface.h | 8 ++++++-- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/EXmDNS.cpp b/EXmDNS.cpp index 14e824b..b5250df 100644 --- a/EXmDNS.cpp +++ b/EXmDNS.cpp @@ -1,5 +1,6 @@ /* * © 2024 Harald Barth + * © 2024 Paul M. Antoine * All rights reserved. * * This file is part of CommandStation-EX @@ -87,7 +88,8 @@ int MDNS::begin(const IPAddress& ip, char* name) { int MDNS::addServiceRecord(const char* name, uint16_t port, MDNSServiceProtocol_t proto) { // we ignore proto, assume TCP - _serviceName = (char *)malloc(strlen(name)+2); + (void)proto; + _serviceName = (char *)malloc(strlen(name) + 2); byte n; for(n = 0; nbeginPacket(mdnsMulticastIPAddr, MDNS_SERVER_PORT); // dns header - dnsHeader.flags = lwip_htons(0x8400); // Response, authorative - dnsHeader.answerCount = lwip_htons(4 /*5 if TXT but we do not do that */); + dnsHeader.flags = HTONS((uint16_t)0x8400); // Response, authorative + dnsHeader.answerCount = HTONS(4 /*5 if TXT but we do not do that */); _udp->write((uint8_t*)&dnsHeader, sizeof(DNSHeader_t)); // rr #1, the PTR record from generic _services.x.local to service.x.local @@ -142,8 +145,8 @@ void MDNS::run() { buf[1] = 0x0c; //PTR buf[2] = 0x00; buf[3] = 0x01; //IN - *((uint32_t*)(buf+4)) = lwip_htonl(120); //TTL in sec - *((uint16_t*)(buf+8)) = lwip_htons( _serviceProto[0] + 1 + strlen(dns_rr_tcplocal) + 1); + *((uint32_t*)(buf+4)) = HTONL(120); //TTL in sec + *((uint16_t*)(buf+8)) = HTONS( _serviceProto[0] + 1 + strlen(dns_rr_tcplocal) + 1); _udp->write(buf, 10); _udp->write(_serviceProto,_serviceProto[0]+1); @@ -152,7 +155,7 @@ void MDNS::run() { // rr #2, the PTR record from proto.x to name.proto.x _udp->write(_serviceProto,_serviceProto[0]+1); _udp->write(dns_rr_tcplocal, strlen(dns_rr_tcplocal)+1); - *((uint16_t*)(buf+8)) = lwip_htons(strlen(_serviceName) + strlen(dns_rr_tcplocal) + 1); // recycle most of buf + *((uint16_t*)(buf+8)) = HTONS(strlen(_serviceName) + strlen(dns_rr_tcplocal) + 1); // recycle most of buf _udp->write(buf, 10); _udp->write(_serviceName, strlen(_serviceName)); @@ -163,14 +166,14 @@ void MDNS::run() { buf[1] = 0x21; // recycle most of buf but here SRV buf[2] = 0x80; // cache flush - *((uint16_t*)(buf+8)) = lwip_htons(strlen(_name) + strlen(dns_rr_local) + 1 + 6); + *((uint16_t*)(buf+8)) = HTONS(strlen(_name) + strlen(dns_rr_local) + 1 + 6); _udp->write(buf, 10); byte srv[6]; // priority and weight srv[0] = srv[1] = srv[2] = srv[3] = 0; // port - *((uint16_t*)(srv+4)) = lwip_htons(_servicePort); + *((uint16_t*)(srv+4)) = HTONS(_servicePort); _udp->write(srv, 6); // target _udp->write(_name, _name[0]+1); @@ -181,7 +184,7 @@ void MDNS::run() { _udp->write(dns_rr_local, strlen(dns_rr_local)+1); buf[1] = 0x01; // recycle most of buf but here A - *((uint16_t*)(buf+8)) = lwip_htons(4); + *((uint16_t*)(buf+8)) = HTONS(4); _udp->write(buf, 10); byte ip[4]; ip[0] = _ipAddress[0]; diff --git a/EXmDNS.h b/EXmDNS.h index 676dbe3..0ec1e5e 100644 --- a/EXmDNS.h +++ b/EXmDNS.h @@ -1,5 +1,6 @@ /* * © 2024 Harald Barth + * © 2024 Paul M. Antoine * All rights reserved. * * This file is part of CommandStation-EX @@ -20,6 +21,11 @@ #ifdef DO_MDNS #define BROADCASTTIME 15 //seconds +// We do this ourselves because every library is different and/or broken... +#define HTONS(x) ((uint16_t)(((x) << 8) | (((x) >> 8) & 0xFF))) +#define HTONL(x) ( ((uint32_t)(x) << 24) | (((uint32_t)(x) << 8) & 0xFF0000) | \ + (((uint32_t)(x) >> 8) & 0xFF00) | ((uint32_t)(x) >> 24) ) + typedef enum _MDNSServiceProtocol_t { MDNSServiceTCP, diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index f8a43f2..266afd8 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -116,7 +116,7 @@ void EthernetInterface::setup() outboundRing=new RingStream(OUTBOUND_RING_SIZE); #ifdef DO_MDNS if (!mdns.begin(Ethernet.localIP(), (char *)WIFI_HOSTNAME)) - DIAG("mdns.begin fail"); // hostname + DIAG(F("mdns.begin fail")); // hostname mdns.addServiceRecord(WIFI_HOSTNAME "._withrottle", IP_PORT, MDNSServiceTCP); mdns.run(); // run it right away to get out info ASAP #endif diff --git a/EthernetInterface.h b/EthernetInterface.h index 13a8b10..e5458d9 100644 --- a/EthernetInterface.h +++ b/EthernetInterface.h @@ -3,7 +3,7 @@ * © 2021 Neil McKechnie * © 2021 Mike S * © 2021 Fred Decker - * © 2020-2022 Harald Barth + * © 2020-2024 Harald Barth * © 2020-2024 Chris Harlow * © 2020 Gregor Baues * All rights reserved. @@ -41,9 +41,10 @@ #ifndef MAX_SOCK_NUM #define MAX_SOCK_NUM 4 #endif + // can't use our MDNS because of a namespace clash with Teensy's NativeEthernet library! + // #define DO_MDNS #elif defined (ARDUINO_NUCLEO_F429ZI) || defined (ARDUINO_NUCLEO_F439ZI) || defined (ARDUINO_NUCLEO_F4X9ZI) #include -// #include "STM32lwipopts.h" #include #include extern "C" struct netif gnetif; @@ -52,7 +53,10 @@ #define DO_MDNS #else #include "Ethernet.h" + #define DO_MDNS #endif + + #include "RingStream.h" /** From e0aa16ff2cbdd243aa80c831951e14e824b9b9cc Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 5 Dec 2024 22:03:55 +0100 Subject: [PATCH 17/22] adjust max default TCP clients to 9 because of bug in LwIP --- STM32lwipopts.h | 10 +++++++++- config.example.h | 5 ++++- defines.h | 10 ++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/STM32lwipopts.h b/STM32lwipopts.h index 8347b66..d5e23c5 100644 --- a/STM32lwipopts.h +++ b/STM32lwipopts.h @@ -29,7 +29,15 @@ // we can not include our "defines.h" here // so we need to duplicate that define -#define MAX_NUM_TCP_CLIENTS 20 +#define MAX_NUM_TCP_CLIENTS_HERE 9 + +#ifdef MAX_NUM_TCP_CLIENTS + #if MAX_NUM_TCP_CLIENTS != MAX_NUM_TCP_CLIENTS_HERE + #error MAX_NUM_TCP_CLIENTS and MAX_NUM_TCP_CLIENTS_HERE must be same + #endif +#else + #define MAX_NUM_TCP_CLIENTS MAX_NUM_TCP_CLIENTS_HERE +#endif // increase ARP cache #undef MEMP_NUM_APR_QUEUE diff --git a/config.example.h b/config.example.h index ff4652f..0108721 100644 --- a/config.example.h +++ b/config.example.h @@ -140,7 +140,10 @@ The configuration file for DCC-EX Command Station ///////////////////////////////////////////////////////////////////////////////////// // // MAX_NUM_TCP_CLIENTS: If you on STM32 Ethernet (and only there) want more than -// 10 TCP clients, enable this here **AND** follow the instructions in STM32lwiopts.h +// 9 (*) TCP clients, change this number to for example 20 here **AND** in +// STM32lwiopts.h and follow the instructions in STM32lwiopts.h +// +// (*) It would be 10 if there would not be a bug in LwIP by STM32duino. // //#define MAX_NUM_TCP_CLIENTS 20 diff --git a/defines.h b/defines.h index 0cd891f..561ed64 100644 --- a/defines.h +++ b/defines.h @@ -240,9 +240,15 @@ #endif #if defined(ARDUINO_ARCH_STM32) -// Allow override of MAX_NUM_TCP_CLIENTS but default is 10 +// The LwIP library for the STM32 wired ethernet has by default 10 TCP +// clients defined but because of a bug in the library #11 is not +// rejected but kicks out any old connection. By restricting our limit +// to 9 the #10 will be rejected by our code so that the number can +// never get to 11 which would kick an existing connection. +// If you want to change this value, do that in +// config.h AND in STM32lwipopts.h. #ifndef MAX_NUM_TCP_CLIENTS - #define MAX_NUM_TCP_CLIENTS 10 + #define MAX_NUM_TCP_CLIENTS 9 #endif #else #if defined(ARDUINO_ARCH_ESP32) From ccbff56355b2808af893a2be76a13ace055434ff Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 5 Dec 2024 22:04:44 +0100 Subject: [PATCH 18/22] rename to STM32lwipopts.h.copyme because of #include hell --- STM32lwipopts.h => STM32lwipopts.h.copyme | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename STM32lwipopts.h => STM32lwipopts.h.copyme (100%) diff --git a/STM32lwipopts.h b/STM32lwipopts.h.copyme similarity index 100% rename from STM32lwipopts.h rename to STM32lwipopts.h.copyme From aa4306123d4d84d859853e5719d68e47f1a480e5 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 5 Dec 2024 22:10:29 +0100 Subject: [PATCH 19/22] more explaining --- STM32lwipopts.h.copyme | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/STM32lwipopts.h.copyme b/STM32lwipopts.h.copyme index d5e23c5..eb9d624 100644 --- a/STM32lwipopts.h.copyme +++ b/STM32lwipopts.h.copyme @@ -20,6 +20,10 @@ // // Rewrite of the STM32lwipopts.h file from STM // To be copied into where lwipopts_default.h resides +// typically into STM32Ethernet/src/STM32lwipopts.h +// or STM32Ethernet\src\STM32lwipopts.h +// search for `lwipopts_default.h` and copy this file into the +// same directory but name it STM32lwipopts.h // #ifndef __STM32LWIPOPTS_H__ #define __STM32LWIPOPTS_H__ From 519cabffb6192cc2a748ffcbaa63f69d1e39d082 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 5 Dec 2024 22:10:55 +0100 Subject: [PATCH 20/22] version tag --- GITHUB_SHA.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index 46f45ee..b3f9e46 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202411041626Z" +#define GITHUB_SHA "devel-more-ether-202412052105Z" From c93dd75323daf543a5ca27240f62ea27cfedf2da Mon Sep 17 00:00:00 2001 From: pmantoine Date: Thu, 12 Dec 2024 15:18:37 +0800 Subject: [PATCH 21/22] Upgrade ststm32 to v18.0.0 for PeripheralPins issue --- platformio.ini | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index 1bc6e60..f31e790 100644 --- a/platformio.ini +++ b/platformio.ini @@ -200,7 +200,7 @@ monitor_speed = 115200 monitor_echo = yes [env:Nucleo-F411RE] -platform = ststm32 @ 17.6.0 +platform = ststm32 @ ^18.0.0 board = nucleo_f411re framework = arduino lib_deps = ${env.lib_deps} @@ -209,7 +209,7 @@ monitor_speed = 115200 monitor_echo = yes [env:Nucleo-F446RE] -platform = ststm32 @ 17.6.0 +platform = ststm32 @ ^18.0.0 board = nucleo_f446re framework = arduino lib_deps = ${env.lib_deps} @@ -221,7 +221,7 @@ monitor_echo = yes ; tested as yet ; [env:Nucleo-F401RE] -platform = ststm32 @ 17.6.0 +platform = ststm32 @ ^18.0.0 board = nucleo_f401re framework = arduino lib_deps = ${env.lib_deps} @@ -234,7 +234,7 @@ monitor_echo = yes ; installed before you can let PlatformIO see this ; ; [env:Nucleo-F413ZH] -; platform = ststm32 @ 17.6.0 +; platform = ststm32 @ ^18.0.0 ; board = nucleo_f413zh ; framework = arduino ; lib_deps = ${env.lib_deps} @@ -246,7 +246,7 @@ monitor_echo = yes ; installed before you can let PlatformIO see this ; [env:Nucleo-F446ZE] -platform = ststm32 @ 17.6.0 +platform = ststm32 @ ^18.0.0 board = nucleo_f446ze framework = arduino lib_deps = ${env.lib_deps} @@ -258,7 +258,7 @@ monitor_echo = yes ; installed before you can let PlatformIO see this ; ; [env:Nucleo-F412ZG] -; platform = ststm32 @ 17.6.0 +; platform = ststm32 @ ^18.0.0 ; board = nucleo_f412zg ; framework = arduino ; lib_deps = ${env.lib_deps} @@ -270,7 +270,7 @@ monitor_echo = yes ; Experimental - Ethernet work still in progress ; [env:Nucleo-F429ZI] -platform = ststm32 @ 17.6.0 +platform = ststm32 @ ^18.0.0 board = nucleo_f429zi framework = arduino lib_deps = ${env.lib_deps} @@ -289,7 +289,7 @@ upload_protocol = stlink ; Experimental - Ethernet work still in progress ; [env:Nucleo-F439ZI] -platform = ststm32 @ 17.6.0 +platform = ststm32 @ ^18.0.0 ; board = nucleo_f439zi ; Temporarily treat it as an F429ZI (they are code compatible) until ; the PR to PlatformIO to update the F439ZI JSON file is available From c99eac6ada20484982382bb4fcc22b6de140e58c Mon Sep 17 00:00:00 2001 From: pmantoine Date: Tue, 11 Feb 2025 11:47:58 +1100 Subject: [PATCH 22/22] STM32 platformio.ini PeripheralPins update --- platformio.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index f31e790..9d4cb46 100644 --- a/platformio.ini +++ b/platformio.ini @@ -270,7 +270,7 @@ monitor_echo = yes ; Experimental - Ethernet work still in progress ; [env:Nucleo-F429ZI] -platform = ststm32 @ ^18.0.0 +platform = ststm32 @ 19.0.0 board = nucleo_f429zi framework = arduino lib_deps = ${env.lib_deps} @@ -281,7 +281,7 @@ lib_ignore = WiFi101 WiFiEspAT WiFiMulti_Generic WiFiNINA_Generic -build_flags = -std=c++17 -Os -g2 -Wunused-variable +build_flags = -std=c++17 -Os -g2 -Wunused-variable -DCUSTOM_PERIPHERAL_PINS monitor_speed = 115200 monitor_echo = yes upload_protocol = stlink @@ -289,7 +289,7 @@ upload_protocol = stlink ; Experimental - Ethernet work still in progress ; [env:Nucleo-F439ZI] -platform = ststm32 @ ^18.0.0 +platform = ststm32 @ 19.0.0 ; board = nucleo_f439zi ; Temporarily treat it as an F429ZI (they are code compatible) until ; the PR to PlatformIO to update the F439ZI JSON file is available @@ -304,7 +304,7 @@ lib_ignore = WiFi101 WiFiEspAT WiFiMulti_Generic WiFiNINA_Generic -build_flags = -std=c++17 -Os -g2 -Wunused-variable +build_flags = -std=c++17 -Os -g2 -Wunused-variable -DCUSTOM_PERIPHERAL_PINS monitor_speed = 115200 monitor_echo = yes upload_protocol = stlink