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

Raspberry Pi Zero - can't get it going here #2

Closed
n9yty opened this issue Oct 25, 2017 · 11 comments
Closed

Raspberry Pi Zero - can't get it going here #2

n9yty opened this issue Oct 25, 2017 · 11 comments

Comments

@n9yty
Copy link

n9yty commented Oct 25, 2017

UP-FRONT: I am sorry, I also was looking at the p-tech-se fork of this, as in many ways it seems more compatible, and my notes below are possibly mixing and matching. But it would be really GREAT to be able to consolidate the efforts and get something that works. I am trying to dig through this, but I am new to golang, new to linux gadgets/drivers, and also haven't done any USB work, so it is a learning curve for sure. ;)

Okay, so, Here is what I have done so far:

I read that you have to make some changes to enable the gadget mode to work:
Change /boot/config.txt, at end:
dtoverlay=dwc2

Change /boot/cmdline.txt add to end:
modules-load=dwc2,g_ether

This lets me plug it into my computer and ssh into it over that connection. If this is conflicting with the ipod-gadget driver, and the cause of my problems, then I apologize!

Couldn't compile the gadget module, seems I was missing kernel headers, so I tried:

sudo apt-get install raspberrypi-kernel-headers
sudo ln -s /usr/src/linux-headers-4.4.50+/ /lib/modules/4.4.50+/build

DId not have golang. The version in the raspbian repo was 1.3.3, not new enough, so I did:
wget https://storage.googleapis.com/golang/go1.9.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.9.linux-armv6l.tar.gz

Add to ~/.bashrc:
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Compiled the kernel module as instructed, it did pass the insmod ok.

Compiled the go client program, but when trying to run it:
./ipod

I set it to do the modprobe/insmod in /etc/rc.local as well as as launch the ipod binary. Plugging it into my Pioneer AVH-4200NEX after it has fully booted just shows INCOMPATIBLE USB. Plugging it into the Mac shows a composite device.

Composite Device:
Product ID: 0x1266
Vendor ID: 0x05ac (Apple Inc.)
Version: 4.04
Speed: Up to 480 Mb/sec
Location ID: 0x14100000 / 29
Current Available (mA): 500
Extra Operating Current (mA): 0
Sleep current (mA): 500

iTunes doesn't see it or pretend there is an iPod there, but that is not surprising.

I do not see any output from the ipod binary, in rc.local when I invoke it (in the background) I am sending output to a log file, but nothing is going in there.

Off to read more about gadgets, but at this point I am feeling pretty overwhelmed. And I realize this is only the start, I would have to write something to handle the requests, scan/parse a library, reply to the headunit, start/stop playback/etc, as it doesn't seem any of that is here yet, but that can only be something to worry about if the first part is working. :) I think mpd might work with the command line client, but that is far away at this point...

OH, and with the p-tech-se additions, when on the Mac I do see a Audio device show up. Upgraded the raspberry pi to the latest, which for some reason it hadn't found easier probably due to network issues, now kernel is 4.9.35+ and I can hook it to my Mac, speaker-test works playing audio through to the Mac. :) Oh, but wait, I was mixing this and the fork done by p-tech-se...

The current status with the radio is that using this version I get "No Reponse", and using the p-tech-se I get "Incompatible USB". Either way I am not yet able to capture any messages/errors from the client program due to difficulties getting my computer connected to the Pi while it is actually connected to the car. But working on that.

