pimoroni / hyperpixel4

Driver for the Pimoroni HyperPixel 4.0" Touchscreen Display
https://shop.pimoroni.com/products/hyperpixel-4?variant=12569485443155
320 stars 43 forks source link

PSA: HyperPixel 4 (Square & Rectangular) on Raspberry Pi OS 64bit 2022-04-04 #177

Open Gadgetoid opened 2 years ago

Gadgetoid commented 2 years ago

:information_source: See this comment for rotation in Raspberry Pi Desktop screen configuration - https://github.com/pimoroni/hyperpixel4/issues/177#issuecomment-1786957639

:warning: PSA: Make sure you disable i2c, SPI and any other interfaces since these will cause a conflict in device-tree with HyperPixel :warning:

:warning: A fresh image is recommended, but otherwise make sure you also disable the hyperpixel4-init system service! :warning:

Pi 3B and Pi 4 users running the latest and greatest Raspberry Pi OS should forego our installer and use the instructions below.

:information_source: If you're tied to an older OS and you want to install the legacy drivers, use: curl -sSL get.pimoroni.com/hyperpixel4-legacy | bash

This new OS can currently be found in Raspberry Pi Imager under "Raspberry Pi OS (Other)"

image

Once installed you need only one line in /boot/config.txt:

You can rotate these in config.txt by adding the rotate= parameter, like so:

dtoverlay=vc4-kms-dpi-hyperpixel4sq,rotate=90

This supports rotation in console, too, for all you CyberDeck builders!

HyperPixel 4 Rectangular Rotations

Ensure rotation is set to "Normal" in "Display Configuration"

And that the dtoverlay is in /boot/config.txt:

dtoverlay=vc4-kms-dpi-hyperpixel4

Finally use one of the following dtparam lines immediately underneath to set the parameters:

HyperPixel 4 Square Rotations

HyperPixel 4 Square does not correctly swap or invert touch input, so you may want to use the Xorg config method below.

Ensure rotation is set to "Normal" in "Display Configuration"

And that the dtoverlay is in /boot/config.txt:

dtoverlay=vc4-kms-dpi-hyperpixel4sq

Finally use one of the following dtparam lines immediately underneath to set the parameters:

:warning: The touchscreen-swapped-x-y parameter does not seem to work with Square. You may need to use the script below for Raspberry Pi OS with Desktop.

On the fly rotation

Rotating the display via "Screen Configuration" ("arandr") results in inverted touch input and other weirdness- use the dtoverlay params.

If you want to rotate on the fly you can use the below bash script to rotate either display and persist settings into Xorg configuration files.

:warning: Note: You must remove the rotate= argument from /boot/config.txt for these to make sense.

You can remove the rotation config by deleting the /usr/share/X11/xorg.conf.d/88-hyperpixel4-touch.conf and /usr/share/X11/xorg.conf.d/88-dsi-1-rotate.conf files.

#!/bin/bash

UTILITY="hyperpixel4-rotate (Rectangular)"
XORG_TOUCH_CONF_FILE="/usr/share/X11/xorg.conf.d/88-hyperpixel4-touch.conf"
XORG_CONF_FILE="/usr/share/X11/xorg.conf.d/88-dsi-1-rotate.conf"

OVERLAY_S="vc4-kms-dpi-hyperpixel4sq"
OVERLAY_R="vc4-kms-dpi-hyperpixel4"

function success() {
    echo -e "$(tput setaf 2)$1$(tput sgr0)"
}

function inform() {
    echo -e "$(tput setaf 6)$1$(tput sgr0)"
}

function warning() {
    echo -e "$(tput setaf 1)$1$(tput sgr0)"
}

function set_xorg_conf {
    if [ "$DISPLAY" == "" ]; then
        inform "No DISPLAY variable set, trying :0.0"
        export DISPLAY=:0.0
    fi

    inform "Rotating display $1";
    xrandr --output DPI-1 --rotate $1

    MATRIX="$2 $3 $4 $5 $6 $7 $8 $9 ${10}"

    inform "Setting libinput Calibration Matrix: 1 0 0 0 1 0";
    xinput set-prop "pointer:$DEVICE" "libinput Calibration Matrix" 1 0 0 0 1 0 0 0 1

    inform "Setting Coordinate Transformation Matrix: $MATRIX";
    xinput set-prop "pointer:$DEVICE" "Coordinate Transformation Matrix" $MATRIX

    inform "Saving xorg touch config to $XORG_TOUCH_CONF_FILE";
    sudo tee $XORG_TOUCH_CONF_FILE > /dev/null <<EOF
# Auto generated by $UTILITY, edit with care!

Section "InputClass"
    Identifier "HyperPixel4 $DEVICE"
    MatchProduct "$DEVICE"
    Option "CalibrationMatrix" "1 0 0 0 1 0 0 0 1"
    Option "TransformationMatrix" "$MATRIX"
EndSection
EOF

    inform "Saving xorg rotate config to $XORG_CONF_FILE";
    sudo tee $XORG_CONF_FILE > /dev/null <<EOF
# Auto generated by $UTILITY, edit with care!

Section "Monitor"
    Identifier "DPI-1"
    Option "Rotate" "$1"
EndSection
EOF
}

