diff --git a/apps/lwip/README.md b/apps/lwip/README.md index a6bca2d0..3a09eb34 100644 --- a/apps/lwip/README.md +++ b/apps/lwip/README.md @@ -14,7 +14,23 @@ arpping -i eth0 192.168.168.2 You should see many packets going back and forth -If there are none check that you are servicing lwip in your timer interrupt. +Check that you have set the interface up [correctly](https://www.nongnu.org/lwip/2_1_x/sys_init.html) + +and you can add logging to LWIP to help for example + +```C +/* debugging */ +#define LWIP_DEBUG 1 +#define NETIF_DEBUG LWIP_DBG_ON +#define ICMP_DEBUG LWIP_DBG_ON +#define IP_DEBUG LWIP_DBG_ON | LWIP_DBG_TRACE +#define RAW_DEBUG LWIP_DBG_ON +#define UDP_DEBUG LWIP_DBG_ON +#define TCP_DEBUG LWIP_DBG_ON +#define INET_DEBUG LWIP_DBG_ON +#define ETHARP_DEBUG LWIP_DBG_ON +#define TIMERS_DEBUG LWIP_DBG_ON +``` ### arp ping only returns one packet diff --git a/apps/lwip/components/Server/src/eth_interface.c b/apps/lwip/components/Server/src/eth_interface.c index 6bbc41c6..0afa9d7e 100644 --- a/apps/lwip/components/Server/src/eth_interface.c +++ b/apps/lwip/components/Server/src/eth_interface.c @@ -163,7 +163,6 @@ void netif_link_callback(struct netif *netif) { err = udp_bind(udp_conn, IP_ADDR_ANY, 7); ZF_LOGF_IF(err != ERR_OK, "Failed to bind port 7"); udp_recv(udp_conn, udp_recv_callback, NULL); - netif_set_up(netif); } } @@ -183,6 +182,7 @@ static struct netif *init_interface(lwip_iface_t *lwip) { netif_set_default(lwip->netif); netif_set_status_callback(lwip->netif, netif_link_callback); netif_set_link_up(lwip->netif); + netif_set_up(netif); // err = dhcp_start(lwip->netif); // ZF_LOGF_IF(err != ERR_OK, "Failed to start dhcp"); diff --git a/apps/lwip/components/Server/src/main.c b/apps/lwip/components/Server/src/main.c index fe5ddb4f..9a53766c 100644 --- a/apps/lwip/components/Server/src/main.c +++ b/apps/lwip/components/Server/src/main.c @@ -28,11 +28,11 @@ void pre_init(void) /* Callback that gets called when the timer fires. */ void timer_complete_callback(void) { - mut_lock(); + int err = mut_lock(); counter_s +=1; sys_check_timeouts(); interface_tick(); - mut_unlock(); + err = mut_unlock(); }