USB IR Toy - PIC 18F2550 fw_update under Linux

I'm in the process of setting up my HTPC, so I ordered USB IR Toy to be able to turn TV on without using remote control.


When I got it, I was unable to make it work. Fortunately, there is V command which returns current version of firmware, and on my device it was V212 which means Hardware V2 and firmware V12. Since latest firmware is V22, I decided to upgrade firmware. In the process I bricked it (using wrong fw_update program which doesn't flash whole device, but just first 2K of application). Fortunately, this PIC has Diolan bootloader which is accessible using jumper (small blue peace of wire on picture) even if you flashed just part of application on it (as I did).

Result it fw_update for PIC 18F2550 which IR Toy uses , updated wiki page about IR Toy firmware update on Linux and comment on bug tracker. Hopefully, this will help someone else instead of learning all this stuff, which was fun in itself :-)

Next step was to try SUMP logic analyzer mode which can produce nice graph of IR communication. I used Debian sump-logicanalyzer package to produce following picture:


Now that I was sure that it works and can communicate with my LG TV remote, I decided to give one of sample programs, IRToyRecPlay a try. It doesn't come with Makefile, so I compiled it using:

gcc *.c -o IRToy
Unfortunatly, it doesn't seem to work for me (can you see pattern here?). So, I decided to try fork of IRToyRecPlay on github which works better under Linux (after PIC fw_update problems I didn't really spent any time investigating why - I suspect that upstream Dangerous Prototypes source works well under Windows).

First, I recorded power button from remote using

./IRToy -d /dev/ttyACM0 -f lgtv -r
This created lgtv_000.bin file which I could reply to get TV turn on:
./IRToy -d /dev/ttyACM0 -f lgtv -p
I noticed that I can't just reply same sequence again to turn TV off, so more works needs to be done... But that's only software problem, so I did my first clash with PIC hardware somewhat well :-)

Update: I had problem with play of IR codes which would die after few tries. It seems that firmware V2x doesn't support USB suspend correctly, so easiest solution is to use powertop to turn off auto-suspend for whole usb bus (including host controller!) on which IR Toy is connected. This will change a bunch of values in grep . /sys/bus/usb/devices/*/power/control from auto to on. But you will have to re-plug you IR Toy after that so better solution is echo "options usbcore autosuspend=-1" > /etc/modprobe.d/irtoy.conf and this will turn autosuspend for all usb devices.