printf "HyperPixel 4: Display & Touch Rotation\n"
printf "This utility requires the Raspberry Pi OS desktop or an *Xorg-based* alternative.\n\n"

ORIENTATION=$1

grep -e "^dtoverlay=$OVERLAY_S.*" /boot/config.txt > /dev/null
if [ $? -ne 0 ]; then
    grep -e "^dtoverlay=$OVERLAY_R.*" /boot/config.txt > /dev/null
    if [ $? -ne 0 ]; then
        warning "Rotation requires hardware support on the Pi 4 or Pi 400"
        warning "Ensure your HyperPixel4 is enabled in /boot/config.txt"
    printf "\nSquare:      dtoverlay=$OVERLAY_S\n"
    printf "Rectangular: dtoverlay=$OVERLAY_R\n\n"
        exit 1
    else
        inform "Detected HyperPixel 4 Rectangular (found \"$OVERLAY_R\" in config.txt)"
        DEVICE="Goodix Capacitive TouchScreen"
    fi
else
    inform "Detected HyperPixel 4 Square (found \"$OVERLAY_S\" in config.txt)"
    DEVICE="EP0110M09"
fi

case $ORIENTATION in
    "right")
        set_xorg_conf $ORIENTATION 0 1 0 -1 0 1 0 0 1
        ;;
    "left")
        set_xorg_conf $ORIENTATION 0 -1 1 1 0 0 0 0 1
        ;;
    "inverted")
        set_xorg_conf $ORIENTATION -1 0 1 0 -1 1 0 0 1
        ;;
    "normal")
        set_xorg_conf $ORIENTATION 1 0 0 0 1 0 0 0 1
        ;;
    *)
        printf "Unsupported orientation: $ORIENTATION\n\n";
        printf "Usage:\n"
        printf "    $0 <orientation>\n\n"
        printf "Where orientation is one of: left, right, normal, inverted.\n"
        exit 1
esac
e28eta commented 2 years ago

This is almost working for me: it only works in the non-rotated orientation on boot.

I bought my HyperPixel 4 Rectangular a month ago to use with a Pi 400 & Adafruit’s Cyberdeck HAT. I removed the diode on the HAT, and then ran into a black screen (backlight but no picture), and found some of the issues linked above. I was really happy to see this update.

With only dtoverlay=vc4-kms-dpi-hyperpixel4 in /boot/config.txt it’ll boot and display, albeit rotated 90° clockwise. This is working well, as far as I can tell.

If I try to use either ,rotate=270 appended to the dtoverlay line or the separate dtparam line that includes the touchscreen options, the display doesn’t work.

If I remove the rotation settings from /boot/config.txt and try to use the embedded script (xrandr, etc), it works on that particular session. When I reboot, it breaks.

The failure looks like either a black screen, or a screen where one pixel (the first??) in each row is repeated all the way across the screen (the latter seems to be more common, but I’m not sure). I haven’t been able to determine when each behavior is triggered.

I’ve been trying both with an HDMI monitor connected, and also with only the hyperpixel (aka DP1) and changing config over ssh. There may be behavior differences, but neither setup is working correctly.

Is there helpful information I can gather, either for this issue or to file a new one? Sometimes, but not always, there’s a register + call trace dump visible inside of dmesg output, related to the goodix_ts_driver. I’ve captured several sets of dmesg logs, but didn’t keep any notes on what the particulars of each were 😞

Gadgetoid commented 2 years ago

Could you paste the lines you have in your config.txt when you're trying to get rotation work? Would help me to recreate.

Gadgetoid commented 2 years ago

Weird, same config and same SD card in my Pi 3B+ versus my Pi 4 results in two different rotations...

:scream:

Edit (For posterity and to nobody in particular):

I have a suspicion that "/usr/share/dispsetup.sh" did this. It's the script that gets updated by Screen Configuration (arandr) and then run on boot via lightdm.conf.

There's also a .config/monitors.xml ~which I guess used by Mutter on Pi 4? Screen Configuration also updates this file, but manually editing it to different rotations doesn't seem to affect my display setup.~ which is for Gnome and unrelated to the Pi config afaict.

