Browse Source

Try to improve boot time by minimizing logging of data on boot

Dumping the whole configuration on init is probably not the best
way to boot the system. Unfortunately there still appears to be a
considerable lag (3-4 s) before the FPGA gets a life sign from ESP32.
H. Peter Anvin 1 year ago
parent
commit
619d19fcae

+ 9 - 1
common/sysvars.c

@@ -6,11 +6,13 @@
 #include <stdio.h>
 #include <time.h>
 
+bool sysvar_print_updates;
+
 #ifndef DEBUG
 # ifdef ON_FPGA
 #  define DEBUG 0
 # else
-#  define DEBUG 1
+#  define DEBUG sysvar_print_updates
 # endif
 #endif
 
@@ -404,16 +406,22 @@ void sysvar_reset(size_t ns)
     if (ns >= (size_t)sysvar_nscount)
 	return;
 
+    bool print_updates = sysvar_print_updates;
+
     enum sysvar_enum i;
     for (i = sysvar_ns[ns].first; i < sysvar_ns[ns+1].first; i++)
 	unsetvar(i);
 
+    sysvar_print_updates = print_updates;
+
     if (sysvar_changed < i)
 	sysvar_changed = i;
 }
 
 void sysvar_init(void)
 {
+    sysvar_print_updates = false;
+
     for (enum sysvar_enum i = sysvar_null+1; i < sysvar_count; i++)
 	unsetvar(i);
 

+ 1 - 0
common/sysvars.h

@@ -56,6 +56,7 @@ typedef struct sysvar_namespace {
 
 extern_c const sysvar_ns_t sysvar_ns[(size_t)sysvar_nscount+1];
 extern_c enum sysvar_enum sysvar_changed;
+extern_c bool sysvar_print_updates;
 
 /* Buffer size needed to represent some data types */
 #define BOOL_BUFLEN 2

+ 2 - 1
esp32/max80/config.c

@@ -191,6 +191,7 @@ void log_config_status(void)
 	if (var >= nsi[1].first)
 	    nsi++;
 
-	logmsg(nsi->name, "%s\n", notempty(getvar_tostr(var)));
+	logmsg(nsi->name, "%s = %s\n", sysvar_name[var],
+	       notempty(getvar_tostr(var)));
     }
 }

+ 8 - 3
esp32/max80/max80.ino

@@ -22,6 +22,8 @@
 #define PIN_USB_PWR_EN		7
 #define PIN_USB_PWR_SINK	8
 
+volatile bool do_log_config_status;
+
 uint8_t efuse_default_mac[6];
 char serial_number[16];		// Canonical board serial number
 
@@ -51,6 +53,7 @@ static void heap_info()
     printf("Heap: sram %zu/%zu, spiram %zu/%zu\n", il, ia, sl, sa);
 }
 
+#if 0
 static void dump_config()
 {
     printf("--- Configuration:\n");
@@ -59,6 +62,7 @@ static void dump_config()
     write_sysvars(stdout, true);
     printf("--- End configuration and status\n");
 }
+#endif
 
 static void init_hw()
 {
@@ -117,7 +121,8 @@ void setup() {
     fpga_service_enable(true);
     SetupWiFi();
     Serial.println("[RDY]");
-    dump_config();
+    sysvar_print_updates = true;
+    do_log_config_status = true; // Print configuration from main loop
     led_set(LED_BLUE, LED_ON);	// Software ready
 
     heap_info();
@@ -158,8 +163,6 @@ static void dump_tasks(void)
     }
 }
 
-volatile bool do_log_config_status;
-
 void loop() {
     if (0) {
 	printf("loop task: %s\n", pcTaskGetName(xTaskGetCurrentTaskHandle()));
@@ -174,6 +177,8 @@ void loop() {
 	log_config_status();
     }
 
+    fflush(stdout);
+
     TTY::ping();
     vTaskDelay(5 * configTICK_RATE_HZ);
 }

+ 9 - 1
esp32/max80/src/common/sysvars.c

@@ -6,11 +6,13 @@
 #include <stdio.h>
 #include <time.h>
 
+bool sysvar_print_updates;
+
 #ifndef DEBUG
 # ifdef ON_FPGA
 #  define DEBUG 0
 # else
-#  define DEBUG 1
+#  define DEBUG sysvar_print_updates
 # endif
 #endif
 
@@ -404,16 +406,22 @@ void sysvar_reset(size_t ns)
     if (ns >= (size_t)sysvar_nscount)
 	return;
 
+    bool print_updates = sysvar_print_updates;
+
     enum sysvar_enum i;
     for (i = sysvar_ns[ns].first; i < sysvar_ns[ns+1].first; i++)
 	unsetvar(i);
 
+    sysvar_print_updates = print_updates;
+
     if (sysvar_changed < i)
 	sysvar_changed = i;
 }
 
 void sysvar_init(void)
 {
+    sysvar_print_updates = false;
+
     for (enum sysvar_enum i = sysvar_null+1; i < sysvar_count; i++)
 	unsetvar(i);
 

+ 1 - 0
esp32/max80/src/common/sysvars.h

@@ -56,6 +56,7 @@ typedef struct sysvar_namespace {
 
 extern_c const sysvar_ns_t sysvar_ns[(size_t)sysvar_nscount+1];
 extern_c enum sysvar_enum sysvar_changed;
+extern_c bool sysvar_print_updates;
 
 /* Buffer size needed to represent some data types */
 #define BOOL_BUFLEN 2

+ 4 - 0
esp32/max80/tty.cpp

@@ -453,6 +453,8 @@ void TTY::init()
     Serial0.begin(BAUD_RATE);
     Serial0.onReceive(uart_onrx, false);
     Serial0.onReceiveError(uart_onerr);
+    static const char uart_tty_msg[] = "[TTY] UART initialized\r\n";
+    uart_tty->port().write(uart_tty_msg, sizeof uart_tty_msg - 1);
 
     usb_tty  = new TTY(Serial);
     usb_tty->_flush = usb_flush;
@@ -463,6 +465,8 @@ void TTY::init()
 	xTaskNotifyIndexed(usb_tty_task, USB_NOTIFY_INDEX, 1, eSetBits);
     }
     Serial.enableReboot(true);
+    static const char usb_tty_msg[] = "[TTY] USB initialized\r\n";
+    usb_tty->port().write(usb_tty_msg, sizeof usb_tty_msg - 1);
 }
 
 void TTY::ping()

BIN
esp32/output/max80.ino.bin


+ 3 - 3
fpga/max80.qpf

@@ -19,14 +19,14 @@
 #
 # Quartus Prime
 # Version 22.1std.2 Build 922 07/20/2023 SC Lite Edition
-# Date created = 12:25:52  September 19, 2023
+# Date created = 13:01:07  September 19, 2023
 #
 # -------------------------------------------------------------------------- #
 
 QUARTUS_VERSION = "22.1"
-DATE = "12:25:52  September 19, 2023"
+DATE = "13:01:07  September 19, 2023"
 
 # Revisions
 
-PROJECT_REVISION = "v1"
 PROJECT_REVISION = "v2"
+PROJECT_REVISION = "v1"

BIN
fpga/output/max80.fw


BIN
fpga/output/v1.fw


BIN
fpga/output/v1.jic


BIN
fpga/output/v1.sof


BIN
fpga/output/v2.fw


BIN
fpga/output/v2.jic


BIN
fpga/output/v2.sof