hyperpixel4 icon indicating copy to clipboard operation
hyperpixel4 copied to clipboard

`hyperpixel4-rotate` commands not working fresh install rectangular Pi4

Open jehanalvani opened this issue 4 years ago • 51 comments

Describe the bug

Unable to rotate display using hyperpixel4-rotate commands.

To Reproduce

  1. Fresh install of Raspbian using Raspberry Pi imager.
  2. touch ssh on boot volume to enable ssh
  3. Boot rPi, login
  4. sudo raspi-config
  5. Set locales [en.US]
  6. curl https://get.pimoroni.com/hyperpixel4 | bash, option 2 (Rpi4 Rect exp touch) affirm where needed, reboot when prompted
  7. Connect via SSH when rebooted (desktop in Portrait (normal) on display)
  8. hyperpixel4-rotate right results in
pi@raspberrypi:~ $ hyperpixel4-rotate right
Rotating display
Can't open display 
Traceback (most recent call last):
  File "<stdin>", line 15, in <module>
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 43, in __init__
    version_output = self._output("--version")
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 64, in _output
    raise Exception("XRandR returned error code %d: %s"%(status,err))
Exception: XRandR returned error code 1: Can't open display 

Setting matrix: 0 1 0 -1 0 1
Unable to connect to X server
Saving touch settings to /etc/udev/rules.d/98-hyperpixel4-calibration.rules

Your HyperPixel 4

Let us know which HyperPixel 4 board you're using. Note: if you're having a problem with the original HyperPixel you should go to: https://github.com/pimoroni/hyperpixel

  1. Rectangular?
  2. Touch
  3. Oct 15th 2020
  4. full 40-pin GPIO

Your Raspberry Pi

Give as much detail about your Pi and OS as possible. We only officially support Raspbian, but might be able to point you in the right direction if the problem is with another OS.

  1. Raspberry Pi Model: Model : Raspberry Pi 4 Model B Rev 1.1 4gb

pi@raspberrypi:~ $ lsb_release --description
Description:	Raspbian GNU/Linux 10 (buster)
pi@raspberrypi:~ $ uname -r
5.4.51-v7l+ 

  1. Fresh as the morning dew

Extra debugging information

If you're having a problem with touch, try checking dmesg for related errors:

  • dmesg | grep Goodix for HyperPixel 4.0" Rectangular
pi@raspberrypi:~ $ dmesg | grep Goodix
[    5.417804] Goodix-TS 11-005d: 11-005d supply AVDD28 not found, using dummy regulator
[    5.417918] Goodix-TS 11-005d: 11-005d supply VDDIO not found, using dummy regulator
[    5.418688] Goodix-TS 11-005d: i2c test failed attempt 1: -6
[    5.454211] Goodix-TS 11-005d: i2c test failed attempt 2: -6
[    5.491025] Goodix-TS 11-005d: I2C communication failure: -6
[    5.491476] Goodix-TS 11-0014: 11-0014 supply AVDD28 not found, using dummy regulator
[    5.491599] Goodix-TS 11-0014: 11-0014 supply VDDIO not found, using dummy regulator
[    5.493618] Goodix-TS 11-0014: ID 911, version: 1060
[    5.536595] input: Goodix Capacitive TouchScreen as /devices/platform/i2c@0/i2c-11/11-0014/input/input4

And check i2c is working:

ls /dev/i2c-*

pi@raspberrypi:~ $ ls /dev/i2c-*
/dev/i2c-11

And your HyperPixel 4 touch is showing up (there should be an address blocked out with UU in the below command):

i2cdetect -y X ( where X is the number of i2c bus found in the command above)

For example:

pi@raspberrypi:~ $ i2cdetect -y 11
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

jehanalvani avatar Nov 07 '20 19:11 jehanalvani

