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)
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