diff --git a/ESP32/console_esp32.cpp b/ESP32/console_esp32.cpp index 5b7a131..56127f6 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/ESP32/main.ino b/ESP32/main.ino index 1c60cc3..058e257 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 Hz", SOC_CPU_CORES_NUM, esp_clk_cpu_freq())); + #if defined(ESP32) heap_caps_register_failed_alloc_callback(heap_caps_alloc_failed_hook); #endif 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 ed529d5..8b61e81 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)"); @@ -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",