improved PSRAM support for MiniAP

This commit is contained in:
Jelmer
2023-05-15 20:14:48 +02:00
parent beb0e639e2
commit be9dba5a30
5 changed files with 53 additions and 1474 deletions

View File

@@ -34,11 +34,15 @@ board_build.f_cpu = 240000000L
platform = https://github.com/platformio/platform-espressif32.git
board=lolin_s2_mini
board_build.partitions = default.csv
build_unflags =
-D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags =
-D OPENEPAPERLINK_MINI_AP_PCB
-D ARDUINO_USB_MODE=0
-D CONFIG_ESP32S3_SPIRAM_SUPPORT=1
-D CONFIG_SPIRAM_USE_MALLOC=y
-D CONFIG_SPIRAM_USE_MALLOC=1
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
;-D DEBUG_VERSION
-D HAS_RGB_LED
-D BOARD_HAS_PSRAM
;-D HAS_USB
@@ -61,8 +65,8 @@ build_src_filter =
board_build.psram_type=qspi_opi
board_upload.maximum_size = 4194304
;board_upload.maximum_ram_size = 327680
board_upload.maximum_ram_size = 2097152
;board_upload.maximum_ram_size = 2097152
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 4MB
@@ -77,14 +81,16 @@ board_build.partitions = default_16MB.csv
build_unflags =
-D ARDUINO_USB_MODE=1
-D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags =
-D OPENEPAPERLINK_PCB
-D ARDUINO_USB_MODE=0
-D CONFIG_ESP32S3_SPIRAM_SUPPORT=1
-D CONFIG_SPIRAM_USE_MALLOC=y
-D CONFIG_SPIRAM_USE_MALLOC=1
-D HAS_USB
-D HAS_RGB_LED
-D BOARD_HAS_PSRAM
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D FLASHER_AP_SS=4
-D FLASHER_AP_CLK=5

File diff suppressed because it is too large Load Diff

View File

@@ -80,6 +80,10 @@ const uint16_t gamma12[256] = {
void addToRGBQueue(struct ledInstructionRGB* rgb, bool requeue) {
rgb->reQueue = requeue;
if (!rgbLedQueue) {
delete rgb;
return;
}
BaseType_t queuestatus = xQueueSend(rgbLedQueue, &rgb, 0);
if (queuestatus == pdFALSE) {
delete rgb;
@@ -286,7 +290,7 @@ void ledTask(void* parameter) {
if (rgbQueueFlush) {
delete rgb;
rgb=nullptr;
rgb = nullptr;
} else {
rgbInstructionFadeTime = rgb->fadeTime;
if (rgb->fadeTime <= 1) {

View File

@@ -38,15 +38,42 @@ void timeTask(void* parameter) {
}
void setup() {
// starts the led task/state machine
xTaskCreate(ledTask, "ledhandler", 2000, NULL, 2, NULL);
vTaskDelay(10/portTICK_PERIOD_MS);
// show a nice pattern to indicate the AP is booting / waiting for WiFi setup
#ifdef HAS_RGB_LED
showColorPattern(CRGB::Aqua, CRGB::Green, CRGB::Blue);
#endif
#ifdef OPENEPAPERLINK_MINI_AP_PCB
APEnterEarlyReset();
// this allows us to view the booting process. After connecting to USB, you have 3 seconds to open a terminal on the COM port
// this allows us to view the booting process. After the device showing up, you have 3 seconds to open a terminal on the COM port
vTaskDelay(3000 / portTICK_PERIOD_MS);
#ifdef DEBUG_VERSION
// Specifically for the Mini-version (using an ESP32-S2), use another serial port for debug output. Makes it possible to see core dumps
Serial0.begin(115200, SERIAL_8N1, 38, 37);
Serial0.printf("Started debug output...\n");
Serial0.setDebugOutput(true);
#endif
#endif
Serial.begin(115200);
Serial.print(">\n");
psramInit();
#ifdef BOARD_HAS_PSRAM
if (!psramInit()) {
Serial.printf("This build of the AP expects PSRAM, but we couldn't find/init any. Something is terribly wrong here! System halted.");
#ifdef HAS_RGB_LED
showColorPattern(CRGB::Yellow, CRGB::Red, CRGB::Red);
#endif
while (1) {
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
};
heap_caps_malloc_extmem_enable(64);
#endif
Serial.println("\n\n##################################");
Serial.printf("Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
@@ -73,32 +100,24 @@ void setup() {
}
#ifdef HAS_USB
// We'll need to start the 'usbflasher' task for boards with a second (USB) port. This can be used as a 'flasher' interface, using a python script on the host
xTaskCreate(usbFlasherTask, "usbflasher", 10000, NULL, configMAX_PRIORITIES - 10, NULL);
#endif
xTaskCreate(ledTask, "ledhandler", 5000, NULL, 2, NULL);
configTzTime("CET-1CEST,M3.5.0,M10.5.0/3", "0.nl.pool.ntp.org", "europe.pool.ntp.org", "time.nist.gov");
// https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv
#ifdef HAS_RGB_LED
showColorPattern(CRGB::Aqua, CRGB::Green, CRGB::Blue);
#endif
initAPconfig();
init_web();
init_udp();
#ifdef HAS_RGB_LED
rgbIdle();
#endif
loadDB("/current/tagDB.json");
xTaskCreate(APTask, "AP Process", 10000, NULL, 2, NULL);
xTaskCreate(webSocketSendProcess, "ws", 5000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(timeTask, "timed tasks", 10000, NULL, 2, NULL);
xTaskCreate(APTask, "AP Process", 6000, NULL, 2, NULL);
xTaskCreate(webSocketSendProcess, "ws", 2000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(timeTask, "timed tasks", 12000, NULL, 2, NULL);
}
void loop() {

View File

@@ -124,7 +124,7 @@ bool waitCmdReply() {
#endif
#endif
void APEnterEarlyReset(){
void APEnterEarlyReset() {
pinMode(AP_RESET_PIN, OUTPUT);
digitalWrite(AP_RESET_PIN, LOW);
}
@@ -601,8 +601,8 @@ bool bringAPOnline() {
}
void APTask(void* parameter) {
xTaskCreate(rxCmdProcessor, "rxCmdProcessor", 10000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(rxSerialTask, "rxSerialTask", 4000, NULL, configMAX_PRIORITIES - 4, NULL);
xTaskCreate(rxCmdProcessor, "rxCmdProcessor", 3000, NULL, configMAX_PRIORITIES - 10, NULL);
xTaskCreate(rxSerialTask, "rxSerialTask", 1750, NULL, configMAX_PRIORITIES - 4, NULL);
#if (AP_PROCESS_PORT == FLASHER_AP_PORT)
AP_SERIAL_PORT.begin(115200, SERIAL_8N1, FLASHER_AP_RXD, FLASHER_AP_TXD);
@@ -650,7 +650,7 @@ void APTask(void* parameter) {
Serial.printf("We're going to try to update the AP's FW in\n");
flashCountDown(30);
Serial.printf("\n");
notifySegmentedFlash();
apInfo.isOnline = false;
apInfo.state = AP_STATE_FLASHING;
if (doAPUpdate(apInfo.type)) {