Here is a sample of output in syslog when in the car:
Oct 26 17:12:49 raspberrypi kernel: [ 747.175077] dwc2 20980000.usb: new device is high-speed
Oct 26 17:12:49 raspberrypi kernel: [ 747.295485] dwc2 20980000.usb: new device is high-speed
Oct 26 17:12:49 raspberrypi kernel: [ 747.360462] dwc2 20980000.usb: new address 2
Oct 26 17:12:49 raspberrypi kernel: [ 747.395267] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:12:49 raspberrypi kernel: [ 747.395296] g_ipod gadget: Control req: 40.40 v01f4 i01f4 l0
Oct 26 17:12:49 raspberrypi kernel: [ 747.395302] Handled: 1f4
Oct 26 17:12:49 raspberrypi kernel: [ 747.395314] g_ipod gadget: = ipod_audio_control_setup()
Oct 26 17:12:49 raspberrypi kernel: [ 747.395325] g_ipod gadget: Control req: 40.40 v01f4 i01f4 l0
Oct 26 17:12:49 raspberrypi kernel: [ 747.395497] g_ipod gadget: high-speed config #2: iPod interface
Oct 26 17:12:49 raspberrypi kernel: [ 747.395530] g_ipod gadget: = ipod_audio_control_set_alt()
Oct 26 17:12:49 raspberrypi kernel: [ 747.395538] g_ipod gadget: = ipod_audio_control_set_alt()
Oct 26 17:12:49 raspberrypi kernel: [ 747.395545] g_ipod gadget: = ipod_hid_set_alt()
Oct 26 17:12:49 raspberrypi kernel: [ 747.398485] g_ipod gadget: = ipod_audio_control_set_alt()
Oct 26 17:12:49 raspberrypi kernel: [ 747.398718] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:12:49 raspberrypi kernel: [ 747.398734] g_ipod gadget: Control req: 22.01 v0100 i0081 l3
Oct 26 17:12:49 raspberrypi kernel: [ 747.398738] Not Handled
Oct 26 17:12:49 raspberrypi kernel: [ 747.398746] g_ipod gadget: = ipod_audio_control_setup()
Oct 26 17:12:49 raspberrypi kernel: [ 747.398756] g_ipod gadget: Control req: 22.01 v0100 i0081 l3
Oct 26 17:12:49 raspberrypi kernel: [ 747.398954] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:12:49 raspberrypi kernel: [ 747.398969] g_ipod gadget: Control req: a2.81 v0100 i0081 l3
Oct 26 17:12:49 raspberrypi kernel: [ 747.398973] Not Handled
Oct 26 17:12:49 raspberrypi kernel: [ 747.398980] g_ipod gadget: = ipod_audio_control_setup()
Oct 26 17:12:49 raspberrypi kernel: [ 747.398990] g_ipod gadget: Control req: a2.81 v0100 i0081 l3
Oct 26 17:12:49 raspberrypi kernel: [ 747.399205] g_ipod gadget: = ipod_audio_control_set_alt()
Oct 26 17:12:49 raspberrypi kernel: [ 747.416704] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:12:49 raspberrypi kernel: [ 747.416730] g_ipod gadget: Control req: 21.0a v0000 i0002 l0
Oct 26 17:12:49 raspberrypi kernel: [ 747.416736] Not Handled
Oct 26 17:12:49 raspberrypi kernel: [ 747.416744] g_ipod gadget: = ipod_hid_setup()
Oct 26 17:12:49 raspberrypi kernel: [ 747.416754] g_ipod gadget: Control req: 21.0a v0000 i0002 l0
Oct 26 17:12:49 raspberrypi kernel: [ 747.416985] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:12:49 raspberrypi kernel: [ 747.417000] g_ipod gadget: Control req: 81.06 v2200 i0002 l60
Oct 26 17:12:49 raspberrypi kernel: [ 747.417004] Not Handled
Oct 26 17:12:49 raspberrypi kernel: [ 747.417011] g_ipod gadget: = ipod_hid_setup()
Oct 26 17:12:49 raspberrypi kernel: [ 747.417020] g_ipod gadget: Control req: 81.06 v2200 i0002 l60
Oct 26 17:13:26 raspberrypi kernel: [ 785.140763] g_ipod gadget: = ipod_audio_control_disable()
Oct 26 17:13:26 raspberrypi kernel: [ 785.140780] g_ipod gadget: = ipod_hid_disable()
Oct 26 17:13:26 raspberrypi kernel: [ 785.140794] g_ipod gadget: = ipod_disconnect()

