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

NTP streams support #1407

Closed
hoiz opened this issue Jan 19, 2022 · 23 comments
Closed

NTP streams support #1407

hoiz opened this issue Jan 19, 2022 · 23 comments
Labels

Comments

@hoiz
Copy link

hoiz commented Jan 19, 2022

I tried to play via OwnTone with forced Airplay 2 and these are the messages in journalctl.

"rtsp.c:2655" Connection 51: SETUP: NTP setup detected.
"rtsp.c:2845" SETUP on Connection 51: ntp stream handling is not implemented!
"rtsp.c:2847" *warning: Shairport Sync can not handle NTP streams.

Is it planned that NTP stream will be supported as well? Or is this legacy technology and OwnTone should also support PTP?

Thank you!

@mikebrady
Copy link
Owner

Thanks for the post. I haven’t any plans at present to implement NTP-based streaming. It is not legacy technology, AFAIK; it’s just that it doesn’t seem to be widely used. I am a big fan of OwnTone, however, and it may get supported in the future.

@hoiz
Copy link
Author

hoiz commented Jan 20, 2022

Thanks for the quick reply and the awesome job you are doing!

@andreadaoud
Copy link

Hi @mikebrady,

I'm trying to play from my macbook pro m1. I compiled shairport-sync with airplay 2 turned on. If I select system-wide airplay, connection will fail and says NTP not implemented. How can I change it to PTP?

         0.005045000 "rtsp.c:2733" Connection 1: SETUP (AirPlay 2)
         0.000142500 "rtsp.c:2744" Connection 1 SETUP: No "streams" array has been found -- create an event thread and open a TCP port.
         0.000030250 "rtsp.c:2771" Connection 1: SETUP: NTP setup detected.
         0.000016875 "rtsp.c:2970" SETUP on Connection 1: ntp stream handling is not implemented!
         0.000018250 "rtsp.c:2972" *warning: Shairport Sync can not handle NTP streams.
         0.000036125 "rtsp.c:3257"  SETUP response
         0.000026750 "rtsp.c:3257"   Response Code: 400.
         0.000016750 "rtsp.c:3257"   Type: "CSeq", content: "6"
         0.000015250 "rtsp.c:3257"   Type: "Server", content: "AirTunes/366.0"
         0.000016250 "rtsp.c:3257"   No Content Plist. Content length: 0.
         0.004322250 "rtsp.c:4825" Connection 1: rtsp_conversation_thread_func_cleanup_function called.
         0.000075375 "rtsp.c:2545" Connection 1: TEARDOWN a NTP stream connection.
         0.000026875 "rtsp.c:2569" Connection 1: TEARDOWN Close Event Socket.
         0.000161250 "rtsp.c:4856" Connection 1: terminating connection from 10.222.11.130:53214 to self at 10.222.11.1:7000.
         0.001119875 "rtsp.c:4915" Connection 1: Closed.
        59.872067000 "rtsp.c:759" Connection 1: deleted in cleanup.

@mikebrady
Copy link
Owner

Thanks for the post. I am not aware of any situation where NTP-based AirPlay 2 is actually used, except for OwnTone, so can you give more details about the the system and application you are using at the Mac end, please? Otherwise, in my experience, PTP-based AirPlay 2 is always used.

@andreadaoud
Copy link

@mikebrady Hi, after some digging I found that when I use USB network to connect my RPi and macOS (RPi runs ncm usb gadget), NTP will be used; if WiFi is used, PTP will be used. Strange.

@mikebrady
Copy link
Owner

Very interesting indeed, thanks. Can you say a tiny bit more about how your setup is organized please? I’d really like to replicate it.

@andreadaoud
Copy link

andreadaoud commented Sep 5, 2022

Steps to reproduce:

  1. Enable dwc2 module on RPi. (Do not enable g_ether)
  2. Connect your RPi Type-C port to your mac
  3. Use the following script to setup USB gadget. After running this script, you will see your RPi appear on your mac as a USB Ethernet card.
#!/bin/sh
GADGET_NAME=g_myusb
CONFIGFS_ROOT=/sys/kernel/config
cd "${CONFIGFS_ROOT}"/usb_gadget

mkdir $GADGET_NAME
cd $GADGET_NAME

echo 0x1234 > idVendor
echo 0x4321 > idProduct

mkdir strings/0x409
echo "Me" > strings/0x409/manufacturer
echo "My Device" > strings/0x409/product

mkdir configs/c.1