And any touch or rotation dropped into /usr/share/X11/xorg.conf.d/ can potentially cause issues, too.

e28eta commented 2 years ago

I've tried three different /boot/config.txt variations. Full contents, summary of changes from default:

dtoverlay=vc4-kms-dpi-hyperpixel4
dtoverlay=vc4-kms-dpi-hyperpixel4,rotate=270
dtoverlay=vc4-kms-dpi-hyperpixel4
dtparam=rotate=270,touchscreen-swapped-x-y,touchscreen-inverted-x

I have an (occasionally) working setup with the first one (no parameters to the overlay), and having run the bash script you provided :tada: After having ran that bash script, I haven't deleted / reset those settings to go back to a dtoverly + dtparam only solution.


Unfortunately, sometimes it fails. I thought the failure was deterministic, but I don't think that's true. I've seen three different failure modes:

https://user-images.githubusercontent.com/483223/163491202-71712123-d062-48cb-a151-4d862a1ac00c.mov

https://user-images.githubusercontent.com/483223/163491325-d370a209-8a0c-4119-8b9e-71c9281c9d7b.mov


I have seen all three display failure modes in each of these cases:

I haven't figured if there's a configuration/sequence that always fails, nor do I know if one is more likely to succeed. ex: I thought cold boot was pretty reliable yesterday, but so far today it's failed 3 out of 4 times. Similarly, my initial assertion that it only worked non-rotated on cold boot could have just been random good luck across 3-4 attempts.


Here's an example of the Goodix-TS failure logs from dmesg: dmesg-goodix-failure.txt

My guess is that the TS is for touch screen. I don't know if this is a red herring / unrelated. It's not always there when the display fails to work.


Late additions:


environment: Pi 400

$ uname -a
Linux pi400 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux

apt says it's fully up to date, and as far as I can remember the only significant thing I've really done with this device / SD card was run the old hyperpixel4 script. I'd be willing to wipe & re-image if you want.

Gadgetoid commented 2 years ago

There's a good chance the old hyperpixel script will break this in ways I can't imagine, but it should suffice to run:

sudo systemctl disable hyperpixel4-init.service

It could easily be this init script half-working that's messing up the display.

Also make sure nothing from the legacy installer is in config.txt.

A wipe and re-image is probably the safest bet though, the old installer is fundamentally a bunch of nasty hacks based around the old config.txt way of setting up DPI.

e28eta commented 2 years ago

There's a good chance the old hyperpixel script will break this in ways I can't imagine, but it should suffice to run:

sudo systemctl disable hyperpixel4-init.service

It could easily be this init script half-working that's messing up the display.

Also make sure nothing from the legacy installer is in config.txt.

That seems to have done it 🎉 🎊

I feel dumb/embarrassed 😞 I'd previously found and reverted the /boot/config.txt changes, and looked through the installer script for other config files that might have been changed, but didn't find the service to disable.

Thanks so much for the help!

cubismod commented 2 years ago

Howdy so I just installed this on a fresh OS install (April 4th 2022 64 bit on a Pi 4) and I get a blank white display. Using the square display.

cubismod commented 2 years ago

Nevermind! My issue was that I had removed dtoverlay=vc4-kms-v3d which caused the display to not work correctly.

Gadgetoid commented 2 years ago

Nevermind! My issue was that I had removed dtoverlay=vc4-kms-v3d which caused the display to not work correctly.

No worries. Useful to know exactly how this fails for future reference!

sunsmoke commented 2 years ago

Should this work with the 2020-and-earlier version of the hyperpixel4sq on a Pi3b+? I tried both the 64bit and 32bit builds of Bullseye, released 2022-04-04. I get what appears to be vertical stripes in both cases. It doesn't seem to matter if hdmi is connected or not. If hdmi is connected, then I get a very low resolution desktop on hdmi. Both installs are fresh, plain installs, and the only change I made was to add "dtoverlay=vc4-kms-dpi-hyperpixel4sq" to the end of /boot/config.txt

Gadgetoid commented 2 years ago

Should this work with the 2020-and-earlier version of the hyperpixel4sq on a Pi3b+? I tried both the 64bit and 32bit builds of Bullseye, released 2022-04-04. I get what appears to be vertical stripes in both cases. It doesn't seem to matter if hdmi is connected or not. If hdmi is connected, then I get a very low resolution desktop on hdmi. Both installs are fresh, plain installs, and the only change I made was to add "dtoverlay=vc4-kms-dpi-hyperpixel4sq" to the end of /boot/config.txt

