Commit e901ff85 authored by Jared Hancock's avatar Jared Hancock Committed by Damien George

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: default avatarJared Hancock <jared@greezybacon.me>
parent b82c9ca7
......@@ -61,6 +61,7 @@
#include "lwip/err.h"
#include "lwip/dns.h"
#include "lwip/dhcp.h"
#include "lwip/ethip6.h"
#include "netif/etharp.h"
#define TRACE_ETH_TX (0x0002)
......@@ -297,13 +298,21 @@ static err_t wiznet5k_netif_init(struct netif *netif) {
netif->hwaddr_len = sizeof(netif->hwaddr);
int ret = WIZCHIP_EXPORT(socket)(0, Sn_MR_MACRAW, 0, 0);
if (ret != 0) {
printf("WIZNET fatal error in netifinit: %d\n", ret);
printf("WIZNET fatal error in netif_init: %d\n", ret);
return ERR_IF;
}
// Enable MAC filtering so we only get frames destined for us, to reduce load on lwIP
setSn_MR(0, getSn_MR(0) | Sn_MR_MFEN);
#if LWIP_IPV6
netif->output_ip6 = ethip6_output;
netif->flags |= NETIF_FLAG_MLD6;
#else
// Drop IPv6 packets if firmware does not support it
setSn_MR(0, getSn_MR(0) | Sn_MR_MIP6B);
#endif
return ERR_OK;
}
......@@ -847,6 +856,10 @@ static mp_obj_t wiznet5k_active(size_t n_args, const mp_obj_t *args) {
setSHAR(mac);
}
#if WIZNET5K_WITH_LWIP_STACK && LWIP_IPV6
netif_create_ip6_linklocal_address(&self->netif, 1);
#endif
// seems we need a small delay after init
mp_hal_delay_ms(250);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment