pimoroni / picade-hat

Picade HAT input daemon and setup script
https://shop.pimoroni.com/products/picade-hat
65 stars 15 forks source link

Pi5 Support #45

Open ilboud opened 8 months ago

ilboud commented 8 months ago

Are there any plans to add support for the Pi 5?

Thanks, A-

Gadgetoid commented 8 months ago

There are some hardware incompatibilities with various versions of the Picade HAT and Pi 5, but most features should work just by building and using the dtoverlay-

sudo apt install make
git clone https://github.com/pimoroni/picade-hat
cd picade-hat
make
sudo cp picade.dtbo /boot/firmware/overlays
sudo nano /boot/firmware/config.txt
- Add "dtoverlay=picade" into config.txt
- Save
- Reboot!
- Cross fingers
Lapin commented 8 months ago

I've also noticed that in the original script, it tries to add the "dtoverlay=picade" to the boot/config.txt. But in the file it says that the original file is moved to 'firmware'. Although because I've ran the script before, I've also noticed that the new lines were added underneath it.

(ps. unfortunately this didn't worked for me. Just blindly playing around the files to make it work)

Gadgetoid commented 8 months ago

I've experimental a little here, and met with similar failure. It seems a lot of the dtoverlay is just incompatible with Pi 5, which is frustrating.

The bits that work are left here - https://github.com/pimoroni/picade-hat/commit/acc01a1930ae8d63d993ea29cbfd77d3d2156d06

Which is the feature/pi5 branch of this repository, if you want to give it a shot. It should get controls working at least.

Lapin commented 8 months ago

sorry forgot to reply, I'd take your fork as a starting point - I also found out "brcm,bcm2711" is the new type of handle for the R1 chip and that was it haha. Still trying to set up a seamless dev enviro between my rpi and between my laptop 😅

ptumelty commented 7 months ago

Ok, so I've just bought a Picade and RP5 and naively assumed that everything would just work :)

Do you think it's likely that we'll get a fully working version of the X Hat USB-C for PI5, or should I just use an old PI4?

Gadgetoid commented 6 months ago

Right I've had another punt at the Pi 5 compatibility and it ... was not fun. I think I have something that might be working in https://github.com/pimoroni/picade-hat/tree/feature/pi5 now.

Install instructions:

sudo apt install make
git clone https://github.com/pimoroni/picade-hat -b feature/pi5
cd picade-hat
make
sudo cp picade.dtbo /boot/firmware/overlays
sudo nano /boot/firmware/config.txt
- Add "dtoverlay=picade" into config.txt
- Save
- Reboot!
- Cross fingers

For some reason I could not for love nor money get the power off button to be configured separately from the rest of the GPIO keys.

Additionally the way that i2s pins are configured has changed - we needed to move PCM Data-In away from its default of GPIO 20, since that's the Left direction input. Hopefully I've got that right- I'm not well prepared for testing since my Picade got salvaged for spares and repairs 💀

Timanious commented 6 months ago

@Gadgetoid : Just like ptumelty I've also bought a Picade and RP5 naively thinking it would work, so your work is very much appreciated. Will try this out to see if I can get both the audio and the buttons to work at the same time, which would be amazing :)

vanfanel commented 6 months ago

@Gadgetoid Hello! Thanks for trying to add support for the Pi5 :)

I have tried the steps above, and input works, but audio does not.

Looking at aplay -L I see that sndrpihifiberry is not detected by ALSA:

null
    Discard all samples (playback) or generate zero samples (capture)
default
    Default Audio Device
sysdefault
    Default Audio Device
default:CARD=vc4hdmi0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    Default Audio Device
hdmi:CARD=vc4hdmi0,DEV=0
    vc4-hdmi-0, MAI PCM i2s-hifi-0
    HDMI Audio Output
default:CARD=vc4hdmi1
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Default Audio Device
sysdefault:CARD=vc4hdmi1
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    Default Audio Device
hdmi:CARD=vc4hdmi1,DEV=0
    vc4-hdmi-1, MAI PCM i2s-hifi-0
    HDMI Audio Output

Manually loading the kernel module with modprobe snd-soc-hifiberry-dacplus doesn't make a difference.

Also, dtparam=audio=off doesn't make a difference (expected as that's for BCM binary blobs audio which luckily isn't a thing on the Pi5).

I had to power the Picade by connecting the USB-C power connector directly to the Pi5, because using the USB-C power connector on the Picade Hat would cause the screen to power on and off every second. However, powering it via the hat USB-C connector does not make any difference with regards to ALSA detecting the hifiberry module.

Do you know what could be going on here, please? I'm about to trash the Picade Hat and use a combo of Hifiberry on GPIO + USB daemonbyte...

vanfanel commented 6 months ago

@Gadgetoid Looking at this line: https://github.com/pimoroni/picade-hat/blob/acc01a1930ae8d63d993ea29cbfd77d3d2156d06/picade.dts#L5

...is brcm,bcm2711 correct? I believe the Pi5 SOC is bcm2712, not bcm2711...

vanfanel commented 6 months ago

@Gadgetoid Ok, using the hifiberry overlay, I can get audio detected by the kernel and the correct module loaded.

So, if I do:

dtoverlay=hifiberry-dac
dtoverlay=picade

