Skip to content

Commit af2671d

Browse files
IPv6 initial support from @oddstr13 (#748)
* Apply @oddstr13 multicast patch to cyw43 driver * Initial work for enabling IPv6 * Allow accessing CYW43 stats when LWIP_SYS_CHECK_MS is not set * Use cyw43_set_allmulti to allow receiving multicast * Add tools/libpico/build to gitignore Co-authored-by: Odd Stråbø <[email protected]>
1 parent 11cb82b commit af2671d

File tree

10 files changed

+34
-3
lines changed

10 files changed

+34
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
system
33
tools/dist
4+
tools/libpico/build

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
url = https://github.com/earlephilhower/ArduinoCore-API.git
44
[submodule "pico-sdk"]
55
path = pico-sdk
6-
url = https://github.com/raspberrypi/pico-sdk.git
6+
url = https://github.com/earlephilhower/pico-sdk.git
77
[submodule "system/pyserial"]
88
path = tools/pyserial
99
url = https://github.com/pyserial/pyserial.git

cores/rp2040/sdkoverride/cyw43_arch_threadsafe_background.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ semaphore_t cyw43_irq_sem;
8989

9090
// Called in low priority pendsv interrupt only to do lwip processing and check cyw43 sleep
9191
static void periodic_worker(void) {
92-
#if CYW43_USE_STATS
92+
#if CYW43_USE_STATS && LWIP_SYS_CHECK_MS
9393
static uint32_t counter;
9494
if (counter++ % (30000 / LWIP_SYS_CHECK_MS) == 0) {
9595
cyw43_dump_stats();

include/lwipopts.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ extern void interrupts();
5353
#define DHCP_DOES_ARP_CHECK 0
5454
#define LWIP_DHCP_DOES_ACD_CHECK 0
5555

56+
#if LWIP_IPV6
57+
#define LWIP_IPV6_DHCP6 1
58+
#endif
59+
5660
// NTP
5761
extern void __setSystemTime(unsigned long long sec, unsigned long us);
5862
#define SNTP_SET_SYSTEM_TIME_US(sec, us) __setSystemTime(sec, us)

lib/libpico-ipv6.a

48.6 KB
Binary file not shown.

lib/libpico.a

13.9 KB
Binary file not shown.

libraries/lwIP_CYW43/src/utility/CYW43shim.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ bool CYW43::begin(const uint8_t* address, netif* netif) {
5050
authmode = CYW43_AUTH_OPEN;
5151
}
5252

53+
// Not currently possible to hook up igmp_mac_filter and mld_mac_filter
54+
// TODO: implement igmp_mac_filter and mld_mac_filter
55+
cyw43_set_allmulti(_self, true);
56+
5357
if (cyw43_arch_wifi_connect_timeout_ms(_ssid, _password, authmode, _timeout)) {
5458
return false;
5559
} else {

libraries/lwIP_Ethernet/src/LwipIntfDev.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
#include <lwip/init.h>
3333
#include <lwip/netif.h>
3434
#include <lwip/etharp.h>
35+
#include <lwip/ethip6.h>
3536
#include <lwip/dhcp.h>
37+
#include <lwip/dhcp6.h>
3638
#include <lwip/dns.h>
3739
#include <lwip/raw.h>
3840
#include <lwip/icmp.h>
@@ -366,6 +368,14 @@ boolean LwipIntfDev<RawDev>::begin(const uint8_t* macAddress, const uint16_t mtu
366368
netif_set_up(&_netif);
367369
}
368370

371+
#if LWIP_IPV6
372+
netif_create_ip6_linklocal_address(&_netif, true);
373+
#endif
374+
#if LWIP_IPV6_DHCP6_STATELESS
375+
err_t __res = dhcp6_enable_stateless(&_netif);
376+
DEBUGV("LwipIntfDev: Enabled DHCP6 stateless: %d\n", __res);
377+
#endif
378+
369379
_started = true;
370380

371381
if (_intrPin >= 0) {
@@ -444,11 +454,19 @@ err_t LwipIntfDev<RawDev>::netif_init() {
444454
_netif.chksum_flags = NETIF_CHECKSUM_ENABLE_ALL;
445455
_netif.flags = NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP | NETIF_FLAG_BROADCAST | NETIF_FLAG_LINK_UP;
446456

457+
#if LWIP_IPV6_MLD
458+
_netif.flags |= NETIF_FLAG_MLD6;
459+
#endif
460+
447461
// lwIP's doc: This function typically first resolves the hardware
448462
// address, then sends the packet. For ethernet physical layer, this is
449463
// usually lwIP's etharp_output()
450464
_netif.output = etharp_output;
451465

466+
#if LWIP_IPV6
467+
_netif.output_ip6 = ethip6_output;
468+
#endif
469+
452470
// lwIP's doc: This function outputs the pbuf as-is on the link medium
453471
// (this must points to the raw ethernet driver, meaning: us)
454472
_netif.linkoutput = linkoutput_s;

pico-sdk

tools/libpico/lwipopts.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ extern void interrupts();
5353
#define DHCP_DOES_ARP_CHECK 0
5454
#define LWIP_DHCP_DOES_ACD_CHECK 0
5555

56+
#if LWIP_IPV6
57+
#define LWIP_IPV6_DHCP6 1
58+
#endif
59+
5660
// NTP
5761
extern void __setSystemTime(unsigned long long sec, unsigned long us);
5862
#define SNTP_SET_SYSTEM_TIME_US(sec, us) __setSystemTime(sec, us)

0 commit comments

Comments
 (0)