russhughes / st7789_mpy

Fast MicroPython driver for ST7789 display module written in C
Other
538 stars 108 forks source link

Can you provide a firmware for Lilygo T-HMI #127

Closed lesept777 closed 1 year ago

lesept777 commented 1 year ago

The T-HMI from Lilygo is equipped with an ST7789V display 240 x 320 pixels : can you provide a firmware ?

https://github.com/Xinyuan-LilyGO/T-HMI

The display is touch enabled: which library should I use for the touchscreen?

Thanks for your great work!

russhughes commented 1 year ago

For the display, try the S3LCD_OCT_16M firmware from https://github.com/russhughes/s3lcd. For the touch screen, I use: https://github.com/fantasticdonkey/uFT6336U.

lesept777 commented 1 year ago

Thanks, you answered quickly! The display uses an 8 wires connexion : is it compatible?

image

russhughes commented 1 year ago

Yes. Look in the examples/configs/t-hmi folder for configuration settings that work with the T-HMI.

lesept777 commented 1 year ago

I tried to flash the firmware you advised (https://github.com/russhughes/s3lcd/tree/main/firmware/S3LCD_OCT_16M), with no success. Here is what I did:

./python.exe -u -m esptool --chip ESP32S3 --port COM27 erase_flash

This works. Then:

./python.exe -u -m esptool --chip ESP32S3 --port COM27 --baud 460800 write_flash -z 0x0 'C:\Users\fa125436\Downloads\firmware.bin' Here, I got an error message:

esptool.py v4.2.1 Serial port COM27 Connecting......................................

A fatal error occurred: Failed to connect to ESP32-S3: No serial data received. For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html

I get the same error with --chip esp32 and without specifying the baudrate. I tried using the regular firmware, from the Micropython.org website (https://micropython.org/download/GENERIC_S3/) and it worked.

./python.exe -u -m esptool --chip ESP32S3 --port COM26 --baud 460800 write_flash -z 0x0 'C:\Users\fa125436\Downloads\GENERIC_S3-20230426-v1.20.0.bin' esptool.py v4.2.1 Serial port COM26 Connecting... Chip is ESP32-S3 Features: WiFi, BLE Crystal is 40MHz MAC: 34:85:18:8d:57:64 Uploading stub... Running stub... Stub running... Changing baud rate to 460800 Changed. Configuring flash size... Flash will be erased from 0x00000000 to 0x00160fff... Compressed 1443040 bytes to 955816... Wrote 1443040 bytes (955816 compressed) at 0x00000000 in 13.2 seconds (effective 877.5 kbit/s)... Hash of data verified.

Leaving... Hard resetting via RTS pin...

Can you help me?

lesept777 commented 1 year ago

Actually, it seems the board is not responding, I cannot erase the flash anymore, I get the same error. But using Thonny, Micropython seems installed as I get answers from the REPL.

MicroPython v1.20.0 on 2023-04-26; ESP32S3 module with ESP32S3

Type "help()" for more information.

i=12 print(i) 12 python.version Traceback (most recent call last): File "", line 1, in NameError: name 'python' isn't defined color='tre'+str(i) color 'tre12'

lesept777 commented 1 year ago

I first erased the flash then installed the generic firmware (my mistake). From that moment on, it's impossible to erase and install again.

lesept777 commented 1 year ago

I saw the instructions here : https://github.com/russhughes/st7789_mpy/blob/74e55d2711ec769ed9f0366b08135c121054ba3b/firmware/ESP32_BOX_LITE/flash_instructions.md

Now erase flash works, and I can upload the firmware. But the device keeps booting on and on. In Thonny, I get the following message:

invalid header: 0x0a0a0a0a invalid header: 0x0a0a0a0a PROBLEM IN THONNY'S BACK-END: Internal error (serial.serialutil.SerialTimeoutException: Write timeout). See Thonny's backend.log for more info. You may need to press "Stop/Restart" or hard-reset your MicroPython device and try again.

Process ended with exit code 0.

I also tried with instructions from here : https://github.com/russhughes/s3lcd/blob/9c8469426165d19c188d3352429ef586e479d288/README.md

esptool.py --port COM26 erase_flash esptool.py --chip esp32s3 --port COM26 write_flash -z 0x1000 firmware.bin

but I obtain the same result.

russhughes commented 1 year ago

The firmware for the ESP32-S3 must be flashed starting at address 0x0, try:

esptool.py --chip esp32s3 --port COM26 write_flash -z 0x0 firmware.bin

lesept777 commented 1 year ago

I first eras the flash again:

Chip erase completed successfully in 42.8s Hard resetting via RTS pin...

But flashing the firmware is still the same. Wait: maybe I didn't download the firmware successfully, as it's only 136kB!

Now, I downloaded it again, and it works ! Sorry for my mistake! And thanks a lot for your support.

lesept777 commented 1 year ago

The display works perfectly. Now I'm trying the touch...

For the touch screen, I use: https://github.com/fantasticdonkey/uFT6336U.

I think this touch device is using a SPI bus. But this library is for I2C bus.

russhughes commented 1 year ago

You are correct, the uFT6336U is for the wt32-sc01 board. You need an xpt2046 library for the T-HMI.

lesept777 commented 1 year ago

You are right, I found one, I'm trying to use it

lesept777 commented 1 year ago

Hi, I actually wrote my own version of the XPT2046 driver, that I put on Github