From 41c92628647107417d53b00d5be0b4b405655702 Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Wed, 12 Jun 2024 20:22:56 +0200 Subject: [PATCH 1/4] system info --- ESP32/main.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ESP32/main.ino b/ESP32/main.ino index 1c60cc3..53f1f8a 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -16,6 +16,7 @@ #include #endif #if defined(ESP32) +#include "esp_clk.h" #include "esp_heap_caps.h" #endif @@ -269,6 +270,8 @@ void setup() { cs->println(format("GIT hash: %s", version_str)); cs->println("Build on: " __DATE__ " " __TIME__); + cs->println(format("# cores: %d, CPU frequency: %d", SOC_CPU_CORES_NUM, esp_clk_cpu_freq())); + #if defined(ESP32) heap_caps_register_failed_alloc_callback(heap_caps_alloc_failed_hook); #endif From 5c3c51cc4836e286798f868cde18d71a24a01f77 Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Wed, 12 Jun 2024 21:10:11 +0200 Subject: [PATCH 2/4] output --- ESP32/main.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ESP32/main.ino b/ESP32/main.ino index 53f1f8a..058e257 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -270,7 +270,7 @@ void setup() { cs->println(format("GIT hash: %s", version_str)); cs->println("Build on: " __DATE__ " " __TIME__); - cs->println(format("# cores: %d, CPU frequency: %d", SOC_CPU_CORES_NUM, esp_clk_cpu_freq())); + cs->println(format("# cores: %d, CPU frequency: %d Hz", SOC_CPU_CORES_NUM, esp_clk_cpu_freq())); #if defined(ESP32) heap_caps_register_failed_alloc_callback(heap_caps_alloc_failed_hook); From a4cc44c222fa59c7ffec631b7ce33673ee175cc9 Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Wed, 12 Jun 2024 21:10:27 +0200 Subject: [PATCH 3/4] atoi -> stoi --- debugger.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debugger.cpp b/debugger.cpp index ed529d5..044e889 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -71,7 +71,7 @@ std::optional select_nbd_server(console *const cnsl) if (port_str.empty()) return { }; - disk_backend *d = new disk_backend_nbd(hostname, atoi(port_str.c_str())); + disk_backend *d = new disk_backend_nbd(hostname, std::stoi(port_str)); if (d->begin(false) == false) { cnsl->put_string_lf("Cannot initialize NBD client"); delete d; @@ -749,7 +749,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto single_step = true; if (parts.size() == 2) - n_single_step = atoi(parts[1].c_str()); + n_single_step = std::stoi(parts[1]); else n_single_step = 1; @@ -915,7 +915,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto cnsl->put_string_lf("parameter missing"); else { uint32_t addr = std::stoi(parts[1], nullptr, 8); - int n = parts.size() == 4 ? atoi(parts[3].c_str()) : 1; + int n = parts.size() == 4 ? std::stoi(parts[3]) : 1; if (parts[2] != "p" && parts[2] != "v") { cnsl->put_string_lf("expected p (physical address) or v (virtual address)"); From eb2f425621eb3746abdb96a3dd7da87351153f25 Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Wed, 12 Jun 2024 22:35:28 +0200 Subject: [PATCH 4/4] timestamps in output / reduced panel screenrate --- ESP32/console_esp32.cpp | 2 +- console.cpp | 15 +++++++++++++++ console.h | 6 ++++++ debugger.cpp | 6 ++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ESP32/console_esp32.cpp b/ESP32/console_esp32.cpp index 548569e..6d603bf 100644 --- a/ESP32/console_esp32.cpp +++ b/ESP32/console_esp32.cpp @@ -108,7 +108,7 @@ void console_esp32::panel_update_thread() pixels.show(); while(!stop_panel) { - vTaskDelay(20 / portTICK_PERIOD_MS); + vTaskDelay(100 / portTICK_PERIOD_MS); try { // note that these are approximately as there's no mutex on the emulation diff --git a/console.cpp b/console.cpp index 82f92d3..ea1de78 100644 --- a/console.cpp +++ b/console.cpp @@ -290,6 +290,21 @@ void console::put_char(const char c) debug_buffer.clear(); } + if (timestamps) { + char buffer[32] { }; + uint64_t timestamp = get_us() - start_ts; + uint64_t seconds = timestamp / 1000000; + + int len = snprintf(buffer, sizeof buffer, "%02d:%02d:%02d.%06d ", + int(seconds / 3600), + int((seconds / 60) % 60), + int(seconds % 60), + int(timestamp % 1000000)); + + for(int i=0; i #include +#include "utils.h" + #if defined(_WIN32) #include "win32.h" #endif @@ -48,6 +50,8 @@ protected: char *screen_buffer { nullptr }; uint8_t tx { 0 }; uint8_t ty { 0 }; + std::atomic_bool timestamps { false }; + const uint64_t start_ts { get_us() }; const size_t n_edit_lines_hist { 8 }; // maximum number of previous edit-lines std::vector edit_lines_hist; @@ -75,6 +79,8 @@ public: std::string read_line(const std::string & prompt); void flush_input(); + void enable_timestamp(const bool state) { timestamps = state; } + void emit_backspace(); void put_char(const char c); void put_string(const std::string & what); diff --git a/debugger.cpp b/debugger.cpp index 044e889..8b61e81 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -1082,6 +1082,11 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto continue; } + else if (parts[0] == "pts" && parts.size() == 2) { + cnsl->enable_timestamp(std::stoi(parts[1])); + + continue; + } else if (cmd == "qi") { show_queued_interrupts(cnsl, c); @@ -1183,6 +1188,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto "trace/t - toggle tracing", "setll x,y - set loglevel: terminal,file", "setsl x,y - set syslog target: requires a hostname and a loglevel", + "pts x - enable (1) / disable (0) timestamps", "turbo - toggle turbo mode (cannot be interrupted)", "debug - enable CPU debug mode", "bt - show backtrace - need to enable debug first",