Skip to content

Commit

Permalink
Lilygo T-DISPLAY S3: Enable PSRAM and 16MB Flash
Browse files Browse the repository at this point in the history
* Enabled PSRAM memory (+8MB usable RAM)
 - This setting is crucial:
     board_build.arduino.memory_type = qio_opi
* Use 16MB flash partition scheme
 - A custom one with 16MB-1Byte size is used to workaround a tool
   bug when trying to upload full 16MB
   see espressif/esptool#795 (comment)
- Add PSRAM to info web page
  • Loading branch information
Norbert Schulz committed Dec 4, 2022
1 parent fa9637d commit 0c57b67
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 65 deletions.
53 changes: 51 additions & 2 deletions data/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ <h3 class="mt-1">Heap</h3>
</table>
</div>
<canvas id="canvasChartHeap" width="240" height="240"></canvas>
<h3 class="mt-1">PSRAM</h3>
<div class="table-responsive">
<table class="table table-striped">
<thead class="thead-light">
<tr>
<th scope="col">Description</th>
<th scope="col">Result</th>
</tr>
</thead>
<tbody class="text-light">
<tr>
<td>PSRAM size</td>
<td>~PSRAM_SIZE~ byte</td>
</tr>
<tr>
<td>Available PSRAM Size</td>
<td id="availablePsramSize">~PSRAM_SIZE_AVAILABLE~ byte</td>
</tr>
<tr>
<td>Used PSRAM Size</td>
<td id="usedPsramSize"></td>
</tr>
</tbody>
</table>
</div>
<canvas id="canvasChartPsram" width="240" height="240"></canvas>
<h2 class="mt-1">MCU</h2>
<div class="table-responsive">
<table class="table table-striped">
Expand Down Expand Up @@ -195,7 +221,7 @@ <h2 class="mt-1">Filesystem</h2>
<canvas id="canvasChartFs" width="240" height="240"></canvas>
</div>
</main>

<!-- Footer -->
<footer class="footer mt-auto py-3">
<div class="container">
Expand All @@ -217,6 +243,8 @@ <h2 class="mt-1">Filesystem</h2>
<script>
var availableHeapSize = parseInt("~HEAP_SIZE_AVAILABLE~");
var heapSize = parseInt("~HEAP_SIZE~");
var availablePsramSize = parseInt("~PSRAM_SIZE_AVAILABLE~");
var psramSize = parseInt("~PSRAM_SIZE~");
var filesystemSize = parseInt("~FS_SIZE~");
var usedFilesystemSize = parseInt("~FS_SIZE_USED~");

Expand All @@ -236,8 +264,11 @@ <h2 class="mt-1">Filesystem</h2>
usedFilesystemSize = 1
}

var availableFsSize = filesystemSize - usedFilesystemSize;
var availableHeapSizeInPercent = Math.round(availableHeapSize * 100 / heapSize);
var availableFsSizeInPercent = Math.round((filesystemSize - usedFilesystemSize) * 100 / filesystemSize);
var availablePsramSizeInPercent = Math.round(availablePsramSize * 100 /psramSize);
var availableFsSizeInPercent = Math.round(availableFsSize * 100 / filesystemSize);
document.getElementById("availableFsSize").innerHTML = availableFsSize + " byte";

window.chartColors = {
red: "rgb(255, 99, 132)",
Expand Down Expand Up @@ -265,9 +296,27 @@ <h2 class="mt-1">Filesystem</h2>
values: [100 - availableHeapSizeInPercent, availableHeapSizeInPercent],
colors: [window.chartColors.red, window.chartColors.green]
});

/* Draw the chart, showing the current situation on the heap. */
generatePieGraph("canvasChartPsram", {
animation: true,
animationSpeed: 20,
fillTextData: true,
fillTextColor: "#fff",
fillTextPosition: "inner",
doughnutHoleColor: "#000",
doughnutHoleSize: 20,
offset: 1,
values: [100 - availablePsramSizeInPercent, availablePsramSizeInPercent],
colors: [window.chartColors.red, window.chartColors.green]
});
$("#availableHeapSize").css("background-color", window.chartColors.green);
$("#usedHeapSize").text("" + (heapSize - availableHeapSize) + " byte");
$("#usedHeapSize").css("background-color", window.chartColors.red);
$("#availablePsramSize").css("background-color", window.chartColors.green);
$("#usedPsramSize").text("" + (psramSize - availablepsramSize) + " byte");
$("#usedPsramSize").css("background-color", window.chartColors.red);