...I can get both audio and controls detected. But audio only works half of the times I reboot. I mean: aplay -L lists hifiberry half the times I reboot only.

Any ideas?

vanfanel commented 6 months ago

After even more experimentation, it seems that doing:

dtoverlay=hifiberry-dac
dtoverlay=picade

...Gets audio or controls working, but not both at the same time. It's one or the other.

Gadgetoid commented 6 months ago

@vanfanel try the above steps again, I apparently completely neglected to force push up my changes sorry 😬

Gadgetoid commented 6 months ago

You'll know if you have the right dts locally if it has a section like: https://github.com/pimoroni/picade-hat/blob/f8e00c6b851cf2d7f100cf20df99bc6c9a0b33ee/picade.dts#L19-L26

vanfanel commented 6 months ago

@Gadgetoid Ah yes, now it works, both controls and hifiberry audio work at the same time with the picade overlay, using the picade.dts for pi5 in https://github.com/pimoroni/picade-hat/blob/feature/pi5/picade.dts.

With this corrected dts, there is no need for separate hifiberry overlay, of course.

Is power button also supposed to work? Things seems smooth so far!

vanfanel commented 6 months ago

The problem with the power button is that I can use it for power-off, but not for power-on. Probably because the power supply has to be connected to the Pi5 directly instead to the PicadeX hat, or the display resets itself every second. Do you happen to know what the problem with the display is?

Gadgetoid commented 6 months ago

I'm guessing the display is pulling enough power from the Pi 5 to trigger the USB current limit, whereas when the power is connected directly it's able to detect a higher capacity power supply and raise that limit.

You could try adding usb_max_current_enable=1 to /boot/firmware/config.txt

vanfanel commented 6 months ago

usb_max_current_enable=1

Perfect! usb_max_current_enable=1 in config.txt did the trick!

I would say this is perfectly working now, maybe you could update the main branch accordingly so this becomes widely known? It will sure help people wanting to couple the fantastic Picade with a Pi5, it's a match made in heaven :)

Gadgetoid commented 6 months ago

I'll have to do some testing to make sure I don't completely hose Pi 4 support, but yes a main branch update is a good idea!

Thanks - even if it was unintentional and possibly frustrating - for testing this!

vanfanel commented 6 months ago

I'll have to do some testing to make sure I don't completely hose Pi 4 support, but yes a main branch update is a good idea!

Thanks - even if it was unintentional and possibly frustrating - for testing this!

Thanks to you for making this possible, it was a pleasure to go into adventure mode to try to pair the Pi5 with a Picade! It seems that I am the second person in the world (after you!) to see this combination working :)

EDIT: Since your Picade is under maintenance according to your previous notes, maybe I am the FIRST person in the world to see a Pi5 working with a Picade? Wow, that's something...

Gadgetoid commented 6 months ago

under maintenance

That's putting it very lightly!

New BIG one in the works, though :wink: but I'm not sure it counts.

ptumelty commented 6 months ago

The problem with the power button is that I can use it for power-off, but not for power-on. Probably because the power supply has to be connected to the Pi5 directly instead to the PicadeX hat, or the display resets itself every second. Do you happen to know what the problem with the display is?

This is interesting. I've started seeing issues like this where the screen seems to drop out every second or so when I have my xbox controller connected. If I pull it out then all is good. Not sure what has changed as this used to work. Will try the config setting and see if that helps :)

vanfanel commented 6 months ago

under maintenance

That's putting it very lightly!

New BIG one in the works, though 😉 but I'm not sure it counts.

Do you mean you are working on a big bartop Picade??

Gadgetoid commented 6 months ago

Do you mean you are working on a big bartop Picade??

It's a very poorly kept secret... :eyes:

vanfanel commented 6 months ago

Do you mean you are working on a big bartop Picade??

It's a very poorly kept secret... 👀

Oh you shouldn't keep that in secret at all! I was about to get a 2 players bartop to put another Pi5 inside, but since the Picade has gave me so much happiness these years, now I will wait for yours to release.. Good thing I got notice about it!

vanfanel commented 6 months ago

BTW, the Pi5 gets hot as hell under the hat... 85 degrees after a minute, which toggles throttling.

I have bought a GPIO extension cable to separate the hat from the Pi5, and install a fan on the Pi5.

So maybe next hat designs should take Pi5 heat (and consequent need of a fan) in mind.

Gadgetoid commented 6 months ago

So maybe next hat designs should take Pi5 heat (and consequent need of a fan) in mind.

There is - at least on the revision I have here - a very generous fan hole in the power board. Though I don't actually have a fan installed... :laughing:

We're close to being production ready and had some prototype units at EMFCamp which got quite a battering I'm told.

Controls have also moved to USB to... save some pain :laughing: ... you can forego the Pi and put a whole Mini ITX (or is it Mini ATX... or is it Micro ATX... or is it....) PC inside there.

Also works great with the Steam Deck! :laughing: though none of the power control stuff works.

vanfanel commented 6 months ago

@Gadgetoid Good on the change to USB! But please get sure that 1000 Hz USB polling rate (passing usbhid.jspoll=1 xpad.cpoll=1) is supported in order to fight lag. From your description, it will be ideal to stuff a MiSTer inside :D