Personal tools

Difference between revisions of "Debian 6 GPIO MC PCIDIO24"

From Rivendell Wiki

Jump to: navigation, search
(Created page with "'''Guide Contents''' # Index # Debian 6 Minimal Gnome Install # Debian 6 Installing Pulse Audio|Installing Pulse...")
 
(No difference)

Latest revision as of 15:47, 13 March 2018

Guide Contents

  1. Index
  2. Debian 6 Minimal Gnome Install
  3. Installing Pulse Audio
  4. Installing JACK2
  5. Setup JACK2 with Pulse Audio
  6. Install Rivendell 2.1.1 from Source
  7. Getting Rivendell, JACK2 and Pulse Audio working together
  8. Connecting to JACK via Rivendell Macros
  9. Connecting to JACK via JACK Patch Bay
  10. Configuring GPIO with Rivendell
  11. Summary Install Process
  12. Links to scripts and other files used


So you've followed the guide and all is well but you'd like to have some Fader activated play back (or any other combination of GPIO support). As usual if you're working with JACK as set up in this guide, it does introduce one major problem.


GPIO can't be accessed unless you run the Rivendell daemons as the root user. You can make JACK run as root but then you have all sorts of other problems as every program needs to be run as root in order to access JACK.


So this guide will do the basics of installing the Rivendell GPIO driver for the Measurement Computing PCI-DIO24 Card. Unless you are handy with C++ I don't recommend trying to get other cards to work with Rivendell as you'll need to write a custom driver.


Installing the GPIO pre-reqs:


sudo apt-get install build-essential linux-headers-`uname -r`


If you've followed the guide, you will already have build-essential so all you'll be installing are the kernel headers for your current kernel (substituted by uname -r).


Once thats complete you'll need to download the GPIO source from the Rivendell website (for the sake of the guide I'll assume you've downloaded it to your home directory):


wget http://www.rivendellaudio.org/ftpdocs/gpio/gpio-1.1.0.tar.gz

Untar it:


tar -zxvf gpio-1.1.0.tar.gz
GPIO Configure result
Go into the unzipped directory and run configure:
cd ~/gpio-1.1.0.tar.gz
./configure --prefix=/usr
GPIO make result
After that finishes (which shouldn't take very long) compile the source:
make

Before installing, the make install script expects the following directory to be available: /lib/modules/`uname-r`/extra. If you don't make this directory the make install step will fail complaining that the directory doesn't exist so lets make that now:


sudo mkdir /lib/modules/`uname -r`/extra
GPIO make install result
Now run the install:
sudo make install

With everything in place, we need to update the module database so that the kernel recognises the new gpio driver module:


sudo depmod -a

Finally we can manually activate the gpio module for testing (in theory a reboot should also detect this on start up and load the module automatically):


sudo /sbin/modprobe gpio


With that done you should find you have a new device under /dev/gpio0. If this isn't there check your dmesg and other system logs to try and hunt for clues to why theres an error.


Please note that Under Ubuntu 10.04 I had an error here that said the resource was busy and could not be added. I believe this is some sort of conflict with the comedi libraries supplied with Ubuntu. I could never figure out how to stop this happening and was a large part of the reason why I switched to Debian.


Time for some testing:


sudo gpitest
gpitest GUI
This will bring up a simple dialog that shows you the status of the inputs on the GPIO card. If you can attach wires to the relevant pins and see inputs then everything is fine. All we need to do now is amend the permissions and we're done.


NB: The Measurement Computing PCI-DIO24 card has several modes of operation. You can usually specify how you want this configured at the point of sale however being in the UK I wasn't given this option so I just received a board without any of the extra options.


By default, you don't have any pull down resistors soldered to the board which means you'll have lots of spurious IO signals lighting up. You can solve this by either purchasing SIPs for the board or making your own mini circuits (More info including circuit diagrams...).


Correcting the permissions

As previously mentioned when using JACK the Rivendell daemons run as the local user. Unfortunately by default /dev/gpio0 is owned and accessed only by root. So we need to change the permissions so that other users can access the device, all we have to do is run:


sudo chmod a+rw /dev/gpio0

Unfortunately this gets reset upon a reboot so we'll need to append some changes to /etc/rc.local so that these permissions get applied at boot up.


sudo vi /etc/rc.local

Inside this file add the following before the exit 0 line:


#Rivendell GPIO needs a+rw permissions
#Test for the existence of /dev/gpio0
logger Rivendell GPIO: Amending gpio0 permissions
if [ -e "/dev/gpio0" ]
then
  chmod a+rw /dev/gpio0
  logger Rivendell GPIO: Permissions changed on /dev/gpio0 to a+rw
fi

Its a good idea to invoke rc.local now to check for typos:


sudo /etc/rc.local

If you get no errors run


sudo tail /var/log/messages

You should see the two logger lines in the system logs at which point all you need to do is restart the Rivendell services (or reboot) and you're done.


Add Switcher GUI
Adding this GPIO card to Rivendell

Great so you now have a working card and you can see things happening in gpitest and/or gpotest (if you want outputs). We still have to add this to the host in Rivendell so lets do that. Open up rdadmin --> Manage Hosts and edit the host with the GPIO card. Click on Switchers GPIO.


Edit Switcher GUI
In this new blank box click on Add and set the Switcher Type to Local GPIO.


List GPIO Macros GUI
Put in a meaningful description and then double check that the device is listed as /dev/gpio0. From here its up to you to decide how many inputs (GPIS) and outputs (GPOs) you want.


Please note that on most GPIO cards I've come across you have GPIO blocks that are grouped. The MC PCI-DIO24 card is no different as there are 3 sets of 8 GPIO pins (marked A, B and C). You may find that on some cards you have to have entire blocks as either input or output. I'm not sure if this card also works this way but its something to remember if you have issues trying to get 3 GPOs and 21 GPIs.


With this decided, click on Configure GPIs and assign macro carts to the inputs so that Riv will actually do something. Repeat for the GPOs and you've successfully setup GPIO under Rivendell in Debian 6.

For testing of the GPIs I simply made a whole bunch of macro carts that changed the rdairplay label. E.g. LB GPIO1! all the way to LB GPIO24!. That way I could see things happening in airplay to confirm everything was moving along nicely.


Security Considerations

Opening up gpio0 to all users might not be a good idea. Consider changing the group of the device to Rivendell and adding just the group permissions of rw to the device. That way you're not opening things up to other users that might not be authenticated.