Skip to content

Commit b0e23fe

Browse files
d-a-vhasenradball
authored andcommitted
lwip2: cleanup logging and use newlib printf (esp8266#8769)
d-a-v/esp82xx-nonos-linklayer#61
1 parent 7dc7206 commit b0e23fe

9 files changed

+14
-60
lines changed

tools/sdk/lib/liblwip2-1460-feat.a

-6.68 KB
Binary file not shown.

tools/sdk/lib/liblwip2-1460.a

-6.69 KB
Binary file not shown.

tools/sdk/lib/liblwip2-536-feat.a

-6.68 KB
Binary file not shown.

tools/sdk/lib/liblwip2-536.a

-6.69 KB
Binary file not shown.

tools/sdk/lib/liblwip6-1460-feat.a

-6.69 KB
Binary file not shown.

tools/sdk/lib/liblwip6-536-feat.a

-6.69 KB
Binary file not shown.

tools/sdk/lwip2/include/glue.h

-16
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,4 @@ err_glue_t glue2esp_linkoutput (int netif_idx, void* ref2save, void* data, size
118118
#define lwip_xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
119119
#define lwip_xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
120120

121-
// quickfix: workaround for definition of __PRI32(x) in inttypes.h
122-
// it has changed with recent version of xtensa-gcc
123-
// __INT32 is missing
124-
// gcc-4.x: __PRI32(x) is __STRINGIFY(l##x)
125-
// gcc-10.2.0: __PRI32(x) is __INT32 __STRINGIFY(x)
126-
#include <inttypes.h>
127-
#if !defined(__INT8)
128-
#define __INT8
129-
#endif
130-
#if !defined(__INT16)
131-
#define __INT16
132-
#endif
133-
#if !defined(__INT32)
134-
#define __INT32 "l"
135-
#endif
136-
137121
#endif // GLUE_H

tools/sdk/lwip2/include/gluedebug.h

+13-43
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
// this is needed separately from lwipopts.h
1010
// because it is shared by both sides of glue
1111

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

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

27-
#define ROTBUFLEN_BIT 11 // (UDEBUGSTORE=1) doprint()'s buffer: 11=2048B
28-
2925
#if ULWIPDEBUG
3026
//#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
3127
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH)
@@ -45,17 +41,11 @@ extern void (*phy_capture) (int netif_idx, const char* data, size_t len, int out
4541
}
4642
#endif
4743

48-
4944
/////////////////////////////////////////////////////////////////////////////
5045
#if ARDUINO
5146
#include <sys/pgmspace.h>
5247
#endif
5348

54-
#if UDEBUG && UDEBUGSTORE
55-
#warning use 'doprint_allow=1' right after Serial is enabled
56-
extern int doprint_allow;
57-
#endif
58-
5949
// print definitions:
6050
// uprint(): always used by glue, defined as doprint() in debug mode or nothing()
6151
// os_printf(): can be redefined as doprint()
@@ -65,41 +55,21 @@ extern int doprint_allow;
6555
#if STRING_IN_FLASH && !defined(USE_OPTIMIZE_PRINTF)
6656
#define USE_OPTIMIZE_PRINTF // at least used in arduino/esp8266
6757
#endif
68-
// os_printf_plus() missing in osapi.h (fixed in arduino's sdk-2.1):
69-
//extern int os_printf_plus (const char * format, ...) __attribute__ ((format (printf, 1, 2)));
7058

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

73-
#if UDEBUG && (UDEBUGINDEX || UDEBUGSTORE)
74-
// doprint() is used
75-
76-
#undef os_printf
77-
#define os_printf(x...) do { doprint(x); } while (0)
78-
79-
#if STRING_IN_FLASH
80-
81-
#define doprint(fmt, ...) \
82-
do { \
83-
static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
84-
doprint_minus(flash_str, ##__VA_ARGS__); \
85-
} while(0)
86-
87-
#else // !STRING_IN_FLASH
88-
89-
#define doprint(fmt, ...) doprint_minus(fmt, ##__VA_ARGS__)
90-
91-
#endif // !STRING_IN_FLASH
92-
93-
int doprint_minus (const char* format, ...) __attribute__ ((format (printf, 1, 2))); // format in flash
94-
95-
#else // !( UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) )
96-
97-
#define doprint(x...) do { os_printf(x); } while (0)
98-
99-
#endif // !( UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) )
61+
#if defined(ARDUINO)
62+
// os_printf() does not understand ("%hhx",0x12345678) => "78") and prints 'h' instead
63+
// now hacking/using ::printf() from updated and patched esp-quick-toolchain-by-Earle
64+
#include <stdio.h>
65+
#undef os_printf
66+
#undef os_printf_plus
67+
#define os_printf printf
68+
#define os_printf_plus printf
69+
#endif
10070

10171
#if UDEBUG
102-
#define uprint(x...) do { doprint(x); } while (0)
72+
#define uprint(x...) do { os_printf(x); } while (0)
10373
#else
10474
#define uprint(x...) do { (void)0; } while (0)
10575
#endif
@@ -127,7 +97,7 @@ do { if ((assertion) == 0) { \
12797

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

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

0 commit comments

Comments
 (0)