1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

lwip2: cleanup logging and use newlib printf (#8769)

https://github.com/d-a-v/esp82xx-nonos-linklayer/pull/61
This commit is contained in:
david gauchard 2022-12-21 09:35:23 +01:00 committed by GitHub
parent 4a639ab015
commit edfde6ba1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 14 additions and 60 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1 +1 @@
Subproject commit cffd11fb091b27f8bd37ea84353adbeb8bf20cd7 Subproject commit 8e3c4eec00ec7f3962705ee095a310642953b5fb

View File

@ -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_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") #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 #endif // GLUE_H

View File

@ -9,11 +9,9 @@
// this is needed separately from lwipopts.h // this is needed separately from lwipopts.h
// because it is shared by both sides of glue // 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 UDEBUG 0 // 0 or 1 (glue debug)
#define UDUMP 0 // 0 or 1 (glue / dump packet) #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 ULWIPDEBUG 0 // 0 or 1 (trigger lwip debug) #define ULWIPDEBUG 0 // 0 or 1 (trigger lwip debug)
#define ULWIPASSERT 0 // 0 or 1 (trigger lwip self-check, 0 saves flash) #define ULWIPASSERT 0 // 0 or 1 (trigger lwip self-check, 0 saves flash)
@ -24,8 +22,6 @@
#define STRING_IN_FLASH 0 // *print("fmt is stored in flash") #define STRING_IN_FLASH 0 // *print("fmt is stored in flash")
#endif #endif
#define ROTBUFLEN_BIT 11 // (UDEBUGSTORE=1) doprint()'s buffer: 11=2048B
#if ULWIPDEBUG #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|LWIP_DBG_HALT)
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH) #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
} }
#endif #endif
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if ARDUINO #if ARDUINO
#include <sys/pgmspace.h> #include <sys/pgmspace.h>
#endif #endif
#if UDEBUG && UDEBUGSTORE
#warning use 'doprint_allow=1' right after Serial is enabled
extern int doprint_allow;
#endif
// print definitions: // print definitions:
// uprint(): always used by glue, defined as doprint() in debug mode or nothing() // uprint(): always used by glue, defined as doprint() in debug mode or nothing()
// os_printf(): can be redefined as doprint() // os_printf(): can be redefined as doprint()
@ -65,41 +55,21 @@ extern int doprint_allow;
#if STRING_IN_FLASH && !defined(USE_OPTIMIZE_PRINTF) #if STRING_IN_FLASH && !defined(USE_OPTIMIZE_PRINTF)
#define USE_OPTIMIZE_PRINTF // at least used in arduino/esp8266 #define USE_OPTIMIZE_PRINTF // at least used in arduino/esp8266
#endif #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 #include <osapi.h> // os_printf* definitions + ICACHE_RODATA_ATTR
#if UDEBUG && (UDEBUGINDEX || UDEBUGSTORE) #if defined(ARDUINO)
// doprint() is used // 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
#define os_printf(x...) do { doprint(x); } while (0) #undef os_printf_plus
#define os_printf printf
#if STRING_IN_FLASH #define os_printf_plus printf
#endif
#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 UDEBUG #if UDEBUG
#define uprint(x...) do { doprint(x); } while (0) #define uprint(x...) do { os_printf(x); } while (0)
#else #else
#define uprint(x...) do { (void)0; } while (0) #define uprint(x...) do { (void)0; } while (0)
#endif #endif
@ -127,7 +97,7 @@ do { if ((assertion) == 0) { \
#define ualwaysassert(assertion...) udoassert(assertion) #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 uhalt() do { *((int*)0) = 0; /* this triggers gdb */ } while (0)
#define nl() do { uprint("\n"); } while (0) #define nl() do { uprint("\n"); } while (0)