Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get things to work on a Pi Zero 2W #28

Open
dangerzau opened this issue May 1, 2024 · 9 comments
Open

Unable to get things to work on a Pi Zero 2W #28

dangerzau opened this issue May 1, 2024 · 9 comments

Comments

@dangerzau
Copy link

Hi All,

So using a few different files from a few different forks of this project I've been able to get the Kernel drivers to compile and install on raspbian bookworm - Same for the client app from the other repo listed at the bottom of the main page.

I can see in dmesg that the kernel modules are loading,

[ 1626.997693] ipod-gadget-hid: ipod_hid_dev_open()
[ 1626.997719] ipod-gadget-hid: activating
[ 1627.155825] dwc2 3f980000.usb: new device is high-speed
[ 1627.189495] dwc2 3f980000.usb: new address 11
[ 1627.222887] g_ipod gadget.0: = ipod_audio_set_alt(0,0)
[ 1627.222906] g_ipod gadget.0: = ipod_audio_set_alt(1,0)
[ 1627.222915] ipod-gadget-audio: audio stop
[ 1627.222922] g_ipod gadget.0: = ipod_hid_set_alt()
[ 1627.223046] g_ipod gadget.0: = ipod_audio_set_alt(1,0)
[ 1627.223056] ipod-gadget-audio: audio stop
[ 1627.237262] g_ipod gadget.0: = ipod_audio_set_alt(1,0)
[ 1627.237276] ipod-gadget-audio: audio stop

I can see the device iap0 listed in /dev
and running the ipod client doesn't throw an error etc. - USing some of the files from the Pipod project - https://github.com/geniass/pipod - I managed to get things to start on boot etc - and at this point I'm not even worrying about getting the audio side to work, simply have the device present as an iPod to my Car and Boat.

This is where things fall down,

In the car - Ford with Sync2 - No matter what I try, the headunit continues to say "No device present" when I try and select USB
and in the Boat - its detecting a USB device of some sort, and a few moments later it disconnects and reboots the pi (Drops power to the USB port when it canges input sources unfortunatly)

I've got trace file output turned on for the ipod client - however when I take a look, all trace files created are 0kb in size so i'm obviously not seeing anything.

I've tried using the Swap_Configs=1 as a kernel module conf option and that has made no difference at all.

Has anyone managed to get this to work with BookWorm and a Zero 2W ??? or am I going it alone?

@oandrew are you still checking in from time to time or has life/other commitments dragged you away from such an awesome project?

Cheers

@dangerzau
Copy link
Author

Got a little further - Lets blame my initial 0 kb trace files on myself... now getting the following when connected to the Ford Sync2

WARN[0000.000585] trace file opened path=/var/log/ipod/2024-05-02T09:29:53+10:00.trace
ERRO[0000.001010] << FRAME error=report id no found: 15 len=0
ERRO[0000.001087] << FRAME error=report id no found: 15 len=0
ERRO[0000.001151] << FRAME error=report id no found: 15 len=0
ERRO[0000.001215] << FRAME error=report id no found: 15 len=0

So if I'm reading the goland doco corectly - thats an incomming request - need to now work out what id its looking for - but the len0 has me buggered as to how it could be a zero length id?

@oandrew
Copy link
Owner

oandrew commented May 8, 2024

Hi!

Could you share the trace file?

@dangerzau
Copy link
Author

Ello oandrew - Awesome to hear from you - was hoping I might be able to grab your attention... I've managed to fix things to the point I can now get BT Audio in from my mobile phone - and play it OUT via the iPod interface on my Ford Sync 2 system.

I do still see some errors listed in the trace file which I'm wondering if you'd mind taking a look at? The reason I ask is, i did try using airplay/shairport-ng to stream music to the headunit, and whilst I could hear sound etc - as far as track title, artist, album or album art... none of that "meta-data" came through.

2024-05-08T170025+1000.txt

Next I'm onto the headunit in the boat... which is what this is all in aid of to be honest (old headunit - no BT audio - and remotes around the boat that should display meta data if I can get it to work)

I tried my working fake_Ipod and unfortunatly the headunit simple appears to see the mass storage device no matter what I do - I've just added the "only_ipod=1" kernel option to g_ipod_gadget .... am I correct in assuming this should disable the mass storage side of the things from loading?

And since I have your attention - I'm wondering if you could point me in the right direction as far as piping dbus meta data into the ipod app rather than just from shairport-sync. Reason being - With the A2DP bluetooth profile and pulseaudio - I can get the title and track data piped into dbus, wondering how to use that in the ipod client

And of course, from there, I'd also like to pipe the media keys from the headunit (Skip, rewind, play pause) to dbus and push those out so that I can control the incomming phones audio from the headunit. All seems feesable to do.

@oandrew
Copy link
Owner

oandrew commented May 8, 2024

I've managed to fix things to the point I can now get BT Audio in from my mobile phone - and play it OUT via the iPod interface on my Ford Sync 2 system.

That's awesome! Glad to hear it's actually working.

I do still see some errors listed in the trace file which I'm wondering if you'd mind taking a look at? The reason I ask is, i did try using airplay/shairport-ng to stream music to the headunit, and whilst I could hear sound etc - as far as track title, artist, album or album art... none of that "meta-data" came through.

I am assuming you are using one of the forks? e.g. https://github.com/teostofell/ipod ?
This is where it's being sent: https://github.com/teostofell/ipod/blob/master/lingo-extremote/handler.go#L101