And on the Mac:
Oct 26 17:27:29 raspberrypi kernel: [ 638.110688] dwc2 20980000.usb: new device is high-speed
Oct 26 17:27:29 raspberrypi kernel: [ 638.121858] dwc2 20980000.usb: new address 19
Oct 26 17:27:29 raspberrypi kernel: [ 638.292990] g_ipod gadget: high-speed config #2: iPod interface
Oct 26 17:27:29 raspberrypi kernel: [ 638.293031] g_ipod gadget: = ipod_audio_control_set_alt()
Oct 26 17:27:29 raspberrypi kernel: [ 638.293040] g_ipod gadget: = ipod_audio_control_set_alt()
Oct 26 17:27:29 raspberrypi kernel: [ 638.293048] g_ipod gadget: = ipod_hid_set_alt()
Oct 26 17:27:29 raspberrypi kernel: [ 638.349099] g_ipod gadget: = ipod_audio_control_set_alt()
Oct 26 17:27:29 raspberrypi kernel: [ 638.360494] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:27:29 raspberrypi kernel: [ 638.360519] g_ipod gadget: Control req: 22.01 v0100 i0081 l3
Oct 26 17:27:29 raspberrypi kernel: [ 638.360525] Not Handled
Oct 26 17:27:29 raspberrypi kernel: [ 638.360534] g_ipod gadget: = ipod_audio_control_setup()
Oct 26 17:27:29 raspberrypi kernel: [ 638.360544] g_ipod gadget: Control req: 22.01 v0100 i0081 l3
Oct 26 17:27:29 raspberrypi kernel: [ 638.361843] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:27:29 raspberrypi kernel: [ 638.361858] g_ipod gadget: Control req: 40.40 v0000 i0000 l0
Oct 26 17:27:29 raspberrypi kernel: [ 638.361864] Handled: 0
Oct 26 17:27:29 raspberrypi kernel: [ 638.361876] g_ipod gadget: = ipod_audio_control_setup()
Oct 26 17:27:29 raspberrypi kernel: [ 638.361886] g_ipod gadget: Control req: 40.40 v0000 i0000 l0
Oct 26 17:27:29 raspberrypi kernel: [ 638.363065] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:27:29 raspberrypi kernel: [ 638.363077] g_ipod gadget: Control req: 40.40 v01f4 i0000 l0
Oct 26 17:27:29 raspberrypi kernel: [ 638.363082] Handled: 0
Oct 26 17:27:29 raspberrypi kernel: [ 638.363092] g_ipod gadget: = ipod_audio_control_setup()
Oct 26 17:27:29 raspberrypi kernel: [ 638.363102] g_ipod gadget: Control req: 40.40 v01f4 i0000 l0
Oct 26 17:27:29 raspberrypi kernel: [ 638.363386] ------------[ cut here ]------------
Oct 26 17:27:29 raspberrypi kernel: [ 638.363568] WARNING: CPU: 0 PID: 368 at drivers/usb/dwc2/gadget.c:1573 dwc2_hsotg_rx_data+0xb0/0xfc [dwc2]
Oct 26 17:27:29 raspberrypi kernel: [ 638.363576] Modules linked in: bnep hci_uart btbcm bluetooth g_ipod(O) brcmfmac brcmutil snd_bcm2835 cfg80211 snd_pcm rfkill snd_timer snd bcm2835_gpiomem uio_pdrv_genirq fixed uio libcomposite i2c_dev fuse dwc2 udc_core ipv6
Oct 26 17:27:29 raspberrypi kernel: [ 638.363678] CPU: 0 PID: 368 Comm: in:imklog Tainted: G O 4.9.35+ #1014
Oct 26 17:27:29 raspberrypi kernel: [ 638.363683] Hardware name: BCM2835
Oct 26 17:27:29 raspberrypi kernel: [ 638.363746] [] (unwind_backtrace) from [] (show_stack+0x20/0x24)
Oct 26 17:27:29 raspberrypi kernel: [ 638.363772] [] (show_stack) from [] (dump_stack+0x20/0x28)
Oct 26 17:27:29 raspberrypi kernel: [ 638.363799] [] (dump_stack) from [] (__warn+0xe4/0x10c)
Oct 26 17:27:29 raspberrypi kernel: [ 638.363819] [] (__warn) from [] (warn_slowpath_null+0x30/0x38)
Oct 26 17:27:29 raspberrypi kernel: [ 638.363929] [] (warn_slowpath_null) from [] (dwc2_hsotg_rx_data+0xb0/0xfc [dwc2])
Oct 26 17:27:29 raspberrypi kernel: [ 638.364103] [] (dwc2_hsotg_rx_data [dwc2]) from [] (dwc2_hsotg_irq+0x690/0x7a0 [dwc2])
Oct 26 17:27:29 raspberrypi kernel: [ 638.364214] [] (dwc2_hsotg_irq [dwc2]) from [] (__handle_irq_event_percpu+0x94/0x1c8)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364240] [] (__handle_irq_event_percpu) from [] (handle_irq_event_percpu+0x2c/0x68)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364261] [] (handle_irq_event_percpu) from [] (handle_irq_event+0x38/0x4c)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364280] [] (handle_irq_event) from [] (handle_level_irq+0x9c/0x130)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364299] [] (handle_level_irq) from [] (generic_handle_irq+0x30/0x44)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364319] [] (generic_handle_irq) from [] (__handle_domain_irq+0x58/0xb8)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364339] [] (__handle_domain_irq) from [] (bcm2835_handle_irq+0x28/0x48)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364361] [] (bcm2835_handle_irq) from [] (__irq_svc+0x5c/0x7c)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364370] Exception stack(0xd87ebf10 to 0xd87ebf58)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364383] bf00: d87ebf60 00000000 cdb6dd00 00099000
Oct 26 17:27:29 raspberrypi kernel: [ 638.364397] bf20: d87ebf88 b635a44c b50014d0 0000004e c000ffc4 d87ea000 00000000 d87ebf84
Oct 26 17:27:29 raspberrypi kernel: [ 638.364409] bf40: d87ebf60 d87ebf60 c00715b8 c0071560 a0000013 ffffffff
Oct 26 17:27:29 raspberrypi kernel: [ 638.364439] [] (__irq_svc) from [] (getnstimeofday64+0x4/0x38)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364469] [] (getnstimeofday64) from [] (SyS_gettimeofday+0x2c/0xc4)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364494] [] (SyS_gettimeofday) from [] (ret_fast_syscall+0x0/0x1c)
Oct 26 17:27:29 raspberrypi kernel: [ 638.364503] ---[ end trace c671e665f44dd987 ]---
Oct 26 17:27:34 raspberrypi kernel: [ 643.465251] g_ipod gadget: = ipod_audio_req_match()
Oct 26 17:27:34 raspberrypi kernel: [ 643.465273] g_ipod gadget: Control req: 81.06 v2200 i0002 l60
Oct 26 17:27:34 raspberrypi kernel: [ 643.465276] Not Handled
Oct 26 17:27:34 raspberrypi kernel: [ 643.465282] g_ipod gadget: = ipod_hid_setup()
Oct 26 17:27:34 raspberrypi kernel: [ 643.465289] g_ipod gadget: Control req: 81.06 v2200 i0002 l60

