oandrew / ipod-gadget

iPod usb gadget for audio playback. Client app: https://github.com/oandrew/ipod
MIT License
191 stars 33 forks source link

Hyundai sits at "Reading USB" and no real debug info #9

Closed cammurray closed 3 years ago

cammurray commented 5 years ago

I'm trying to use this purely to obtain steering wheel controls and onscreen display of tracks. My car (Hyundai i30) takes the audio from an AUX port, and uses the USB port for iPod Accessory communication..

On the other end is a Raspberry Pi Zero which i've managed to compile the kernel module fine.

As soon as you load the iPod client, however, the i30 states; "Reading USB" for around a minute or two, then comes up with an error that it cannot read the USB.

I've tried changing swap_configs and product_id's when performing the insmod on the g_ipod_gadget kernel module as such:

insmod /home/pi/ipod-gadget/gadget/g_ipod_gadget.ko swap_configs=1 product_id=0x1207

i've tried various different product_id's to no avail.

Any ideas?

oandrew commented 5 years ago

did the client receive anything or just silence?
try to run the client in debug mode and write a trace file to understand what the problem is

cammurray commented 5 years ago

Hey @oandrew complete silence - but that is to be expected, as the project i'm trying to use your code in is only for the accessory protocol stuff - e.g I just want to get a hold of the commands the car is sending for track control, and also be able to display on the screen. In my particular car, audio is not set over the USB, but instead via an AUX 3.5 jack. There are a couple of cars that do it this way..

The trace file comes back empty, which is a little weird. Any thoughts on that?

nadavami commented 5 years ago

Funny timing, I'm looking to do exactly this with my 2012 Elantra.

From what I can tell the car needs to connect through a special cable like this one and won't work through a the standard iPod cable. This leads me to think that there might be something active in the cable itself preventing the car from recognizing the iPod (or PI in this case) as an iPod...

I'm still waiting on mine from Aliexpress and will post back with a tear down if there's anything interesting going on in the cable.

cammurray commented 5 years ago

Hey @nadavami - great to see someone else with similar requirements, will be great to work together to come to a solution.

I thought the same thing as you, but I had one of the official cables. I ripped it apart and noticed there was a bunch of resistors, but I don't recall seeing any IC's. I'm away for work at the moment but if I get back before you get yours from Aliexpress i'll post a picture of the insides of mine.

nadavami commented 5 years ago

Absolutely and thanks, pictures should really help!

That also reinforces some of my previous suspicions. I have a strong feeling the cable is using the resistors as a voltage divider to tell the car that the "OEM" dongle is plugged in and go into iPod mode (vs Mass Storage).

My guess is that they're using the Mic pin on the dongle's TRRS connector to do that. Especially since leaving the cable it's only TRS without the Mic pin.

Time will tell :)

nadavami commented 5 years ago

So, I I got impatient and ordered a cable from Amazon earlier this week, I took it apart and it looks like the cheap knockoffs don't actually work or have any components inside.

Undeterred, I found an original on Facebook marketplace (which I should have checked in the first place) and spent the day reverse engineering it.

Here's a summary of what I found (i'll probably do a full blog post at some point).

  1. This project unfortunately won't work (at least not unmodified) in the cars that require this cable. From the way things are connected, it seems that in the car's iPod mode the USB port actually just transmits plain old TTL serial data not iAP over USB.
  2. The real device has a few resistors and a single transistor. All they do is to put the iPod into serial mode (using a roughly 500k resistor) and make it connect like an apple certified accessory.
  3. The TRRS plug is indeed carrying analog audio, but also analog video out apparently. My guess is that this is for some head units, mine does not do video. I plan to un-solder this wire and see if it changes anything in the car.
oandrew commented 5 years ago

@nadavami you might want to check out PodEmu app for Android + this thread: https://forum.xda-developers.com/android/apps-games/app-podemu-connect-android-to-30pin-t3234840

nadavami commented 5 years ago

@oandrew Thanks for the tip! I've decided to build something specific to my use-case in the end.

For anyone else who might be interested in the future, here is the schematic for the cable used in these cars https://github.com/nadavami/Hyundai-iPod-Cable.

cammurray commented 4 years ago

@nadavami did you manage to get this project working using one of your custom cables?

nadavami commented 4 years ago

@cammurray I wasn't able to get this one working, but I have a working proof of concept running over here https://github.com/nadavami/iAP-to-AVRCP.