You can try replacing it with some static value to first check if things work at all.
e.g. https://github.com/oandrew/ipod/blob/master/lingo-extremote/handler.go#L99

Next I'm onto the headunit in the boat... which is what this is all in aid of to be honest (old headunit - no BT audio - and remotes around the boat that should display meta data if I can get it to work)
I tried my working fake_Ipod and unfortunatly the headunit simple appears to see the mass storage device no matter what I do - I've just added the "only_ipod=1" kernel option to g_ipod_gadget .... am I correct in assuming this should disable the mass storage side of the things from loading?

Yep, you can try experimenting with these:
only_ipod=1 will disable the mass storage USB config.
swap_configs=1 - this will reorder USB config to be (ipod,mass_storage)
product_id=0x1297 - you can try advertising a different a iphone model. See full list here: https://github.com/oandrew/ipod-gadget/blob/master/doc/apple-usb.ids

And since I have your attention - I'm wondering if you could point me in the right direction as far as piping dbus meta data into the ipod app rather than just from shairport-sync. Reason being - With the A2DP bluetooth profile and pulseaudio - I can get the title and track data piped into dbus, wondering how to use that in the ipod client.

I think this fork had some initial impl that uses dbus to passthough metadata: https://github.com/geniass/ipod/blob/playstatusnotification/lingo-extremote/handler.go#L199

And of course, from there, I'd also like to pipe the media keys from the headunit (Skip, rewind, play pause) to dbus and push those out so that I can control the incomming phones audio from the headunit. All seems feesable to do.

You can try pressing all possible buttons while recording a trace to see what kind of commands are received.

You can then view the trace file using ipod -d view path/to/trace.log

@dangerzau
Copy link
Author

Well I broke it again - So I've gone back to the time and tested version of starting from scratch and journaling the changes...

I've created a new fork of your repo - however for some reason - git desktop has told me my new repo is based on a different fork where they did fix compile errors.... although their solution only fixed ipod_audio and not ipod_hid - So I've made changes in both to make those dynamic depending on which Kernel version a person is running...

I guess I should merge in the DKMS code as well, as this would make things easier at compile time.

Anyways.... off to test my new setup and see if I can get audio out just via mpg123 and alsa for now as that seems to be the first hurdle to overcome, and for the life of me I can't recall how I fixed that.

The Ford Sync 2 sees and ipod_gadget however no audio - so i suspect I need to work out how to change the default alsa sound card first and work my way from there into installing pulseaudio and pulseblueooth/dbus support.

I'll keep you posted if you like and see what I find, at least if I document here, others may be able to solve their own issues as well. Was thinking if I can finally get this all complete if Ok with you, I'd simply create an img of the SD-Card and host it somewhere for anyone else that may want to achieve a similar setup. Getting track/title/album data from dbus is my main goal here as thats the one thing I need for the boat.

Thank you so much for you help as well. Truly do appreciate it.

@dangerzau
Copy link
Author

I'm obviously able to compile the drivers etc - I managed to get audio from speaker-test, airshair-sync and mpg123 to play ONCE... That was using the -l (old client) option in the ipod command - I found when I had it working previously that this wasn't required, so i'm not 100% on what the difference is.

On rebooting - It hasn't worked again since - I'm starting wonder if something is telling the "usb audio" to become available and hence I can't get sound output.

I've included all trace files generated that weren't 0kb in size - the largest I believe is the trace that had working audio..

I see "errors" in each of the traces - What do they mean and should I be concerned?
Anyway to make the usb audio become available the moment the system has initialised - its eems to be waiting for something and I can't work out what it is.

2024-05-10T182459+1000.txt
2024-05-11T125521+1000.txt
2024-05-11T125021+1000.txt
2024-05-10T082101+1000.txt
2024-05-10T083951+1000.txt
2024-05-10T151155+1000.txt

@dangerzau
Copy link
Author

Oh I've also switch back to using your own version of the ipod client to see if that brings any joy.

@dangerzau
Copy link
Author

Okay - Still no joy

bob@ipod:~ $ sudo speaker-test -D plughw:CARD=iPodUSB,DEV=0 -c 2 -r 44100

speaker-test 1.2.8

Playback device is plughw:CARD=iPodUSB,DEV=0
Stream parameters are 44100Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 44100Hz (requested 44100Hz)
Buffer size range from 92 to 16384
Period size range from 23 to 1024
Using max buffer size 16384
Periods = 4
was set period_size = 1024
was set buffer_size = 16384
0 - Front Left
Write error: -5,Input/output error
xrun_recovery failed: -5,Input/output error
Transfer failed: Input/output error
bob@ipod:~ $ sudo cat /proc/asound/iPodUSB/pcm0p/sub0/status
closed
bob@ipod:~ $
traceme3.txt

@dangerzau
Copy link
Author

Have moved my investigation over to the boat which uses a clarion CMD6 head unit - This head unit does not see the Pi zero 2w as an ipod at all... Have tried swap_configs=1 still shows "File Read" on the screen as if its trying to access a mass storage device. Tried Only_Ipod (or however that flag goes) and the same thing happens

Now trying as an iPod 5th Gen as the support documentation seems to list is as compatible - https://www.clarion.com/xe/en/user-support/connection/ipod/2009-MainUnit/index.html

And nope - Even tried with -l on the ipod startup line ... its as if the headunit is not seeing this device as ipod/apple product at all.

For refrence.. I did plug an iphone 11 into the headunit and i can use that to stream spotify and tracks through the headunit - so clearly its compatible with apple devices.... I've got to be missing something here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants