Skip to content

Commit 4c587e2

Browse files
committed
Fix Exception 2 when using printf or vprintf
ets_vprintf signature is not the same as vprintf, it takes an output function as a first argument.
1 parent 797c78d commit 4c587e2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cores/esp8266/libc_replacements.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ int ICACHE_RAM_ATTR putchar(int c) {
5252
}
5353

5454
int ICACHE_RAM_ATTR printf(const char* format, ...) {
55-
int ret;
5655
va_list arglist;
5756
va_start(arglist, format);
58-
ret = ets_vprintf(format, arglist);
57+
int ret = ets_vprintf(ets_putc, format, arglist);
5958
va_end(arglist);
6059
return ret;
6160
}
@@ -79,7 +78,7 @@ int ICACHE_RAM_ATTR snprintf(char* buffer, size_t size, const char* format, ...)
7978
}
8079

8180
int ICACHE_RAM_ATTR vprintf(const char * format, va_list arg) {
82-
return ets_vprintf(format, arg);
81+
return ets_vprintf(ets_putc, format, arg);
8382
}
8483

8584
int ICACHE_RAM_ATTR vsnprintf(char * buffer, size_t size, const char * format, va_list arg) {

tools/sdk/include/ets_sys.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ inline uint32_t ETS_INTR_PENDING(void)
155155

156156
#define ETS_SDIO_INTR_DISABLE() \
157157
ETS_INTR_DISABLE(ETS_SDIO_INUM)
158-
158+
159159

160160
void *pvPortMalloc(size_t xWantedSize, const char* file, int line) __attribute__((malloc, alloc_size(1)));
161161
void *pvPortRealloc(void* ptr, size_t xWantedSize, const char* file, int line) __attribute__((alloc_size(2)));
@@ -183,7 +183,8 @@ void ets_isr_attach(int intr, int_handler_t handler, void *arg);
183183
void ets_intr_lock();
184184
void ets_intr_unlock();
185185
int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg) __attribute__ ((format (printf, 3, 0)));
186-
int ets_vprintf(const char * format, va_list arg) __attribute__ ((format (printf, 1, 0)));
186+
int ets_vprintf(int (*print_function)(int), const char * format, va_list arg) __attribute__ ((format (printf, 2, 0)));
187+
int ets_putc(int);
187188
bool ets_task(ETSTask task, uint8 prio, ETSEvent *queue, uint8 qlen);
188189
bool ets_post(uint8 prio, ETSSignal sig, ETSParam par);
189190

0 commit comments

Comments
 (0)