mkdir functions/ncm.usb0
ln -s functions/ncm.usb0 configs/c.1

ls /sys/class/udc > UDC
  1. Use ip addr command to set IP address on your RPi, and also set IP address on your mac. Set to the same subnet.
  2. Run shairport-sync on RPi. Try if you can produce this issue.

@mikebrady
Copy link
Owner

Super -- many thanks!

@mikebrady
Copy link
Owner

Unfortunately, it won't let me proceed.

I added this line to /boot/config.txt:

dtoverlay=dwc2

and set /boot/cmdline.txt to:

console=serial0,115200 console=tty1 root=PARTUUID=86c3c3c2-02 rootfstype=ext4 fsck.repair=yes rootwait modules-load=dwc2

I must be missing something...

@andreadaoud
Copy link

@mikebrady Could you please post more details? What doesn't work?

@mikebrady
Copy link
Owner

Thanks for the quick response. Okay, so on a Raspberry Pi 3B

Linux RaspberryPi3B 5.15.56-v8+ #1575 SMP PREEMPT Fri Jul 22 20:31:26 BST 2022 aarch64 GNU/Linux

I put your script into a file called usbethsetup.sh:

pi@RaspberryPi3B:~ $ cat usbethsetup.sh 
#!/bin/sh
GADGET_NAME=g_myusb
CONFIGFS_ROOT=/sys/kernel/config
cd "${CONFIGFS_ROOT}"/usb_gadget

mkdir $GADGET_NAME
cd $GADGET_NAME

echo 0x1234 > idVendor
echo 0x4321 > idProduct

mkdir strings/0x409
echo "Me" > strings/0x409/manufacturer
echo "My Device" > strings/0x409/product

mkdir configs/c.1

mkdir functions/ncm.usb0
ln -s functions/ncm.usb0 configs/c.1

ls /sys/class/udc > UDC

Then I tried to run it:

pi@RaspberryPi3B:~ $ sudo sh usbethsetup.sh 
usbethsetup.sh: 4: cd: can't cd to /sys/kernel/config/usb_gadget
mkdir: cannot create directory ‘g_myusb’: File exists
mkdir: cannot create directory ‘strings/0x409’: No such file or directory
usbethsetup.sh: 13: cannot create strings/0x409/manufacturer: Directory nonexistent
usbethsetup.sh: 14: cannot create strings/0x409/product: Directory nonexistent
mkdir: cannot create directory ‘configs/c.1’: No such file or directory
mkdir: cannot create directory ‘functions/ncm.usb0’: No such file or directory
ln: failed to create symbolic link 'configs/c.1': No such file or directory

so that directory /sys/kernel/config/usb_gadget doesn't seem to exist...

@andreadaoud
Copy link

Could you please try running modprobe libcomposite before running the script?

@mikebrady
Copy link
Owner

Sure. There was no response:

pi@RaspberryPi3B:~ $ modprobe libcomposite 
pi@RaspberryPi3B:~ $ 
pi@RaspberryPi3B:~ $ sudo modprobe libcomposite 
pi@RaspberryPi3B:~ $ 

@andreadaoud
Copy link

Yes, and please check if that directory appears?

@mikebrady
Copy link
Owner

Yes, it's there now:

pi@RaspberryPi3B:~ $ cd /sys/kernel/config/
pi@RaspberryPi3B:/sys/kernel/config $ ls
device-tree  usb_gadget
pi@RaspberryPi3B:/sys/kernel/config $ 

So I'll go ahead and try it out now.

@mikebrady
Copy link
Owner

Got further, but still no cigar yet:

pi@RaspberryPi3B:~ $ sudo sh usbethsetup.sh 
mkdir: cannot create directory ‘functions/ncm.usb0’: No such file or directory
ln: failed to create symbolic link 'configs/c.1/ncm.usb0': No such file or directory
ls: write error: Invalid argument
pi@RaspberryPi3B:~ $ 

@andreadaoud
Copy link

Another mod is missing, pleaes try modprobe usb_f_ncm

@mikebrady
Copy link
Owner

Okay -- it'll take me a few minutes...

@mikebrady
Copy link
Owner

Thanks -- the script ran with no errors!

Got some very encouraging logs entries too:

