Skip to content

installing wiringPi on openelec

I’ve been having fun with Raspberry Pis recently. I’ve got one setup with openelec that I bring on camping trips, with some movies on a USB hard drive. By default, the pi doesn’t provide enough power on it’s USB ports, so I had to use an external USB hub. This meant two AC adapters, and lot more cabling. After some research, I found it’s possible to increase the power output on the USB ports (lock in auxillary power?) from 600mA to 1.2A. Testing & Setting the USB current limiter on the Raspberry Pi B+ has the details; you can use gpio to temporary bump the power, and then edit config.txt to retain that setting on reboot.

gpio is part of wiringPi, which has a pretty straightforward “git clone then build” installation story, but openelec is pretty locked down; no apt-get. To get a working copy of gpio, I followed the install instructions on another pi, then copied the compiled output over. But gpio relies on some shared C libraries, and didn’t run for me:

    ./gpio: error while loading shared libraries: libwiringPi.so: cannot open shared object file: No such file or directory

To see which shared libraries gpio needs, we can run ldd:

    /lib/libarmmem.so (0xb6ef2000)
    libwiringPi.so => not found
    libwiringPiDev.so => not found
    libpthread.so.0 => /lib/libpthread.so.0 (0xb6ed2000)
    libm.so.6 => /lib/libm.so.6 (0xb6e5f000)
    libc.so.6 => /lib/libc.so.6 (0xb6d39000)
    /lib/ld-linux-armhf.so.3 (0xb6efc000)

So it needs to find libwiringPi.so and libwiringPiDev.so. the wiringPi compiled output has wiringPi/libwiringPi.so.2.0 and devLib/libwiringPiDev.so.2.0, so we make a directory with those symlinked in, and then tell C to look for shared libraries there.

    mkdir /storage/lib
    ln -s /storage/wiringPi/wiringPi/libwiringPi.so.2.0 /storage/lib/libwiringPi.so
    ln -s /storage/wiringPi/devLib/libwiringPiDev.so.2.0 /storage/lib/libwiringPiDev.so
    export LD_LIBRARY_PATH=/storage/lib:$LD_LIBRARY_PATH

Now gpio can find it’s libraries. I was able to test my usb hard drive, and it works with 1.2A!

4 Comments

  1. Henk wrote:

    Hi,
    I’m also looking for GPIO under OpenElec. Many thanks for your explanation, but I’m not a Linux-expert.
    Can you give me a link to “I followed the install instructions on another pi”?
    May be you can share the compiled code? Is it dependent to the version of OpenElec?

    Friday, December 26, 2014 at 9:57 am | Permalink
  2. ryan wrote:

    The wiringPi instructions I followed on another pi: http://wiringpi.com/download-and-install/

    I can post the compiled code, but I think it might depend on what version of the pi you compiled it on. I had two B+ models I recently ordered, so was confident they were similar enough to be binary compatible. I’ll try to upload it sometime this weekend.

    Friday, December 26, 2014 at 5:53 pm | Permalink
  3. Henk wrote:

    Ryan, thanks for the help, I found it!
    Some more details for others…:
    Installed Raspbmc on a sd-card. Login SSH.
    Enter the following commands (see http://wiringpi.com/download-and-install/)
    sudo apt-get update
    sudo apt-get install make
    sudo apt-get install gcc
    git clone git://git.drogon.net/wiringPi
    cd wiringPi
    git pull origin
    sudo ./build
    The compilation ends succesfully!
    To find the libraries, I enter ldd gpio:
    pi@raspbmc:~/wiringPi/gpio$ ldd gpio
    libwiringPi.so => /usr/local/lib/libwiringPi.so (0xb6f97000)
    libwiringPiDev.so => /usr/local/lib/libwiringPiDev.so (0xb6f89000)
    libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6f6a000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6ef9000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6dc9000)
    /lib/ld-linux-armhf.so.3 (0xb6faf000)
    Copy the 2 library files and gpio to a windows machine.
    Replace sd-card for OE-sd-card and boot, login SSH.
    Make 2 directories:
    /storage/bin
    /storage/lib
    Copy the 2 library files from the windows-PC to /storage/lib
    Copy gpio to /storage/bin
    Execute on both directories chmod +x *
    Execute on /storage/bin commands:
    chown root:root gpio
    chmod 4755 gpio
    Extend paths:
    export PATH=$PATH:/storage/bin
    export LD_LIBRARY_PATH=/storage/lib:$LD_LIBRARY_PATH
    Test installation with:
    Gpio –v
    Gpio readall
    That should give you some confidence that it’s working OK.
    Also set pin high and low and measure good values.

    Still one question:
    I there a way to extend PATH and LD_LIBRARY_PATH permanently for every user?

    Tuesday, December 30, 2014 at 4:42 pm | Permalink
  4. ryan wrote:

    I’m sure there IS a way, but it’d beyond my casual knowledge. A brief googling reveals a dozen different ways for different linux distributions; http://stackoverflow.com/questions/13428910/how-to-set-the-environmental-variable-ld-library-path-in-linux might be a decent place to start.

    Tuesday, January 13, 2015 at 9:36 pm | Permalink