Youch- that's a good question, to which the answer is: no. They require - iirc - very different configurations and bringup. That's something I'm going to have to look into. I had forgotten there were two flavours of Square :grimacing:

sunsmoke commented 2 years ago

Thanks! If you would like me to test anything, let me know.

brotherlogic commented 2 years ago

This new version does not work on my Pi Zero 2 W, the screen is just blank - my dtoverlay is:

dtoverlay=vc4-kms-v3d dtoverlay=vc4-kms-dpi-hyperpixel4sq

confirmed that the screen works fine on the prior install (with the script config). Is there anything else that I need to configure?

tl8roy commented 2 years ago

I have done a clean SD card wipe and reinstall on a Pi 400 and I am now getting a blank screen even after adding the new dto in the config.txt.

It was working on my existing installation which had the legacy drivers installed previously. I disabled the legacy service, but I also removed the old hyperpixel.dto. Once I did that and rebooted, the display stopped working. At that point I flashed the new OS to see if that would work.

This is a completely vanilla install with nothing done other than an apt update.

sudo cat /boot/config.txt
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
dtoverlay=vc4-kms-dpi-hyperpixel4
#,rotate=270
#,touchscreen-swapped-x-y,touchscreen-inverted-x

# Run in 64-bit mode
arm_64bit=1

# Disable compensation for displays with overscan
disable_overscan=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

[all]
tl8roy commented 2 years ago

Top Gear Top Tip: i2c and spi both need to be commented out/disabled.

Gadgetoid commented 2 years ago

Top Gear Top Tip: i2c and spi both need to be commented out/disabled.

Ooof. I did not spot that. Thanks for reporting it back here!

I tend to fall into the false assumption that - like the old config.txt magic setup method did - the DPI display will trump anything else, but with device-tree it'll throw a pin conflict instead. :grimacing:

LazLong commented 2 years ago

Annoyingly, I had rotation working on my Pi4 with the rectangular screen. Filesystem died and I rebuilt and now it doesn't work. The difference being that I'm now running Raspian OS Lite. Do we need X to have the rotation work?

Jeroennl commented 2 years ago

For some reason I can't get chromium in kiosk mode to display properly (landscape), boot and without chromium is fine. I'm using a PI Zero 2 W and a rectangle screen. Any ideas what i'm missing?

Gadgetoid commented 2 years ago

Annoyingly, I had rotation working on my Pi4 with the rectangular screen. Filesystem died and I rebuilt and now it doesn't work. The difference being that I'm now running Raspian OS Lite. Do we need X to have the rotation work?

@LazLong Yes. Or your application must support rotation somehow. This is a frustrating consequence of RPi's move to upstream blessed methods of supporting DPI displays. You can fall back to legacy drivers and the config.txt method, but that has its own tradeoffs.

@Jeroennl as above, there's no hardware rotation in the new drivers and no config.txt setting will affect display rotation. If Kiosk mode chromium uses X under the hood you should be looking at xrandr and xorg config. See the script in my original post.

Gadgetoid commented 2 years ago

@brotherlogic if you haven't done a fresh install, one is highly recommended. Make sure "hyperpixel4-init" or other services aren't running at startup and breaking things.

There are also, IIRC, two versions of HyperPixel 4 Square (pre and post 2021) which are not compatible with each other. If you have an older display it's very likely these drivers don't work with it. That's something I need to follow up on.

Jeroennl commented 2 years ago

@Jeroennl as above, there's no hardware rotation in the new drivers and no config.txt setting will affect display rotation. If Kiosk mode chromium uses X under the hood you should be looking at xrandr and xorg config. See the script in my original post.

@Gadgetoid Fixed it using xrandr, thnx!

Footleg commented 2 years ago

Top Gear Top Tip: i2c and spi both need to be commented out/disabled.

Ooof. I did not spot that. Thanks for reporting it back here!

I tend to fall into the false assumption that - like the old config.txt magic setup method did - the DPI display will trump anything else, but with device-tree it'll throw a pin conflict instead. 😬

Please add this to the top of this PSA post. I just lost 2 hours trying to find out why my display apparently stopped working when I applied a rotate setting. But it was because I had also enabled i2c for the same reboot while doing initial set up from the refresh OS image. This might also be why the display did not appear to work on my original CM4 hardware stack.

Gadgetoid commented 2 years ago

@Footleg story of my life! Duly noted and warnings added.

Footleg commented 2 years ago

