Merge branch 'master' into DC11
This commit is contained in:
commit
aabff63ddb
8 changed files with 73 additions and 34 deletions
|
@ -7,12 +7,11 @@
|
|||
|
||||
#include "console_esp32.h"
|
||||
#include "cpu.h"
|
||||
#include "esp32.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
#define NEOPIXELS_PIN 25
|
||||
|
||||
console_esp32::console_esp32(std::atomic_uint32_t *const stop_event, std::vector<Stream *> & io_ports, const int t_width, const int t_height) :
|
||||
console(stop_event, t_width, t_height),
|
||||
io_ports(io_ports)
|
||||
|
@ -62,7 +61,7 @@ void console_esp32::refresh_virtual_terminal()
|
|||
|
||||
void console_esp32::panel_update_thread()
|
||||
{
|
||||
#if !defined(BUILD_FOR_RP2040)
|
||||
#if !defined(BUILD_FOR_RP2040) && defined(NEOPIXELS_PIN)
|
||||
Serial.println(F("panel task started"));
|
||||
|
||||
cpu *const c = b->getCpu();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// (C) 2018-2023 by Folkert van Heusden
|
||||
// (C) 2018-2024 by Folkert van Heusden
|
||||
// Released under MIT license
|
||||
|
||||
#pragma once
|
||||
|
@ -12,3 +12,8 @@
|
|||
#define SD_FAT_TYPE 1
|
||||
#include <SdFat.h>
|
||||
#endif
|
||||
|
||||
// #define NEOPIXELS_PIN 24
|
||||
|
||||
// #define CONSOLE_SERIAL_RX 16
|
||||
// #define CONSOLE_SERIAL_TX 17
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -125,9 +125,11 @@ void set_hostname()
|
|||
|
||||
void configure_network(console *const c)
|
||||
{
|
||||
WiFi.disconnect();
|
||||
|
||||
WiFi.persistent(true);
|
||||
WiFi.setAutoReconnect(true);
|
||||
|
||||
WiFi.useStaticBuffers(true);
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
c->put_string_lf("Scanning for wireless networks...");
|
||||
|
@ -159,7 +161,7 @@ void wait_network(console *const c)
|
|||
|
||||
int i = 0;
|
||||
|
||||
while (WiFi.waitForConnectResult() != WL_CONNECTED && i < timeout) {
|
||||
while (WiFi.status() != WL_CONNECTED && i < timeout) {
|
||||
c->put_string(".");
|
||||
|
||||
delay(1000 / 3);
|
||||
|
@ -184,7 +186,7 @@ void start_network(console *const c)
|
|||
set_hostname();
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
WiFi.useStaticBuffers(true);
|
||||
WiFi.begin();
|
||||
|
||||
wait_network(c);
|
||||
|
@ -202,6 +204,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 +212,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)
|
||||
|
@ -267,9 +271,14 @@ void setup() {
|
|||
#endif
|
||||
|
||||
#if !defined(BUILD_FOR_RP2040)
|
||||
uint32_t free_heap = ESP.getFreeHeap();
|
||||
Serial.printf("Free RAM before init: %d decimal bytes (or %d pages (value for the ramsize command in the debugger))", free_heap, std::min(int(free_heap / 8192l), DEFAULT_N_PAGES));
|
||||
Serial.println(F(""));
|
||||
Serial.print(F("Free RAM after init (decimal bytes): "));
|
||||
Serial.println(ESP.getFreeHeap());
|
||||
|
||||
if (psramInit()) {
|
||||
uint32_t free_psram = ESP.getFreePsram();
|
||||
Serial.printf("Free PSRAM: %d decimal bytes (or %d pages (see 'ramsize' in the debugger))", free_psram, free_psram / 8192l);
|
||||
Serial.println(F(""));
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.println(F("Init bus"));
|
||||
|
@ -291,14 +300,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)
|
||||
|
@ -318,7 +329,6 @@ void setup() {
|
|||
rl02_dev->begin();
|
||||
b->add_rl02(rl02_dev);
|
||||
|
||||
|
||||
Serial.println(F("Init TTY"));
|
||||
tty_ = new tty(cnsl, b);
|
||||
Serial.println(F("Connect TTY to bus"));
|
||||
|
@ -330,13 +340,9 @@ void setup() {
|
|||
#endif
|
||||
|
||||
#if !defined(BUILD_FOR_RP2040)
|
||||
Serial.print(F("Free RAM after init (decimal bytes): "));
|
||||
Serial.println(ESP.getFreeHeap());
|
||||
|
||||
if (psramFound()) {
|
||||
Serial.print(F("Free PSRAM: "));
|
||||
Serial.println(ESP.getFreePsram());
|
||||
}
|
||||
uint32_t free_heap = ESP.getFreeHeap();
|
||||
Serial.printf("Free RAM after init: %d decimal bytes", free_heap);
|
||||
Serial.println(F(""));
|
||||
#endif
|
||||
|
||||
#if !defined(SHA2017)
|
||||
|
|
|
@ -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 -Wall
|
||||
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
|
||||
|
||||
|
@ -47,6 +47,21 @@ 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
|
||||
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
bus.cpp
4
bus.cpp
|
@ -638,9 +638,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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -866,7 +868,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
|||
if (parts.size() == 2)
|
||||
b->set_memory_size(std::stoi(parts.at(1)));
|
||||
else {
|
||||
int n_pages = b->getRAM()->get_memory_size();
|
||||
int n_pages = b->getRAM()->get_memory_size() / 8192;
|
||||
|
||||
cnsl->put_string_lf(format("Memory size: %u pages or %u kB (decimal)", n_pages, n_pages * 8192 / 1024));
|
||||
}
|
||||
|
@ -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",
|
||||
|
|
20
memory.cpp
20
memory.cpp
|
@ -8,20 +8,30 @@
|
|||
|
||||
#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): "));
|
||||
Serial.println(size);
|
||||
#endif
|
||||
|
||||
m = new uint8_t[size]();
|
||||
if (psramFound()) {
|
||||
Serial.println(F("Using PSRAM"));
|
||||
|
||||
m = reinterpret_cast<uint8_t *>(ps_malloc(size));
|
||||
|
||||
reset();
|
||||
}
|
||||
else {
|
||||
m = reinterpret_cast<uint8_t *>(calloc(1, size));
|
||||
}
|
||||
#else
|
||||
m = reinterpret_cast<uint8_t *>(calloc(1, size));
|
||||
#endif
|
||||
}
|
||||
|
||||
memory::~memory()
|
||||
{
|
||||
delete [] m;
|
||||
free(m);
|
||||
}
|
||||
|
||||
void memory::reset()
|
||||
|
|
4
memory.h
4
memory.h
|
@ -10,8 +10,8 @@
|
|||
class memory
|
||||
{
|
||||
private:
|
||||
const uint32_t size { 0 };
|
||||
uint8_t *m { nullptr };
|
||||
const uint32_t size { 0 };
|
||||
uint8_t *m { nullptr };
|
||||
|
||||
public:
|
||||
memory(const uint32_t size);
|
||||
|
|
Loading…
Add table
Reference in a new issue