使用lwip调试

This commit is contained in:
2025-10-10 12:02:16 +08:00
parent 31c7f9242c
commit 781374be51
8 changed files with 26 additions and 16 deletions

View File

@@ -519,7 +519,7 @@ tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call)
* e.g. the message is allocated once and posted several times from an IRQ
* using tcpip_callbackmsg_trycallback().
* Example usage: Trigger execution of an ethernet IRQ DPC routine in lwIP thread context.
*
*
* @param function the function to call
* @param ctx parameter passed to function
* @return a struct pointer to pass to tcpip_callbackmsg_trycallback().

View File

@@ -40,10 +40,10 @@
#define U16_F "hu"
#define S16_F "hd"
#define X16_F "hx"
// #define X16_F "hx"
#define U32_F "lu"
#define S32_F "ld"
#define X32_F "lx"
#define X32_F "08x"
#ifdef RT_USING_LIBC
#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__)
@@ -97,7 +97,7 @@ void sys_arch_assert(const char* file, int line);
#include "string.h"
#define SYS_ARCH_DECL_PROTECT(level)
#define SYS_ARCH_DECL_PROTECT(level)
#define SYS_ARCH_PROTECT(level) rt_enter_critical()
#define SYS_ARCH_UNPROTECT(level) rt_exit_critical()

View File

@@ -423,7 +423,7 @@ etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct et
{
s16_t i;
LWIP_ASSERT("netif->hwaddr_len == ETH_HWADDR_LEN", netif->hwaddr_len == ETH_HWADDR_LEN);
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n",
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F":%"X8_F"\n",
ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr),
(u16_t)ethaddr->addr[0], (u16_t)ethaddr->addr[1], (u16_t)ethaddr->addr[2],
(u16_t)ethaddr->addr[3], (u16_t)ethaddr->addr[4], (u16_t)ethaddr->addr[5]));

View File

@@ -1096,7 +1096,7 @@ ip4_debug_print(struct pbuf *p)
LWIP_DEBUGF(IP_DEBUG, ("IP header:\n"));
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" |%2"S16_F" | 0x%02"X16_F" | %5"U16_F" | (v, hl, tos, len)\n",
LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" |%2"S16_F" | 0x%"X16_F" | %5"U16_F" | (v, hl, tos, len)\n",
(u16_t)IPH_V(iphdr),
(u16_t)IPH_HL(iphdr),
(u16_t)IPH_TOS(iphdr),
@@ -1109,7 +1109,7 @@ ip4_debug_print(struct pbuf *p)
(u16_t)(lwip_ntohs(IPH_OFFSET(iphdr)) >> 13 & 1),
(u16_t)(lwip_ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)));
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | 0x%04"X16_F" | (ttl, proto, chksum)\n",
LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | 0x%"X16_F" | (ttl, proto, chksum)\n",
(u16_t)IPH_TTL(iphdr),
(u16_t)IPH_PROTO(iphdr),
lwip_ntohs(IPH_CHKSUM(iphdr))));

View File

@@ -911,7 +911,7 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d
/**
* @ingroup udp_raw
* Bind an UDP PCB.
*
*
* @param pcb UDP PCB to be bound with a local address ipaddr and port.
* @param ipaddr local IP address to bind with. Use IP_ANY_TYPE to
* bind to all local interfaces.
@@ -1168,8 +1168,8 @@ udp_recv(struct udp_pcb *pcb, udp_recv_fn recv, void *recv_arg)
/**
* @ingroup udp_raw
* Removes and deallocates the pcb.
*
* Removes and deallocates the pcb.
*
* @param pcb UDP PCB to be removed. The PCB is removed from the list of
* UDP PCB's and the data structure is freed from memory.
*
@@ -1242,7 +1242,7 @@ udp_new(void)
* Create a UDP PCB for specific IP type.
* The pcb is not active until it has either been bound to a local address
* or connected to a remote address.
*
*
* @param type IP address type, see @ref lwip_ip_addr_type definitions.
* If you want to listen to IPv4 and IPv6 (dual-stack) packets,
* supply @ref IPADDR_TYPE_ANY as argument and bind to @ref IP_ANY_TYPE.
@@ -1305,7 +1305,7 @@ udp_debug_print(struct udp_hdr *udphdr)
LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n",
lwip_ntohs(udphdr->src), lwip_ntohs(udphdr->dest)));
LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | 0x%04"X16_F" | (len, chksum)\n",
LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | 0x%"X16_F" | (len, chksum)\n",
lwip_ntohs(udphdr->len), lwip_ntohs(udphdr->chksum)));
LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
}

View File

@@ -74,7 +74,7 @@
/** Platform specific diagnostic output.\n
* Note the default implementation pulls in printf, which may
* in turn pull in a lot of standard libary code. In resource-constrained
* in turn pull in a lot of standard libary code. In resource-constrained
* systems, this should be defined to something less resource-consuming.
*/
#ifndef LWIP_PLATFORM_DIAG
@@ -85,7 +85,7 @@
/** Platform specific assertion handling.\n
* Note the default implementation pulls in printf, fflush and abort, which may
* in turn pull in a lot of standard libary code. In resource-constrained
* in turn pull in a lot of standard libary code. In resource-constrained
* systems, this should be defined to something less resource-consuming.
*/
#ifndef LWIP_PLATFORM_ASSERT
@@ -147,7 +147,7 @@ typedef uintptr_t mem_ptr_t;
#if !LWIP_NO_INTTYPES_H
#include <inttypes.h>
#ifndef X8_F
#define X8_F "02" PRIx8
#define X8_F "02x"
#endif
#ifndef U16_F
#define U16_F PRIu16
@@ -156,7 +156,7 @@ typedef uintptr_t mem_ptr_t;
#define S16_F PRId16
#endif
#ifndef X16_F
#define X16_F PRIx16
#define X16_F "04x"
#endif
#ifndef U32_F
#define U32_F PRIu32

View File

@@ -85,6 +85,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
#if LWIP_ARP || ETHARP_SUPPORT_VLAN || LWIP_IPV6
u16_t next_hdr_offset = SIZEOF_ETH_HDR;
#endif /* LWIP_ARP || ETHARP_SUPPORT_VLAN */
LWIP_DEBUGF(ETHARP_DEBUG, ("recv %d bytes\n", p->len));
LWIP_ASSERT_CORE_LOCKED();

View File

@@ -217,7 +217,16 @@
#define RT_USING_LIBC
#define RT_LWIP_TCP
#define RT_LWIP_UDP
#define RT_LWIP_ICMP
#define RT_LWIP_DEBUG
#define RT_LWIP_TCPIP_DEBUG
#define RT_LWIP_NETIF_DEBUG
#define RT_LWIP_ETHARP_DEBUG
#define RT_LWIP_IP_DEBUG
#define RT_LWIP_UDP_DEBUG
#define RT_LWIP_DHCP
#define RT_LWIP_IGMP
#define RT_LWIP_RAW
// <<< end of configuration section >>>