Pi GPIO in place of USB-UART

Need help? Ask here and someone will help
riggs
Posts: 5
Joined: Sat May 28, 2016 12:57 pm

Pi GPIO in place of USB-UART

Post by riggs »

So I'm attempting to put together an all-in-one solution for using my DFGT on PS4. I'm wanting to use a Pi Zero in place of a PC/laptop, purely for convenience (and the fact I've got a spare Pi kicking around).

Reading through the Wiki it sounds as though I can use the Pis GPIO/UART in place of the USB-UART device, the question is how? I've hooked up the Arduino Lenoardo (clone) to the Pi following the instructions (GND-GND, Rx(Pi)-Tx(AVR) via voltage divider, Tx(Pi)-Rx(AVR) but I'm wondering how I tell Gimx to use the GPIO instead of a USB-UART adaptor?
The guide says to use ttyUSB0, but that doesn't exist on my system (I'm assuming would be the /dev/ listing for the USB-UART adaptor if one plugged in?). Which device should I be using to use the GPIO?

Also, is there any way of actually testing the AVR, either through the Pi or plugged into PC/Mac? I'm not totally sure the I flashed the device properly...I had trouble with the instructions and ended up using a different flashing program.
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Pi GPIO in place of USB-UART

Post by Matlo »

Hi,

The UART device is /dev/ttyAMA0.
It's not possible to test the AVR separately.
GIMX creator
riggs
Posts: 5
Joined: Sat May 28, 2016 12:57 pm

Re: Pi GPIO in place of USB-UART

Post by riggs »

Thanks pal. I'll do some tinkering and see if I can get it up and running.

[edit]
Ok, so first off my config.txt needed editing to include the line

Code: Select all

enable_uart=1
. Now ttyAMA0 is listed in my /dev/ directory. The problem now is that the Gimx application doesn't detect the adaptor. I need to mess around some more but I'm assuming this is down to the board not being flashed properly. I've ordered a CP2102 and will attempt to reflash the device.

Speaking of which, when the AVR board is connected to a PC it doesn't show up in device manger. If I hit the reset button twice I can get it to show up in boot loader mode, but after 10 seconds or so it disappears again. Is this normal, or have I messed up the flashing procedure?
My only other experience with AVR flashing is with a Minimus; I've got one flashed with a Dualshock3 firmware which, when plugged into my PC, shows up as a Dualshock3. I kinda assumed that the Arduino, when flashed with the G29 firmware would be listed as a "Logitech G29", but maybe that's not how the Gimx firmwares work...?
User avatar
Rudi Rastelli
Posts: 16
Joined: Sat Jun 04, 2016 3:17 pm

Re: Pi GPIO in place of USB-UART

Post by Rudi Rastelli »

Seems I'm in the same boat. But i'm pretty sure my teensy++ is flashed ok.

Here's gmix output when i start it manually:

Code: Select all

pi@raspberrypi:~ $ /usr/bin/gimx -p /dev/ttyAMA0 -c LogitechDrivingForceGT_G29.xml --nograb
controller #1: option -p with value `/dev/ttyAMA0'
now reading arguments for controller #2
global option -c with value `LogitechDrivingForceGT_G29.xml'
grab flag is unset
src/linux/usbhidasync.c:535 claim_device: libusb_claim_interface failed with error: Resource busy
Detected USB adapter: G29 PS4.

After that gimx seems to hang and i can't return to command line (tried CTRL-C as well)

I'm a linux noob so i could really need some help.


Edit - Fixed some failures i've made and therefore i've made some progress:

1. 'rpi-update'
The wiki says to use 'rpi-update' to update the firmware/kernel but that doesnt work out of the box.
So i googled and run across a statment saying the 'apt-get upgrade' is enough to update the firmware/kernel and that turns out to be totaly nonsense.
U need to do a 'sudo apt-get install rpi-update' first followed by 'sudo rpi-update' (this should be added to the wiki i guess)

2. 'enable_uart'-option in config.txt
If i follow the wiki it says to open raspi-config and disable that serial thing... but this sets 'enable_uart=0' in '/boot/config.txt' which seems to disable the onboard uart at all. That's ok for the 'DIY Adapter Way' but NOT for the 'Onboard UART way'.
But i must assume i'm not totaly sure about this... maybe @Matlo or someone else can tell use something about this !?

3. Wrong Mapping File
As u can see above i'd choosen wrong mapping file for what i'd tried to achive (G27 as G29). That one was totaly my fault.

Overall my suggestion is to split the 'gimx pi wiki':
- One wiki for : PI+DIY-Aadapter
- One wiki for : PI+Onboard-UART+AVR USB board

And i'm wondering that most gimx-pi-users go the 'DIY Adapter Way'... is it because of the resitor-voltage-divider ?
May be it's a good idea to add a picture of how it can be build so people can see how it looks like.
Here's mine:
http://i.imgur.com/wnWHGbz.jpg


Regards
Rudi
riggs
Posts: 5
Joined: Sat May 28, 2016 12:57 pm

Re: Pi GPIO in place of USB-UART

Post by riggs »

So have you actually got this to work? I'm still unsure as to whether my AVR is flashed properly. I received my USB-UART adaptor this morning and managed to re-flash the firmware file to it, but it still does nothing. Just out of curiosity, if I had the Rx/Tx connections the wrong way around it wouldn't flash at all, right?

If I plug the AVR into my laptop I can get it to show up in bootloader mode (by double pressing the reset button), but after the 8 second timeout it disappears and doesn't show up again. Like I said, I would've assumed that it would show up as a Logitech G29 (as that's the FW file I flashed), but no. I'll have another play around with it tomorrow, but time is limited at the moment.

Bah...

Code: Select all

pi@raspberrypi:~ $ gimx -c LogitechDrivingForceGT_G29.xml -p /dev/ttyAMA0 --status
global option -c with value `LogitechDrivingForceGT_G29.xml'
controller #1: option -p with value `/dev/ttyAMA0'
now reading arguments for controller #2
status flag is set
native mode is already enabled for HID device 01:01:05 (PID=c29a)
can't read packet header
No controller detected.
adapter_detect failed
alkex92
Posts: 5
Joined: Mon Jun 06, 2016 9:13 am

