Hi,
Has anyone got a ST7789V Waveshare 240x240 display to work under PlatformIO/Zephyr on a nRF52840, STM32 or another similar MCU?
I’ve tried to get a ST7789V running on nRF52840 (Particle Xenon) and
STM32 (blackpill_f411ce) boards but ran into a problem. I’m not sure if it is an error in
configuration or possibly a bug associated with the ST7789V driver.
An earlier version of Zephyr had a sample code for ST87789V display but the sample got removed in the recent releases.
I’ve found that although I have the correct devicetree label for the ST7789V and
the physical display hookup matches the overlay, a call to device_get_binding() from main.c fails to bind correctly. A NULL display device handle gets returned with a
“app: Device ST7789V not found. Aborting test.”
Below is my setup and Zephyr configuration for review.
Can someone please chime in and suggest what I may be doing incorrectly or possibly missing?
I thought I may share the info before following up with the Zephyr folks, in case someone has used a ST7789V with Zephyr and ran into similar issues.
Any assistance would be much appreciated! Thank you.
Development Environment:
PlatformIO Core: 5.0.4
VSC: 1.52.1
Host: macOS Mojave 10.14.6
PlatformIO Framework: Zephyr
Target: Particle Xenon
Debug: Segger Edu Mini J-Link
particle_xenon.overlay:
/*
* Particle Xenon with Waveshare ST7789V (240x240)
*
* Xenon ST7789V
* P0.18 (RESET) RST
* P1.15 (SPI_SCK) SPI_SCK
* P1.14 (SPI_MISO) -
* P1.13 (SPI_MOSI) SPI_MOSI
* P1.10 (D5) DC (DATA/CMD)
* P1.08 (D4) CS
* GND GND
* 3V3 VCC
*
*/
/ {
aliases {
wave = &waveshare_device;
};
};
&spi0 {
status = "okay";
sck-pin = <47>;
mosi-pin = <45>;
miso-pin = <46>;
cs-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>; /* D4 */
waveshare_device: st7789v@0 {
compatible = "sitronix,st7789v";
label = "ST7789V";
spi-max-frequency = <20000000>;
reg = <0>;
cmd-data-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>; /* D5 */
reset-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; /* RESET */
width = <240>;
height = <240>;
x-offset = <0>;
y-offset = <0>;
vcom = <0x19>;
gctrl = <0x35>;
vrhs = <0x12>;
vdvs = <0x20>;
mdac = <0x00>;
lcm = <0x2c>;
colmod = <0x05>;
gamma = <0x01>;
porch-param = [0c 0c 00 33 33];
cmd2en-param = [5a 69 02 01];
pwctrl1-param = [a4 a1];
pvgam-param = [D0 04 0D 11 13 2B 3F 54 4C 18 0D 0B 1F 23];
nvgam-param = [D0 04 0C 11 13 2C 3F 44 51 2F 1F 1F 20 23];
ram-param = [00 F0];
rgb-param = [CD 08 14];
};
};
prj.conf:
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_GPIO=y
CONFIG_SPI_0=y
CONFIG_ST7789V=y
CONFIG_ST7789V_RGB565=y
CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
CONFIG_LOG_IMMEDIATE=y
CONFIG_DISPLAY=y
CONFIG_DISPLAY_LOG_LEVEL_DBG=y
platformio.ini:
[platformio]
default_envs = xenon
[env:xenon]
platform = nordicnrf52
framework = zephyr
board = particle_xenon
build_flags = -DSHIELD_ST7789V_WAVESHARE_240X240
upload_protocol = jlink
debug_tool = jlink
debug_init_break = tbreak main
monitor_speed = 115200
From main.c:
...
...
display_dev = device_get_binding(DT_INST_0_SITRONIX_ST7789_LABEL)
if (display_dev == NULL) {
LOG_ERR("Device %s not found. Aborting test.", label);
return;
}
...
...
From z_impl_device_get_binding():
In the call to /framework-zephyr/kernel/device.c/z_impl_device_get_binding()/:
- search for device names doesn't see any ST7789V device
- only the following devices are found
UART0
CLOCK
sys_clock
GPIO_0
GPIO_1
- No ST7789V is found and returns a NULL display_dev pointer
- LOG_ERR printed to UART0
Serial UART0 output
10:43:00.891 -> *** Booting Zephyr OS build zephyr-v20400 ***
10:43:00.891 ->
[00:00:12.298,065] e[0m<inf> app: Waveshare ST7789V display samplee[0m
10:43:14.012 -> Particle Xenon with Waveshare ST7789V...
10:43:14.012 ->
[00:05:15.421,020] e[1;31m<err> app: Device ST7789V not found. Aborting test.e[0m
From the generated devicetree_unfixed.h
/* Node parent (/soc/spi@40003000) identifier: */
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_PARENT DT_N_S_soc_S_spi_40003000
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_FOREACH_CHILD(fn)
/* Existence and alternate IDs: */
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_EXISTS 1
#define DT_N_ALIAS_wave DT_N_S_soc_S_spi_40003000_S_st7789v_0
#define DT_N_INST_0_sitronix_st7789v DT_N_S_soc_S_spi_40003000_S_st7789v_0
#define DT_N_NODELABEL_waveshare_device DT_N_S_soc_S_spi_40003000_S_st7789v_0
/* Special property macros: /
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_REG_NUM 1
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_REG_IDX_0_EXISTS 1
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_REG_IDX_0_VAL_ADDRESS 0 / 0x0 */
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_IRQ_NUM 0
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_COMPAT_MATCHES_sitronix_st7789v 1
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_STATUS_okay 1
/* Generic property macros: /
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_compatible {“sitronix,st7789v”}
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_compatible_IDX_0 “sitronix,st7789v”
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_compatible_LEN 1
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_compatible_EXISTS 1
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_label “ST7789V”
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_label_EXISTS 1
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_reg {0 / 0x0 */}
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_reg_IDX_0 0
#define DT_N_S_soc_S_spi_40003000_S_st7789v_0_P_reg_EXISTS 1