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: cannot open shared object file: No such file or directory

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

    /lib/ (0xb6ef2000) => not found => not found => /lib/ (0xb6ed2000) => /lib/ (0xb6e5f000) => /lib/ (0xb6d39000)
    /lib/ (0xb6efc000)

So it needs to find and the wiringPi compiled output has wiringPi/ and devLib/, 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/ /storage/lib/
    ln -s /storage/wiringPi/devLib/ /storage/lib/
    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!


  1. Henk wrote:

    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:

    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
    sudo apt-get update
    sudo apt-get install make
    sudo apt-get install gcc
    git clone git://
    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 => /usr/local/lib/ (0xb6f97000) => /usr/local/lib/ (0xb6f89000) => /lib/arm-linux-gnueabihf/ (0xb6f6a000) => /lib/arm-linux-gnueabihf/ (0xb6ef9000) => /lib/arm-linux-gnueabihf/ (0xb6dc9000)
    /lib/ (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:
    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; might be a decent place to start.

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