LIRC GPIO driver for homebrew adapter


209 posts   Page 2 of 9   1, 2, 3, 4, 5 ... 9
by ar0n » Sat Jun 16, 2012 7:48 am
mba wrote:Applying the rest of the patch manually makes the difference :D

pi@raspbmc:~$ sudo insmod lirc_dev.ko
pi@raspbmc:~$ sudo insmod lirc_rpi.ko gpio_in_pin=0 gpio_out_pin=1
pi@raspbmc:~$ lsmod
Module Size Used by
lirc_rpi 4512 0
lirc_dev 8728 1 lirc_rpi
fuse 49448 1

You were faster than me ;) I uploaded the fixed patch file to my site. (lirc_rpi-0.2.1.patch)
Could you check this ?
Posts: 20
Joined: Thu Jun 07, 2012 9:33 pm
by ar0n » Sat Jun 16, 2012 6:57 pm
I've added a pull request here: https://github.com/raspberrypi/linux/pull/38
I hope it will be accepted, so it makes people's lives simpler...
Posts: 20
Joined: Thu Jun 07, 2012 9:33 pm
by mba » Sun Jun 17, 2012 9:06 am
Unfortunately it seems that the patch doesn't include the drivers/lirc_rpi/Makefile.in

Running ./autogen.sh fails:

daemons/Makefile.am: installing `./depcomp'
Makefile.am: installing `./INSTALL'
configure.ac:1775: required file `drivers/lirc_rpi/Makefile.in' not found
autoreconf: automake failed with exit status: 1
configure.ac:1775: required file `drivers/lirc_rpi/Makefile.in' not found
Creating setup-driver.sh ...
rpi: There is no param type, but default parameter is none, should be OK
AMOTE - a LIRC client for Android. Build your own Android-based universal remote. Get it on Google Play! Visit www.datscharf.dk/amote
Posts: 109
Joined: Fri Jun 08, 2012 7:05 pm
Location: Denmark
by ar0n » Sun Jun 17, 2012 9:44 am
I really hate when I f*** up like this ... :/
Pleas check out the 0.2.2 version, sorry ...
Posts: 20
Joined: Thu Jun 07, 2012 9:33 pm
by mba » Sun Jun 17, 2012 5:26 pm
I know what you mean :-), compilation and insmodding with parameters is working now, I will built a blaster and receiver next week and test the actual functionality.
AMOTE - a LIRC client for Android. Build your own Android-based universal remote. Get it on Google Play! Visit www.datscharf.dk/amote
Posts: 109
Joined: Fri Jun 08, 2012 7:05 pm
Location: Denmark
by mredeker » Sun Jun 17, 2012 9:51 pm
If you could create a bill of materials for receiver and blaster that would be nice.
I am ok with soldering but not sure what pieces to get.
Posts: 8
Joined: Tue Jan 31, 2012 12:54 pm
by mba » Mon Jun 18, 2012 7:17 pm
I have it running now on raspbmc. The modules is built separately on my ubuntu desktop and copied to target. I have built the serial IR transmitter curcuit from the lirc page, and hooked it up to GPIO 0. It works perfectly and I have just turned on my amp for the first time :D. Thanks for your work on making this possible aron. If you need help with testing or any other thing just let me know.

I am using a network based remote, and in order for this to work I needed lircd listen on network connections. With a tip from s7mx1 at the raspbmc forum I discovered that I needed to add the "--listen" parameter to /etc/udev/rules.d/20-lirc.rules.
AMOTE - a LIRC client for Android. Build your own Android-based universal remote. Get it on Google Play! Visit www.datscharf.dk/amote
Posts: 109
Joined: Fri Jun 08, 2012 7:05 pm
Location: Denmark
by Penfold » Wed Jun 20, 2012 12:31 pm
ar0n wrote:I really hate when I f*** up like this ... :/
Pleas check out the 0.2.2 version, sorry ...


I'll forgive you given it is working great for me and you beat me to it by about a week.

