Skip to content

Commit

Permalink
tweaks to make PSRAM work
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Apr 30, 2024
1 parent ff3e5ba commit 848ea62
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ESP32/esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
#endif

// #define NEOPIXELS_PIN 24

// #define CONSOLE_SERIAL_RX 16
// #define CONSOLE_SERIAL_TX 17
12 changes: 8 additions & 4 deletions ESP32/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -202,13 +202,15 @@ 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);

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)
Expand Down Expand Up @@ -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<Stream *> serial_ports { &Serial_RS232, &Serial };
#else
std::vector<Stream *> serial_ports { &Serial };
#endif
#if defined(SHA2017)
cnsl = new console_shabadge(&stop_event, serial_ports);
#elif defined(ESP32) || defined(BUILD_FOR_RP2040)
Expand Down
15 changes: 15 additions & 0 deletions ESP32/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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/> -<example/> -<examples/> -<test/> -<tests/> -<build> -<player.cpp> -<SHAdisplay/> -<console_shabadge.cpp>
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
4 changes: 4 additions & 0 deletions debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t *>(ps_malloc(size));
Expand Down

0 comments on commit 848ea62

Please sign in to comment.