There's a couple of issues in here already to do with screen rotation and/or touch rotation not working on Pi4, you should look around a bit. I'm having similar ones. The gist of it is: the default drivers don't support 90° or 270° rotation on Pi4. There's a few workarounds through the commandline. The easiest one is disabling dtoverlay=vc4-fkms-v3d and replacing it with dtoverlay=hyperpixel4:rotation + adding a line for the rotation setting (See the comments sprinkled throughout here). But the downside of it is that you lose some functionality (eg. can't run RetroPie). Which is why I'm still looking for an alternative.

LordRembo avatar Nov 08 '20 10:11 LordRembo

Sounds like it'd be useful to me, thanks for the heads up, @LordRembo.

Devs, though, LMK if you want me to provide anything more. I can re-flash this Pi anytime.

jehanalvani avatar Nov 08 '20 18:11 jehanalvani

This comment Included the following

/boot/config.txt:

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
#dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

dtoverlay=hyperpixel4
gpio=0-25=a2
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
display_rotate=1

My /boot/config.txt after running the installation script and choosing option 2 for rect w/ exp pi 4 fix did not comment out

#dtoverlay=vc4-fkms-v3d from the [pi4] section, nor did it include display_rotate=1 in [all]. I assume the latter was because the hyperpixel4-rotate command couldn't execute successfully. Manually updating the file resolved my issue for my use-case, though I suspect the bug should remain open (or closed as dupe if there's another issue that is addressing this).

jehanalvani avatar Nov 08 '20 19:11 jehanalvani

I was experiencing the same issues as @jehanalvani with latest Raspberry OS, Pi 4 and HyperPixel4. The following worked for me without having to disable vc4-fkms-v3d @LordRembo .

Process #Download Latest HP4 Pi4 Drivers git clone https://github.com/pimoroni/hyperpixel4 -b pi4 #Swap x y screen size in hyperpixel4-overlay sed -i 's/screen-size-x = <480>/screen-size-x = <800>/' ~/hyperpixel4/src/hyperpixel4-overlay.dts sed -i 's/screen-size-y = <800>/screen-size-y = <480>/' ~/hyperpixel4/src/hyperpixel4-overlay.dts #Install cd hyperpixel4 sudo ./install.sh #Reboot sudo reboot #Rotate the screen (in my case right) hyperpixel4-rotate right #Correct issue where touch is 90 degrees to screen for 'right' orientation. echo 'ATTRS{name}=="Goodix Capacitive TouchScreen", ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 1 0"' > /etc/udev/rules.d/98-hyperpixel4-calibration.rules #Reboot sudo reboot

A note, if you were to want a rotation different than 'right' then LIBINPUT_CALIBRATION_MATRIX would need to be set to something else.

Credit Where it's Due Modification of hyperpixel4-overlay.dts Touch Screen Calibration

David-26 avatar Nov 29 '20 12:11 David-26

Is this ever going to be fixed? I've tried the process above, and no luck.

It would appear to have been broken on the RPi-4 since at least 2019 by the looks of other issues raised about exactly the same thing

travellingkiwi avatar Jan 12 '21 17:01 travellingkiwi

I've had to image subsequent pi devices since this post. Found that the part done by sed needed done manually using vi. Results were inconsistent but got there eventually.

Previously when I had a Pi3 the solution that worked for me was...

image

David-26 avatar Jan 12 '21 19:01 David-26

@David-26 We know how it works on Pi3, that's been documented extensively. It's Pi4 that's the issue. I never got it to work either and went back to a Pi3.

LordRembo avatar Jan 12 '21 20:01 LordRembo

Modifying the standard hyperpixel 4 for Pi4 install worked for me. Must have build it 6-7 times and had a few failures. The make or break point was after modifying ~/hyperpixel4/src/hyperpixel4-overlay.dts installing and rebooting, should I be able to move the mouse to all extremes of the display then the rest worked ok.

David-26 avatar Jan 12 '21 20:01 David-26

@David-26 I've followed your directions from Nov 29. Still doesn't work.

This is a brand new HyperPixel 4.0 on a brand new raspberrypi 4...

happy to help debug if I can, but any more info is appreciated. Thank you!

alphex avatar Jan 16 '21 03:01 alphex

Alright, I think I found a fix. Using @jehanalvani 's comment, and just reinstalling the software again, I was able to get it to work. With the USB C port on the bottom.

I picked option 2 for the 2 : Rectangular - Pi 4 - Experimental Touch Fix and then my boot/config.txt looks like this.

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
# dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

dtoverlay=hyperpixel4
gpio=0-25=a2
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
display_rotate=3

dtoverlay=hyperpixel4-common
dtoverlay=hyperpixel4-0x14
dtoverlay=hyperpixel4-0x5d

I hope that helps someone!

alphex avatar Jan 16 '21 03:01 alphex

alphex: after three weeks mucking with this problem, I must say this:

THANK YOU, THANK YOU, THANK YOU, THANK YOU, THANK YOU.

There is no reason this was so incredibly difficult!

Alright, I think I found a fix. Using @jehanalvani 's comment, and just reinstalling the software again, I was able to get it to work. With the USB C port on the bottom.

I picked option 2 for the 2 : Rectangular - Pi 4 - Experimental Touch Fix and then my boot/config.txt looks like this.

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
# dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

dtoverlay=hyperpixel4
gpio=0-25=a2
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
display_rotate=3

dtoverlay=hyperpixel4-common
dtoverlay=hyperpixel4-0x14
dtoverlay=hyperpixel4-0x5d

I hope that helps someone!

tubbybtch avatar Jan 27 '21 19:01 tubbybtch

@alphex Yes, that's rad. Thank you. I still get the errors below, but the screen works in this orientation.

jehan@displaypi:~ $ hyperpixel4-rotate left
Rotating display
Can't open display 
[sudo] password for jehan: 
Traceback (most recent call last):
  File "<stdin>", line 15, in <module>
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 43, in __init__
    version_output = self._output("--version")
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 64, in _output
    raise Exception("XRandR returned error code %d: %s"%(status,err))
Exception: XRandR returned error code 1: Can't open display 

Setting matrix: 0 -1 1 1 0 0
Unable to connect to X server
Saving touch settings to /etc/udev/rules.d/98-hyperpixel4-calibration.rules

jehanalvani avatar Jan 29 '21 14:01 jehanalvani

try

export DISPLAY=:0.0

before executing the command

@alphex Yes, that's rad. Thank you. I still get the errors below, but the screen works in this orientation.

jehan@displaypi:~ $ hyperpixel4-rotate left
Rotating display
Can't open display 
[sudo] password for jehan: 
Traceback (most recent call last):
  File "<stdin>", line 15, in <module>
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 43, in __init__
    version_output = self._output("--version")
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 64, in _output
    raise Exception("XRandR returned error code %d: %s"%(status,err))
Exception: XRandR returned error code 1: Can't open display 

Setting matrix: 0 -1 1 1 0 0
Unable to connect to X server
Saving touch settings to /etc/udev/rules.d/98-hyperpixel4-calibration.rules

tubbybtch avatar Jan 29 '21 19:01 tubbybtch

@tubbybtch

jehan@displaypi:~ $ export DISPLAY=:0.0
jehan@displaypi:~ $ hyperpixel4-rotate right
Rotating display
Invalid MIT-MAGIC-COOKIE-1 keyCan't open display :0.0
[sudo] password for jehan: 
Traceback (most recent call last):
  File "<stdin>", line 15, in <module>
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 43, in __init__
    version_output = self._output("--version")
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 64, in _output
    raise Exception("XRandR returned error code %d: %s"%(status,err))
Exception: XRandR returned error code 1: No protocol specified
Can't open display :0.0

Setting matrix: 0 1 0 -1 0 1
Invalid MIT-MAGIC-COOKIE-1 keyUnable to connect to X server
Saving touch settings to /etc/udev/rules.d/98-hyperpixel4-calibration.rules

No bueno, unfortunately. 3rd and 12th lines in output above.

jehanalvani avatar Jan 29 '21 19:01 jehanalvani

You may also need: export XAUTHORITY=/home/pi/.Xauthority or equivalent.

Sorry to sweep in here and be less than useful, but I'm between homes and all my Pi stuff is packed away in boxes. As such I've currently got no access to test this stuff and iron out any wrinkles in the documentation, but it's on my radar.

Gadgetoid avatar Jan 29 '21 19:01 Gadgetoid

@Gadgetoid No worries; happy to be a ginuea pig if it makes resolving this easier.

jehan@displaypi:~ $ export XAUTHORITY=/home/jehan/.Xauthority
jehan@displaypi:~ $ hyperpixel4-rotate right
Rotating display
Invalid MIT-MAGIC-COOKIE-1 keyCan't open display :0.0
Traceback (most recent call last):
  File "<stdin>", line 15, in <module>
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 43, in __init__
    version_output = self._output("--version")
  File "/usr/lib/python2.7/dist-packages/screenlayout/xrandr.py", line 64, in _output
    raise Exception("XRandR returned error code %d: %s"%(status,err))
Exception: XRandR returned error code 1: Invalid MIT-MAGIC-COOKIE-1 keyCan't open display :0.0

Setting matrix: 0 1 0 -1 0 1
Invalid MIT-MAGIC-COOKIE-1 keyUnable to connect to X server
Saving touch settings to /etc/udev/rules.d/98-hyperpixel4-calibration.rules

jehanalvani avatar Jan 29 '21 19:01 jehanalvani

bump

Does the Pimoroni crew have any plans to address this issue with a fix?

Would love to be able to use my Hyper Pixel in a reliable way...

metaColin avatar Mar 09 '21 06:03 metaColin

It's on my radar, but contingent on me having space to set up a Pi and familiarise myself with whatever is causing all this chaos.

Gadgetoid avatar Mar 09 '21 17:03 Gadgetoid

Just did a Pi4 install with the fix that was posted above because in the last 20 days, this has not been resolved apparently.

cmdshft avatar Mar 29 '21 22:03 cmdshft

The only fixes that seem work semi-consistently, are the ones that involve first removing the original vc4-fkms-v3d overlay. Since that removes original functionality (eg. 3D acceleration) and the core problem is Pi4 hardware based (there's links in previous comments and related threads), I think the best course of action is to 1) document the suggested fixes in this project's install info (including a caveat about losing functionality) and 2) throw in the towel and admit this is just not fully fixable for this screen + device combo. You need to buy a different screen or use a Pi3 to use horizontal orientation is you absolutely need 3D acceleration or run things like RetroPie.

LordRembo avatar Apr 18 '21 09:04 LordRembo

Which reminds me, even when I did get it working with 3D acceleration, as soon as I run 'apt upgrade' it reverts back to not working correctly. Which is fine for my use case but definitely not for most.

David-26 avatar Apr 18 '21 09:04 David-26

Not sure if this helps anyone, but it got me past the MIT-MAGIC_COOKIE error, but only as root. FWIW I still can't get the screen to rotate.

In any case, I ran ps aux | grep -i auth and noticed that lightdm was specifying an auth file

root       827  0.5  2.4 137480 47432 tty7     Ssl+ 16:01   0:01 /usr/lib/xorg/Xorg :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch

I then logged in as root, and symlinked that file to become my $HOME/.Xauthority file

ln -s /var/run/lightdm/root/:0 $HOME/.Xauthority

Now I'm left with the following

root@raspberrypi4:~# DISPLAY=:0.0 hyperpixel4-rotate normal
Rotating display
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
ImportError: No module named screenlayout
Setting matrix: 1 0 0 0 1 0
unable to find device pointer:Goodix Capacitive TouchScreen
Saving touch settings to /etc/udev/rules.d/98-hyperpixel4-calibration.rules

iainp999 avatar Apr 28 '21 15:04 iainp999

To be able to connect as non-root, what I did next was a little naughty, but I'll live with it for now.

As root

DISPLAY=:0.0 xhost +
access control disabled, clients can connect from any host

Still no further forward with the rotating though.

raspberrypi4:  ~   DISPLAY=:0.0 hyperpixel4-rotate normal
Rotating display
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
ImportError: No module named screenlayout
Setting matrix: 1 0 0 0 1 0
unable to find device pointer:Goodix Capacitive TouchScreen
Saving touch settings to /etc/udev/rules.d/98-hyperpixel4-calibration.rules```

iainp999 avatar Apr 28 '21 15:04 iainp999

In the end, doing the above and running DISPLAY=:0.0 xrandr --output DSI-1 --rotate left worked. Couldn't get the Pimorini script to play ball.

iainp999 avatar Apr 28 '21 15:04 iainp999

OK, finally got the script working. Added comments at https://github.com/pimoroni/hyperpixel4/issues/51

iainp999 avatar Apr 28 '21 16:04 iainp999

I've managed to rotate the display with the rotate_display config and it's working well but how do I calibrate the touchscreen? I tried reinstalling with the experimental touch fix also didn't work. The touchscreen still responds as if it's still in portrait even though it supposedly has updated the 98-hyperpixel4-calibration.rules file.

joaolisboa avatar May 13 '21 14:05 joaolisboa

I've been trying other methods, back to the point where I don't even have rotate_display any longer. It's like the touchscreen is still assuming a portrait orientation. dtparams touchscreen_inverted_x or y, swapped_x_y and a combinations of these and still no luck I've also tried the usual xinput_calibrator and the 99-calibration.conf file and still no luck, when I do that the cursor just goes to the edges of the display.

joaolisboa avatar May 13 '21 18:05 joaolisboa

Found a fix. This command properly sets the touchscreen calibration rotation for me:

xinput set-prop 'Goodix Capacitive TouchScreen' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1

This setting isn't persisted after rebooting though. For now I put it inside a .desktop file to run on startup and it's working fine.

joaolisboa avatar May 28 '21 18:05 joaolisboa

xinput set-prop 'Goodix Capacitive TouchScreen' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1

This is... odd... what OS are you running? I'm guessing it doesn't use libinput.

Gadgetoid avatar Jun 18 '21 13:06 Gadgetoid

This is... odd... what OS are you running? I'm guessing it doesn't use libinput.

Latest Raspberry Pi OS. This command was given to me by the PiHut support.

joaolisboa avatar Jun 18 '21 13:06 joaolisboa