top work... but! I have found a couple of things:
1) it seems to leave the LED on after sending codes - maybe we can add a call at the end to turn the led off. this could cause problems for people over-driving their LEDs with excessive current. This is usually ok for short bursts, but leaving it on may cause it to fail prematurely
2) I cant get autogen.sh to work on the Pi. As the lirc download is nfs exported from a fedora x86 box, I just ran autogen from there and then did the rest on the pi itself, but i'd like to work out what im missing on the pi:
here is the start of the errors:
root@raspberrypi:/artemis/lirc# ./autogen.sh
configure.ac:24: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
configure.ac:10: required file `./install-sh' not found

thanks again for your great work on this.
Posts: 1
Joined: Wed Jun 20, 2012 12:04 pm
by g0rdon » Fri Jun 22, 2012 12:28 am
(The previous version of this post contained incorrect files in that the transistor package was EBC instead of CBE. The board wouldn't let me correct but only delete the post -- hopefully not much harm was done yet.)

@mredeker and other interested parties,

Attached to this post are the complete design files in Eagle CAD format for a possible implementation of a transceiver for the RPi and LIRC. (The tar.gz is really tar.xz, I guess this forum isn't really configured for sharing files the type and size needed for this stuff, so I had to make a few unorthodox moves here.)

The only safe way to do the transmitter part is to use a separate power supply for the IR LEDs (you can't know in advance what PSU will one drive the RPi from) so it runs off two AA batteries. This is the safest bet if you don't know what you are doing, electronics-wise.

The board itself is designed so that it can be glued (with hot glue or double-sided tape or whatever) on top of a 2xAA battery holder. The only thing one has to make very sure of is that the driver turns the transmitter off after it's done sending, or else smokes will puffs. On the plus side, the design provides pretty good range. One may solder the LEDs a bit bent so they are turning away from one another a couple of degrees for increased radiation angle. Soldering should be a breeze even for the unexperienced (all through-hole components and plenty of clearance between them).

The CAM files can be sent to Seeed Studio for manufacturing (about $15 for 10 boards shipped, or 20 boards if someone panelizes the design); or possibly any other PCB manufacturer, but the Gerbers were generated with Seeed's CAM rules. The other components should not cost more than a couple of bucks in one-off quantities.

BOM is on the schematic.

For reference, here are the schematic and the board layout images (download them for full size):
rpi_lirc_transceiver_sch.png
Schematic
rpi_lirc_transceiver_sch.png (24.99 KiB) Viewed 10326 times

rpi_lirc_transceiver_brd.png
Board layout
rpi_lirc_transceiver_brd.png (13.44 KiB) Viewed 10326 times


I have also sent Áron an amended version of the schematic that is up on his site (he's yet to publish them) that has actually been built. That one runs off the RPi entirely, range unknown, also the only thing there is to be said about that one is that it runs with my RPi off my power supply. You are much better off using the battery-powered version.

No warranty, also I will not be monitoring this forum in the future. Good luck with your transceivers.
Attachments
rpi_lirc_transceiver.tar.gz
Eagle files
(46.47 KiB) Downloaded 456 times
Posts: 1
Joined: Thu Jun 21, 2012 10:12 pm
by podly » Mon Jun 25, 2012 2:34 pm
This is really nice add-on, thanks for it!

Could you provide some manual, how to include patch when compiling OpenElec from git?
It would be nice to have up-to-date kernel.

Any chance, to have this feature included in future OpenElec distributions?
User avatar
Posts: 38
Joined: Fri Jun 22, 2012 8:57 pm
by podly » Tue Jun 26, 2012 8:04 am
I found how to compile OpenELEC with your patch, maybe it will be usefull for someone:

Assuming that you allready have git OpenELEC in /home/OpenELEC.tv/.

1. wget http://aron.ws/projects/lirc_rpi/kernel ... -0.2.patch
2. copy it to /home/OpenELEC.tv/packages/linux/patches/linux-3.2.21-602-RPi_lirc_gpio.patch
2. edit /home/OpenELEC.tv/packages/linux/patches/linux-3.2.21-602-RPi_lirc_gpio.patch and change all paths /staging/lirc/ to /staging/media/lirc/
3. edit /home/OpenELEC.tv/packages/linux/patches/linux-3.2.21-601-RPi_support-0.1.patch and add in line 1642: +CONFIG_LIRC_RPI=y

and just make OpenELEC normal: PROJECT=RPi ARCH=arm make release

It is possible that you will need to press the y(yes) key two times during compilation, when asked for LIRC_RPI=y

This soluttion is little crappy, but it works.I tested it with r11392 and r11404.
User avatar
Posts: 38
Joined: Fri Jun 22, 2012 8:57 pm
by Ollzer » Fri Jun 29, 2012 8:01 am
Hi guys,
Could someone be so nice and make quick instructions on how to make this work on Debian?
I've been a Debian user for quite long (on server side) but when it comes to lirc patching and kernel recompiling I feel I'm a total newbie.

But thanks for making all these nice things.
Posts: 1
Joined: Fri Jun 29, 2012 7:51 am
by pi_vip » Tue Jul 03, 2012 12:01 pm
hello,

many thanks for the work done! the driver works great out of the box within raspbmc RC3 and TSOP4838 together with my harmony remote.

bye
Posts: 4
Joined: Tue Jul 03, 2012 11:59 am
by Izzeho » Sun Jul 08, 2012 5:39 am
Just set this up and gave it a whirl. Working perfectly with my RPi for controlling XBMC. Now I just need to solve audio (as sound over HDMI to my projector is less than excellent) and I've got a full blown media center.

I am curious if you have any links to some good documentation on sending IR out? Looking to be able to press buttons on my remote which will output another to switch on my aircon/projector/etc.
Posts: 2
Joined: Fri Jun 29, 2012 9:33 am
by selectnone » Fri Jul 20, 2012 12:14 am
Hi, might there be some reason why I can't get this to make properly?

Might the patch have gone out-of-sync with the latest source or something?
(sorry, I'm fairly new to Linux, so I'm not certain what might go wrong here)

I'm cross-compiling for Debian, in Ubuntu, with config taken from the official Raspbian.
I've successfully managed to patch and build the kernel, and patched and configured the Lirc.

I get this error-screed when I run "make ARCH=arm":

root@angelBrain-VirtualBuntu:/home/neal/raspberrypi/lirc# make ARCH=arm
make all-recursive
make[1]: Entering directory `/home/neal/raspberrypi/lirc'
Making all in drivers
make[2]: Entering directory `/home/neal/raspberrypi/lirc/drivers'
Making all in lirc_dev
make[3]: Entering directory `/home/neal/raspberrypi/lirc/drivers/lirc_dev'
cp ./../lirc_dev/Module*.symvers .
cp: cannot stat `./../lirc_dev/Module*.symvers': No such file or directory
make[3]: [lirc_dev.o] Error 1 (ignored)
mv Makefile Makefile.automake
cp ./../Makefile.kernel Makefile
CPPFLAGS="" CFLAGS="" LDFLAGS="" \
make -C /home/neal/raspberrypi/linux/ SUBDIRS=/home/neal/raspberrypi/lirc/drivers/lirc_dev modules \
KBUILD_VERBOSE=1
make[4]: Entering directory `/home/neal/raspberrypi/linux'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
echo; \
echo " ERROR: Kernel configuration is invalid."; \
echo " include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo; \
/bin/false)
mkdir -p /home/neal/raspberrypi/lirc/drivers/lirc_dev/.tmp_versions ; rm -f /home/neal/raspberrypi/lirc/drivers/lirc_dev/.tmp_versions/*
make -f scripts/Makefile.build obj=/home/neal/raspberrypi/lirc/drivers/lirc_dev
gcc -Wp,-MD,/home/neal/raspberrypi/lirc/drivers/lirc_dev/.lirc_dev.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include -I/home/neal/raspberrypi/linux/arch/arm/include -Iarch/arm/include/generated -Iinclude -include /home/neal/raspberrypi/linux/include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-bcm2708/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -fno-dwarf2-cfi-asm -fno-omit-frame-pointer -mapcs -mno-sched-prolog -fstack-protector -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv5t -Wa,-march=armv6 -mtune=strongarm -msoft-float -Uarm -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -DCC_HAVE_ASM_GOTO -DEXPORT_SYMTAB -DHAVE_CONFIG_H -I. -I../.. -I/home/neal/raspberrypi/lirc/drivers/lirc_dev/. -I/home/neal/raspberrypi/lirc/drivers/lirc_dev/. -I/home/neal/raspberrypi/lirc/drivers/lirc_dev/../.. -I/home/neal/raspberrypi/lirc/drivers/lirc_dev/../.. -I/home/neal/raspberrypi/linux//include/ -I/home/neal/raspberrypi/linux//drivers/media/video/ -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(lirc_dev)" -D"KBUILD_MODNAME=KBUILD_STR(lirc_dev)" -c -o /home/neal/raspberrypi/lirc/drivers/lirc_dev/.tmp_lirc_dev.o /home/neal/raspberrypi/lirc/drivers/lirc_dev/lirc_dev.c
cc1: error: unrecognised command line option ‘-mlittle-endian’
cc1: error: unrecognised command line option ‘-mapcs’
cc1: error: unrecognised command line option ‘-mno-sched-prolog’
cc1: error: unrecognised command line option ‘-mno-thumb-interwork’
/home/neal/raspberrypi/lirc/drivers/lirc_dev/lirc_dev.c:1:0: error: unknown ABI (aapcs-linux) for -mabi= switch
/home/neal/raspberrypi/lirc/drivers/lirc_dev/lirc_dev.c:1:0: error: bad value (armv5t) for -march= switch
/home/neal/raspberrypi/lirc/drivers/lirc_dev/lirc_dev.c:1:0: error: bad value (strongarm) for -mtune= switch
make[5]: *** [/home/neal/raspberrypi/lirc/drivers/lirc_dev/lirc_dev.o] Error 1
make[4]: *** [_module_/home/neal/raspberrypi/lirc/drivers/lirc_dev] Error 2
make[4]: Leaving directory `/home/neal/raspberrypi/linux'
make[3]: *** [lirc_dev.o] Error 2
make[3]: Leaving directory `/home/neal/raspberrypi/lirc/drivers/lirc_dev'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/neal/raspberrypi/lirc/drivers'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/neal/raspberrypi/lirc'
make: *** [all] Error 2


Any clue?

I managed to compile Lirc a couple of weeks ago (getting a USB IR Toy to work) so I'm pretty sure it's not meant to look like that ;)
I want to try using a GPIO IR transmitter, I quite like the idea of using a simpler bit of hardware that I made myself :D
Posts: 55
Joined: Fri Jun 22, 2012 10:16 pm
by Xxyzzy » Sun Jul 22, 2012 9:59 am
Regarding that the transmitter is left on after sending codes.

There seem to be a line missing in lirc_rpi.c, lirc_write(), after the for-loop:

for (i = 0; i < count; i++) {
if (i%2)
send_space(wbuf[i] - delta);
else
delta = send_pulse(wbuf[i]);
}

+ GPIO_CLEAR_PIN(gpio_out_pin);

spin_unlock_irqrestore(&lock, flags);
Posts: 2
Joined: Sun Jul 22, 2012 9:51 am
by Xxyzzy » Sun Jul 22, 2012 2:39 pm
The driver seem to work very well also with 433.92 Mhz RF modules (RX433 and TX433N).

433-1.jpg
Raspberry Pi with 433 Mhz RF receiver and transmitter modules.
433-1.jpg (27.04 KiB) Viewed 9693 times


The transmitter module is directly connected to VCC, Gnd and GPIO17.

The receiver module has two 1N4148 in series with GPIO18 (to reduce the +5V) and is also loaded with a 100k resistor towards Gnd.
Posts: 2
Joined: Sun Jul 22, 2012 9:51 am
by naicheben » Thu Jul 26, 2012 5:56 pm
Aron
Is the driver stable and does it use device tree instead of direct programming the GPIO pins like it's been asked for here: https://github.com/raspberrypi/linux/pull/38
If so, why is it not merged into git-kernel? I don't have any bad issues with your driver for a month now. To me it looks very stable.
Posts: 344
Joined: Sat Jan 28, 2012 12:28 pm
by selectnone » Thu Jul 26, 2012 8:51 pm
selectnone wrote:Hi, might there be some reason why I can't get this to make properly?

Might the patch have gone out-of-sync with the latest source or something?
(sorry, I'm fairly new to Linux, so I'm not certain what might go wrong here)

I'm cross-compiling for Debian, in Ubuntu, with config taken from the official Raspbian.
I've successfully managed to patch and build the kernel, and patched and configured the Lirc.


I eventually managed to get this to work by compiling on the Pi instead - rebuilding the kernel took a night instead of a few minutes, but it worked...
Posts: 55
Joined: Fri Jun 22, 2012 10:16 pm
by klims » Sun Jul 29, 2012 9:46 am
This looks awesome! Exactly what I was looking for. I'm having a little trouble getting it working though. Any chance someone can give me a basic sudo code run down of what I need to do to get this compiling on my Pi? I'm guessing I have missed a step somewhere.

Also, will this work on raspbian?
Posts: 7
Joined: Wed Jul 25, 2012 4:46 am
by cen » Mon Aug 06, 2012 9:04 pm
you can download the Modules.symvers from this site:

https://www.grendelman.net/wp/compiling ... pberry-pi/

then you don't need to build the entire kernel, just the one module via "make M=drivers/staging/lirc" (haven't tried the receiver yet, but i can modprobe lirc_rpi)
Posts: 1
Joined: Mon Aug 06, 2012 9:00 pm
by TomPi91 » Wed Aug 08, 2012 3:55 pm
Is there a possibility of someone writing a more detailed instruction on how to get the whole lirc running on Raspbian and maybe explaining if we really have to recompile the kernel or which modules we have to compile?
Best regards
Posts: 6
Joined: Mon Aug 06, 2012 11:04 am
Location: Stuttgart, Germany
by mba » Thu Aug 09, 2012 7:50 pm
You asked for it ;-) i installed lirc in 33 simple steps on my own raspbian. I just went through the list again and tested that it worked, hopefully I haven't made too many typos.

Best regards
Martin

1. cd ~
2. wget https://www.grendelman.net/files/raspi/Module.symvers --no-check-certificate
3. cd /usr/src
4. sudo wget -O raspberrypi-linux-3.1.9.tar.gz https://github.com/raspberrypi/linux/ta ... pi-patches
5. sudo tar xzf raspberrypi-linux-3.1.9.tar.gz
6. sudo ln -s /usr/src/raspberrypi-linux-<tab> /lib/modules/`uname -r`/build
7. cd raspberrypi-linux-<tab>
8. sudo sh -c 'zcat /proc/config.gz > .config'
9. sudo sed -i 's/EXTRAVERSION =.*/EXTRAVERSION = +/' Makefile
10. sudo cp ~/Module.symvers .
11. sudo make oldconfig
12. sudo make modules_prepare
13. sudo apt-get install libtool
14. sudo apt-get install autoconf
15. sudo apt-get install git
16. cd ~
17. git clone git://lirc.git.sourceforge.net/gitroot/lirc/lirc
18. cd lirc
19. wget http://aron.ws/projects/lirc_rpi/lirc_rpi-0.2.2.patch
20. patch -p1 < lirc_rpi-0.2.2.patch
21. nano drivers/lirc_rpi/lirc_rpi.c
Added the line GPIO_CLEAR_PIN(gpio_out_pin); in this function:
static ssize_t lirc_write(struct file *file, const char *buf,
size_t n, loff_t *ppos)
{
int i, count;
unsigned long flags;
long delta = 0;
int *wbuf;

count = n / sizeof(int);
if (n % sizeof(int) || count % 2 == 0)
return -EINVAL;
wbuf = memdup_user(buf, n);
if (IS_ERR(wbuf))
return PTR_ERR(wbuf);
spin_lock_irqsave(&lock, flags);

for (i = 0; i < count; i++) {
if (i%2)
send_space(wbuf[i] - delta);
else
delta = send_pulse(wbuf[i]);
}
----> GPIO_CLEAR_PIN(gpio_out_pin);
spin_unlock_irqrestore(&lock, flags);
kfree(wbuf);
return n;
}

