|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2025 Damien P. George |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + * of this software and associated documentation files (the "Software"), to deal |
| 10 | + * in the Software without restriction, including without limitation the rights |
| 11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + * copies of the Software, and to permit persons to whom the Software is |
| 13 | + * furnished to do so, subject to the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice shall be included in |
| 16 | + * all copies or substantial portions of the Software. |
| 17 | + * |
| 18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + * THE SOFTWARE. |
| 25 | + */ |
| 26 | +#ifndef MICROPY_INCLUDED_LWIPOPTS_COMMON_H |
| 27 | +#define MICROPY_INCLUDED_LWIPOPTS_COMMON_H |
| 28 | + |
| 29 | +#include "py/mpconfig.h" |
| 30 | + |
| 31 | +// This sys-arch protection is not needed. |
| 32 | +// Ports either protect lwIP code with flags, or run it at PendSV priority. |
| 33 | +#define SYS_ARCH_DECL_PROTECT(lev) do { } while (0) |
| 34 | +#define SYS_ARCH_PROTECT(lev) do { } while (0) |
| 35 | +#define SYS_ARCH_UNPROTECT(lev) do { } while (0) |
| 36 | + |
| 37 | +#define NO_SYS 1 |
| 38 | +#define SYS_LIGHTWEIGHT_PROT 1 |
| 39 | +#define MEM_ALIGNMENT 4 |
| 40 | + |
| 41 | +#define LWIP_CHKSUM_ALGORITHM 3 |
| 42 | +#define LWIP_CHECKSUM_CTRL_PER_NETIF 1 |
| 43 | + |
| 44 | +#define LWIP_ARP 1 |
| 45 | +#define LWIP_ETHERNET 1 |
| 46 | +#define LWIP_RAW 1 |
| 47 | +#define LWIP_NETCONN 0 |
| 48 | +#define LWIP_SOCKET 0 |
| 49 | +#define LWIP_STATS 0 |
| 50 | +#define LWIP_NETIF_HOSTNAME 1 |
| 51 | + |
| 52 | +#define LWIP_DHCP 1 |
| 53 | +#define LWIP_DHCP_CHECK_LINK_UP 1 |
| 54 | +#define LWIP_DHCP_DOES_ACD_CHECK 0 // to speed DHCP up |
| 55 | +#define LWIP_DNS 1 |
| 56 | +#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1 |
| 57 | +#define LWIP_MDNS_RESPONDER 1 |
| 58 | +#define LWIP_IGMP 1 |
| 59 | + |
| 60 | +#if MICROPY_PY_LWIP_PPP |
| 61 | +#define PPP_SUPPORT 1 |
| 62 | +#define PAP_SUPPORT 1 |
| 63 | +#define CHAP_SUPPORT 1 |
| 64 | +#endif |
| 65 | + |
| 66 | +#define LWIP_NUM_NETIF_CLIENT_DATA LWIP_MDNS_RESPONDER |
| 67 | +#define MEMP_NUM_UDP_PCB (4 + LWIP_MDNS_RESPONDER) |
| 68 | + |
| 69 | +// The mDNS responder requires 5 timers per IP version plus 2 others. Not having enough silently breaks it. |
| 70 | +#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + (LWIP_MDNS_RESPONDER * (2 + (5 * (LWIP_IPV4 + LWIP_IPV6))))) |
| 71 | + |
| 72 | +#define SO_REUSE 1 |
| 73 | +#define TCP_LISTEN_BACKLOG 1 |
| 74 | + |
| 75 | +// TCP memory settings. |
| 76 | +// Default lwIP settings takes 15800 bytes; TCP d/l: 380k/s local, 7.2k/s remote; TCP u/l is very slow. |
| 77 | +#ifndef MEM_SIZE |
| 78 | + |
| 79 | +#if 0 |
| 80 | +// lwIP takes 19159 bytes; TCP d/l and u/l are around 320k/s on local network. |
| 81 | +#define MEM_SIZE (5000) |
| 82 | +#define TCP_WND (4 * TCP_MSS) |
| 83 | +#define TCP_SND_BUF (4 * TCP_MSS) |
| 84 | +#endif |
| 85 | + |
| 86 | +#if 1 |
| 87 | +// lwIP takes 26700 bytes; TCP dl/ul are around 750/600 k/s on local network. |
| 88 | +#define MEM_SIZE (8000) |
| 89 | +#define TCP_MSS (800) |
| 90 | +#define TCP_WND (8 * TCP_MSS) |
| 91 | +#define TCP_SND_BUF (8 * TCP_MSS) |
| 92 | +#define MEMP_NUM_TCP_SEG (32) |
| 93 | +#endif |
| 94 | + |
| 95 | +#if 0 |
| 96 | +// lwIP takes 45600 bytes; TCP dl/ul are around 1200/1000 k/s on local network. |
| 97 | +#define MEM_SIZE (16000) |
| 98 | +#define TCP_MSS (1460) |
| 99 | +#define TCP_WND (8 * TCP_MSS) |
| 100 | +#define TCP_SND_BUF (8 * TCP_MSS) |
| 101 | +#define MEMP_NUM_TCP_SEG (32) |
| 102 | +#endif |
| 103 | + |
| 104 | +#endif // MEM_SIZE |
| 105 | + |
| 106 | +// Needed for PPP. |
| 107 | +#define sys_jiffies sys_now |
| 108 | + |
| 109 | +typedef uint32_t sys_prot_t; |
| 110 | + |
| 111 | +#endif // MICROPY_INCLUDED_LWIPOPTS_COMMON_H |
0 commit comments