diff --git a/docs/ota.rst b/docs/ota.rst index 34f8dc6b0..435f2c90d 100644 --- a/docs/ota.rst +++ b/docs/ota.rst @@ -235,7 +235,7 @@ Requirements Implementation Overview ~~~~~~~~~~~~~~~~~~~~~~~ -Updates with a web browser are implemented using ``HTTPUpdateServer`` class together with ``WebServer`` and ``LEAmDNS`` classes. The following code is required to get it work: +Updates with a web browser are implemented using ``HTTPUpdateServer`` class together with ``WebServer`` and ``LEAmDNS`` or ``SimpleMDNS`` classes. The following code is required to get it work: setup() diff --git a/docs/wifi.rst b/docs/wifi.rst index 2c65f1baa..f10b3d065 100644 --- a/docs/wifi.rst +++ b/docs/wifi.rst @@ -44,7 +44,7 @@ Please note that WiFi on the Pico W is a work-in-progress and there are some imp * FreeRTOS is supported only on core 0 and from within ``setup`` and ``loop``, not tasks, due to the requirement for a very different LWIP implementation. PRs always appreciated! - * LEAmDNS (``MDNS``) is not supported in FreeRTOS due to internal IRQ-time memory allocations. + * LEAmDNS (``MDNS``) is not supported in FreeRTOS due to internal IRQ-time memory allocations. Instead, use the SimpleMDNS library ( ``#include `` ) which has no such allocations. The WiFi library borrows much work from the `ESP8266 Arduino Core `__ , especially the ``WiFiClient`` and ``WiFiServer`` classes. diff --git a/include/lwipopts.h b/include/lwipopts.h index 5a8cb6549..ac9875c23 100644 --- a/include/lwipopts.h +++ b/include/lwipopts.h @@ -21,50 +21,57 @@ extern unsigned long __lwip_rand(void); // Common settings used in most of the pico_w examples // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html for details) -#define NO_SYS 1 -#define LWIP_SOCKET 0 -#define MEM_LIBC_MALLOC 0 +#define NO_SYS 1 +#define LWIP_SOCKET 0 +#define MEM_LIBC_MALLOC 0 -#define MEM_ALIGNMENT 4 -#define MEM_SIZE (__LWIP_MEMMULT * 16384) -#define MEMP_NUM_TCP_SEG (32) -#define MEMP_NUM_ARP_QUEUE (10) -#define PBUF_POOL_SIZE (__LWIP_MEMMULT > 1 ? 32 : 24) -#define LWIP_ARP 2 -#define LWIP_ETHERNET 1 -#define LWIP_ICMP 1 -#define LWIP_RAW 1 -#define TCP_WND (8 * TCP_MSS) -#define TCP_MSS 1460 -#define TCP_SND_BUF (8 * TCP_MSS) -#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS)) -#define LWIP_NETIF_STATUS_CALLBACK 1 -#define LWIP_NETIF_LINK_CALLBACK 1 -#define LWIP_NETIF_HOSTNAME 1 -#define LWIP_NETCONN 0 -#define LWIP_STATS 0 -#define LWIP_STATS_DISPLAY 0 -#define MEM_STATS 0 -#define SYS_STATS 0 -#define MEMP_STATS 0 -#define LINK_STATS 0 -#define LWIP_CHKSUM_ALGORITHM 0 -#define LWIP_DHCP 1 -#define LWIP_IPV4 1 -#define LWIP_TCP 1 -#define LWIP_UDP 1 -#define LWIP_DNS 1 -#define LWIP_TCP_KEEPALIVE 1 -#define LWIP_NETIF_TX_SINGLE_PBUF 1 -#define DHCP_DOES_ARP_CHECK 0 -#define LWIP_DHCP_DOES_ACD_CHECK 0 +#define MEM_ALIGNMENT 4 +#define MEM_SIZE (__LWIP_MEMMULT * 16384) +#define MEMP_NUM_TCP_SEG (32) +#define MEMP_NUM_ARP_QUEUE (10) +//#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 4) +#define PBUF_POOL_SIZE (__LWIP_MEMMULT > 1 ? 32 : 24) +#define LWIP_ARP 5 +#define LWIP_ETHERNET 1 +#define LWIP_ICMP 1 +#define LWIP_RAW 1 +#define TCP_WND (8 * TCP_MSS) +#define TCP_MSS 1460 +#define TCP_SND_BUF (8 * TCP_MSS) +#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS)) +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NUM_NETIF_CLIENT_DATA 5 +#define LWIP_NETCONN 0 +#define LWIP_STATS 0 +#define LWIP_STATS_DISPLAY 0 +#define MEM_STATS 0 +#define SYS_STATS 0 +#define MEMP_STATS 0 +#define LINK_STATS 0 +#define LWIP_CHKSUM_ALGORITHM 0 +#define LWIP_DHCP 1 +#define LWIP_IPV4 1 +#define LWIP_TCP 1 +#define LWIP_UDP 1 +#define LWIP_DNS 1 +#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1 +#define LWIP_TCP_KEEPALIVE 1 +#define LWIP_NETIF_TX_SINGLE_PBUF 1 +#define DHCP_DOES_ARP_CHECK 0 +#define LWIP_DHCP_DOES_ACD_CHECK 0 +#define LWIP_IGMP 1 +#define LWIP_MDNS_RESPONDER 1 +#define MDNS_MAX_SERVICES 4 // See #1285 -#define MEMP_NUM_UDP_PCB (__LWIP_MEMMULT * 6) -#define MEMP_NUM_TCP_PCB (__LWIP_MEMMULT * 5) +#define MEMP_NUM_UDP_PCB (__LWIP_MEMMULT * 7) +#define MEMP_NUM_TCP_PCB (__LWIP_MEMMULT * 5) #if LWIP_IPV6 -#define LWIP_IPV6_DHCP6 1 +#define LWIP_IPV6_DHCP6 1 +#define LWIP_IPV6_MLD 1 #endif // NTP diff --git a/lib/rp2040/libipv4-big.a b/lib/rp2040/libipv4-big.a index 28d876874..b2398a1d8 100644 Binary files a/lib/rp2040/libipv4-big.a and b/lib/rp2040/libipv4-big.a differ diff --git a/lib/rp2040/libipv4-bt-big.a b/lib/rp2040/libipv4-bt-big.a index 8190b44a6..e0f4baa7d 100644 Binary files a/lib/rp2040/libipv4-bt-big.a and b/lib/rp2040/libipv4-bt-big.a differ diff --git a/lib/rp2040/libipv4-bt.a b/lib/rp2040/libipv4-bt.a index 36bbd2fa9..1e07fa553 100644 Binary files a/lib/rp2040/libipv4-bt.a and b/lib/rp2040/libipv4-bt.a differ diff --git a/lib/rp2040/libipv4-ipv6-big.a b/lib/rp2040/libipv4-ipv6-big.a index 7b98671d5..0db53a937 100644 Binary files a/lib/rp2040/libipv4-ipv6-big.a and b/lib/rp2040/libipv4-ipv6-big.a differ diff --git a/lib/rp2040/libipv4-ipv6-bt-big.a b/lib/rp2040/libipv4-ipv6-bt-big.a index 5158e60de..901067575 100644 Binary files a/lib/rp2040/libipv4-ipv6-bt-big.a and b/lib/rp2040/libipv4-ipv6-bt-big.a differ diff --git a/lib/rp2040/libipv4-ipv6-bt.a b/lib/rp2040/libipv4-ipv6-bt.a index b6affc75a..1cb85f032 100644 Binary files a/lib/rp2040/libipv4-ipv6-bt.a and b/lib/rp2040/libipv4-ipv6-bt.a differ diff --git a/lib/rp2040/libipv4-ipv6.a b/lib/rp2040/libipv4-ipv6.a index b2e5afd8d..9bdb3d978 100644 Binary files a/lib/rp2040/libipv4-ipv6.a and b/lib/rp2040/libipv4-ipv6.a differ diff --git a/lib/rp2040/libipv4.a b/lib/rp2040/libipv4.a index a2e1d0af5..96217885c 100644 Binary files a/lib/rp2040/libipv4.a and b/lib/rp2040/libipv4.a differ diff --git a/lib/rp2040/libpico.a b/lib/rp2040/libpico.a index 85037146d..494bd7ec5 100644 Binary files a/lib/rp2040/libpico.a and b/lib/rp2040/libpico.a differ diff --git a/lib/rp2350-riscv/libipv4-big.a b/lib/rp2350-riscv/libipv4-big.a index f16c9ab33..ee01d604d 100644 Binary files a/lib/rp2350-riscv/libipv4-big.a and b/lib/rp2350-riscv/libipv4-big.a differ diff --git a/lib/rp2350-riscv/libipv4-ipv6-big.a b/lib/rp2350-riscv/libipv4-ipv6-big.a index 37107618d..6174832b4 100644 Binary files a/lib/rp2350-riscv/libipv4-ipv6-big.a and b/lib/rp2350-riscv/libipv4-ipv6-big.a differ diff --git a/lib/rp2350-riscv/libipv4-ipv6.a b/lib/rp2350-riscv/libipv4-ipv6.a index 6aae9fc6f..fb770b218 100644 Binary files a/lib/rp2350-riscv/libipv4-ipv6.a and b/lib/rp2350-riscv/libipv4-ipv6.a differ diff --git a/lib/rp2350-riscv/libipv4.a b/lib/rp2350-riscv/libipv4.a index 38e4b3171..96ecf85ff 100644 Binary files a/lib/rp2350-riscv/libipv4.a and b/lib/rp2350-riscv/libipv4.a differ diff --git a/lib/rp2350-riscv/libpico.a b/lib/rp2350-riscv/libpico.a index 357d986cf..6cbb175ed 100644 Binary files a/lib/rp2350-riscv/libpico.a and b/lib/rp2350-riscv/libpico.a differ diff --git a/lib/rp2350/libipv4-big.a b/lib/rp2350/libipv4-big.a index 358b7e462..b13797fcc 100644 Binary files a/lib/rp2350/libipv4-big.a and b/lib/rp2350/libipv4-big.a differ diff --git a/lib/rp2350/libipv4-ipv6-big.a b/lib/rp2350/libipv4-ipv6-big.a index 25b8ed42a..56f1d38bc 100644 Binary files a/lib/rp2350/libipv4-ipv6-big.a and b/lib/rp2350/libipv4-ipv6-big.a differ diff --git a/lib/rp2350/libipv4-ipv6.a b/lib/rp2350/libipv4-ipv6.a index 7b3aa360a..c979be81c 100644 Binary files a/lib/rp2350/libipv4-ipv6.a and b/lib/rp2350/libipv4-ipv6.a differ diff --git a/lib/rp2350/libipv4.a b/lib/rp2350/libipv4.a index 4c6c2dbf6..2ba2becc3 100644 Binary files a/lib/rp2350/libipv4.a and b/lib/rp2350/libipv4.a differ diff --git a/lib/rp2350/libpico.a b/lib/rp2350/libpico.a index 2ecd4f7f5..efcf588e3 100644 Binary files a/lib/rp2350/libpico.a and b/lib/rp2350/libpico.a differ diff --git a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino index f80607095..72adf8e66 100644 --- a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino +++ b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/libraries/ArduinoOTA/examples/OTALeds/OTALeds.ino b/libraries/ArduinoOTA/examples/OTALeds/OTALeds.ino index 89cfe8f99..10b7e9f8c 100644 --- a/libraries/ArduinoOTA/examples/OTALeds/OTALeds.ino +++ b/libraries/ArduinoOTA/examples/OTALeds/OTALeds.ino @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/libraries/ArduinoOTA/examples/SignedOTA/SignedOTA.ino b/libraries/ArduinoOTA/examples/SignedOTA/SignedOTA.ino index 6c354f46e..81765aa19 100644 --- a/libraries/ArduinoOTA/examples/SignedOTA/SignedOTA.ino +++ b/libraries/ArduinoOTA/examples/SignedOTA/SignedOTA.ino @@ -13,7 +13,7 @@ #include -#include +#include #include #include diff --git a/libraries/ArduinoOTA/src/ArduinoOTA.cpp b/libraries/ArduinoOTA/src/ArduinoOTA.cpp index ea19bbfac..07ded5e61 100644 --- a/libraries/ArduinoOTA/src/ArduinoOTA.cpp +++ b/libraries/ArduinoOTA/src/ArduinoOTA.cpp @@ -28,10 +28,7 @@ #include #include - -#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS) -#include -#endif +#include #ifdef DEBUG_RP2040_CORE #ifdef DEBUG_RP2040_PORT diff --git a/libraries/HTTPUpdateServer/examples/WebUpdater/WebUpdater.ino b/libraries/HTTPUpdateServer/examples/WebUpdater/WebUpdater.ino index 54178a7ef..7b301ebca 100644 --- a/libraries/HTTPUpdateServer/examples/WebUpdater/WebUpdater.ino +++ b/libraries/HTTPUpdateServer/examples/WebUpdater/WebUpdater.ino @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #ifndef STASSID diff --git a/libraries/LEAmDNS/src/LEAmDNS.h b/libraries/LEAmDNS/src/LEAmDNS.h index 8116bf165..e27269700 100644 --- a/libraries/LEAmDNS/src/LEAmDNS.h +++ b/libraries/LEAmDNS/src/LEAmDNS.h @@ -1348,3 +1348,8 @@ class MDNSResponder { } // namespace esp8266 #include + +#define __LEAMDNS_H 1 +#ifdef __SIMPLEMDNS_H +#error SimpleMDNS and LeaMDNS both included. Only one allowed at a time. +#endif diff --git a/libraries/SimpleMDNS/README.md b/libraries/SimpleMDNS/README.md new file mode 100644 index 000000000..99a3e742c --- /dev/null +++ b/libraries/SimpleMDNS/README.md @@ -0,0 +1,21 @@ +# SimpleMDNS Library for Arduino-Pico + +This library implements a very basic MDNS responder (xxx.local) for the +Pico to enable things like local name resolution and Arduino IDE OTA +connections. It uses the LWIP-provided simplified MDNS application. + +Unlike LEAmDNS, this library only supports very simple configurations. +They should be sufficient for OTA and name resolution and simple web +servers, but for more complicated needs please use LEAmDNS. + +The benefit of this simplicity is that it is low code and has no runtime +memory allocations. This means it can be run under FreeRTOS (which LEAmDNS +does not presently support). + +This should be a drop-in replacement, just replace `#include ` +with `#include `. + +Be sure to `MDNS.begin()` after enabling WiFi/Ethernet.begin(). + +-Earle F. Philhower, III + diff --git a/libraries/SimpleMDNS/keywords.txt b/libraries/SimpleMDNS/keywords.txt new file mode 100644 index 000000000..1fb27b7ce --- /dev/null +++ b/libraries/SimpleMDNS/keywords.txt @@ -0,0 +1,23 @@ +####################################### +# Syntax Coloring Map +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +SimpleMDNS KEYWORD1 +MDNS KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +addService KEYWORD2 +enableArduino KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/libraries/SimpleMDNS/library.properties b/libraries/SimpleMDNS/library.properties new file mode 100644 index 000000000..dafea5d4b --- /dev/null +++ b/libraries/SimpleMDNS/library.properties @@ -0,0 +1,10 @@ +name=SimpleMDNS +version=1.0 +author=Earle F. Philhower, III +maintainer=Earle F. Philhower, III +sentence=Creates a simple mDNS responder using LWIP features +paragraph=Creates a mDNS responder to ensure host domain uniqueness in local networks and to allow for mDNS service discovery and announcement. +category=Communication +url=https://github.com/earlephilhower/arduino-pico +architectures=rp2040 +dot_a_linkage=true diff --git a/libraries/SimpleMDNS/src/SimpleMDNS.cpp b/libraries/SimpleMDNS/src/SimpleMDNS.cpp new file mode 100644 index 000000000..581cd994d --- /dev/null +++ b/libraries/SimpleMDNS/src/SimpleMDNS.cpp @@ -0,0 +1,96 @@ +/* + SimpleMDNS for Rasperry Pi Pico + Implements a basic MDNS responder (xxx.local) + + Copyright (c) 2024 Earle F. Philhower, III + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include "SimpleMDNS.h" +#include +#include + +void SimpleMDNS::begin(const char *hostname, unsigned int ttl) { + if (_running) { + return; + } + mdns_resp_init(); + struct netif *n = netif_list; + while (n) { + mdns_resp_add_netif(n, hostname); + n = n->next; + } + __setStateChangeCallback(_statusCB); + _hostname = strdup(hostname); + _running = true; +} + +void SimpleMDNS::enableArduino(unsigned int port, bool passwd) { + if (!_running) { + return; + } + struct netif *n = netif_list; + while (n) { + mdns_resp_add_service(n, _hostname, "_arduino", DNSSD_PROTO_TCP, port, _arduinoGetTxt, (void *)passwd); + n = n->next; + } +} + +void SimpleMDNS::addService(const char *service, const char *proto, unsigned int port) { + if (!_running) { + return; + } + char s[128]; + snprintf(s, sizeof(s), "_%s", service); + s[sizeof(s) - 1] = 0; + struct netif *n = netif_list; + while (n) { + mdns_resp_add_service(n, _hostname, s, !strcasecmp("tcp", proto) ? DNSSD_PROTO_TCP : DNSSD_PROTO_UDP, port, _nullGetTxt, nullptr); + n = n->next; + } +} + +void SimpleMDNS::update() { + /* No-op */ +} + +void SimpleMDNS::end() { + /* No-op */ +} + +void SimpleMDNS::_statusCB(struct netif *netif) { + mdns_resp_netif_settings_changed(netif); +} + +void SimpleMDNS::_addServiceTxt(struct mdns_service *service, const char *str) { + mdns_resp_add_service_txtitem(service, str, strlen(str)); +} + +void SimpleMDNS::_arduinoGetTxt(struct mdns_service *service, void *txt_userdata) { + _addServiceTxt(service, "tcp_check=no"); + _addServiceTxt(service, "ssh_upload=no"); + _addServiceTxt(service, "board=" ARDUINO_VARIANT); + _addServiceTxt(service, (bool)txt_userdata ? "auth_upload=yes" : "auth_upload=no"); +} + +void SimpleMDNS::_nullGetTxt(struct mdns_service *service, void *txt_userdata) { + /* nop */ +} + +const char *SimpleMDNS::_hostname = nullptr; + +SimpleMDNS MDNS; diff --git a/libraries/SimpleMDNS/src/SimpleMDNS.h b/libraries/SimpleMDNS/src/SimpleMDNS.h new file mode 100644 index 000000000..62539fa30 --- /dev/null +++ b/libraries/SimpleMDNS/src/SimpleMDNS.h @@ -0,0 +1,51 @@ +/* + SimpleMDNS for Rasperry Pi Pico + Implements a basic MDNS responder (xxx.local) + + Copyright (c) 2024 Earle F. Philhower, III + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#pragma once +#include + +class SimpleMDNS { + +public: + void begin(const char *hostname, unsigned int ttl = 60); + void enableArduino(unsigned int port, bool passwd = false); + void addService(const char *service, const char *proto, unsigned int port); + + // No-ops here + void end(); + void update(); + +private: + static void _statusCB(struct netif *netif); + static void _addServiceTxt(struct mdns_service *service, const char *str); + static void _arduinoGetTxt(struct mdns_service *service, void *txt_userdata); + static void _nullGetTxt(struct mdns_service *service, void *txt_userdata); + + bool _running = false; + static const char *_hostname; +}; + +extern SimpleMDNS MDNS; + +#define __SIMPLEMDNS_H 1 +#ifdef __LEAMDNS_H +#error SimpleMDNS and LeaMDNS both included. Only one allowed at a time. +#endif diff --git a/libraries/lwIP_Ethernet/src/LwipEthernet.cpp b/libraries/lwIP_Ethernet/src/LwipEthernet.cpp index 7a8adedfc..2702e5576 100644 --- a/libraries/lwIP_Ethernet/src/LwipEthernet.cpp +++ b/libraries/lwIP_Ethernet/src/LwipEthernet.cpp @@ -229,3 +229,8 @@ void lwipPollingPeriod(int ms) { _pollingPeriod = ms; } } + +std::function _scb; +void __setStateChangeCallback(std::function s) { + _scb = s; +} diff --git a/libraries/lwIP_Ethernet/src/LwipEthernet.h b/libraries/lwIP_Ethernet/src/LwipEthernet.h index 96611740c..e0434d99f 100644 --- a/libraries/lwIP_Ethernet/src/LwipEthernet.h +++ b/libraries/lwIP_Ethernet/src/LwipEthernet.h @@ -44,3 +44,6 @@ int hostByName(const char *aHostname, IPAddress &aResult, int timeout_ms = 5000) // Set the LWIP polling time (default 50ms). Lower polling times == lower latency but higher CPU usage void lwipPollingPeriod(int ms); + +// Sets the global netif state change callback +void __setStateChangeCallback(std::function s); diff --git a/libraries/lwIP_Ethernet/src/LwipIntfDev.h b/libraries/lwIP_Ethernet/src/LwipIntfDev.h index dca8f9199..6a0bf9b50 100644 --- a/libraries/lwIP_Ethernet/src/LwipIntfDev.h +++ b/libraries/lwIP_Ethernet/src/LwipIntfDev.h @@ -181,6 +181,7 @@ class LwipIntfDev: public LwipIntf, public RawDev { static err_t linkoutput_s(netif* netif, struct pbuf* p); static void netif_status_callback_s(netif* netif); static void _irq(void *param); + public: // called on a regular basis or on interrupt err_t handlePackets(); @@ -533,6 +534,7 @@ err_t LwipIntfDev::netif_init() { return ERR_OK; } +extern std::function _scb; template void LwipIntfDev::netif_status_callback() { check_route(); @@ -540,6 +542,9 @@ void LwipIntfDev::netif_status_callback() { sntp_stop(); sntp_init(); } + if (_scb) { + _scb(&_netif); + } } template diff --git a/tests/restyle.sh b/tests/restyle.sh index 2a1b41dcf..4d22c0b30 100755 --- a/tests/restyle.sh +++ b/tests/restyle.sh @@ -17,7 +17,7 @@ for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleF ./libraries/SPISlave ./libraries/lwIP_ESPHost ./libraries/FatFS\ ./libraries/FatFSUSB ./libraries/BluetoothAudio ./libraries/BluetoothHCI \ ./libraries/BluetoothHIDMaster ./libraries/NetBIOS ./libraries/Ticker \ - ./libraries/VFS ./libraries/rp2350; do + ./libraries/VFS ./libraries/rp2350 ./libraries/SimpleMDNS; do find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" \) -a \! -path '*api*' -exec astyle --suffix=none --options=./tests/astyle_core.conf \{\} \; find $dir -type f -name "*.ino" -exec astyle --suffix=none --options=./tests/astyle_examples.conf \{\} \; done diff --git a/tools/libpico/CMakeLists.txt b/tools/libpico/CMakeLists.txt index 3d32a58d3..a47943f03 100644 --- a/tools/libpico/CMakeLists.txt +++ b/tools/libpico/CMakeLists.txt @@ -232,6 +232,7 @@ set(picow_link_libraries pico_lwip pico_lwip_nosys pico_lwip_sntp + pico_lwip_mdns pico_stdlib ) @@ -332,4 +333,5 @@ add_custom_command(TARGET pico-${cpu} POST_BUILD COMMAND sed 's/include.*pico-sdk/include \"..\\/..\\/pico-sdk/' ./generated/pico_base/pico/config_autogen.h > ../../../include/${cpu}/pico_base/pico/config_autogen.h COMMAND cp ../tusb_config.h ../../../include/${cpu}/. COMMAND cp ../btstack_config.h ../../../include/${cpu}/. + COMMAND cp ../lwipopts.h ../../../include/. ) diff --git a/tools/libpico/lwipopts.h b/tools/libpico/lwipopts.h index 5a8cb6549..9ec17c56a 100644 --- a/tools/libpico/lwipopts.h +++ b/tools/libpico/lwipopts.h @@ -21,50 +21,56 @@ extern unsigned long __lwip_rand(void); // Common settings used in most of the pico_w examples // (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html for details) -#define NO_SYS 1 -#define LWIP_SOCKET 0 -#define MEM_LIBC_MALLOC 0 +#define NO_SYS 1 +#define LWIP_SOCKET 0 +#define MEM_LIBC_MALLOC 0 -#define MEM_ALIGNMENT 4 -#define MEM_SIZE (__LWIP_MEMMULT * 16384) -#define MEMP_NUM_TCP_SEG (32) -#define MEMP_NUM_ARP_QUEUE (10) -#define PBUF_POOL_SIZE (__LWIP_MEMMULT > 1 ? 32 : 24) -#define LWIP_ARP 2 -#define LWIP_ETHERNET 1 -#define LWIP_ICMP 1 -#define LWIP_RAW 1 -#define TCP_WND (8 * TCP_MSS) -#define TCP_MSS 1460 -#define TCP_SND_BUF (8 * TCP_MSS) -#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS)) -#define LWIP_NETIF_STATUS_CALLBACK 1 -#define LWIP_NETIF_LINK_CALLBACK 1 -#define LWIP_NETIF_HOSTNAME 1 -#define LWIP_NETCONN 0 -#define LWIP_STATS 0 -#define LWIP_STATS_DISPLAY 0 -#define MEM_STATS 0 -#define SYS_STATS 0 -#define MEMP_STATS 0 -#define LINK_STATS 0 -#define LWIP_CHKSUM_ALGORITHM 0 -#define LWIP_DHCP 1 -#define LWIP_IPV4 1 -#define LWIP_TCP 1 -#define LWIP_UDP 1 -#define LWIP_DNS 1 -#define LWIP_TCP_KEEPALIVE 1 -#define LWIP_NETIF_TX_SINGLE_PBUF 1 -#define DHCP_DOES_ARP_CHECK 0 -#define LWIP_DHCP_DOES_ACD_CHECK 0 +#define MEM_ALIGNMENT 4 +#define MEM_SIZE (__LWIP_MEMMULT * 16384) +#define MEMP_NUM_TCP_SEG (32) +#define MEMP_NUM_ARP_QUEUE (10) +#define PBUF_POOL_SIZE (__LWIP_MEMMULT > 1 ? 32 : 24) +#define LWIP_ARP 5 +#define LWIP_ETHERNET 1 +#define LWIP_ICMP 1 +#define LWIP_RAW 1 +#define TCP_WND (8 * TCP_MSS) +#define TCP_MSS 1460 +#define TCP_SND_BUF (8 * TCP_MSS) +#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS)) +#define LWIP_NETIF_STATUS_CALLBACK 1 +#define LWIP_NETIF_LINK_CALLBACK 1 +#define LWIP_NETIF_HOSTNAME 1 +#define LWIP_NUM_NETIF_CLIENT_DATA 5 +#define LWIP_NETCONN 0 +#define LWIP_STATS 0 +#define LWIP_STATS_DISPLAY 0 +#define MEM_STATS 0 +#define SYS_STATS 0 +#define MEMP_STATS 0 +#define LINK_STATS 0 +#define LWIP_CHKSUM_ALGORITHM 0 +#define LWIP_DHCP 1 +#define LWIP_IPV4 1 +#define LWIP_TCP 1 +#define LWIP_UDP 1 +#define LWIP_DNS 1 +#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1 +#define LWIP_TCP_KEEPALIVE 1 +#define LWIP_NETIF_TX_SINGLE_PBUF 1 +#define DHCP_DOES_ARP_CHECK 0 +#define LWIP_DHCP_DOES_ACD_CHECK 0 +#define LWIP_IGMP 1 +#define LWIP_MDNS_RESPONDER 1 +#define MDNS_MAX_SERVICES 4 // See #1285 -#define MEMP_NUM_UDP_PCB (__LWIP_MEMMULT * 6) -#define MEMP_NUM_TCP_PCB (__LWIP_MEMMULT * 5) +#define MEMP_NUM_UDP_PCB (__LWIP_MEMMULT * 7) +#define MEMP_NUM_TCP_PCB (__LWIP_MEMMULT * 5) #if LWIP_IPV6 -#define LWIP_IPV6_DHCP6 1 +#define LWIP_IPV6_DHCP6 1 +#define LWIP_IPV6_MLD 1 #endif // NTP