From 848ea620259fc63c9bdb27ec2259ac9be73f9281 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Tue, 30 Apr 2024 20:22:47 +0200 Subject: [PATCH] tweaks to make PSRAM work --- ESP32/esp32.h | 3 +++ ESP32/main.ino | 12 ++++++++---- ESP32/platformio.ini | 15 +++++++++++++++ debugger.cpp | 4 ++++ memory.cpp | 2 +- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ESP32/esp32.h b/ESP32/esp32.h index 08ee59e..39e0813 100644 --- a/ESP32/esp32.h +++ b/ESP32/esp32.h @@ -14,3 +14,6 @@ #endif // #define NEOPIXELS_PIN 24 + +// #define CONSOLE_SERIAL_RX 16 +// #define CONSOLE_SERIAL_TX 17 diff --git a/ESP32/main.ino b/ESP32/main.ino index 395dc84..f11b4b5 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -52,7 +52,7 @@ constexpr const char SERIAL_CFG_FILE[] = "/serial.json"; #if defined(BUILD_FOR_RP2040) #define Serial_RS232 Serial1 -#else +#elif defined(CONSOLE_SERIAL_RX) HardwareSerial Serial_RS232(1); #endif @@ -202,6 +202,7 @@ void recall_configuration(console *const cnsl) } #endif +#if defined(CONSOLE_SERIAL_RX) void set_tty_serial_speed(console *const c, const uint32_t bps) { Serial_RS232.begin(bps); @@ -209,6 +210,7 @@ void set_tty_serial_speed(console *const c, const uint32_t bps) if (save_serial_speed_configuration(bps) == false) c->put_string_lf("Failed to store configuration file with serial settings"); } +#endif #if defined(ESP32) void heap_caps_alloc_failed_hook(size_t requested_size, uint32_t caps, const char *function_name) @@ -296,14 +298,16 @@ void setup() { Serial.print(bitrate); Serial.println(F("bps")); -#if !defined(BUILD_FOR_RP2040) - Serial_RS232.begin(bitrate, hwSerialConfig, 16, 17); +#if !defined(BUILD_FOR_RP2040) && defined(CONSOLE_SERIAL_RX) + Serial_RS232.begin(bitrate, hwSerialConfig, CONSOLE_SERIAL_RX, CONSOLE_SERIAL_TX); Serial_RS232.setHwFlowCtrlMode(0); -#endif Serial_RS232.println(F("\014Console enabled on TTY")); std::vector serial_ports { &Serial_RS232, &Serial }; +#else + std::vector serial_ports { &Serial }; +#endif #if defined(SHA2017) cnsl = new console_shabadge(&stop_event, serial_ports); #elif defined(ESP32) || defined(BUILD_FOR_RP2040) diff --git a/ESP32/platformio.ini b/ESP32/platformio.ini index e44c199..edc8d7a 100644 --- a/ESP32/platformio.ini +++ b/ESP32/platformio.ini @@ -50,3 +50,18 @@ lib_deps = greiman/SdFat@^2.1.2 build_flags = -std=gnu++17 -DESP32=1 -ggdb3 -D_GLIBCXX_USE_C99 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DCONFIG_SPIRAM_USE_MALLOC build_unflags = -std=gnu++11 extra_scripts = pre:prepare.py + +[env:adafruit_qtpy_esp32s3_n4r2] +platform = espressif32 +board = adafruit_qtpy_esp32s3_n4r2 +build_src_filter = +<*> -<.git/> -<.svn/> - - - - - - - - +framework = arduino +monitor_speed = 115200 +upload_speed = 1000000 +board_build.filesystem = littlefs +lib_deps = greiman/SdFat@^2.1.2 + adafruit/Adafruit NeoPixel + bblanchon/ArduinoJson@^6.19.4 +build_flags = -std=gnu++17 -DESP32=1 -ggdb3 -D_GLIBCXX_USE_C99 -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DCONFIG_SPIRAM_USE_MALLOC +build_unflags = -std=gnu++11 +extra_scripts = pre:prepare.py diff --git a/debugger.cpp b/debugger.cpp index ba3cd07..129c446 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -843,6 +843,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto continue; } +#if defined(CONSOLE_SERIAL_RX) else if (parts.at(0) == "serspd") { if (parts.size() == 2) { uint32_t speed = std::stoi(parts.at(1), nullptr, 10); @@ -856,6 +857,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto continue; } +#endif #endif else if (cmd == "stats") { show_run_statistics(cnsl, c); @@ -1022,7 +1024,9 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto "cfgnet - configure network (e.g. WiFi)", "startnet - start network", "chknet - check network status", +#if defined(CONSOLE_SERIAL_RX) "serspd - set serial speed in bps (8N1 are default)", +#endif "debug - debugging info", #endif "cfgdisk - configure disk", diff --git a/memory.cpp b/memory.cpp index 6d205f3..d50beb5 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 && psramFound()) { + if (psramFound()) { Serial.println(F("Using PSRAM")); m = reinterpret_cast(ps_malloc(size));