Sep 07 12:39:19 RaspberryPi3B kernel: using random self ethernet address
Sep 07 12:39:19 RaspberryPi3B kernel: using random host ethernet address
Sep 07 12:39:19 RaspberryPi3B kernel: usb0: HOST MAC fe:1d:65:5e:77:30
Sep 07 12:39:19 RaspberryPi3B kernel: usb0: MAC 96:5f:4c:56:a8:8c
Sep 07 12:39:19 RaspberryPi3B kernel: dwc2 3f980000.usb: bound driver configfs-gadget
Sep 07 12:39:19 RaspberryPi3B sudo[733]: pam_unix(sudo:session): session closed for user root
Sep 07 12:39:19 RaspberryPi3B systemd-udevd[741]: Using default interface naming scheme 'v247'.
Sep 07 12:39:19 RaspberryPi3B dhcpcd[601]: usb0: waiting for carrier
Sep 07 12:39:28 RaspberryPi3B dhcpcd[601]: wlan0: Router Advertisement from fe80::362c:c4ff:fe37:f17c
Sep 07 12:40:31 RaspberryPi3B sudo[764]:       pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/journalctl -n 100 -f
Sep 07 12:40:31 RaspberryPi3B sudo[764]: pam_unix(sudo:session): session opened for user root(uid=0) by pi(uid=1000)
Sep 07 12:40:55 RaspberryPi3B kernel: usb 1-1.2: new high-speed USB device number 4 using dwc2
Sep 07 12:40:55 RaspberryPi3B kernel: usb 1-1.2: New USB device found, idVendor=05ac, idProduct=1902, bcdDevice=17.01
Sep 07 12:40:55 RaspberryPi3B kernel: usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 07 12:40:55 RaspberryPi3B kernel: usb 1-1.2: Product: MacBook Pro
Sep 07 12:40:55 RaspberryPi3B kernel: usb 1-1.2: Manufacturer: Apple Inc.
Sep 07 12:40:55 RaspberryPi3B kernel: usb 1-1.2: SerialNumber: FVFF20AUQ05Q
Sep 07 12:40:55 RaspberryPi3B mtp-probe[767]: checking bus 1, device 4: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2"
Sep 07 12:40:55 RaspberryPi3B mtp-probe[767]: bus: 1, device: 4 was not an MTP device
Sep 07 12:40:55 RaspberryPi3B kernel: usbcore: registered new interface driver cdc_ether
Sep 07 12:40:55 RaspberryPi3B kernel: cdc_ncm 1-1.2:1.0: bind() failure
Sep 07 12:40:55 RaspberryPi3B kernel: cdc_ncm 1-1.2:1.2: bind() failure
Sep 07 12:40:55 RaspberryPi3B kernel: usbcore: registered new interface driver cdc_ncm
Sep 07 12:40:55 RaspberryPi3B kernel: usbcore: registered new interface driver cdc_wdm
Sep 07 12:40:55 RaspberryPi3B kernel: usbcore: registered new interface driver cdc_mbim
Sep 07 12:40:55 RaspberryPi3B mtp-probe[772]: checking bus 1, device 4: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2"
Sep 07 12:40:55 RaspberryPi3B mtp-probe[772]: bus: 1, device: 4 was not an MTP device
Sep 07 12:41:05 RaspberryPi3B dhcpcd[601]: wlan0: Router Advertisement from fe80::362c:c4ff:fe37:f17c
Sep 07 12:42:21 RaspberryPi3B dhcpcd[601]: wlan0: Router Advertisement from fe80::362c:c4ff:fe37:f17c

so I'll play around with it now.

Thanks for your help!

@andreadaoud
Copy link

Are you connecting a C-C cable? From the logs, I think somewhere is wrong: the MacBook is currently a device, not host. RPi should be the device. Could you please try to use a USB A-C cable to connect the Pi? i.e. Use some expansion docker to get USB-A port on Mac, And connect the A side of the cable to the mac, C side of the cable to RPi.

@mikebrady
Copy link
Owner

I think you are right. I have a MacBook Pro M1, so USB-C sockets. The Pi is a 3B, so USB-A sockets. Right now, I'm using a regular USB-C to USB-C cable with a little A-plug-to-C-socket adapter to plug into the 3B's USB socket. I guess this is the cause of the problem you are referring to (C to C cable)? I'm travelling right now, so haven't access to my bag of cables. I will be able to check over the weekend though. But this is good going -- thanks again for your help.

@andreadaoud
Copy link

@mikebrady
Copy link
Owner

Unfortunately you may need to use Pi4: https://raspberrypi.stackexchange.com/questions/71613/how-to-use-raspberry-pi-3-as-a-usb-gadget

That's very useful, thanks.

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

No branches or pull requests

3 participants