Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Does this work with Banana Pi(s) or Orange Pi(s)?? #1896

Closed
conkydong opened this issue Oct 25, 2022 · 4 comments
Closed

Does this work with Banana Pi(s) or Orange Pi(s)?? #1896

conkydong opened this issue Oct 25, 2022 · 4 comments
Labels

Comments

@conkydong
Copy link

conkydong commented Oct 25, 2022

Does this work with Banana Pi(s) or Orange Pi(s)?

Edit: Bought an OrangePi Zero2 (Allwinner H616) but can't get RPi-Jukebox-RFID to run that.

@conkydong
Copy link
Author

Help?

@conkydong conkydong changed the title Banana Pi BPI-Zero? Does thsi work Banana Pi(s)? Oct 27, 2022
@conkydong conkydong changed the title Does thsi work Banana Pi(s)? Does this work with Banana Pi(s)? Oct 27, 2022
@micxer
Copy link
Contributor

micxer commented Nov 7, 2022

Taking into account that regular Pi's are almost impossible to buy this is a valid question. Is there anything that would make it impossible to use a Banana pi for a Phoniebox?

@bjentsch
Copy link

I'm a bit late to the party, but I managed to get Phoniebox up and running on a Pine A64 which costs about 40 Euros at the time of writing, of course excluding all accessories like WiFi, rotary encoders, power supplies, buttons, NFC reader...

I'll just dump my experiences here and create some tickets here for the bugs I found here in the repo after I have finished scanning the open issues for them 😁

Here we go, this is what you need for Pine64!

Step 0 - preparation (partly because of differences between RPi and Pine64 (or Banana Pi?)

  1. Prepare a user account called "pi", make them administrator
$ useradd pi
$ passwd pi # default on raspbian is "raspberry"
$ sudo usermod -aG sudo pi
$ groups pi # should say pi sudo
  1. Install some software that will be of use later on
$ sudo apt install libasound2-dev lighttpd-mod-deflate

Step 1 - download buster-install-default.sh ("One line install command" doesn't work out of the box as expected)

Download https://raw.githubusercontent.com/MiczFlor/RPi-Jukebox-RFID/master/scripts/installscripts/buster-install-default.sh

Edit the file as follows:

buster-install-default.sh line 693: change from

local php_ini="/etc/php/7.3/cgi/php.ini"

to

local php_ini="/etc/php/$(ls -1 /etc/php)/cgi/php.ini"

Why?

The [email protected] package isn't available anymore in major distros, most offer 7.4 as their oldest supported version.

This is fixed in #1849 but not merged yet; it's plain broken in master.

Make another amendment to the install script:

buster-install-default.sh line 841: add a line to pause the install script there so you have the chance to edit the cloned repository before python dependencies are installed.

Why?

Because the python requirements.txt contains a git repository on GitHub that is referenced with the git:// protocol, which isn't supported by GitHub any more apparently.

The line to add:

read -rp "MODIFY requirements.txt in the cloned directory now! After finishing, hit ENTER to proceed to the next step." INPUT

What does it do? It stops the install script, allowing you to make the changes from #1791 inside requirements.txt: https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/1791/files#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552

Open a second Terminal / SSH connection to your soon-to-be phoniebox.

Then just change git:// to https:// in line 8.

Step 2 - run buster-install-default.sh

Go through the installation configuring the phoniebox as you wish. Complete it, ignoring the errors. If you want, you can restart now.

A few of the things that will fail (because of hardware differences to RPi, some config fails in the config templates, missing permissions, and general Linux sissyness):

  1. GPIO common setup (because the original RPi.GPIO package only works on RPi, and possibly because of outdated pip version)
  2. MPD (Music Player Daemon, the phoniebox's music backend) (because of wrong permission setup and probably missing config)
  3. Card reader (first because of the GPIO package, then because of wrong permissions)
  4. lighttpd PHP server initialization (because of missing packages, wrong permissions, missing/outdated modules)
  5. Audio output (probably)

Step 3 - All the fixes

1) GPIO common setup

The RPi.GPIO package that is being installed by the buster script doesn't work on alternative single board systems such as the Pine A64.

Therefore, we remove it first to install the correct version later:

$ sudo pip3 uninstall RPi.GPIO
$ pip3 cache purge
$ sudo pip3 cache purge

Then, install the version that fits your board:

For Pine A64

$ git clone https://github.com/swkim01/RPi.GPIO-PineA64.git
$ cd RPi.GPIO-PineA64
$ sudo python setup.py install

For Banana Pi

$ git clone https://github.com/LeMaker/RPi.GPIO_BP -b bananapi
$ cd RPi.GPIO_BP
$ sudo python setup.py install

2) MPD (Music Player Daemon)

There are two problems here. First is that MPD is started as root user, but according to every other config file it should run as mpd user (or even pi would be okay). Second problem is that the mpd system service doesn't seem to be enabled by default.

Let's tackle that:

Edit the file /etc/mpd.conf, line 70:

$ sudo nano /etc/mpd.conf

Content of this line after the change:

user				"mpd"

After that, enabled mpd to run at system startup:

$ sudo systemctl enable mpd

3) Card reader permissions (careful: this section covers an i2c card reader!)

We already tackled RPi.GPIO problem, but whack-a-mole continues: Our pi user doesn't have access rights on the i2c device.

$ ll /dev/i2c-1 
# crw-rw---- 1 root i2c 89, 1 Nov 22 00:08 /dev/i2c-1

This is because pi is not inside the i2c user group. Check for yourself:

$ groups pi
# pi : pi sudo

yeah

$ sudo usermod -aG i2c pi
$ groups pi
# pi : pi sudo i2c

Done. By the way, this is the reader I'm using, which works perfectly fine: https://www.amazon.de/dp/B071NZ4SYS/