I need to get the golang ipod to log something or else I can't tell what packets it may or may not be processing, but then again, when using the p-tech-se fork and gettign "Incompatible USB" it may not even be trying. :(

I was so excited to see this, I hope it can be revived and made to work.

@cr08
Copy link

cr08 commented Nov 3, 2017

Off topic but could you link to that fork you were looking at? I've been trying to track it down but am not having any luck. I may take a whack at that and provide some feedback if I can.

@n9yty
Copy link
Author

n9yty commented Nov 3, 2017

The fork is here:

https://github.com/p-tech-se/ipod-gadget

I did find out that the hid_report he is using, which he said he got form his iPod/iPad, is I think only 64 bytes as opposed to the 208 in the original here. I had read online that depending on how you try to dump it you sometimes get the shorter length, and I think that may be the source of the "incompatible USB" message. I was able to dump my own iPod Classic and managed to get the 208 byte version, and when I put that in the source it went from "Incompatible USB" to "No Response".

I simply don't know how to debug this or watch it in real-time while connected to the radio in order to find out what it is sending or looking for. :(

@cr08
Copy link

cr08 commented Nov 3, 2017

I'd definitely look into getting a Zero W. That's how I've made my attempts at debugging. I get enough signal to my home Wifi in my garage and SSH in that way while it's connected to my car.

