Import Arduino Lilygo T-deck project

Hi

I’ve been coding on a project for the Lilygo T-deck for a while, in Arduino IDE. Everything is good and working, but the compiling is so slow. Then i found PlatformIO which is said to be faster so, now I’m trying to import my project to it.

My code is in main.cpp

Having some problems compiling…
Error:

Executing task: C:\Users\Michael\.platformio\penv\Scripts\platformio.exe run --target upload --upload-port COM12 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.11.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20017.241212+sha.dcc1105b 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- CST816S @ 1.3.0+sha.03e28b7
|-- RadioLib @ 7.2.0
|-- TFT_eSPI @ 2.5.43
|-- Time @ 1.6.1
|-- ArduinoJson @ 7.4.2
|-- SensorLib @ 0.3.1
|-- Preferences @ 2.0.0
|-- SPI @ 2.0.0
Building in release mode
Linking .pio\build\esp32dev\firmware.elf
c:/users/michael/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\main.cpp.o: plugin needed to handle lto object
c:/users/michael/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\libFrameworkArduino.a(main.cpp.o): plugin needed to handle lto object
c:/users/michael/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\libFrameworkArduino.a(esp32-hal-uart.c.o): plugin needed to handle lto object
c:/users/michael/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Michael\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib\libfreertos.a(port_common.c.obj):(.literal.main_task+0x18): undefined reference to `app_main'
c:/users/michael/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Michael\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib\libfreertos.a(port_common.c.obj): in function `main_task':
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port/port_common.c:130: undefined reference to `app_main'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32dev\firmware.elf] Error 1
=============================================================================================================== [FAILED] Took 8.78 seconds ===============================================================================================================

 *  The terminal process "C:\Users\Michael\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--upload-port', 'COM12'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

  

Here is my platformio.ini

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

;lib_extra_dirs = ~/Documents/Arduino/libraries

lib_deps =
  https://github.com/fbiego/CST816S.git
  jgromes/RadioLib@7.2.0
  bodmer/TFT_eSPI
  paulstoffregen/Time
  bblanchon/ArduinoJson
  lewisxhe/SensorLib
build_flags = 
  -Os
  -flto
  -DVext=0
  -DTOUCH_CS=-1


Is there anyone who could help me figure out what I need to do and what more information I need to provide.

Discord: epa1337.

Where did you get these settings from?
Please remove them and your project should compile fine.

I think you’ll need a few more settings here to setup TFT_eSPI properly.
See TFT_eSPI/docs/PlatformIO/Configuring options.txt at master · Bodmer/TFT_eSPI · GitHub

I don’t know the Liligo T-deck but isn’t it based on an ESP32-S3 FN16R8? So you might need different settings in your platformio.ini for this board.

; Flash: 16MB QD, PSRAM: 8MB OT
[env:esp32-s3-devkitc-1]
platform = espressif32 @ 6.11.0
board = esp32-s3-devkitc-1
framework = arduino

board_build.arduino.memory_type = qio_opi
board_build.flash_mode = qio
board_build.psram_type = opi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = default_16MB.csv
board_build.extra_flags = 
  -DARDUINO_USB_CDC_ON_BOOT=1
  -DARDUINO_USB_MODE=1
  -DBOARD_HAS_PSRAM

lib_deps =
  https://github.com/fbiego/CST816S.git
  jgromes/RadioLib@7.2.0
  bodmer/TFT_eSPI
  paulstoffregen/Time
  bblanchon/ArduinoJson
  lewisxhe/SensorLib

build_flags = 
  -DTOUCH_CS=-1

See GitHub - sivar2311/ESP32-S3-PlatformIO-Flash-and-PSRAM-configurations: ESP32-S3 PlatformIO Flash and PSRAM configurations

1 Like

This is great stuff. Thank you so much. It now compiles after i removed this

 -Os
  -flto
  -DVext=0

But the device does not boot, reports in serial monitor:

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4203ae5e
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x42009bef  PS      : 0x00060c30  A0      : 0x82009cc4  A1      : 0x3fcebfd0
A2      : 0x00000010  A3      : 0x00000000  A4      : 0x60004000  A5      : 0x0000000d
A6      : 0x000000ff  A7      : 0x00000000  A8      : 0x08000000  A9      : 0x3fcebfa0
A10     : 0x3fc97e74  A11     : 0x00000001  A12     : 0xffffffff  A13     : 0x00000004
A14     : 0x00000000  A15     : 0x00000001  SAR     : 0x00000010  EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000010  LBEG    : 0x4200dfe0  LEND    : 0x4200e044  LCOUNT  : 0x00000000


Backtrace: 0x42009bec:0x3fcebfd0 0x42009cc1:0x3fcec000 0x42009ccc:0x3fcec020 0x42003f31:0x3fcec040 0x4200f2c6:0x3fcec0b0

Ive also changed now to the settings you supplied for platformio.ini.

And still same problem. Stuck rebooting. This should be a problem in my code perhaps, but it works when uploading from Arduino IDE…So still need to find it.

Here is my working settings in the Arduino IDE, can you maybe see what I’m missing in platformio?

You also have to apply the extra settings (flash_mode, psram_type etc etc) I have mentioned above. Use the platformio.ini from my posting above.

I’ve noticed USB Mode: "Hardware CDC and JTAG" and USB CDC On Boot: "Enabled" in your ArduinoIDE settings so i added this to the platformio.ini as well.

1 Like

Thank you very much. Updated my platformio.ini with your newest update and the T-deck compiles / uploads but still stuck rebooting crashing.

ELF file SHA256: 33cbb64b94c6a7ba

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42037f2a
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x42009a17  PS      : 0x00060430  A0      : 0x82009aec  A1      : 0x3fcebfe0
A2      : 0x00000010  A3      : 0x00000000  A4      : 0x60004000  A5      : 0x0000000d
A6      : 0x000000ff  A7      : 0x00000000  A8      : 0x08000000  A9      : 0x3fcebfb0
A10     : 0x3fc980d4  A11     : 0x00000001  A12     : 0xffffffff  A13     : 0x00000004
A14     : 0x00000000  A15     : 0x00000001  SAR     : 0x00000010  EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000010  LBEG    : 0x4200e088  LEND    : 0x4200e0ec  LCOUNT  : 0x00000000


Backtrace: 0x42009a14:0x3fcebfe0 0x42009ae9:0x3fcec010 0x42009af4:0x3fcec030 0x42003d5d:0x3fcec050 0x4200e22e:0x3fcec0b0




ELF file SHA256: 33cbb64b94c6a7ba

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42037f2a
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x42009a17  PS      : 0x00060430  A0      : 0x82009aec  A1      : 0x3fcebfe0
A2      : 0x00000010  A3      : 0x00000000  A4      : 0x60004000  A5      : 0x0000000d
A6      : 0x000000ff  A7      : 0x00000000  A8      : 0x08000000  A9      : 0x3fcebfb0
A10     : 0x3fc980d4  A11     : 0x00000001  A12     : 0xffffffff  A13     : 0x00000004
A14     : 0x00000000  A15     : 0x00000001  SAR     : 0x00000010  EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000010  LBEG    : 0x4200e088  LEND    : 0x4200e0ec  LCOUNT  : 0x00000000


Backtrace: 0x42009a14:0x3fcebfe0 0x42009ae9:0x3fcec010 0x42009af4:0x3fcec030 0x42003d5d:0x3fcec050 0x4200e22e:0x3fcec0b0


Does a simple Blink or “Hello World” sketch work?

platformio.ini

[env:esp32-s3-devkitc-1]
platform = espressif32 @ 6.11.0
board = esp32-s3-devkitc-1
framework = arduino

board_build.arduino.memory_type = qio_opi
board_build.flash_mode = qio
board_build.psram_type = opi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = default_16MB.csv
board_build.extra_flags = 
  -DARDUINO_USB_CDC_ON_BOOT=1
  -DARDUINO_USB_MODE=1
  -DBOARD_HAS_PSRAM

main.cpp

#include <Arduino.h>

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Hello, World!");
  delay(1000);
}
1 Like

Sure thing. So thank you for the help with compiling/uploading to the T-deck. Your settings are totally right. There is just something in my code that does not compile correctly / or the same as in Arduino IDE. Hm…

:+1:

Does your code work in the ArduinoIDE? If so there might be other differences. Check

  • the Arduino Framework version
  • the libraries version

Can you share your project (github or something like that)?
I have an ESP32-S3 N16R8, so it should be compatible. Unfortunately there is no display.

So, I just remembered I had an issue in the Arduino IDE when first beginning to code the T-deck. The library for the screen, TFT_eSPI, is not compatible with ESP32 boardmanager above 2.0.14. Having a higher version gave the same problem, the T-deck constantly rebooting. So I need to downgrade PIO just like I did in board manager in Arduino IDE. Not sure how though. More about this here

To get Espressif Arduino Core 2.0.14 you have to change the platform setting your platformio.ini:

platform = espressif32 @ 6.6.0

For more infos about the version numbers see platform-espressif32 versions · GitHub

Unfortunately the TFT_eSPI library seems to be outdated.

1 Like

This is wonderful. That version-translation was very much needed. Now the code runs on the T-deck, I can see my code printing stuff in Serial Monitor. But the screen is not showing any graphics. Looking in to it after dinner. Your help are very much appreciated.

:+1:
Reading this, it looks like that the macro USE_HSPI_PORT should help.

Adding the following line to your platformio.ini should allow you to use newer Espressif Arduino Core versions including 3.x (*):

build_flags =
  -DUSE_HSPI_PORT

(*) which would require the use of piorarduino:

platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip