Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero 2W 64bit port #261

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

zxfishhack
Copy link

@zxfishhack zxfishhack commented Mar 29, 2022

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

@mrkprdo
Copy link

mrkprdo commented Mar 31, 2022

Will this work on 64bit pi4?

@zxfishhack
Copy link
Author

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.

@juj
Copy link
Owner

juj commented Apr 13, 2022

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.

@zxfishhack
Copy link
Author

rewrite CMA allocate code and remove code licensed under GPL 2

@leandroalbero
Copy link

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.

@zxfishhack
Copy link
Author

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"

@leandroalbero
Copy link

leandroalbero commented Apr 13, 2022

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 #100 (comment)

@zxfishhack
Copy link
Author

  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 vc_dispmanx_display_open: command not found #262)
  2. try increase gpu_mem to 64 or higher

@leandroalbero
Copy link

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 :)

@ustix
Copy link

ustix commented Jul 16, 2022

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
Copy link

ustix commented Jul 18, 2022

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?

@vineet131
Copy link

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.

spi.cpp Outdated
@@ -553,10 +568,11 @@ int InitSPI()
// Set the SPI 0 pin explicitly to output, and enable chip select on the line by setting it to low.
// fbcp-ili9341 assumes exclusive access to the SPI0 bus, and exclusive presence of only one device on the bus,
// which is (permanently) activated here.
SET_GPIO_MODE(GPIO_SPI0_CE0, 0x01);
CLEAR_GPIO(GPIO_SPI0_CE0);
SET_GPIO_MODE(GPIO_SPI0_CE1, 0x01);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably didn't mean to permanently change this to CS1 outside of the #ifdef DISPLAY_USES_CS1 below?

hakmo added a commit to hakmo/fbcp-ili9341 that referenced this pull request Nov 10, 2023
@arrio464
Copy link

Works well for me.
If you do #100 (comment) but it has no effect, you can try sn-lab/MouseGoggles#23

Here is my cmdline on RPI4:

coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1 clk_ignore_unused smsc95xx.macaddr=D8:3A:DD:8E:6B:31 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=ttyS0,115200 multipath=off dwc_otg.lpm_enable=0 console=tty1 root=LABEL=writable rootfstype=ext4 rootwait fixrtc

@zxfishhack zxfishhack changed the title Rpi2w 64bit port Zero 2W 64bit port May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants