Hi!
I got an ST7789v3 working with the Milk-v Duo
It’s really easy to make it work, here are the instructions on how to do it with the latest SDK.
- Enable the SPI device in the mux config.
Modify the file build/boards/cv180x/cv1800b_milkv_duo_sd/u-boot/cvi_board_init.c
and change with this:
//Default config of sd1 removed as SPI2 will use its pins
// sd1
//PINMUX_CONFIG(SD1_D3, PWR_GPIO_18);
//PINMUX_CONFIG(SD1_D2, PWR_GPIO_19);
//PINMUX_CONFIG(SD1_D1, PWR_GPIO_20);
//PINMUX_CONFIG(SD1_D0, PWR_GPIO_21);
//PINMUX_CONFIG(SD1_CMD, PWR_GPIO_22);
//PINMUX_CONFIG(SD1_CLK, PWR_GPIO_23);
//Enable SPI2
pinmux_config(PINMUX_SPI2);
- Create the ST screen connected to the SPI port in the device tree.
Modify the file build/boards/cv180x/cv1800b_milkv_duo_sd/dts_riscv/cv1800b_milkv_duo_sd.dts
and add this:
&spi2 {
status = "okay";
cs-gpios = <&porta 18 0>;
spidev@0 {
status = "disabled";
};
st7789v: st7789v@0{
compatible = "sitronix,st7789v";
reg = <0>;
status = "okay";
spi-max-frequency = <48000000>;
spi-cpol;
spi-cpha;
rotate = <90>; //This depends on your screen
fps = <60>;
rgb;
buswidth = <8>;
dc-gpios = <&porta 24 GPIO_ACTIVE_HIGH>;
reset-gpios = <&porta 23 GPIO_ACTIVE_HIGH>;
debug = <0x4000000>;
};
};
- Enable the device drivers.
Modify the file build/boards/cv180x/cv1800b_milkv_duo_sd/linux/cvitek_cv1800b_milkv_duo_sd_defconfig
and add this.
CONFIG_SPI_MASTER=y
CONFIG_SPI_DESIGNWARE=y
CONFIG_SPI_DW_MMIO=y
CONFIG_SPI_SPIDEV=y
CONFIG_FB=y
CONFIG_FB_TFT=y
CONFIG_FB_TFT_ST7789V=y
That’s it! With this you should have the fb0 device and you can write to it.
The device is connected like this:
Duo | st7789
GND | GND
3.3v(out) | VCC
GPIO23 | SCL
GPIO22 | SDA
GPIOA23 | RES
GPIOA24 | DC
GPIO18 | CS
Thanks to @firstman as his post has been really helpful to get it working!
Cheers!