-
Notifications
You must be signed in to change notification settings - Fork 175
Description
I see that most people have problems connecting their iPhone to Rpi, and I'm curious if anyone has managed to connect Rpi to Head Unit via USB?
From what I've been able to determine and partially accomplish, the following steps should be taken (I'm working on Rpi5 with Rasbian 6.12.55):
-
Connect USB C to HeadUnit and Rpi
-
Configure USB C to be a device:
sudo dtoverlay dwc2,dr_mode=peripheral -
We configure USBC using functionfs and libcomposite
-
We should receive the appropriate USB frame and send a response:
if (bmRequestType == 0xC0 && bRequest == 0x53) {
uint8_t resp[4] = {0x01, 0x00, 0x00, 0x00};
size_t len = wLength < sizeof(resp) ? wLength : sizeof(resp);
ssize_t wd = write(ep0, resp, len);
-
USB roles are reversed, RPi becomes the host and HeadUnit becomes the device
-
We perform reconfiguration:
sudo dtoverlay -R
sudo dtoverlay dwc2,dr_mode=host
-
At the same time, we launch IP over USB:
sudo modprobe cdc_ncmThis is necessary for exchanging information and transmitting video and audio, but here it is only a configuration so that the HU receives an IP address (IPv6).
We also need to have mDNS or Avahi configured so that the HU can get
the list of available services -
Using libusb, Rpi must communicate with HU using the Iap2 protocol. In this step, we need to send an authorization request and HU must authorize itself in relation to Rpi. We do not need an MFI chip for this because since we are authorizing HU, we simply send back that everything is OK with the certificate without checking anything.
-
Once we have communicated using IAP2, the HU will now try to connect to the http server with the _carplay-ctrl._tcp service on the port we announced in mdns or avahi. Here, the HU sends us a “GET /ctrl-int/1/connect” request, and we have to respond something like this:
HTTP/1.1 200 OK\r\n
Server: AirTunes/320.17.7\r\n
Content-Type: application/x-apple-binary-plist\r\n
Connection: keep-alive\r\n
- Now you need to send the video stream using the RTSP protocol
ffmpeg -re -loop 1 -framerate 25 -i test.png -c:v libx264 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -f rtsp rtsp://localhost:7000/mystreamUnfortunately, this does not work because ffmpeg does not communicate with HU using the appropriate protocol.
My question is: has anyone managed to display at least an image, or preferably a video, on the Head unit screen?