Monday, 29 April 2019

IR Toy v2 firmware update and at last, it flies my helicopter!

I've tried twice in the past, and in limited time, I wasn't able to upgrade the USB Infrared Toy to the latest firmware version (v.22). The instructions aren't easy to read and there are pieces of software all over the place. In retrospect it all looks simple, just because I tried and failed with almost any possible way.

I had to look at the schematics to figure out where PGC and PGD are because there weren't any photos for this version of the hardware. Yep - later I found it was also written on the bottom of the PCB. By the way, you can see that I added two cables to "steal" the IR signal. I'm wondering why they don't expose this on the connector. It would be useful. Anyway. By connecting those two, one enables the bootloader.


The thing is that I was trying to make it work in OS-X. I installed libraries and more libraries. libusb and libusb-compat (it forwards to libusb-1.0) and everything in between. Went from crying formum post to another (1, 2, 3, 4). Some of the comments there were quite fun to read. People in despair, like myself! Found out how to configure properly and then even started debugging libusb on Mac with the help of smaller examples. A good part of the problem was IR Toy (or the library) failing during libusb_claim_interface(). I think that  find_usbfs_path() here, searches on specific paths, but on Mac and maybe without the proper drivers, all you get is a /dev/ttys000.

Long story short, I switched to a linux machine I had nearby. I was able to quickly compile fw_update from source.

sudo apt-get update
sudo apt-get install libusb-dev
tar xf IRToy-fw_update.tar.gz 
cd IRToy-fw_update/
LIBS=-lusb ./configure
make

Then I downloaded the latest hex (search for package.v22). Then the firmware update was successful.

sudo ./fw_update -e -w -v -m all -vid 0x04d8 -pid 0xfd0b -ix ../USBIRToy.package.v22/firmware/USBIRToy.v22.hex 


All those instructions where (roughly) back in the original page by the way. My advice is - if it doesn't work for you - don't try hard to fix it. Just grab some other laptop and try it there. Maybe your Linux version is too recent. Maybe this or that. Try something else, before you start digging in. It's not like you will be using the bootloader every day after all.

Finally - I wanted to use the "record and playback application" described here and here. It worked great! Here's IR Toy is driving a helicopter!



Semi-relevant Reference Material




software/IRToyRecPlay/MacOS/Release/irtoy  -d /dev/cu.usbmodem000000011 -f play.ref -r

./irtoy -d /dev/cu.usbmodem14501 -f play.ref -r

./irtoy -d /dev/ttyACM0  -f lg-power -r -v 1


# The device path for USB:
ls -lha /dev/tty* > plugged.txt:
/dev/ttys000

lsof

system_profiler SPUSBDataType

        Diolan:

          Product ID: 0xfd0b
          Vendor ID: 0x04d8  (Microchip Technology Inc.)
          ...

./configure
make

sudo ./fw_update -e -w -v -m all -vid 0x04d8 -pid 0xfd0b -ix ../USBIRToy.package.v22/firmware/USBIRToy.v22.hex 


# In docker/linux - compile example.c
apt-get update
apt-get install -y gcc libusb-dev libusb-1.0-0 libusb-1.0-0-dev pkg-config
gcc example.c `pkg-config --libs --cflags libusb-1.0`

# In mac after a few brew installs
gcc -lusb-1.0 example.c

No comments:

Post a Comment