Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refreshing for debug #61

Merged
merged 4 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmake/lwip-builder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ function(glue_variant)

# Debug utils for the -glue package
add_library(${GLUE_VARIANT_NAME}-glue-debug STATIC
${CMAKE_SOURCE_DIR}/glue/doprint.c
${CMAKE_SOURCE_DIR}/glue/uprint.c
)
target_include_directories(${GLUE_VARIANT_NAME}-glue-debug BEFORE
Expand Down
8 changes: 1 addition & 7 deletions glue-esp/lwip-1.4-arduino/include/arch/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,11 @@
#include "osapi.h"
#define EFAULT 14
#include <sys/pgmspace.h>
//#include <../../../cores/esp8266/core_esp8266_features.h>

//#define LWIP_PROVIDE_ERRNO

#if (1)
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#else
#define BYTE_ORDER BIG_ENDIAN
#endif


typedef unsigned char u8_t;
typedef signed char s8_t;
typedef unsigned short u16_t;
Expand Down
2 changes: 1 addition & 1 deletion glue-esp/lwip-esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ void glue2esp_ifupdown (int netif_idx, uint32_t ip, uint32_t mask, uint32_t gw)
oldmask = netif->netmask;
oldgw = netif->gw;

uprint(DBG "glue2esp_ifupdown new %d.%d.%d.%d old %ld.%ld.%ld.%ld\n",
uprint(DBG "glue2esp_ifupdown new %d.%d.%d.%d old %d.%d.%d.%d\n",
ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, ip >> 24,
oldip.addr & 0xff, (oldip.addr >> 8) & 0xff, (oldip.addr >> 16) & 0xff, oldip.addr >> 24);

Expand Down
4 changes: 2 additions & 2 deletions glue-lwip/espconn_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ espconn_udp_sent(void *arg, uint8 *psent, uint16 length)
pudp_sent->pespconn->proto.udp->remote_ip[2],
pudp_sent->pespconn->proto.udp->remote_ip[3]);

LWIP_DEBUGF(ESPCONN_UDP_DEBUG, ("espconn_udp_sent %d %x %d\n", __LINE__, upcb->remote_ip, upcb->remote_port));
LWIP_DEBUGF(ESPCONN_UDP_DEBUG, ("espconn_udp_sent %d %x %d\n", __LINE__, ip_2_ip4(&upcb->remote_ip)->addr, upcb->remote_port));

struct netif *sta_netif = (struct netif *)eagle_lwip_getif(0x00);
struct netif *ap_netif = (struct netif *)eagle_lwip_getif(0x01);
Expand Down Expand Up @@ -236,7 +236,7 @@ espconn_udp_sendto(void *arg, uint8 *psent, uint16 length)
IP4_ADDR(&dst_ip, pespconn->proto.udp->remote_ip[0],
pespconn->proto.udp->remote_ip[1], pespconn->proto.udp->remote_ip[2],
pespconn->proto.udp->remote_ip[3]);
LWIP_DEBUGF(ESPCONN_UDP_DEBUG, ("espconn_udp_sent %d %x %d\n", __LINE__, upcb->remote_ip, upcb->remote_port));
LWIP_DEBUGF(ESPCONN_UDP_DEBUG, ("espconn_udp_sent %d %x %d\n", __LINE__, ip_2_ip4(&upcb->remote_ip)->addr, upcb->remote_port));

//struct netif *sta_netif = (struct netif *)eagle_lwip_getif(0x00);
//struct netif *ap_netif = (struct netif *)eagle_lwip_getif(0x01);
Expand Down
170 changes: 0 additions & 170 deletions glue/doprint.c

This file was deleted.

16 changes: 0 additions & 16 deletions glue/glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,4 @@ err_glue_t glue2esp_linkoutput (int netif_idx, void* ref2save, void* data, size
#define lwip_xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
#define lwip_xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")

// quickfix: workaround for definition of __PRI32(x) in inttypes.h
// it has changed with recent version of xtensa-gcc
// __INT32 is missing
// gcc-4.x: __PRI32(x) is __STRINGIFY(l##x)
// gcc-10.2.0: __PRI32(x) is __INT32 __STRINGIFY(x)
#include <inttypes.h>
#if !defined(__INT8)
#define __INT8
#endif
#if !defined(__INT16)
#define __INT16
#endif
#if !defined(__INT32)
#define __INT32 "l"
#endif

#endif // GLUE_H
56 changes: 13 additions & 43 deletions glue/gluedebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
// this is needed separately from lwipopts.h
// because it is shared by both sides of glue

#define UNDEBUG 1 // 0 or 1 (1: uassert removed)
#define UNDEBUG 1 // 0 or 1 (1: uassert removed = saves flash)
#define UDEBUG 0 // 0 or 1 (glue debug)
#define UDUMP 0 // 0 or 1 (glue / dump packet)
#define UDEBUGINDEX 0 // 0 or 1 (show debug line number)
#define UDEBUGSTORE 0 // 0 or 1 (store debug into buffer until doprint_allow=1=serial-available)
#define UDUMP 0 // 0 or 1 (glue: dump packet)

#define ULWIPDEBUG 0 // 0 or 1 (trigger lwip debug)
#define ULWIPASSERT 0 // 0 or 1 (trigger lwip self-check, 0 saves flash)
Expand All @@ -24,8 +22,6 @@
#define STRING_IN_FLASH 0 // *print("fmt is stored in flash")
#endif

#define ROTBUFLEN_BIT 11 // (UDEBUGSTORE=1) doprint()'s buffer: 11=2048B

#if ULWIPDEBUG
//#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH)
Expand All @@ -45,17 +41,11 @@ extern void (*phy_capture) (int netif_idx, const char* data, size_t len, int out
}
#endif


/////////////////////////////////////////////////////////////////////////////
#if ARDUINO
#include <sys/pgmspace.h>
#endif

#if UDEBUG && UDEBUGSTORE
#warning use 'doprint_allow=1' right after Serial is enabled
extern int doprint_allow;
#endif

// print definitions:
// uprint(): always used by glue, defined as doprint() in debug mode or nothing()
// os_printf(): can be redefined as doprint()
Expand All @@ -65,41 +55,21 @@ extern int doprint_allow;
#if STRING_IN_FLASH && !defined(USE_OPTIMIZE_PRINTF)
#define USE_OPTIMIZE_PRINTF // at least used in arduino/esp8266
#endif
// os_printf_plus() missing in osapi.h (fixed in arduino's sdk-2.1):
//extern int os_printf_plus (const char * format, ...) __attribute__ ((format (printf, 1, 2)));

#include <osapi.h> // os_printf* definitions + ICACHE_RODATA_ATTR

#if UDEBUG && (UDEBUGINDEX || UDEBUGSTORE)
// doprint() is used

#undef os_printf
#define os_printf(x...) do { doprint(x); } while (0)

#if STRING_IN_FLASH

#define doprint(fmt, ...) \
do { \
static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
doprint_minus(flash_str, ##__VA_ARGS__); \
} while(0)

#else // !STRING_IN_FLASH

#define doprint(fmt, ...) doprint_minus(fmt, ##__VA_ARGS__)

#endif // !STRING_IN_FLASH

int doprint_minus (const char* format, ...) __attribute__ ((format (printf, 1, 2))); // format in flash

#else // !( UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) )

#define doprint(x...) do { os_printf(x); } while (0)

#endif // !( UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) )
#if defined(ARDUINO)
// os_printf() does not understand ("%hhx",0x12345678) => "78") and prints 'h' instead
// now hacking/using ::printf() from updated and patched esp-quick-toolchain-by-Earle
#include <stdio.h>
#undef os_printf
#undef os_printf_plus
#define os_printf printf
#define os_printf_plus printf
#endif

#if UDEBUG
#define uprint(x...) do { doprint(x); } while (0)
#define uprint(x...) do { os_printf(x); } while (0)
#else
#define uprint(x...) do { (void)0; } while (0)
#endif
Expand Down Expand Up @@ -127,7 +97,7 @@ do { if ((assertion) == 0) { \

#define ualwaysassert(assertion...) udoassert(assertion)

#define uerror(x...) do { doprint(x); } while (0)
#define uerror(x...) do { os_printf(x); } while (0)
#define uhalt() do { *((int*)0) = 0; /* this triggers gdb */ } while (0)
#define nl() do { uprint("\n"); } while (0)

Expand Down
2 changes: 1 addition & 1 deletion patches/napt.patch
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ index 26c26a91..c8948b9c 100644
+ struct napt_table *t;
+
+ LWIP_DEBUGF(NAPT_DEBUG, ("ip_napt_find\n"));
+ LWIP_DEBUGF(NAPT_DEBUG, ("looking up in table %s: %"U16_F".%"U16_F".%"U16_F".%"U16_F", port: %lu, mport: %lu\n",
+ LWIP_DEBUGF(NAPT_DEBUG, ("looking up in table %s: %"U16_F".%"U16_F".%"U16_F".%"U16_F", port: %u, mport: %u\n",
+ (dest ? "dest" : "src"),
+ ((const u8_t*) (&addr))[0], ((const u8_t*) (&addr))[1],
+ ((const u8_t*) (&addr))[2], ((const u8_t*) (&addr))[3],
Expand Down