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

Zero 2W 64bit port

Open zxfishhack opened this issue 3 years ago • 13 comments

since mmap memory allocate by GPU trigger SIGBUS in 64bit system, I change DMA memory allocate to vcsm-cma. I test only on rpi zero 2w, screen info: ili9341, resolution is 320x240

CMA Usage

root@rpizero:/home/fish# grep -i cma /proc/meminfo
CmaTotal:           8192 kB
CmaFree:            2308 kB

OS info below

root@rpizero:/home/fish# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

/boot/cmdline.txt

console=serial0,115200 root=PARTUUID=b92f61f3-02 rootfstype=ext4 fsck.repair=yes rootwait cma=8M fbcon=map:2

/boot/config.txt

[pi02]
core_freq=420
hdmi_group=2
hdmi_mode=87
hdmi_cvt=240 320 60 1 0 0 0
dtoverlay=cma,cma-size=8M

#43

zxfishhack avatar Mar 29 '22 20:03 zxfishhack

Will this work on 64bit pi4?

mrkprdo avatar Mar 31 '22 14:03 mrkprdo

I don't have a pi4, so I can't test it myself. I think this will work. Add -DAARCH=YES will enable 64bit build.

zxfishhack avatar Mar 31 '22 17:03 zxfishhack

Solid work! Unfortunately it looks like there is a licensing conflict that will prevent from merging this code in :( Part of the code in this PR is licensed under GPL 2, which to my understanding is not compatible with the MIT license.

juj avatar Apr 13 '22 11:04 juj

rewrite CMA allocate code and remove code licensed under GPL 2

zxfishhack avatar Apr 13 '22 12:04 zxfishhack

Thanks for the port. I am not able to get it working on my Pi4 8GB, I get stuck with a 'Bus error' message.

cmake options

cmake -DADAFRUIT_ILI9341_PITFT=ON -DILI9341=ON -DSPI_BUS_CLOCK_DIVISOR=30 -DGPIO_TFT_DATA_CONTROL=26 -DGPIO_TFT_RESET_PIN=22 -DAARCH=YES ..

running fbcp-ili9341

[email protected]:~/fbcp-ili9341/build(rpi2w-64bit-port) ₿ sudo ./fbcp-ili9341 
bcm_host_get_peripheral_address: 0xfe000000, bcm_host_get_peripheral_size: 25165824, bcm_host_get_sdram_address: 0xc0000000
BCM core speed: current: 500000000hz, max turbo: 500000000hz. SPI CDIV: 30, SPI max frequency: 16666667hz
Allocated DMA channel 7
Allocated DMA channel 1
Enabling DMA channels Tx:7 and Rx:1
Bus error

OS Info below

[email protected]:~/fbcp-ili9341/build(rpi2w-64bit-port) ₿ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

[email protected]:~/fbcp-ili9341/build(rpi2w-64bit-port) ₿ uname -a
Linux raspberrypi 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64 GNU/Linux

/boot/config.txt and /boot/cmdline.txt are same as yours. I have also tried setting different DMA ports using DDMA_TX_CHANNEL=0 -DDMA_RX_CHANNEL=5 #262 and tried disabling DMA with no luck.

leandroalbero avatar Apr 13 '22 16:04 leandroalbero

bus error seen it don't enable 64bit port, 64bit port is disable by default. add -DAARCH64=YES will enable new port. and you will see cmake output message "Enable AARCH64 build" and "Enabling Map Memory from CPU instead of GPU"

zxfishhack avatar Apr 13 '22 16:04 zxfishhack

That solved the 'Bus error', now I get an 'vc_dispmanx_display_open failed! Make sure to have hdmi_force_hotplug=1 setting in /boot/config.txt' even with hdmi_force_hotplug set to 1

[email protected]:~ ₿ sudo tvservice -s
state 0xa [HDMI DMT (87) RGB full 4:3 x4], 320x240 @ 27.00Hz, progressive

EDIT: This solved the problem https://github.com/juj/fbcp-ili9341/issues/100#issuecomment-581139331

leandroalbero avatar Apr 13 '22 16:04 leandroalbero

  1. check GL Driver is 'Legacy', GL display driver will lead same error on my rpi zero 2w.(if DMA conflict, try change DMA channel as you mention in #262)
  2. try increase gpu_mem to 64 or higher

zxfishhack avatar Apr 13 '22 16:04 zxfishhack

Tried points 1 (I can't find an option to change to legacy GL driver on Debian 11) and 2. But I can't get the screen to change state, all I get is a white screen. It is connected exactly as it was to my previously working Pi 3, here's the program output:

[email protected]:~/fbcp-ili9341/build(rpi2w-64bit-port) ₿ sudo ./fbcp-ili9341 
bcm_host_get_peripheral_address: 0xfe000000, bcm_host_get_peripheral_size: 25165824, bcm_host_get_sdram_address: 0xc0000000
BCM core speed: current: 500000000hz, max turbo: 500000000hz. SPI CDIV: 30, SPI max frequency: 16666667hz
Allocated DMA channel 7
Allocated DMA channel 1
Enabling DMA channels Tx:7 and Rx:1
Allocated 32768 bytes of GPU memory for DMA control blocks (bus address=0xfbc10000). Total GPU memory used: 32768 bytes
Allocated 921600 bytes of GPU memory for DMA source data (bus address=0xfbe00000). Total GPU memory used: 954368 bytes
Allocated 4096 bytes of GPU memory for DMA constant data (bus address=0xc1801000). Total GPU memory used: 958464 bytes
DMA hardware register file is at ptr: 0x7fb30ea000, using DMA TX channel: 7 and DMA RX channel: 1
DMA hardware TX channel register file is at ptr: 0x7fb30ea700, DMA RX channel register file is at ptr: 0x7fb30ea100
Resetting DMA channels for use
DMA all set up
Initializing display
Resetting display at reset GPIO pin 22
Creating SPI task thread
InitSPI done
DISPLAY_FLIP_ORIENTATION_IN_SOFTWARE: Swapping width/height to update display in portrait mode to minimize tearing.
Relevant source display area size with overscan cropped away: 240x320.
Source GPU display is 240x320. Output SPI display is 240x320 with a drawable area of 240x320. Applying scaling factor horiz=1.00x & vert=1.00x, xOffset: 0, yOffset: 0, scaledWidth: 240, scaledHeight: 320
Creating dispmanX resource of size 240x320 (aspect ratio=0.750000).
GPU grab rectangle is offset x=0,y=0, size w=240xh=320, aspect ratio=0.750000
All initialized, now running main loop...

Thanks for your help :)

leandroalbero avatar Apr 13 '22 17:04 leandroalbero

bus error seen it don't enable 64bit port, 64bit port is disable by default. add -DAARCH64=YES will enable new port. and you will see cmake output message "Enable AARCH64 build" and "Enabling Map Memory from CPU instead of GPU"!``

Hi! This not resolves the bus error for me, I have already built it with that in mind: sudo cmake -DWAVESHARE_ST7789VW_HAT=ON -DGPIO_TFT_DATA_CONTROL=22 -DGPIO_TFT_RESET_PIN=27 -DSPI_BUS_CLOCK_DIVISOR=6 -DSTATISTICS=number -DAARCH64=YES -DDMA_TX_CHANNEL=6 -DDMA_RX_CHANNEL=2 .. I am on 64bit Bullseye (DietPi) (same config and cmdline.txt as yours), Rpi zero 2 w, it's almost a WaveShare 240x240 1.3inch IPS LCD Hat with ST7789VW controller. (https://spotpear.com/index.php/index/product/detail/id/721.html). The building gives me no error, other RX and TX channels are also not helping. Do you have any other advice? Thanks in advance

ustix avatar Jul 16 '22 09:07 ustix

bus error seen it don't enable 64bit port, 64bit port is disable by default. add -DAARCH64=YES will enable new port. and you will see cmake output message "Enable AARCH64 build" and "Enabling Map Memory from CPU instead of GPU"!``

Hi! This not resolves the bus error for me, I have already built it with that in mind: sudo cmake -DWAVESHARE_ST7789VW_HAT=ON -DGPIO_TFT_DATA_CONTROL=22 -DGPIO_TFT_RESET_PIN=27 -DSPI_BUS_CLOCK_DIVISOR=6 -DSTATISTICS=number -DAARCH64=YES -DDMA_TX_CHANNEL=6 -DDMA_RX_CHANNEL=2 .. I am on 64bit Bullseye (DietPi) (same config and cmdline.txt as yours), Rpi zero 2 w, it's almost a WaveShare 240x240 1.3inch IPS LCD Hat with ST7789VW controller. (https://spotpear.com/index.php/index/product/detail/id/721.html). The building gives me no error, other RX and TX channels are also not helping. Do you have any other advice? Thanks in advance

Got it working, with "-DUSE_DMA_TRANSFERS=OFF" switch, but now it is only showing white stripes with a lot of colorful noise in it. Any idea, how to fix this?

ustix avatar Jul 18 '22 14:07 ustix

Hello, Thank you very much for this PR! I just tested it today on my Pi 3B with 64 bit Raspi OS and Waveshare 1.3" LCD and I can confirm that it is working. Although I haven't tested out the refresh rate or in-depth details, I can just confirm that it is drawing well using the Waveshare provided source code.

vineet131 avatar May 07 '23 14:05 vineet131