# LIRC multi-GPIO output for the Raspberry Pi

LIRC gives your Raspberry Pi infrared superpowers, but the current included version (as of rpi-3.12.y) does not allow for controlling multiple IR LEDs simultaneuously. Bengt Martensson updated the source to make this possible, but you probably have to recompile the kernel and modules and install them on to your Rasperry Pi. This took me a while to figure out, so I thought I’d document the steps here.

I compiled these instructions from the following sources:

• Alex Bain’s instructions and wiring diagrams for creating a universal remote with a Raspberry Pi.
• ELinux Guide to cross-compiling the the Linux kernel for the Raspberry Pi
• Aron Szabo’s work on porting LIRC to the Raspberry Pi
• Bengt Martensson’s work on creating multiple GPIO outputs for LIRC on the Raspberry Pi

You want to do this on a different machine than your Raspberry Pi. This process will take half a day on a rasppi, much less time if on a more powerful machine. If you have a spare, fast linux machine running, use that. If not, I suggest using Vagrant and VirtualBox to create a virtual Ubuntu box. This is pretty easy, and look here for more information. You can do this on any host operating system.

## 2. Change the 2 files needed so LIRC supports multiple GPIO outputs

Add these lines in linux/drivers/staging/media/lirc/Kconfig

And add these lines to linux/drivers/staging/media/lirc/Makefile

Download the file lirc_rpi.c from Bengt Mårtensson here and put it in the folder linux/drivers/staging/media/lirc

## 4. Set an environment variable KERNEL_SRC to point to the location of the source

If you cloned the repository in step 1 to your ~, then use the following. Otherwise adjust the path accordingly.

## 8. Pull the /proc/config.gz from the running Raspbian installation

Do this form the Raspberry Pi. I assume you are running a Debian flavor OS on your Raspberry Pi.

## 9. Prime kernel with the old config

You need to have the .config file in the folder from step 1 and then run

If you are asked a bunch of questions, press enter and accept all of the default values.

## 10. Build the new kernel

This will take about an hour, depending on the speed of your processor. This will take 12 hours if you do it on the Raspberry Pi.

## 12. Set aside the new kernel modules by using

From the directory in step 1, run:

## 13. Create the kernel image

From the tools/mkimage clone location in step 5 run:

## 14. Move kernel.img to the Raspberry Pi’s /boot/ directory

There now should be a file kernel.img in the same directory from the previous step.

Copy the file kernel.img somehow (USB, scp, Dropbox, whatever) to the /boot dir on the Raspberry Pi

## 15. Package up the modules into an archive

Move into the ~/modules directory and package up the lib dir.

Now move the file lib.tgz to your Raspberry Pi.

## 16. Move the modules archive to the Raspberry Pi

Now back to the Raspberry Pi. Find lib.tgz from the previous step and:

## 17. Get the latest raspberrypi firmware

Do this on the Raspberry Pi.

## 18. Transfer more files to /boot

Transfer the following files from the firmware/boot directory from the above step to the Raspberry Pi /boot directory:

## 20. Update /etc/modules

add the following lines to /etc/modules

## 23. Check that the right lirc module is installed

If all went correctly, you should see something similar after running modinfo lirc_rpi

You should see something similar to the following. You should see a mention of gpio_out_pins, instead of just gpio_out_pin.