Problem:
I purchased some t-display compatible boards and wanted to setup them up for some fun projects I have in mind. I generally prefer to use VSCode for my editing over Arduino IDE due to the flexability of control.
Here is what I needed to figure out:
- SPI.h was missing
- Correct Partitions for my board (16MB)
- How to get pio to understand the board as 16MB and not 4MB (the default lilygo configuration value)
- Getting my system to use the littlefs filesystem and not spiffs
- Getting TFT to render following pio upload (worked after arduino IDE upload)
Solutions:
Missing SPI.h, LittleFS.h, FS.h and more
For some reason my build would not find these libraries even though I made sure they existed properly in the esp32 folder. So I included them manually in the platformio.ini file build flags. Once I did this, the system actually healed itself somehow, and I was later able to remove these references.
build_flags =
-I"C:\Users\CorrLabs\.platformio\packages\framework-arduinoespressif32\libraries\SPI\src"
-I"C:\Users\CorrLabs\.platformio\packages\framework-arduinoespressif32\libraries\FS\src"
-I"C:\Users\CorrLabs\.platformio\packages\framework-arduinoespressif32\libraries\LittleFS\src"
Partitions
The huge_app.csv partition scheme would probably work fine, but I wanted to allocate 4MB for app0 and app1 and then have a large chunk for data, so I created my own partition scheme.
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x480000,
app1, app, ota_1, 0x490000,0x480000,
spiffs, data, spiffs, 0x910000,0x6E0000,
coredump, data, coredump,0xFF0000,0x10000,
16MB not 4MB!
Despite having specified that my build.flash_size was 16MB in my platformio.ini file, the system insisted that my board was only 4MB and therefore would complain when trying to upload my filesystem image. I could not find any settings I could set from the ini that would solve this problem. I ended up creating my own board definition by copying lilygo t-display and making one called lilygo-t-display16mb and updated the values inside the file to be for 16MB. I also created the variant folder of the same name with the pins_arduino.h so it would be able to find those by default.
C:\Users\CorrLabs\.platformio\platforms\espressif32\boards\lilygo-t-display.json
C:\Users\CorrLabs\.platformio\platforms\espressif32\boards\lilygo-t-display16mb.json
"build": {
...
"variant": "lilygo_t_display16mb"
},
...
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
...
},
C:\Users\CorrLabs\.platformio\packages\framework-arduinoespressif32\variants
LittleFS
PlatformIO really wanted to make my filesystem SPIFFS, but on certain projects I prefer the safety of littlefs. This seemed to do the trick.
board_build.filesystem = littlefs
TFT Display Issues
I have the display working fine in my Arduino IDE, but for some reason it does not display anything when trying to load a bmp from my LittleFS filesystem. It also would not display a red screen using only the TFT_eSPI library, so I knew it had to be something with the configuration for the TDT display. Oddly, the User_Setup.h file was identical to my Arduino IDE one - and that one worked. The versions of TFT were the same, so I did a Full Clean and reinstalled the one in pio just to be sure. Still no dice.
I was also able to eliminate that something was incorrect with my spiffs partition, as a partition flashed from my PIO project will work fine when connected to firmware flashed by Arduino IDE without flashing the spiffs partition again. This means the problem is exclusively related to the firmware code.
Turns out if you have the right build flags, in your ini - it will work just fine, no User_Setup.h needed and no modifying dependency code:
build_flags =
-D USER_SETUP_LOADED
-D ST7789_DRIVER
-D TFT_WIDTH=135
-D TFT_HEIGHT=240
-D CGRAM_OFFSET
-D TFT_MOSI=19
-D TFT_SCLK=18
-D TFT_CS=5
-D TFT_DC=16
-D TFT_RST=23
-D TFT_BL=4
-D TFT_BACKLIGHT_ON=1
-D SPI_FREQUENCY=40000000
No comments:
Post a Comment