/* Draw the chart, showing the current situation on the filesystem. */
generatePieGraph("canvasChartFs", {
Expand Down
10 changes: 10 additions & 0 deletions partitionTables/custom_16MB.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x640000,
app1, app, ota_1, 0x650000,0x640000,

# full 16MB not useable, see https://github.com/espressif/esptool/issues/795#issuecomment-1321487813
# use 1 byte less to avoid upload error
#spiffs, data, spiffs, 0xc90000,0x370000,
spiffs, data, spiffs, 0xc90000,0x36FFFF,
112 changes: 57 additions & 55 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ build_flags =
-DTFT_MATRIX_HEIGHT=8U
-DTFT_PIXEL_WIDTH=6
-DTFT_PIXEL_HEIGHT=6
-DPIXEL_DISTANCE=1
-DTFT_BRIGHTNESS=127
-DTFT_PIXEL_DISTANCE=1
-DTFT_DEFAULT_BRIGHTNESS=127
lib_deps_builtin =
HalTtgoTDisplay
lib_deps_external =
Expand All @@ -170,6 +170,54 @@ lib_ignore_builtin =
HalLedMatrix
lib_ignore_external =


; ********************************************************************************
; TTGO T-Display S3
; https://github.com/Xinyuan-LilyGO/T-Display-S3
; ********************************************************************************
[display:ttgo_tdisplay-S3]
build_flags =
-DUSER_SETUP_LOADED=1
-DST7789_DRIVER
-DTFT_PARALLEL_8_BIT
-DCGRAM_OFFSET
-DTFT_INVERSION_ON
-DTFT_RGB_ORDER=TFT_BGR
-DTFT_WIDTH=170
-DTFT_HEIGHT=320
-DTFT_CS=6
-DTFT_DC=7
-DTFT_RST=5
-DTFT_WR=8
-DTFT_RD=9
-DTFT_DATA_PIN_OFFSET_EN
-DTFT_BL=38
-DTFT_D0=39
-DTFT_D1=40
-DTFT_D2=41
-DTFT_D3=42
-DTFT_D4=45
-DTFT_D5=46
-DTFT_D6=47
-DTFT_D7=48
-DSPI_FREQUENCY=5000000
-DSPI_READ_FREQUENCY=2000000
-DSPI_TOUCH_FREQUENCY=2500000
-DDISABLE_ALL_LIBRARY_WARNINGS
-DTFT_MATRIX_WIDTH=32U
-DTFT_MATRIX_HEIGHT=8U
-DTFT_PIXEL_WIDTH=8
-DTFT_PIXEL_HEIGHT=8
-DTFT_PIXEL_DISTANCE=1
-DTFT_DEFAULT_BRIGHTNESS=200
lib_deps_builtin =
HalTtgoTDisplay
lib_deps_external =
https://github.com/nhjschulz/TFT_eSPI
lib_ignore_builtin =
HalLedMatrix
lib_ignore_external =

; ********************************************************************************
; Common for programming via USB
; ********************************************************************************
Expand Down Expand Up @@ -400,19 +448,22 @@ extra_scripts =
${common:prog_usb.extra_scripts}

; ********************************************************************************
; TTGO T-Display ESP32 WiFi and Bluetooth Module Development Board
; TTGO T-Display ESP32 S3 WiFi and Bluetooth Module Development Board
; ********************************************************************************
[board:ttgo-t-display-S3]
extends = common:esp32_env, display:ttgo_tdisplay-S3
board = esp32-s3-devkitc-1
board_build.partitions = default_8MB.csv
board_name = "Lilygo TTGO T-Display S3 (16 MB QD, 8MB PSRAM)",
board_build.arduino.memory_type = qio_opi
board_build.partitions = ./partitionTables/custom_16MB.csv
board_build.filesystem = littlefs
board_upload.flash_size = "8MB"
board_upload.maximum_size = 8388608
board_upload.maximum_size = 16777216
board_upload.flash_size = 16MB
build_flags =
${common:esp32_env.build_flags}
${display:ttgo_tdisplay-S3.build_flags}
-DBOARD_LILYGO_T_DISPLAY_S3
-DBOARD_HAS_PSRAM
lib_deps =
${common:esp32_env.lib_deps_builtin}
${common:esp32_env.lib_deps_external}
Expand All @@ -426,55 +477,6 @@ lib_ignore =
extra_scripts =
pre:./scripts/get_git_rev.py



; ********************************************************************************
; TTGO T-Display S3
; https://github.com/Xinyuan-LilyGO/T-Display-S3
; ********************************************************************************
[display:ttgo_tdisplay-S3]
build_flags =
-DUSER_SETUP_LOADED=1
-DST7789_DRIVER
-DTFT_PARALLEL_8_BIT
-DCGRAM_OFFSET
-DTFT_INVERSION_ON
-DTFT_RGB_ORDER=TFT_BGR
-DTFT_WIDTH=170
-DTFT_HEIGHT=320
-DTFT_CS=6
-DTFT_DC=7
-DTFT_RST=5
-DTFT_WR=8
-DTFT_RD=9
-DTFT_DATA_PIN_OFFSET_EN
-DTFT_BL=38
-DTFT_D0=39
-DTFT_D1=40
-DTFT_D2=41
-DTFT_D3=42
-DTFT_D4=45
-DTFT_D5=46
-DTFT_D6=47
-DTFT_D7=48
-DSPI_FREQUENCY=5000000
-DSPI_READ_FREQUENCY=2000000
-DSPI_TOUCH_FREQUENCY=2500000
-DDISABLE_ALL_LIBRARY_WARNINGS
-DTFT_MATRIX_WIDTH=32U
-DTFT_MATRIX_HEIGHT=8U
-DTFT_PIXEL_WIDTH=8
-DTFT_PIXEL_HEIGHT=8
-DTFT_PIXEL_DISTANCE=1
-DTFT_BRIGHTNESS=200
lib_deps_builtin =
HalTtgoTDisplay
lib_deps_external =
https://github.com/nhjschulz/TFT_eSPI
lib_ignore_builtin =
HalLedMatrix
lib_ignore_external =

; ********************************************************************************
; Adafruit ESP32 Feather V2 - LED matrix
; ********************************************************************************
Expand Down
18 changes: 10 additions & 8 deletions src/Web/Pages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ static TmplKeyWordFunc gTmplKeyWordToFunc[] =
"FS_SIZE_USED", []() -> String { return String(FILESYSTEM.usedBytes()); },
"HEAP_SIZE", []() -> String { return String(ESP.getHeapSize()); },
"HEAP_SIZE_AVAILABLE", []() -> String { return String(ESP.getFreeHeap()); },
"PSRAM_SIZE", []() -> String { return String(ESP.getPsramSize()); },
"PSRAM_SIZE_AVAILABLE", []() -> String { return String(ESP.getFreePsram()); },
"HOSTNAME", tmpl::getHostname,
"IPV4", tmpl::getIPAddress,
"LWIP_VERSION", []() -> String { return LWIP_VERSION_STRING; },
Expand Down Expand Up @@ -646,7 +648,7 @@ namespace tmpl
{
/**
* Get ESP chip id.
*
*
* @return ESP chip id
*/
static String getEspChipId()
Expand All @@ -666,7 +668,7 @@ namespace tmpl

/**
* Get ESP type.
*
*
* @return ESP type
*/
static String getEspType()
Expand All @@ -685,7 +687,7 @@ namespace tmpl

/**
* Get flash chip mode.
*
*
* @return Flash chip mode.
*/
static String getFlashChipMode()
Expand Down Expand Up @@ -725,13 +727,13 @@ namespace tmpl
result = "UNKNOWN";
break;
}

return result;
}

/**
* Get hostname, depended on current WiFi mode.
*
*
* @return Hostname
*/
static String getHostname()
Expand All @@ -758,7 +760,7 @@ namespace tmpl

/**
* Get IP address, depended on WiFi mode.
*
*
* @return IPv4
*/
static String getIPAddress()
Expand All @@ -779,7 +781,7 @@ namespace tmpl

/**
* Get wifi RSSI.
*
*
* @return WiFi station SSID
*/
static String getRSSI()
Expand All @@ -803,7 +805,7 @@ namespace tmpl

/**
* Get wifi station SSID.
*
*
* @return WiFi station SSID
*/
static String getSSID()
Expand Down

0 comments on commit 0c57b67

Please sign in to comment.