diff options
| author | hathach <[email protected]> | 2020-03-28 15:31:39 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2020-03-28 15:31:39 +0700 |
| commit | 69698ed2e06325003fdf381a2949bbcd7353ddb9 (patch) | |
| tree | 3014bce17046aeb8f2f9f6edf7f235ba88c15403 /examples | |
| parent | 09262d7f7e7bc462e2badac6caeb03cc57bf6761 (diff) | |
| parent | dc6f90eaf76fee3961b034e442dbfb81ad01108a (diff) | |
Merge branch 'master' into develop
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/device/net_lwip_webserver/src/main.c | 6 | ||||
| -rw-r--r-- | examples/device/net_lwip_webserver/src/usb_descriptors.c | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/examples/device/net_lwip_webserver/src/main.c b/examples/device/net_lwip_webserver/src/main.c index c193aeb0f..fe904e8e8 100644 --- a/examples/device/net_lwip_webserver/src/main.c +++ b/examples/device/net_lwip_webserver/src/main.c @@ -53,7 +53,8 @@ static struct pbuf *received_frame; /* this is used by this code, ./class/net/net_driver.c, and usb_descriptors.c */ /* ideally speaking, this should be generated from the hardware's unique ID (if available) */ -const uint8_t tud_network_mac_address[6] = {0x20,0x89,0x84,0x6A,0x96,0x00}; +/* it is suggested that the first two bytes are 0x02,0x02 to indicate a link-local address */ +const uint8_t tud_network_mac_address[6] = {0x02,0x02,0x84,0x6A,0x96,0x00}; /* network parameters of this MCU */ static const ip_addr_t ipaddr = IPADDR4_INIT_BYTES(192, 168, 7, 1); @@ -124,8 +125,11 @@ static void init_lwip(void) struct netif *netif = &netif_data; lwip_init(); + + /* the lwip virtual MAC address must be different from the host's; to ensure this, we toggle the LSbit */ netif->hwaddr_len = sizeof(tud_network_mac_address); memcpy(netif->hwaddr, tud_network_mac_address, sizeof(tud_network_mac_address)); + netif->hwaddr[5] ^= 0x01; netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, netif_init_cb, ip_input); netif_set_default(netif); diff --git a/examples/device/net_lwip_webserver/src/usb_descriptors.c b/examples/device/net_lwip_webserver/src/usb_descriptors.c index c7a8cc767..a4eba205f 100644 --- a/examples/device/net_lwip_webserver/src/usb_descriptors.c +++ b/examples/device/net_lwip_webserver/src/usb_descriptors.c @@ -112,7 +112,7 @@ uint8_t const desc_configuration[] = #if CFG_TUD_NET == OPT_NET_ECM // Interface number, description string index, MAC address string index, EP notification address and size, EP data address (out, in), and size, max segment size. - TUD_CDC_ECM_DESCRIPTOR(ITF_NUM_CDC, STRID_INTERFACE, STRID_MAC, 0x81, 8, EPNUM_CDC, 0x80 | EPNUM_CDC, CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU), + TUD_CDC_ECM_DESCRIPTOR(ITF_NUM_CDC, STRID_INTERFACE, STRID_MAC, 0x81, 64, EPNUM_CDC, 0x80 | EPNUM_CDC, CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU), #elif CFG_TUD_NET == OPT_NET_RNDIS // Interface number, string index, EP notification address and size, EP data address (out, in) and size. TUD_RNDIS_DESCRIPTOR(ITF_NUM_CDC, STRID_INTERFACE, 0x81, 8, EPNUM_CDC, 0x80 | EPNUM_CDC, CFG_TUD_NET_ENDPOINT_SIZE), |