I can now confirm my 2019 era Hyperpixel4 rectangular with touch is working on my CM4 mounted on a Waveshare carrier board. I discovered the i2c bus mapped to 22, rather than 3 as told here https://learn.pimoroni.com/article/getting-started-with-hyperpixel-4#using-the-alternate-i2c-interface-on-hyperpixel-4-0-for-advanced-users so maybe a quick update to that article to mention you can see which bus numbers are active using the command ls /dev/i2c-* (as I learned from this comment: https://github.com/pimoroni/hyperpixel4/issues/122#issue-789137822 ).

Note that when rotating the display using the console, the touch does not map to the rotated display. It also does not map to the correct display when a second display is attached to the HDMI output either. I've not looking into options to deal with that yet, but at least I am up and running now.

hothsolo commented 2 years ago

After doing the instructions exactly as described here and looking thru all the comments on everything that could be wrong, I still cannot get this working. I get a black screen. Nothing else. Any ideas?

locki-cz commented 2 years ago

Hello, I spend few days tryed everything, and I wasnt able to make it working again, just reinstalled my some old Octoprint with octodash and want to move to mainsail klipper, also tryed all 32bit and 64bit version of great awesome Raspberry Pi OS 64bit 2022-04-04 bullseye and nothing, i can get some picture when i set dtoverlay=vc4-kms-dpi-hyperpixel4sq or some weird desktop picture after display wakeup after sleep ... just rpi console then only ugly lines :(

all what i have:

I will try all to test what is wrong! Because it working before ... :(

djbetterly commented 2 years ago

I'm having zero luck with rotation in any direction, I've disable I2C, SPI, edited the config.txt according to the notes above and zero luck. Has anyone worked it out?

Footleg commented 2 years ago

I'm having zero luck with rotation in any direction, I've disable I2C, SPI, edited the config.txt according to the notes above and zero luck. Has anyone worked it out?

This worked for me as per the instructions at the top of this page with a fresh Raspberry Pi OS image (Bullseye). You do need the latest (use apt to upgrade everything if on an older Bullseye release). Check you are on Bullseye (it lists the repos being used when you run sudo apt update).

J4CY commented 2 years ago

Edit: I contacted Pimoroni support and was told the screen was indeed defective.

Hi all, I'm new to the HyperPixel 4.0 and RPI. I've got an RPI 4B w/ 2GB with Raspberry Pi OS 64bit bullseye installed.

Installed the screen and applied the following to /boot/config.txt.

dtoverlay=vc4-kms-dpi-hyperpixel4 
dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y

Rotation and touch are all working as expected, but I am noticing screen tearing of some sort on this specific side of the screen. I've tried other rotations and they all seem to have the same effect. Is this expected, a software bug, or potentially a hardware issue? I've attached some videos to demonstrate my issues.

https://user-images.githubusercontent.com/89369480/173922485-b24e53d6-9450-48c5-bdc5-5938b9fe68d0.mp4

https://user-images.githubusercontent.com/89369480/173923288-7383116a-883c-4140-829a-dcfadda60476.mp4

Edit: Also gave Buster a shot and installed the drivers, screen and touch works, but still has the tearing on the same side of the screen.

inevio-git commented 2 years ago

I'm having zero luck with rotation in any direction, I've disable I2C, SPI, edited the config.txt according to the notes above and zero luck. Has anyone worked it out?

This worked for me as well booting into terminal. For the rotation to work in X, I had to rotate left.

rnbarrett commented 2 years ago

I am totally editing out my previous post and putting in the notes for my ultimate goal: Making a Pi4 work with a rectangular HyperPixel 4 (bought in 2022) with OctoPrint/OctoDash connected to a Prusa MK3S+, with a clean/new install in January 2023. This means that the USB ports stick out to the right (power out of the bottom) so that the Pi can be mounted into a new display panel on the front of the Prusa. https://forum.prusa3d.com/wp-content/uploads/2021/07/01-600x500.jpg

I got some good help from here (hint: use "Alternate Step 2"). Rotation was good, but touch screen parameters were wonky. https://github.com/TxBillbr/octodash-hyperpixel-fix

With some testing of various x-y parameters, everything is working now. Here's the process I think folks can follow to arrive at my same config:

- This will get the display semi-functional: sudo apt install git git clone https://github.com/pimoroni/hyperpixel4 -b pi4 cd hyperpixel4 sudo ./install.sh sudo reboot now

- Edit your /boot/config.txt file to look like below The "modded" comment areas below are the ones I believe I changed, but this is a direct copy/paste from my working config. Everything else that appeared earlier in the config.txt file was unchanged. [pi4]

Enable DRM VC4 V3D driver on top of the dispmanx display stack

**#modded to comment out the line below

dtoverlay=vc4-fkms-v3d**

max_framebuffers=2

[all]

dtoverlay=vc4-fkms-v3d

enable raspicam

start_x=1 gpu_mem=128

#modded - original just had "dtoverlay=hyperpixel4" dtoverlay=hyperpixel4:rotate,touchscreen-swapped-x-y,touchscreen-inverted-x enable_dpi_lcd=1 dpi_group=2 dpi_mode=87 dpi_output_format=0x7f216 dpi_timings=480 0 10 16 59 800 0 15 113 15 0 0 0 60 0 32000000 6 #modded - added the line below display_lcd_rotate=3

djbetterly commented 2 years ago

I followed this and had good luck...though the touch screen is still a bit finicky at times https://www.instructables.com/Rotate-Raspberry-Pi-Display-and-Touchscreen/

naitse commented 2 years ago

Hi!, I'm running the latest version of MainsailOS, is there a way to manually install the drivers and stuff whitout having to install RaspbianOS image instead of the MainsailOS image??

ETE-Design commented 2 years ago

Seems like it dosen't work with KlipperScreen :-( When Fluidd start up it show all the start lines in Landscape Mode, but when it start KlipperScreen it is in Portrait Mode.... In Config.txt I have set: dtoverlay=vc4-kms-dpi-hyperpixel4 dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y

With Raspberry Pi OS Lite + MainSail + KlipperScreen: I can rotate with "DISPLAY=:0 xrandr --output DPI-1 --rotate right" but it wont keep it on each boot... And resolution is changed from 480x800 to 800x480 with that command, can't seem to find a solution for it...

@Gadgetoid Can you help?

david-goal commented 2 years ago

Nevermind! My issue was that I had removed dtoverlay=vc4-kms-v3d which caused the display to not work correctly.

No worries. Useful to know exactly how this fails for future reference!

I had blank display, backlight only issues using a fresh Bullseye image - 32 bit - in a Pi 4. By default /boot/config.txt shows the following: `[all]

dtoverlay=vc4-kms-v3d`

[pi4] dtoverlay=vc4-fkms-v3d

I toggled lines comments: [all] dtoverlay=vc4-kms-v3d

`[pi4]

dtoverlay=vc4-fkms-v3d`

My rectangular hyperpixel display works nicely now.

nitz commented 2 years ago

So here's some interesting bits.

Starting with a fresh image of 64-bit (2022-04-04) (Linux pi 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux)

via ssh:

$ sudo nano /boot/config.txt

Add to end:

[all]
dtoverlay=vc4-kms-dpi-hyperpixel4
dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y
$ sudo reboot

After rebooting, re-attach via ssh; but the screen is displaying correctly, in the correct orientation, with touch working properly.

Then, enable VNC:

$ sudo raspi-config nonint do_vnc 0 # alternatively 3, I3 through the GUI.

Notice that the VNC server starts and everything still looks correct... until:

$ sudo reboot

Now the display comes up in portrait (but the touch dtparams still seem to be correct.)

Comparing the output of xrandr before and after rebooting with VNC enabled, the difference is it seems to believe that HDMI-1 is primary rather than DPI-1. As well, the resolution reported for DPI-1 looks to be incorrectly swapped back to 480x800 as well. # Edited to add: looks like DPI-1 dropped the right designation, too!

$ xrandr # before rebooting w/vnc enabled
Screen 0: minimum 320 x 200, current 800 x 480, maximum 7680 x 7680
HDMI-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)
DPI-1 connected primary 800x480+0+0 right (normal left inverted right x axis y axis) 0mm x 0mm
   480x800       60.06*+

$ xrandr --listmonitors
Monitors: 1
 0: +*DPI-1 800/212x480/127+0+0  DPI-1

# rebooting here...

$ xrandr # after rebooting w/vnc enabled
Screen 0: minimum 320 x 200, current 480 x 800, maximum 7680 x 7680
HDMI-1 disconnected primary (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)
DPI-1 connected 480x800+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   480x800       60.06*+

$ xrandr --listmonitors
Monitors: 1
 0: +DPI-1 480/127x800/212+0+0  DPI-1

So I assume somewhere a script is futzing with things, but I've not found where yet.

# nothing in /usr/share/X11/xorg.conf.d/ has been modified...
$ sudo ls -la /usr/share/X11/xorg.conf.d/
total 32
drwxr-xr-x 2 root root 4096 Apr  4 10:35 .
drwxr-xr-x 5 root root 4096 Apr  4 10:31 ..
-rw-r--r-- 1 root root   69 Jan  4 05:24 00-glamor.conf
-rw-r--r-- 1 root root   92 Sep 17  2020 10-amdgpu.conf
-rw-r--r-- 1 root root 1350 Jan  4 05:24 10-quirks.conf
-rw-r--r-- 1 root root   92 Sep 18  2020 10-radeon.conf
-rw-r--r-- 1 root root 1429 Aug 17  2020 40-libinput.conf
-rw-r--r-- 1 root root  607 Jul  8  2021 99-fbturbo.~

# dispsetup.sh is still boring...
$ sudo cat /usr/share/dispsetup.sh
#!/bin/sh
exit 0

# I'm assuming the answer lies somewhere within a VNC specific script, but as of yet, I can't figure out how it's futzing with it!
$ sudo cat /etc/vnc/config
# Default X Server command-line parameters for VNC Server.
#
# This file is automatically generated. DO NOT EDIT.
# To override settings in this file, create or edit /etc/vnc/config.custom.

# Continue even if standard ports fail
-pn
$ sudo cat /etc/vnc/config.d/*
# Default settings for all VNC programs.
#
# This file is automatically generated. DO NOT EDIT.
# To override settings in this file, create or edit
# /etc/vnc/config.d/common.custom

Any guesses as to a good spot to look?

ETE-Design commented 2 years ago

@nitz Seems like we have same problem, mine is just with KlipperScreen

When I add this to Config.txt:

[all] dtoverlay=vc4-kms-dpi-hyperpixel4 dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y

it is looking correct in landscape on the Prompt, but when it start KlipperScreen it is in is start in Portrait mode but Touch in Landscape... Seems like it is not possible to tell other program to Rotate to Landscape other that Prompt :-(

osfa commented 1 year ago

will these bundled drivers work for 2020 and earlier boards? trying to install fresh from mentioned bullseye dist with a 2020 square board and setting dtoverlay=vc4-kms-dpi-hyperpixel4sq but only seeing white flickering and glitching. if I instead start fresh and then clone the repo and install via the square-pi4 branch I at least see the boot screen but then after that just black with a white halosque light in the middle. what is the recommended image and install process for a 2020 board on a rpi4? will bullseye work?

osfa commented 1 year ago

will these bundled drivers work for 2020 and earlier boards? trying to install fresh from mentioned bullseye dist with a 2020 square board and setting dtoverlay=vc4-kms-dpi-hyperpixel4sq but only seeing white flickering and glitching. if I instead start fresh and then clone the repo and install via the square-pi4 branch I at least see the boot screen but then after that just black with a white halosque light in the middle. what is the recommended image and install process for a 2020 board on a rpi4? will bullseye work?

to answer my own question: for a 2020 or earlier board one seems to need to install the drivers via the square-pi4 branch and then disable dtoverlay=vc4-kms-v3d (and omit dtoverlay=vc4-kms-dpi-hyperpixel4sq)

Dianoga commented 1 year ago

On a Pi 4 running the latest and greatest nightly OctoPi build and using the simplified /boot/config.txt settings from above, I'm getting a consistent screen flicker (see video). I've tried going back to the legacy drivers with the same effect. Any suggestions?

Relevant lines from /boot/config.txt

dtoverlay=vc4-kms-dpi-hyperpixel4
dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y

https://user-images.githubusercontent.com/1618956/178836782-b3ac6ffb-90db-42a0-b814-dd52353a0705.mp4

ChrisZ32 commented 1 year ago

Pi Zero 2 running a freshly installed/updated Bullseye 64bit - The new instructions aren't working for me fully for a new rectangular screen. It installs and displays, and the touchscreen works no problem in portrait and 180 rotated portrait - but 90 and 270 landscape rotations don't work. The boot screen(s) are correct, but the OS GUI remains in portrait. @Gadgetoid FYI as I thought I saw somewhere that you wanted some feedback on a Zero 2.

I ran the legacy installer for a Pi 4 rectangular and the landscape display worked after some tweaks (well technically I ran it for a Pi 3 first, then when that didn't work I ran for a Pi 4). I had to change in /boot/config.txt:

This gives you landscape with header at the bottom, will need other combinations for other orientations. I needed both new settings - adding rotate=270, to the beginning of the dtparam didn't work by itself.

Hopefully this helps a few people struggling with this

EDIT: when I booted the pi again the next day the screen was blank - journalctl -u hyperpixel4-init.service showed an error of ImportError: No module named RPi.GPIO, editing sudo nano /usr/bin/hyperpixel4-init to have #!/usr/bin/env python3 instead of #!/usr/bin/env python fixed it. Just saying in case it helps someone

jacyhung commented 1 year ago

When I add this to Config.txt:

[all] dtoverlay=vc4-kms-dpi-hyperpixel4 dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y

it is looking correct in landscape on the Prompt, but when it start KlipperScreen it is in is start in Portrait mode but Touch in Landscape... Seems like it is not possible to tell other program to Rotate to Landscape other that Prompt :-(

@ETE-Design still need help figuring out rotation w/ KlipperScreen? I have it working.

In my /boot/config.txt,

dtoverlay=vc4-kms-dpi-hyperpixel4
dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y

Then create a new file,

sudo nano /usr/share/X11/xorg.conf.d/90-monitor.conf

with the following contents,

Section "Monitor"
    Identifier "DPI-1"
    Option "Rotate" "right"
EndSection

and restart KlipperScreen. IMG_4305

jmacdonald commented 1 year ago

On a Pi 4 running the latest and greatest nightly OctoPi build and using the simplified /boot/config.txt settings from above, I'm getting a consistent screen flicker (see video). I've tried going back to the legacy drivers with the same effect. Any suggestions?

I'm seeing these as well. I'm running 2022-04-04 with all of the updates installed. I have two HyperPixel 4 Square displays with two separate RPi Zero 2Ws and am seeing this on both. Here's my /boot/config.txt:

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Add HyperPixel support
dtoverlay=vc4-kms-dpi-hyperpixel4sq

# Disable compensation for displays with overscan
disable_overscan=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

[all]
jmacdonald commented 1 year ago

It's worth noting that these issues were on the 32-bit version of the Bullseye release of Rasperry Pi OS ^. I had tried the 64-bit release, but oddly enough, memory consumption and general performance were so problematic as to make it unusable for my project (which involves Chromium on an RPi Zero 2W).

As a workaround, I've installed the legacy Buster-based version of Rasperry Pi OS alongside the legacy drivers. In this scenario, everything works perfectly; no flickering at all.

hoegge commented 1 year ago

How do you make the original Hyperpixel display work on Bullseye?

jiki974 commented 1 year ago

Should this work with the 2020-and-earlier version of the hyperpixel4sq on a Pi3b+? I tried both the 64bit and 32bit builds of Bullseye, released 2022-04-04. I get what appears to be vertical stripes in both cases. It doesn't seem to matter if hdmi is connected or not. If hdmi is connected, then I get a very low resolution desktop on hdmi. Both installs are fresh, plain installs, and the only change I made was to add "dtoverlay=vc4-kms-dpi-hyperpixel4sq" to the end of /boot/config.txt

Youch- that's a good question, to which the answer is: no. They require - iirc - very different configurations and bringup. That's something I'm going to have to look into. I had forgotten there were two flavours of Square 😬

I ran into same situation with the hyperpixel 4 square 2020, any guideline to make it work on bullseye ?

jarrah31 commented 1 year ago

I have a Hyperpixel 4 rectangle bought in 2018. I'm attempting to get this working on a Raspberry Pi 3 B using Bullseye 64-bit 2022-04-04 build. Should this combination work?

The display does actually show the desktop, but the problem is I can't rotate the screen to landscape when trying each of the following lines:

dtoverlay=vc4-kms-dpi-hyperpixel4
# with one of the following below
dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y
dtparam=rotate=180
dtparam=rotate=270,touchscreen-swapped-x-y,touchscreen-inverted-x
mjrintam commented 1 year ago

In my /boot/config.txt,

dtoverlay=vc4-kms-dpi-hyperpixel4
dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y

Then create a new file,

sudo nano /usr/share/X11/xorg.conf.d/90-monitor.conf

with the following contents,

Section "Monitor"
    Identifier "DPI-1"
    Option "Rotate" "right"
EndSection

Finally! Thank you so much! Works now also on pi zero w with a few years old Hyperpixel 4.0 and fresh install of 32-bit Bullseye.

Bizzaro commented 1 year ago

If anyone's confused like me, I just added dtoverlay=vc4-kms-dpi-hyperpixel4sq to /boot/config.txt and then ran the script with the desired orientation.

I am using a pi zero and the square display.

Using dtparam=rotate=180 would rotate the desktop, but not the mouse cursor.

omarandlorraine commented 1 year ago

In my /boot/config.txt,

dtoverlay=vc4-kms-dpi-hyperpixel4
dtparam=rotate=90,touchscreen-swapped-x-y,touchscreen-inverted-y

Then create a new file,

sudo nano /usr/share/X11/xorg.conf.d/90-monitor.conf

with the following contents,

Section "Monitor"
    Identifier "DPI-1"
    Option "Rotate" "right"
EndSection

Do you know why you needed rotate settings both in xorg.conf.d and in /boot/config.txt? Is one for touch and the other for the framebuffer itself?