fbcp-ili9341 icon indicating copy to clipboard operation
fbcp-ili9341 copied to clipboard

Screen only works with `-DUSE_DMA_TRANSFERS=OFF`

Open golgobot opened this issue 5 years ago • 5 comments

Setup

  • Pi Zero W
  • 1.54" 240x240 ST7789
  • Stock Raspbian OS
  • Compiling on the Pi

/boot/config.txt

hdmi_group=2
hdmi_mode=87
hdmi_cvt=240 240 60 1 0 0 0
hdmi_force_hotplug=1

Build Command

When compiling with DMA transfers OFF the screen works great for about 30 seconds, then, very suddently, it suddenly turns into static.

image

cmake \
    -DST7789=ON \
    -DGPIO_TFT_RESET_PIN=24 \
    -DGPIO_TFT_DATA_CONTROL=25 \
    -DSPI_BUS_CLOCK_DIVISOR=40 \
    -DUSE_DMA_TRANSFERS=OFF \
    -DDISPLAY_ROTATE_180_DEGREES=ON \
    ..

When compiling with the option turned on, there's just a black screen (the backlight is on though). There are no errors from running sudo ./fbcp-ili9341

image

cmake \
    -DST7789=ON \
    -DGPIO_TFT_RESET_PIN=24 \
    -DGPIO_TFT_DATA_CONTROL=25 \
    -DSPI_BUS_CLOCK_DIVISOR=40 \
    -DUSE_DMA_TRANSFERS=ON \
    -DDISPLAY_ROTATE_180_DEGREES=ON \
    ..

I've tried playing around with RX and TX channels, but I'm not really sure what those are, so I tried different numbers for both. Always had the black screen. I've also played around with clock divisor testing numbers from 8 to 50 all with exactly the same results in both cases above.

golgobot avatar Jan 26 '20 22:01 golgobot

Running into the same issue on Pi Zero w https://learn.adafruit.com/2-0-inch-320-x-240-color-ips-tft-display

WeiDongGitHub avatar Mar 10 '20 07:03 WeiDongGitHub

I didn't dig too far, but I noticed with the Pi Zero & Zero W, ALL_TASKS_SHOULD_DMA is enabled, which enables a bunch of optimizations. I got this ST7789 working with DMA by removing ALL_TASKS_SHOULD_DMA from config.h.

jessa0 avatar Oct 18 '20 23:10 jessa0

I also using pizero and nope doesn't work if ALL_TASKS_SHOULD_DMA enabled.

DrJaymz avatar Apr 21 '21 17:04 DrJaymz

I didn't dig too far, but I noticed with the Pi Zero & Zero W, ALL_TASKS_SHOULD_DMA is enabled, which enables a bunch of optimizations. I got this ST7789 working with DMA by removing ALL_TASKS_SHOULD_DMA from config.h.

That 'fixed' my problem but did it actually turn it off?

DrJaymz avatar Apr 21 '21 17:04 DrJaymz

That 'fixed' my problem but did it actually turn it off?

ALL_TASKS_SHOULD_DMA is activated here:

https://github.com/juj/fbcp-ili9341/blob/7c4a05aabc1d88e22eb126ccb18835ebfbd28853/config.h#L116

IIRC, it seemed like some of the code that ALL_TASKS_SHOULD_DMA enabled wasn't actually related to DMA, but rather other optimizations geared toward getting acceptable performance on the Pi Zero for example. I didn't test whether they were the cause for sure, but they seemed suspiciously dangerous/sketchy to me.

Edit: this is the hand-written optimized asm I'm referring to:

https://github.com/juj/fbcp-ili9341/blob/7c4a05aabc1d88e22eb126ccb18835ebfbd28853/dma.cpp#L400

It seems the ALL_TASKS_SHOULD_DMA functionality could be written in C without the hand-written ASM.

jessa0 avatar Apr 21 '21 19:04 jessa0