Merge branch 'psram' of ssh://172.29.0.8/home/folkert/git/PDP-11 into psram

This commit is contained in:
folkert van heusden 2024-04-29 22:29:41 +02:00
commit 6da098a9b9
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
4 changed files with 11 additions and 22 deletions

View file

@ -17,7 +17,7 @@ board_build.filesystem = littlefs
lib_deps = greiman/SdFat@^2.1.2 lib_deps = greiman/SdFat@^2.1.2
adafruit/Adafruit NeoPixel adafruit/Adafruit NeoPixel
bblanchon/ArduinoJson@^6.19.4 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 build_unflags = -std=gnu++11 -std=gnu++17
extra_scripts = pre:prepare.py extra_scripts = pre:prepare.py
@ -45,8 +45,8 @@ monitor_speed = 115200
upload_speed = 1000000 upload_speed = 1000000
board_build.filesystem = littlefs board_build.filesystem = littlefs
lib_deps = greiman/SdFat@^2.1.2 lib_deps = greiman/SdFat@^2.1.2
adafruit/Adafruit NeoPixel adafruit/Adafruit NeoPixel
bblanchon/ArduinoJson@^6.19.4 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_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 build_unflags = -std=gnu++11
extra_scripts = pre:prepare.py extra_scripts = pre:prepare.py

View file

@ -637,9 +637,9 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
uint32_t m_offset = a; uint32_t m_offset = a;
if (mmu_->is_enabled() || (is_write && (mmu_->getMMR0() & (1 << 8 /* maintenance check */)))) { 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 uint16_t p_offset = a & 8191; // page offset

View file

@ -1,4 +1,4 @@
// (C) 2018-2023 by Folkert van Heusden // (C) 2018-2024 by Folkert van Heusden
// Released under MIT license // Released under MIT license
#if defined(ESP32) #if defined(ESP32)
@ -8,38 +8,30 @@
#include "memory.h" #include "memory.h"
memory::memory(const uint32_t size) : size(size) memory::memory(const uint32_t size): size(size)
{ {
#if defined(ESP32) #if defined(ESP32)
Serial.print(F("Memory size (in bytes, decimal): ")); Serial.print(F("Memory size (in bytes, decimal): "));
Serial.println(size); Serial.println(size);
if (size > 12 * 8192) { if (size > 12 * 8192 && psramFound()) {
Serial.println(F("Using PSRAM")); Serial.println(F("Using PSRAM"));
is_psram = true;
m = reinterpret_cast<uint8_t *>(ps_malloc(size)); m = reinterpret_cast<uint8_t *>(ps_malloc(size));
reset(); reset();
} }
else { else {
m = new uint8_t[size](); m = reinterpret_cast<uint8_t *>(calloc(1, size));
} }
#else #else
m = new uint8_t[size](); m = reinterpret_cast<uint8_t *>(calloc(1, size));
#endif #endif
} }
memory::~memory() memory::~memory()
{ {
#if defined(ESP32) free(m);
if (is_psram)
free(m);
else
delete [] m;
#else
delete [] m;
#endif
} }
void memory::reset() void memory::reset()

View file

@ -13,9 +13,6 @@ class memory
private: private:
const uint32_t size { 0 }; const uint32_t size { 0 };
uint8_t *m { nullptr }; uint8_t *m { nullptr };
#ifdef ESP32
bool is_psram { false };
#endif
public: public:
memory(const uint32_t size); memory(const uint32_t size);