]> granicus.if.org Git - esp-idf/commitdiff
catch log output from WiFi libs
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 21 Nov 2016 14:56:11 +0000 (22:56 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Tue, 22 Nov 2016 13:14:36 +0000 (21:14 +0800)
components/esp32/cpu_start.c
components/esp32/lib_printf.c [new file with mode: 0644]
components/log/include/esp_log.h

index 293be565df7f642fdf6861c78a534695aea9f539..f55bc0350ea68150491fcb3cc9d85da0860a67d5 100644 (file)
@@ -152,6 +152,7 @@ void IRAM_ATTR call_start_cpu1()
 
 void start_cpu0_default(void)
 {
+    esp_setup_syscall_table();
 //Enable trace memory and immediately start trace.
 #if CONFIG_MEMMAP_TRACEMEM
 #if CONFIG_MEMMAP_TRACEMEM_TWOBANKS
@@ -172,7 +173,6 @@ void start_cpu0_default(void)
 #if CONFIG_TASK_WDT
     esp_task_wdt_init();
 #endif
-    esp_setup_syscall_table();
     esp_setup_time_syscalls();
     esp_vfs_dev_uart_register();
     esp_reent_init(_GLOBAL_REENT);
diff --git a/components/esp32/lib_printf.c b/components/esp32/lib_printf.c
new file mode 100644 (file)
index 0000000..8a537ff
--- /dev/null
@@ -0,0 +1,112 @@
+// Copyright 2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "esp_log.h"
+#include "esp_attr.h"
+
+#define VPRINTF_STACK_BUFFER_SIZE 80
+
+static int lib_printf(const char* tag, const char* format, va_list arg)
+{
+    char temp[VPRINTF_STACK_BUFFER_SIZE];
+    int len = vsnprintf(temp, sizeof(temp) - 1, format, arg);
+    temp[sizeof(temp) - 1] = 0;
+    int i;
+    for (i = len - 1; i >= 0; --i) {
+        if (temp[i] != '\n' && temp[i] != '\r' && temp[i] != ' ') {
+            break;
+        }
+        temp[i] = 0;
+    }
+    if (i > 0) {
+        ESP_EARLY_LOGI(tag, "%s", temp);
+    }
+    va_end(arg);
+    return len;
+}
+
+int phy_printf(const char* format, ...)
+{
+    va_list arg;
+    va_start(arg, format);
+    int res = lib_printf("phy", format, arg);
+    va_end(arg);
+    return res;
+}
+
+
+int rtc_printf(const char* format, ...)
+{
+    va_list arg;
+    va_start(arg, format);
+    int res = lib_printf("rtc", format, arg);
+    va_end(arg);
+    return res;
+}
+
+int wpa_printf(const char* format, ...)
+{
+    va_list arg;
+    va_start(arg, format);
+    int res = lib_printf("wpa", format, arg);
+    va_end(arg);
+    return res;
+}
+
+int wps_printf(const char* format, ...)
+{
+    va_list arg;
+    va_start(arg, format);
+    int res = lib_printf("wps", format, arg);
+    va_end(arg);
+    return res;
+}
+
+int pp_printf(const char* format, ...)
+{
+    va_list arg;
+    va_start(arg, format);
+    int res = lib_printf("pp", format, arg);
+    va_end(arg);
+    return res;
+}
+
+int sc_printf(const char* format, ...)
+{
+    va_list arg;
+    va_start(arg, format);
+    int res = lib_printf("smartconfig", format, arg);
+    va_end(arg);
+    return res;
+}
+
+int core_printf(const char* format, ...)
+{
+    va_list arg;
+    va_start(arg, format);
+    int res = lib_printf("core", format, arg);
+    va_end(arg);
+    return res;
+}
+
+int net80211_printf(const char* format, ...)
+{
+    va_list arg;
+    va_start(arg, format);
+    int res = lib_printf("net80211", format, arg);
+    va_end(arg);
+    return res;
+}
index f4b9aa28856d259974df171161a42abf49f6ed76..33bc10b42afa67ca9e76bb14f2c7da01506c4724 100644 (file)
 #include <stdint.h>
 #include <stdarg.h>
 #include "sdkconfig.h"
-
-#ifdef BOOTLOADER_BUILD
 #include <rom/ets_sys.h>
-#endif
 
 #ifdef __cplusplus
 extern "C" {