Just done some more experiments and wonder if the results might be at all informative.
On the Pi4, I started with both the gpio-poweroff tweak and the squeezelite power on/off option switched off.
I never touched the gpio-poweroff tweak during these tests.
Logged in via SSH, I checked the state of GPIO 13. It was set as an input, so I set it to output:
Next, I ensured it was low:Code:pcp-gpio mode 13 out
and verified that it was low:Code:pcp-gpio write 13 0
Next, I made sure that the player was switched off in the LMS web interface.Code:pcp-gpio read 13
Then I turned on the squeezelite power on/off option, setting the GPIO pin as 13 and active high.
After saving, which restarted squeezelte, the LMS web interface showed te player as OFF.
But when I ran:
the pin was HIGH, even though the player was off.Code:pcp-gpio read 13
Switching the player on & off in the LMS web interface made no difference to the state of GPIO 13; it stayed HIGH at all times.
So the squeezelite power on/off option is clearly doing SOMETHING with GPIO 13; just not what is expected.
Just out of interest, I tried the same experiment but choosing the Active LOW option in the squeezelite power on/off setting.
This time GPIO 13 stayed LOW at all times.
Results 21 to 29 of 29
-
2020-12-23, 13:35 #21
- Join Date
- Apr 2005
- Location
- Watford, UK
- Posts
- 1,927
Transporter -> ATC SCM100A
-
2020-12-24, 09:52 #22
- Join Date
- Apr 2005
- Location
- Watford, UK
- Posts
- 1,927
Problem apparently solved
OK, today the GPIO pin suddenly started working as desired, but I had no idea which of the many things I fiddled with had done the trick.
So I've spent a lot of time experimenting, being very methodical to try and find out what fixed it.
Here's what I found. Bear in mind this is on a RPi4 using piCorePlayer 6.1.0.
1. Flash SD card with a fresh piCorePlayer image and boot up.
2. SSH in and check some things:
a). GPIO 13 is in mode IN, voltage low.
b). ps -ef shows squeezelite running with these options: -o hw:CARD=ALSA -a 80 1
3. Try playing a track: No audio, pause causes track to restart rather than pause, seek skips to position but then plays back a loop of about 5 secs.
4. Set power on/off to GPIO 13, active high. Squeezelite restarts.
5. readall.sh now shows GPIO in mode OUT, voltage high (even though player is off).
6. Switching player on & off makes no difference; GPIO 13 remains high at all times.
7. ps -ef shows squeezelite with options: -o hw:CARD=ALSA -a 80 1 -G 13 H
8. Try playing a track: no change, behaviour as in (3) above.
9. Restart squeezelite: no change.
10. Reboot piCorePlayer: no change.
11. Change audio output to RPiDAC and save, then back to analog audio and save. Squeezelite fails to restart.
12. Reboot.
13. Now we have a fully functioning player!
a). GPIO 13 behaves as required: voltage low when player is off, high when player is on.
b). Playback works correctly: pause pauses, seek skips as it should.
c). ps -ef shows squeezelite options: -o hw:CARD=ALSA -a 80 0 -G 13 H
So it would seem that switching the audio output device is the crucial step that gets everything going.
(I speculate that the reason others say "it just works" is perhaps because they had already set their output device to something other than the default analog audio).
I am also intruiged by the change in the parameters to the -a option that happened.
That second parameter (0 instead of 1) is presumably the thing that got the audio output working.
The documentation says that this is the "period count or size in bytes". No idea what that means.
In summary, to get it working on the Pi4, the minimum sequence of steps is:
1. Flash SD card with piCorePlayer, boot up.
2. Set power on/off to desired GPIO.
3. Set audio output to something else, save.
4. Set audio output back to analog, save.
5. Reboot.
6. Player now behaves as expected.
Mysteries that remain:
1. Why does changing the audio output fix the behaviour of the GPIO control?
2. Why did pause and seek do the wrong things until the audio output was fixed? (It's not like LMS has any idea that the player's output device is set up wrong).
Thanks to everyone who helped me with this.
It was a bit of an ordeal, but of course orders of magnitude less work than creating my own plugin, as I had originally thought I would need to do!Transporter -> ATC SCM100A
-
2020-12-24, 11:15 #23
Hi Cliveb
Glad you got it working, if by a long winded process !
However
So it would seem that switching the audio output device is the crucial step that gets everything going.
(I speculate that the reason others say "it just works" is perhaps because they had already set their output device to something other than the default analog audio).
BUT
I ALWAYS resize the fs to full sdcard capacity before doing anything
Maybe its ANY operation rather than changing O/P device
I'll give it a try when I get a minute and report back
Edit:
Have just tried, I burned SDCard once booted went straight to Web SL settings and set GPIO 13 High. As soon as SL restarted (after save) LED came on.
From SL-X I turned off the player and the LED went out. LED continues to correctly follow the power state.
Weird !
Edit2: I Used piCorePlayer7.0.0b6
At first boot
tc@pCP:~$ ps -ef | grep squeezelite
8364 root /usr/local/bin/squeezelite -n piCorePlayer -o hw:CARD=Headphones -a 80 1
9737 root /usr/local/bin/squeezelite -n piCorePlayer -o hw:CARD=Headphones -a 80 1 -G 13 H
JeffLast edited by Jeff07971; 2020-12-24 at 11:50. Reason: Added Result
-
2020-12-24, 15:56 #24
- Join Date
- Apr 2005
- Location
- Watford, UK
- Posts
- 1,927
I did try that at one point, but it didn't seem to help.
I guess that's possible.
I'll try using that version and see what happens.
But probably not for a couple of days now.
(Interesting that the default output device for you was CARD=Headphones rather than CARD=ALSA. I'll check that when I try 7.0.0b6).
Merry Christmas!Transporter -> ATC SCM100A
-
2020-12-24, 18:57 #25
Headphones is the correct output for onboard audio in pCP7. They finally cleaned up the driver to make it more user friendly.
piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
2020-12-26, 04:58 #26
- Join Date
- Apr 2005
- Location
- Watford, UK
- Posts
- 1,927
Just been doing a few more experiments.
Using piCorePlayer 6.1.0, I finally discovered that the critical step is to change the fourth option on the ALSA output setting to 0. After restarting squeezelite, everything just works, including the GPIO toggling. No reboot required. Once I discovered this, a quick search of the forums found a few threads where Paul had stated that mmap=1 doesn't work on the Pi4B in 64 bit mode. I didn't even realise that 6.1.0 was 64 bit. (Or perhaps it is 32 bit and mmap=1 doesn't work on a Pi4B in any mode?).
Can anyone explain what the mmap option actually does?
Weird that an audio output setting affects the GPIO control.
Anyhow, I then tried out piCorePlayer 7.0.0.
Both versions (standard - which I presume is 32 bit, and 64 bit) worked straight out of the box, even with mmap set to 1. Setting the GPIO power on/off worked without any issue. So I guess whatever the issue was with mmap has been resolved in Squeezelite 1.9.8 (piCorePlayer 6.1.0 shows that it uses Squeezelite 1.9.6).
But it is interesting to note that the non-working mmap setting seems to affect other apparently unrelated subsystems - perhaps not just the GPIO control. Presumably had Paul or Jeff been aware of this they'd have pointed me in the right direction much sooner.
Ironic that if I had waited a few days to start playing around with this and 7.0.0 had been released, none of this would have come to light. But it has at least revealed a possibly useful piece of info for anyone else who encounters the issue.Transporter -> ATC SCM100A
-
2020-12-26, 06:24 #27
Squeezelite uses mmap by default....there are some cases with a 64bit kernel, where it doesn’t work. I’ve not been very successful setting their automatically.
piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
2020-12-26, 07:38 #28
- Join Date
- Apr 2005
- Location
- Watford, UK
- Posts
- 1,927
-
2020-12-26, 09:00 #29
Something may have changed....its so hard to keep up with testing. But
in pCP6.1 the RPI4 used a 64bit kernel with 32 bit userspace. In this configuration, onboard audio did not work with mmap turned on. However USB and i2s cards worked fine.
in pCP7, in 64bit system, it does now appear that the headphone jack does work with mmap enabled.piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer