About Lilygo TTGO T-Display-GD32

Sunday, November 29, 2020

Longan Nano

t f B! P L
The Lilygo TTGO T-Display-GD32 (hereafter Lilygo T-Display-GD32) is a RISC-V core board that is a clone of the Sipeed Longan Nano (hereafter Longan Nano). I purchased it from Aliexpress.
Lilygo TTGO T-Display-GD32

Differences from Sipeed Longan Nano

The differences from the Longan Nano are as follows:
  • Physical form factor
  • Pin layout (only power-related pins added)
  • LCD resolution and LCD driver
  • LCD backlight control
  • microSD card slot
  • USB Type-C connection and program download notes (important)
The SoC used is exactly the same GD32VF103CBT6 as the Longan Nano, and the board pin layout is nearly identical. However, due to differences in the LCD driver and the presence of backlight control, programs written for the Longan Nano need to be modified when using the LCD.

Physical Form Factor

The Longan Nano PCB size is 46mm x 20mm, while the Lilygo T-Display-GD32 has a larger PCB at 51mm x 26mm due to the larger LCD (both measurements exclude connectors and protrusions). On the Longan Nano, the LCD is placed on top of the main component mounting side, with the LCD attached to the SoC using double-sided tape — a somewhat problematic mounting method. On the Lilygo T-Display-GD32, the main components are mounted on the back side, and the LCD is directly fixed to the PCB for a cleaner design. However, the LCD connector has been eliminated, making LCD removal essentially impossible.

Pin Layout (Power-Related Pins Added)

The pin layout largely follows the Longan Nano's pin positions and order. Thanks to the larger PCB, one additional 3.3V pin has been added (2 total) and three additional GND pins (5 total). On the Longan Nano, there were 8 surface-mount pads (4 on each side) on the opposite edge of the microSD slot, with header pins sandwiching them. On the Lilygo T-Display-GD32, 8 through-hole pads are used with right-angle header pins.

LCD Resolution and LCD Driver

The Longan Nano uses a 0.96-inch 160x80 pixel display with the ST7735S LCD driver. The Lilygo T-Display-GD32 uses a 1.14-inch 240x135 pixel display with the ST7789V LCD driver. The pixel count aspect ratio is 16:9, but the actual drawing area is 24.912mm x 14.864mm, resulting in a Pixel Aspect Ratio (PAR) of approximately 1.0:1.06 — note that squares will appear slightly taller than wide. Since the LCD driver is different, the initialization process must be modified.

LCD Backlight Control

On the Longan Nano, the LCD backlight is always ON. On the Lilygo T-Display-GD32, it can be controlled via a transistor connected to the PB10 pin (PB10 HIGH = backlight ON). Since the backlight LED circuit directly switches 3.3V via the transistor, leaving it always ON may be too bright and could cause overcurrent. PWM control as described below is recommended.

microSD Card Slot

The Longan Nano has a small push-in slot without a locking mechanism, which raises some concerns about card retention. The Lilygo T-Display-GD32 has a standard push-to-lock/push-to-eject slot that clicks into place.

USB Type-C Connection and Program Download Notes (Important)

This may be specific to my PC environment, but surprisingly, the USB Type-C connector orientation matters. USB Type-C connectors are designed to be reversible through symmetrical A-side/B-side wiring, but the Lilygo T-Display-GD32's USB Type-C connector has differences between the A-side and B-side wiring. Specifically, the CC-related pins that should be pulled down to indicate the device side are left open on one side.
USB Type-C connector wiring differences

As a result, depending on the connector orientation, the board may or may not be recognized as a DFU device. Whether directly related or not, the DFU plugin in the PlatformIO environment frequently appears to complete programming successfully but actually fails. On the other hand, the GD32 MCU Dfu Tool (v3.8.1.5784) released by GigaDevice always programs successfully when the Type-C orientation is correct. Therefore, even for projects built in the PlatformIO environment, I download the firmware.bin file from the project folder \.pio\build\sipeed-longan-nano\ using the GD32 MCU Dfu Tool.
Downloading with Dfu Tool

Sample Project

The following sample project is available from Lilygo's official(?) repository:
I needed to modify the board section in platformio.ini as follows:
; board = sipeed-longan-nano-lite
board = sipeed-longan-nano

By placing the logo.bin file from the resource folder into the root folder of the microSD card and booting, you can view a Lilygo logo animation demo.

PWM Backlight Control

To control the backlight via PWM, Timer1 Ch2 must be enabled, and pin PB10 must be set to Alternate Function mode with Timer1 Partial Remap mode 1.
Timer1 Remap assignment


The following functions were prepared for initializing a 10 KHz PWM signal and setting the ON-time ratio from 0 to 100 (%):
// PWM for PB10 (Timer1 Ch2: partial remap1, alternate function)
void timer1_pwm_init(void)
{
    ... (same as original)
}

// on_term: 0 ~ 100 (%)
void timer1_pwm_set_ratio(uint16_t on_term)
{
    timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_2, on_term);
}
A modified version of the Lilygo sample project with PWM backlight control and microSD exFAT support is available below.
A PWM ON-time ratio of 50 is already very bright, and even a value of 1 is sufficient in dark environments. The sample cycles between 0 and 50.

PWM backlight control sample:

Additional Resources


Other resources for the Longan Nano can be used as is:


About Me

My photo
Electronics, programming & audio

Featured Post

Synchronizing Radio-Controlled Clocks with Raspberry Pi Pico W (JJY Standard Radio Wave Emulator)

As a Raspberry Pi Pico W application, I built a JJY emulator for radio-controlled clocks (for time synchronization) with minimal peripheral...

QooQ