Skip to content

Commit e901ff8

Browse files
Jared Hancockdpgeorge
Jared Hancock
authored andcommitted
extmod/network_wiznet5k: Add support for IPv6.
This adds support for the WIZNET5K nic to use IPv6 with the LWIP stack. Additionally, if LWIP_IPV6 is disabled, the device is configured to drop all IPv6 packets to reduce load on the MCU. Signed-off-by: Jared Hancock <[email protected]>
1 parent b82c9ca commit e901ff8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

extmod/network_wiznet5k.c

+14-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include "lwip/err.h"
6262
#include "lwip/dns.h"
6363
#include "lwip/dhcp.h"
64+
#include "lwip/ethip6.h"
6465
#include "netif/etharp.h"
6566

6667
#define TRACE_ETH_TX (0x0002)
@@ -297,13 +298,21 @@ static err_t wiznet5k_netif_init(struct netif *netif) {
297298
netif->hwaddr_len = sizeof(netif->hwaddr);
298299
int ret = WIZCHIP_EXPORT(socket)(0, Sn_MR_MACRAW, 0, 0);
299300
if (ret != 0) {
300-
printf("WIZNET fatal error in netifinit: %d\n", ret);
301+
printf("WIZNET fatal error in netif_init: %d\n", ret);
301302
return ERR_IF;
302303
}
303304

304305
// Enable MAC filtering so we only get frames destined for us, to reduce load on lwIP
305306
setSn_MR(0, getSn_MR(0) | Sn_MR_MFEN);
306307

308+
#if LWIP_IPV6
309+
netif->output_ip6 = ethip6_output;
310+
netif->flags |= NETIF_FLAG_MLD6;
311+
#else
312+
// Drop IPv6 packets if firmware does not support it
313+
setSn_MR(0, getSn_MR(0) | Sn_MR_MIP6B);
314+
#endif
315+
307316
return ERR_OK;
308317
}
309318

@@ -847,6 +856,10 @@ static mp_obj_t wiznet5k_active(size_t n_args, const mp_obj_t *args) {
847856
setSHAR(mac);
848857
}
849858

859+
#if WIZNET5K_WITH_LWIP_STACK && LWIP_IPV6
860+
netif_create_ip6_linklocal_address(&self->netif, 1);
861+
#endif
862+
850863
// seems we need a small delay after init
851864
mp_hal_delay_ms(250);
852865

0 commit comments

Comments
 (0)