Re: Pi GPIO in place of USB-UART

Post by alkex92 »

@riggs
Every time i've got "adapter_detect failed" error there was a wiring problem, try to double check the connections and solders
riggs
Posts: 5
Joined: Sat May 28, 2016 12:57 pm

Re: Pi GPIO in place of USB-UART

Post by riggs »

In my haste I soldered the AVR directly to some perfboard (along with the resistors, reset switch and a pin header so I can plug it directly into the Pi). It's probably de-solderable, if I had the tools to do so. Luckily, it was cheap and I've got another on the way. I think I'll just use a breadboard with temporary wiring for this one so I can test it properly. Having said that, I've tested continuity and it's fine across the board.

Anyway, I'll update when the new one arrives.

On a related note, does anyone know of a test program I could flash to the AVR? Maybe something like a simple keyboard encoder HEX, just so I can confirm that I'm actually flashing the thing ok. I've tried the "blink" test program that comes with the Arduino software but it doesn't seem to work on my (clone) Leonardo.
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Pi GPIO in place of USB-UART

Post by Matlo »

Make sure to adjust the led pin in the Arduino sketch.
GIMX creator
riggs
Posts: 5
Joined: Sat May 28, 2016 12:57 pm

Re: Pi GPIO in place of USB-UART

Post by riggs »

Thanks for that tip! Got the Blink test program working, so I'm definitely flashing the board ok.

Will re-flash the G29 HEX tomorrow and set up the breadboard for testing.

[edit]
Just wired everything up, but used the UART-USB adaptor instead - seems to work (dpad etc), although I've not tested the pedals, force feedback or tested using a game etc. So it's a GPIO/wiring problem. Will test further tomorrow...

[edit2]
Seems to work when started from the cli, can't get it to auto start though (it is however showing as running when I list active processes with "top"). May be related; the blink.py also doesn't auto start. If I run it manually I can get the power button to work, but the LED doesn't come on.

My bad. There was a problem with the xml file location. Sorted that and it now starts at boot. I got the LED/button working by adding the following to crontab;

Code: Select all

@reboot /home/pi/blink.py &
The wiki instructions don't have that "&" symbol. Not sure if this is needed, but it works for me. From what I've read, the "&" means that the script will run in the background...so that's something new I learnt about Linux today ;-)

So I'm all up and running with the USB-UART, but I'm still hoping to get it working with the GPIO. I've re-wired everything on a breadboard and it's still not detecting the AVR.

[another edit]
It worked! Once! Not sure what I did but I managed to get it working using the GPIO. I ditched the breadboard (cheap Chinese thing) and wired everything up with jumper cables. It wasn't working to begin with, but after a random combination of rebooting and unplugging it fired up from the command line.
zblad
Posts: 32
Joined: Tue Jul 05, 2016 3:19 pm

Re: Pi GPIO in place of USB-UART

Post by zblad »

Hello,

I was wondering if you ever figured out how to get the UART to work consistently. I followed the directions for Raspberry pi with the usb adaptor and it worked fine but I wanted to eliminated the usb dongle. I reflashed my SD card and skipped the part where you go into raspi-config part. I added the init_uart_clock=8000000 to the config file and did everything else like it states. I am also using the voltage divider but for some reason I always get the adaptor failed error and I cannot figure out why.

I have the Raspberry pi 2
I am using the Teensy 2.0++

I know its flashed correctly because it worked with the usb dongle on the raspberry pi and my windows 7 laptop. I don't believe I mixed up the tx and rx connections because I believe it would state that they are possibly switched. If you have any ideas I would GREATLY appreciate it.

Thank You... I cant take some screenshots tonight if needed.
Post Reply