⚠ Note: requires a tiny bit of soldering for the connector!

4) lighttpd PHP server initialization

So many issues here. Let's tackle them.

  1. missing packages - we already installed lighttpd-mod-deflate in step 0

  2. wrong permissions

lighttpd runs as www-data user, but www-data doesn't have the rights to access the default location of the phoniebox UI (/home/pi/RPi-Jukebox-RFID/htdocs/):

$ sudo -u www-data find /home/pi/RPi-Jukebox-RFID/htdocs
# /home/pi/RPi-Jukebox-RFID/htdocs
# find: ‘/home/pi/RPi-Jukebox-RFID/htdocs’: Permission denied

yeah

I just went with the full-scale method of giving 755 permissions on the folder:

$ sudo chmod -R 755 /home/pi
  1. missing/outdated modules

The lighttpd config from this repo uses mod_compress, which is deprecated. It's not strictly necessary, but to get rid of the warning, you can change /etc/lighttpd/lighttpd.conf (use sudo!) to specify mod_deflate instead of mod_compress in the server.modules section at the bottom of the file.

5) Audio output

I wanted to use a spare USB sound card that I had left sitting on the bottom of some old cable box™. My problem was that its output device ID assigned by ALSA changed on every boot, so sometimes I had audio output working fine, sometimes not. *mild rambling

The basic procedure is like this:

  1. Find your sound card's id using cat /proc/asound/cards:
$ cat /proc/asound/cards

Output on my machine looks like this:

 0 [sun9ihdmi      ]: sun9i-hdmi - sun9i-hdmi
                      sun9i-hdmi
 1 [sun50ia64audio ]: simple-card - sun50i-a64-audio
                      sun50i-a64-audio
 2 [Xmod           ]: USB-Audio - Creative Xmod
                      Creative Technology Ltd Creative Xmod at usb-1c1b400.usb-1, full speed

So, the old Xmod has a "short name" called Xmod (yeah...) and has ID 2 assigned.

Let's configure it to stay the same even after reboots.

$ sudo nano /etc/modprobe.d/alsa-base.conf

...and this content (adapt to your use case!):

options snd-usb-audio id=Xmod index=2

After that, modify /etc/asound.conf to reflect this:

$ sudo nano /etc/asound.conf

File content:

pcm.!default {
        type hw
        card 2
}

ctl.!default {
        type hw
        card 2
}

Finally, adapt the content of RPi-Jukebox-RFID/settings/Audio_iFace_Name. The file content should be the name of the output where you'll connect the phoniebox's speakers to. In my case, it's Speaker:

$ sudo amixer -c 2 scontrols
# Simple mixer control 'Speaker',0 # <-- this is it on the Xmod!
# Simple mixer control 'PCM Capture Source',0
# Simple mixer control 'Line',0
# Simple mixer control 'Mic',0
# Simple mixer control 'Auto Gain Control',0
# Simple mixer control 'Up Down',0

So, Speaker it is for the RPi-Jukebox-RFID/settings/Audio_iFace_Name:

$ echo Speaker > RPi-Jukebox-RFID/settings/Audio_iFace_Name

Step 4 - REBOOT

I mean it!

Step 5 - actually use this thing

This is where I'm at. I'm in the process of selecting and purchasing a case, buttons, rotary dials for the volume, cabling...

I hope these steps help you manage building your own phoniebox on non-RPi hardware. If you have any questions left, or the instructions are unclear, let me know.

@conkydong conkydong changed the title Does this work with Banana Pi(s)? Does this work with Banana Pi(s) or Orange Pi(s)?? Nov 26, 2022
@bjentsch
Copy link

bjentsch commented Dec 8, 2022

An update for you guys trying to get this stuff to work on any other system than the original RPi.

I got everything up and running in a pretty satisfying way. Here's what works:

The system is consuming about 4W of energy during playback.

Having to use USB buttons for my setup

I tried to get GPIO buttons to work for one or two eternities. I read metric tons of code to understand if it was an issue in my configuration or in the phoniebox code. Turns out it was neither.

After reading the RPi.GPIO port's README for the 374th time, I stumbled across this remark in the "features" list:

GPIO interrupts(callbacks when events occur on input gpios) Not Implemented yet!!!

Yeah, well. That's exactly what the phoniebox code is using for GPIO button control. So, the conclusion in this case is:

You can't use GPIO buttons or rotary encoders with your phoniebox with Pine A64!

💡 I'm pretty sure that this doesn't apply to Orange/Banana Pi, as their GPIO implementations don't mention any non-implemented functionality.

This still leaves me with output functionality for GPIO - meaning I have to connect my physical buttons to the above-mentioned USB encoder board while still being able to connect the Status LED to the GPIO pins.

Tackling final permission problems

Things that got in the way in the meantime:

  • GPIO service permissions and
  • USB buttons service permissions

...and for the same reason, namely running as pi:pi user. If you want to change this, head for the config file:

$ sudo nano /etc/systemd/system/phoniebox-buttons-usb-encoder.service

or

$ sudo nano /etc/systemd/system/phoniebox-gpio-control.service

and just delete these two lines:

User=pi
Group=pi

This will cause the services to run as root, eliminating permission problems.

Conclusion

Whew, one hell of a ride. It took me about one week of net working time to get here, split up across about six weeks.

I'd lie if I said it was fun all the time, but it was definitely worth it. I got all the hardware for about the same price as a regular RPi 3B/4, maybe 20 or 30 Euros more. It was an awesome experience to get the phoniebox ecosystem up and running literally bit by bit.

And now it's time to go for the casing, which will be a tiny little wooden suitcase :-D

Repository owner locked and limited conversation to collaborators Dec 19, 2022
@s-martin s-martin converted this issue into discussion #1930 Dec 19, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

4 participants