@n9yty
Copy link
Author

n9yty commented Nov 3, 2017

I have a Zero W, great idea, I think I just fall down on knowing the HOW TO part, I've never deal with linux USB stuff, gadget/drivers, or anything of this sort so I'm a bit out of my element. LOL

@cr08
Copy link

cr08 commented Nov 3, 2017

The good news, at least to my eye, is you are good on the kernel module side. That all seems to be functioning. Just something with the ipod process isn't doing what it is supposed to. Or worst case the ipod process is functioning correctly (may be the case if you are seeing the USB Audio and HID devices on your Mac. Running ./ipod essentially enables the kernel and causes those USB endpoints to appear and then does the communication magic) but the Pioneer isn't seeing something it should and isn't bothering to attempt communications.

I'll try compiling and running the p-tech-se fork later this afternoon/evening and see how I fare. With oandrew's version I at least get some communication visible with my Ford Sync system as seen in issue #1 . I know it is doing -something- as normally it will complain if any USB device is connected it is not expecting and with the Zero W with all this running it doesn't say anything or throw up any messages but does appear to be trying to communicate.

@n9yty
Copy link
Author

n9yty commented Nov 4, 2017

I was going to look into some way to test the ipod handler by sending commands and watching what it sent back, but haven't gotten that far, well, not even sure how since it seems wired to watch the communications from the gadget. I can't seem to get it to log/capture what, if anything, it is getting from the head unit, but I haven't looked since giving up in frustration after the first batch of attempts. :)

@cr08
Copy link

cr08 commented Nov 5, 2017

Yeah, I just had a chance to try it in my car with p-tech-se's fork and it doesn't even log anything that I can see outside of the lines in dmesg. I even tried that kernel module and the ipod command from oandrew here and didn't get anything.

@n9yty
Copy link
Author

n9yty commented Nov 6, 2017

Ok, sounds like that fork has other problems. This original one didn't work for me either, but it sounds like it would be better to start here. I had tried it, but it didn't work either. I'll keep poking at things as well when time permits.

@oandrew
Copy link
Owner

oandrew commented Nov 20, 2017

Hi guys.
I had some time and rewrote the library and the app from scratch.
The new app includes extensive logging and tracing and hopefully will help us understand why it doesn't work for you.
https://github.com/oandrew/ipod
Also join gitter chat if you have any questions.
Thanks

@cr08
Copy link

cr08 commented Nov 21, 2017

Awesome. Well, I did a completely clean re-compile of both the kernel module and ipod application. A lot nicer with the readable debug messaging. Sadly not being familiar with the IAP process, not exactly sure what end is failing. Here's what I have in both the trace log and my console log:

ipod_trace.log

putty.log

@oandrew
Copy link
Owner

oandrew commented Nov 21, 2017

@cr08 Just pushed a bugfix for that specific case.

@oandrew oandrew closed this as completed Nov 8, 2020
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

3 participants