diff --git a/cpu/esp32/Makefile.include b/cpu/esp32/Makefile.include index 87bb89ff16..fdf445a7c0 100644 --- a/cpu/esp32/Makefile.include +++ b/cpu/esp32/Makefile.include @@ -142,11 +142,6 @@ LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.ld LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.nanofmt.ld LINKFLAGS += -nostdlib -lgcc -Wl,-gc-sections -ifneq (,$(filter stdio_uart,$(USEMODULE))) - LINKFLAGS += -Wl,-wrap,putchar - LINKFLAGS += -Wl,-wrap,getchar -endif - # The ELFFILE is the base one used for flashing FLASHFILE ?= $(ELFFILE) diff --git a/cpu/esp32/include/syscalls.h b/cpu/esp32/include/syscalls.h index 0151453b70..038492d2cb 100644 --- a/cpu/esp32/include/syscalls.h +++ b/cpu/esp32/include/syscalls.h @@ -35,9 +35,6 @@ extern "C" { /** Necessary initializations of system call functions */ void syscalls_init (void); -/** System standard printf function */ -int printf(const char* format, ...); - /** Determine free heap size */ unsigned int get_free_heap_size (void); diff --git a/cpu/esp32/log_module.c b/cpu/esp32/log_module.c index 9d1659e273..b90b26850f 100644 --- a/cpu/esp32/log_module.c +++ b/cpu/esp32/log_module.c @@ -25,7 +25,7 @@ #include "log.h" #include "syscalls.h" -extern char _printf_buf[PRINTF_BUFSIZ]; +char _printf_buf[PRINTF_BUFSIZ]; bool _new_line = true; void log_write(unsigned level, const char *format, ...) diff --git a/cpu/esp32/startup.c b/cpu/esp32/startup.c index 747fdc5e46..1b85a1e041 100644 --- a/cpu/esp32/startup.c +++ b/cpu/esp32/startup.c @@ -279,12 +279,6 @@ static NORETURN void IRAM system_init (void) /* Disable the hold flag of all RTC GPIO pins */ RTCCNTL.hold_force.val = 0; - /* initialize newlib data structure */ - esp_reent_init(_GLOBAL_REENT); - _GLOBAL_REENT->_stdin = (FILE*) &__sf_fake_stdin; - _GLOBAL_REENT->_stdout = (FILE*) &__sf_fake_stdout; - _GLOBAL_REENT->_stderr = (FILE*) &__sf_fake_stderr; - /* execute constructors */ do_global_ctors(); diff --git a/cpu/esp32/syscalls.c b/cpu/esp32/syscalls.c index cd484aed97..4691564b83 100644 --- a/cpu/esp32/syscalls.c +++ b/cpu/esp32/syscalls.c @@ -64,61 +64,6 @@ #define MHZ 1000000UL -#ifdef MODULE_STDIO_UART -#include "stdio_uart.h" - -int IRAM __wrap_putchar(int c) -{ - char tmp = c; - if (stdio_write(&tmp, 1) > 0) { - return c; - } - return -EOF; -} - -int IRAM __wrap_getchar(void) -{ - char tmp; - if (stdio_read(&tmp, 1) > 0) { - return tmp; - } - return -EOF; -} -#endif /* MODULE_STDIO_UART */ - -int IRAM puts(const char *s) -{ - if (!s) { - return EOF; - } - int len = strlen(s); - for (int i = 0; i < len; i++) { - __wrap_putchar(s[i]); - } - __wrap_putchar('\n'); - return len; -} - -char _printf_buf[PRINTF_BUFSIZ]; - -int IRAM printf(const char* format, ...) -{ - va_list arglist; - va_start(arglist, format); - - int ret = vsnprintf(_printf_buf, PRINTF_BUFSIZ, format, arglist); - - if (ret > 0) { - for (int i = 0; i < ret; i++) { - __wrap_putchar(_printf_buf[i]); - } - } - - va_end(arglist); - - return ret; -} - #ifndef MODULE_PTHREAD #define PTHREAD_CANCEL_DISABLE 1 diff --git a/cpu/esp32/vendor/esp-idf/esp_funcs.c b/cpu/esp32/vendor/esp-idf/esp_funcs.c index 9f929d0756..204eaea107 100644 --- a/cpu/esp32/vendor/esp-idf/esp_funcs.c +++ b/cpu/esp32/vendor/esp-idf/esp_funcs.c @@ -50,34 +50,6 @@ #include "syscalls.h" -/* This function is not part on newlib API, it is defined in libc/stdio/local.h - * There is no nice way to get __cleanup member populated while avoiding __sinit, - * so extern declaration is used here. - */ -extern void _cleanup_r(struct _reent* r); - -/** - * This is the replacement for newlib's _REENT_INIT_PTR and __sinit. - * The problem with __sinit is that it allocates three FILE structures - * (stdin, stdout, stderr). Having individual standard streams for each task - * is a bit too much on a small embedded system. So we point streams - * to the streams of the global struct _reent, which are initialized in - * startup code. - */ -void IRAM_ATTR esp_reent_init(struct _reent* r) -{ - memset(r, 0, sizeof(*r)); - r->_stdout = _GLOBAL_REENT->_stdout; - r->_stderr = _GLOBAL_REENT->_stderr; - r->_stdin = _GLOBAL_REENT->_stdin; - r->__cleanup = &_cleanup_r; - r->__sdidinit = 1; - r->__sglue._next = NULL; - r->__sglue._niobs = 0; - r->__sglue._iobs = NULL; - r->_current_locale = "C"; -} - /* source: /path/to/esp-idf/components/esp32/panic.c */ void IRAM_ATTR esp_panic_wdt_stop (void) {