21. ./autogen.sh
22. ./configure --with-driver=rpi; make; sudo make install
23. sudo cp contrib/lirc.rules /etc/udev/rules.d/10-lirc.rules
24. sudo cp contrib/lirc.debian /etc/init.d/lirc
25. nano /etc/init.d/lirc
insert at beginning:
### BEGIN INIT INFO
# Provides: lirc
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
insert at start and restart:
if test ! -d /var/run/lirc; then
mkdir /var/run/lirc
fi
insert this under start and restart where lircd is started:
start-stop-daemon --start --quiet --exec /usr/local/sbin/lircd -- --device=/dev/lirc/0 --listen

26. sudo insserv /etc/init.d/lirc
27. sudo mkdir /etc/lirc
28. sudo cp contrib/lircd.conf /etc/lirc/ (or copy your own conf with your preferred set of remotes)
29. sudo cp contrib/lircmd.conf /etc/lirc/
30. sudo mv /lib/modules/3.1.9+/misc/lirc_dev.ko /lib/modules/3.1.9+/kernel/drivers/media/rc/
31. sudo depmod -a
32. sudo nano /etc/modules
insert at the end of the file:
lirc_dev
lirc_rpi gpio_out_pin=0 gpio_in_pin=1

33. sudo shutdown now -r
AMOTE - a LIRC client for Android. Build your own Android-based universal remote. Get it on Google Play! Visit www.datscharf.dk/amote
Posts: 109
Joined: Fri Jun 08, 2012 7:05 pm
Location: Denmark
by TomPi91 » Thu Aug 09, 2012 9:02 pm
Wow, that's what I call some detailed instructions :D!
Thank you very much! Just followed them and I hope to be able to give you some feedback tomorrow in the morning! So far the whole installation process worked like a charm.
There is only one "typo" if you can call it that.
At 25. it should be "sudo nano /etc/init.d/lirc" I think because otherwise you can't save the file.
Thank you very much again!
Best regards!
Posts: 6
Joined: Mon Aug 06, 2012 11:04 am
Location: Stuttgart, Germany
by klims » Sun Aug 12, 2012 9:48 pm
Thanks for the detailed instruction mba! I don't think I would have worked that out on my own...
Works like a charm on my raspberrypi with raspbian
Posts: 7
Joined: Wed Jul 25, 2012 4:46 am