From c18b9f307b3cd9dde198c8fb1f498d4702ec0419 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 27 Apr 2024 20:52:49 +0200 Subject: [PATCH 1/7] missing define --- ESP32/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ESP32/platformio.ini b/ESP32/platformio.ini index 88edc7f..e533a3d 100644 --- a/ESP32/platformio.ini +++ b/ESP32/platformio.ini @@ -17,7 +17,7 @@ board_build.filesystem = littlefs lib_deps = greiman/SdFat@^2.1.2 adafruit/Adafruit NeoPixel bblanchon/ArduinoJson@^6.19.4 -build_flags = -std=gnu++2a -DESP32=1 -ggdb3 -D_GLIBCXX_USE_C99 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue +build_flags = -std=gnu++2a -DESP32=1 -ggdb3 -D_GLIBCXX_USE_C99 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DCONFIG_SPIRAM_USE_MALLOC build_unflags = -std=gnu++11 -std=gnu++17 extra_scripts = pre:prepare.py From d74e54342d3417100f4d6df1111efc6484b23205 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 27 Apr 2024 20:53:08 +0200 Subject: [PATCH 2/7] spaces --- bus.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bus.cpp b/bus.cpp index 5d73884..8ac8d26 100644 --- a/bus.cpp +++ b/bus.cpp @@ -629,9 +629,9 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c uint32_t m_offset = a; if (mmu_->is_enabled() || (is_write && (mmu_->getMMR0() & (1 << 8 /* maintenance check */)))) { - const uint8_t apf = a >> 13; // active page field + uint8_t apf = a >> 13; // active page field - bool d = space == d_space && mmu_->get_use_data_space(run_mode) ? space == d_space : false; + bool d = space == d_space && mmu_->get_use_data_space(run_mode) ? space == d_space : false; uint16_t p_offset = a & 8191; // page offset From 5683a21dbb36b130eecbe720a68e2d5061961293 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 27 Apr 2024 20:54:31 +0200 Subject: [PATCH 3/7] date --- memory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/memory.cpp b/memory.cpp index 6a9f1cf..c4fafc4 100644 --- a/memory.cpp +++ b/memory.cpp @@ -1,4 +1,4 @@ -// (C) 2018-2023 by Folkert van Heusden +// (C) 2018-2024 by Folkert van Heusden // Released under MIT license #if defined(ESP32) @@ -8,7 +8,7 @@ #include "memory.h" -memory::memory(const uint32_t size) : size(size) +memory::memory(const uint32_t size): size(size) { #if defined(ESP32) Serial.print(F("Memory size (in bytes, decimal): ")); From 8106dc4683987e2054a48dd0b351b2b00b08da62 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 27 Apr 2024 21:46:01 +0200 Subject: [PATCH 4/7] only use psram when available --- memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory.cpp b/memory.cpp index c4fafc4..64fa1ba 100644 --- a/memory.cpp +++ b/memory.cpp @@ -14,7 +14,7 @@ memory::memory(const uint32_t size): size(size) Serial.print(F("Memory size (in bytes, decimal): ")); Serial.println(size); - if (size > 12 * 8192) { + if (size > 12 * 8192 && psramFound()) { Serial.println(F("Using PSRAM")); is_psram = true; From 6201f8006e3c6a027fd2ca0a27a0b02f19e4e048 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 27 Apr 2024 21:50:15 +0200 Subject: [PATCH 5/7] code reduction --- memory.cpp | 14 +++----------- memory.h | 3 --- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/memory.cpp b/memory.cpp index 64fa1ba..ab3d526 100644 --- a/memory.cpp +++ b/memory.cpp @@ -16,30 +16,22 @@ memory::memory(const uint32_t size): size(size) if (size > 12 * 8192 && psramFound()) { Serial.println(F("Using PSRAM")); - is_psram = true; m = reinterpret_cast(ps_malloc(size)); reset(); } else { - m = new uint8_t[size](); + m = reinterpret_cast(calloc(1, size)); } #else - m = new uint8_t[size](); + m = reinterpret_cast(calloc(1, size)); #endif } memory::~memory() { -#if defined(ESP32) - if (is_psram) - free(m); - else - delete [] m; -#else - delete [] m; -#endif + free(m); } void memory::reset() diff --git a/memory.h b/memory.h index 5bf11e6..7a43089 100644 --- a/memory.h +++ b/memory.h @@ -13,9 +13,6 @@ class memory private: const uint32_t size { 0 }; uint8_t *m { nullptr }; -#ifdef ESP32 - bool is_psram { false }; -#endif public: memory(const uint32_t size); From f2f418fe643ce8bf175ef7179e6217ebe4f93b86 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 27 Apr 2024 21:57:09 +0200 Subject: [PATCH 6/7] static -> constexpr const --- loaders.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/loaders.cpp b/loaders.cpp index 8752141..3c89805 100644 --- a/loaders.cpp +++ b/loaders.cpp @@ -30,7 +30,7 @@ void loadbin(bus *const b, uint16_t base, const char *const file) void set_boot_loader(bus *const b, const bootloader_t which) { - cpu *const c = b->getCpu(); + cpu *const c = b->getCpu(); uint16_t offset = 0; uint16_t start = 0; @@ -40,7 +40,7 @@ void set_boot_loader(bus *const b, const bootloader_t which) if (which == BL_RK05) { start = offset = 01000; - static uint16_t rk05_code[] = { + constexpr const uint16_t rk05_code[] = { 0012700, 0177406, 0012710, @@ -92,7 +92,7 @@ void set_boot_loader(bus *const b, const bootloader_t which) start = offset = 01000; /* from https://www.pdp-11.nl/peripherals/disk/rl-info.html - static uint16_t rl02_code[] = { + constexpr const uint16_t rl02_code[] = { 0012701, 0174400, 0012761, @@ -120,7 +120,7 @@ void set_boot_loader(bus *const b, const bootloader_t which) */ // from http://gunkies.org/wiki/RL11_disk_controller - static uint16_t rl02_code[] = { + constexpr const uint16_t rl02_code[] = { 0012700, 0174400, 0012760, From 53fcfe169b7a1b28aa5f7948d9b13754c5d46e45 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 27 Apr 2024 22:01:13 +0200 Subject: [PATCH 7/7] old code --- debugger.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/debugger.cpp b/debugger.cpp index 9b5fcb9..c276cbe 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -37,13 +37,9 @@ #include "rp2040.h" #endif -void set_boot_loader(bus *const b); - -void configure_disk(console *const c); - -void configure_network(console *const c); -void check_network(console *const c); -void start_network(console *const c); +void configure_network(console *const cnsl); +void check_network(console *const cnsl); +void start_network(console *const cnsl); void set_tty_serial_speed(console *const c, const uint32_t bps); #endif