Raspberry PI and NDX

Posted by: Simon-in-Suffolk on 14 April 2013

Just to advise if anyone is interested I have successfully set up the Raspberry Pi to act as uPNP server and successfully work with the NDX and Nstream in fullI operation mode with playlists.

For those that are not aware, the Raspberry Pi (RPI) is a tiny computer about the size of a large box of matches and is powered by a  USB connector and costs about $35.

I have mounted my NAS shares and am using MiniDLNA and am running it headless using athe RPI's inbuilt wired Ethernet adapter.

It sounds as good as any other UPNP server, but then why shouldn't it.. Very impressed.. and it is very quick with Nstream.

No transcoding sorted yet...

Simon

Posted on: 03 January 2014 by Simon-in-Suffolk

Simon, the bottleneck if you are have the. CPU headroom, is most likely the IO bus, which is centred around the USB bus on the Pi, even for  Ethernet. The IO for 192 / 24 is approx 10Mbps x 2, remember the media is dog legging in and out of the UPnP server. If you have SMB (CIFS) issues this can raise significantly on the 'read' side.

 

I had crackles at first with my Pi, but I found I had. SMB (CIFS) read errors, and my /var/logs were filling up. I fixed by changing mount command and using latest SMB package and a later beta of Asset.

 

you might want to try running as 100Mbps instead of 1Gbps, just to see if that improves things. I'll mount my 192/24 stuff via my Pi later today and see what happens here. I use 100Mbps 

 

Simon

Posted on: 03 January 2014 by Foxman50
Originally Posted by Simon-in-Suffolk:

Simon, good write up. One thing I would add, as it is (was?) slightly mis leading on the Spoon site. Make sure you run Asset as a regular user and not Root. That is if you use crontab to automatically start Asset, do not configure crontab with the 'sudo' prefix command, run it  as you so you are the owner of the Asset processes.

 

The config files should be in your own home directory and not root. Asset puts the files in your own home directory the first time you run it as you.

 

Simon

 

 

 

Hi Simon

 

Does this have any effect on the system in any way, or is it more to do with good house keeping. 

Posted on: 03 January 2014 by Simon-in-Suffolk

Good question.. When I ran mine as root, ( I was running using root's crontab) I sometimes had issues saving config settings and running debug.

i corresponded with the Asset team, and they said I should not run as root, and they will put a check for this in a future version.

Since I stopped running as root I have had no such issues.

But absolutely irrespective of usability, you are right it good housekeeping as well.

Posted on: 03 January 2014 by Foxman50
Originally Posted by simes_pep:

Using Asset on the Raspberry Pi is certainly better than Twonky Server on my ReadyNAS Duo NAS. In terms of Metadata management of the Album Artist tag, Compilations, Album Artwork etc.

 

However the only issue I am experiencing is trying to transcode 24/192 and 24/176.4 files to WAV.

The ND5 buffer doesn't get to 100% during replay, and every minute or so, is down to 0% and the music drops out for a few seconds, but it struggles to be served. It works fine for 24/96 and below.

 

Now looking at iStat during replay of these files, the Pi's CPU load is 20% (load average under 5), with some free RAM and no Swap file being used. I/O to the ND5 is about 1MB/s (so 8 Mbit/s or so) and this is easily served by the NAS, which is just idling with a 1% CPU usage and the 1MB/s to the Pi. All devices are connected to a GIgabit switch, with a throughput capability of 16Gb/s.

The non-transcoded FLAC files play perfectly.

 

So where is the bottleneck? Is it just a hardware limitation of the Pi?

I do have the NAS configured for Jumbo frames support, so the MTU is 7936.

 

Any else got experience of transcoding 24/192 files and what network settings do they have.

 

Thanks,

Simon.

Hi Simon

 

I noticed on the Asset forum you mentioned that your ND5 is connected via "Mains Plugs", are you able to by pass these with a long cat 5 cable for testing.

 

I know there have been many discussions on this forum regarding these units, although ive no experience myself of them.

 

Graeme

Posted on: 03 January 2014 by Foxman50
Originally Posted by Simon-in-Suffolk:

Good question.. When I ran mine as root, ( I was running using root's crontab) I sometimes had issues saving config settings and running debug.

i corresponded with the Asset team, and they said I should not run as root, and they will put a check for this in a future version.

Since I stopped running as root I have had no such issues.

But absolutely irrespective of usability, you are right it good housekeeping as well.

So i would use, in my case

 

"pi crontab - e" instead of "sudo crontab -e"

 

Could you elaborate on your previous post about issues with your cifs shares and how you amended your mount command.

 

Graeme 

Posted on: 03 January 2014 by Simon-in-Suffolk

Graeme, could point, Powerline Adapters are rather poor at this sort of thing (irrespective of the. RFI issues) as they simply don't have session throughput. They are fine for a simple transfer, but you have multiple TCP sessions at anything other than trivial bandwidths then the interruption to the streams that is occurring underneath the covers will start to appear. You really need to have a duplex end to end link in place.

 

Simon, you mention Jumbo frames.. Have you set the Pi to read jumbo frames on the TCP session to the NAS.. If not there could be more issues here, again try switch off jumbo frames off to see if there is an improvement.

 

Simon

Posted on: 03 January 2014 by simes_pep

Ok,

 

Many thanks for the feedback.

 

My crontab entries for Asset are not sudo'ed

 

they are:

@reboot sudo mount /home/pi/nas

@reboot /usr/bin/asset/bin/AssetUPnP

@reboot /usr/local/bin/istatd -d

 

So I remount the NAS, start Asset and start the iStat monitoring.

 

What change did you make to your CIFS mount command?

 

I have run sudo apt-get update, sudo apt-get upgrade so everything should be up-to-date.

 

Thanks,

Simon.

Posted on: 03 January 2014 by Simon-in-Suffolk

Graeme, I ended up using the following line in /etc/fstab. (clearly your NAS address will vary)

I added the _netdev and mounted as Guest as apposed to authenticated user.. the last bit perhaps was an Asset limitation, but there has since been a later beta with better CIFS support, so might not be necessary now.

 

//192.168.2.236/media   /home/pi/nas cifs guest,_netdev 0 0  

 

also on the crontab -e, you don't have the word Pi at the start. That is you would log in as Pi, and simply type   crontab - e   

 

Simon

Posted on: 03 January 2014 by Foxman50

Thanks Simon

 

Getting a bit off topic but im still trying to get my NAS to go to sleep. I have stopped asset, no effect, so its not Asset. Im trying to unmount my share, but it keeps returning "umount: /home/pi/nas:device is busy"


Im using "sudo umount /home/pi/nas"

 

Want to unmount the share to see if this allows the NAS to sleep. I know i can rem out the statement in fstab, but thought umount should work.

 

Graeme

Posted on: 03 January 2014 by Simon-in-Suffolk

Graeme, i think you might just need to work it through to see what is holding your mount

http://www.raspberrypi.org/php...php?f=27&t=10109

Simon

 

Posted on: 03 January 2014 by Foxman50
Originally Posted by Simon-in-Suffolk:

Graeme, i think you might just need to work it through to see what is holding your mount

http://www.raspberrypi.org/php...php?f=27&t=10109

Simon

 

Seems there is lots to learn on the pi. Simple case of it not being able to unmount while im in the mounted directory.

Thanks again Simon

Posted on: 03 January 2014 by simes_pep
Originally Posted by Simon-in-Suffolk:

Graeme, I ended up using the following line in /etc/fstab. (clearly your NAS address will vary)

I added the _netdev and mounted as Guest as apposed to authenticated user.. the last bit perhaps was an Asset limitation, but there has since been a later beta with better CIFS support, so might not be necessary now.

 

//192.168.2.236/media   /home/pi/nas cifs guest,_netdev 0 0  

 

also on the crontab -e, you don't have the word Pi at the start. That is you would log in as Pi, and simply type   crontab - e   

 

Simon

Ok,

My fstab entry is very similar

//192.168.1.3/media /home/pi/nas cifs guest,_netdev,sec=ntlm 0 0

 

with the _netdev option but also the sec=ntlm needed by later Kernels.

 

I have unset the Jumbo frame option on my NAS, and the MTU entry in that setting is now 1500, which is the same as the Pi's MTU on eth0

 

Unfortunately I don't have a long enough Ethernet cable to reach between the switch and the ND5. I get reasonable performance on the Mains Plugs - 153 Mbit/s or so, and there is nothing else sharing the bandwidth. Again the non-transcoded FLAC 24/192 files play perfectly, it only when the Pi is transcoding them to WAV.

 

Thanks - reading the pages on mount.cifs

Simon.

 

 

Posted on: 03 January 2014 by Simon-in-Suffolk

Hi Simon,

i don't have any 192/24 FLACs, but I do have WAVs, so I have now mounted my Hidef NAS to the Pi, and just playing back Antonio Forcione's Meet Me in London (192/24 WAV) ... Actually forgot how good this sounds 

No problems at all.. 

 

So the only thing I haven't done is transcoded 192/24 FLACs, but clearly that will have less IO load than playing and streaming 192/24 WAV files because of the smaller FLAC reading sizes.

You could always manually transcode a FLAC track to a WAV to see if it makes a difference.

 

BTW my kernel is

Linux raspberrypi 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/LInux

 

Simon

Posted on: 03 January 2014 by Simon-in-Suffolk

Simon.. Just done some fiddling around..

Streaming a  192/24 WAV from a CIFS mount, (no transcoding) the Asset streaming process was at around 75% CPU which is high...

Streaming a 88/24 FLAC and real time transcoding to WAV had the Asset streaming process at around 18% CPU. Which is more what I would expect.

i will try to transcode a 192/24 FLAC later and see what that turns out as.. But it does look like the Pi  is possibly becoming IO bound at the higher bandwidths.

Simon

 

Posted on: 03 January 2014 by Slioch
Originally Posted by Simon-in-Suffolk:

Simon.. Just done some fiddling around..

Streaming a  192/24 WAV from a CIFS mount, (no transcoding) the Asset streaming process was at around 75% CPU which is high...

Streaming a 88/24 FLAC and real time transcoding to WAV had the Asset streaming process at around 18% CPU. Which is more what I would expect.

i will try to transcode a 192/24 FLAC later and see what that turns out as.. But it does look like the Pi  is possibly becoming IO bound at the higher bandwidths.

Simon

 

I happened to have the flac of Meet Me In London in my library.  If I transcode to wav then Asset is typically about 25% CPU though some interestingly big transient peaks to about 70%.

 

General setup is (I think) the same as Simon in Suffolk - wired connections, CIFS mount, NDX.  But I'm running a later version of the kernel & firmware on Rpi:

 

Linux raspberrypi 3.10.24+ #614 PREEMPT Thu Dec 19 20:38:42 GMT 2013 armv6l GNU/Linux

 

although I haven't adjusted memory settings in anyway so they still are at default.  

 

Also I'm not using iStat to take those readings - and I'm not sure I trust/understand the package I have  (RPi-Monitor).  But using top gives the same kind of readings, though, and I seem to have remembered how to use that....

 

And I'm not seeing drop outs/buffer exhaustion at any time.

 

Not sure that that helps - nothing worse than people saying 'it just works' when you're having problems....but does show that it can be made to work.

Posted on: 03 January 2014 by simes_pep

Ok, Many thanks for all your posts. Had to go for a long (windy) walk up the Dublin mountains!

 

Now my Pi is running the following version (pretty up-to-date!)

Linux raspberrypi 3.10.25+ #618 PREEMPT Thu Jan 2 20:00:10 GMT 2014 armv6l

 

Earlier I tried some additional options in the fstab entry

//192.168.1.3/media /home/pi/nas cifs cache=none,guest,_netdev,sec=ntlm 0 0

//192.168.1.3/media /home/pi/nas cifs cache=none, rsize=8096, guest,_netdev,sec=ntlm 0 0

//192.168.1.3/media /home/pi/nas cifs cache=strict, guest,_netdev,sec=ntlm 0 0

etc. The cache=none replaces the earlier directio option, which is mentioned in a number of postings, as well as reducing the rsize - which in the newer Kernels and CIFS modules is much larger.

I have checked that all the MTUs pf the devices were all at 1500, so buffer size was consistent across the network.

 

But 24/192 was still dropping out, without any change. So I reset back to how it is was.

 

I was using Brandenburg Concerto No 3 in G Major BWV 1048 (A Linn Recording actually) and Anna Netrebko Sempre Libera (ripped from a Pure Audio Blu-ray) to test, but I also have the Meet Me In London album and it does sound great.

 

I then applied some Port-based QoS settings in my switch, giving priority to the Ports connected to the NAS, ND5 (via the Mains Plugs) and the Pi - now interesting this did almost stop the dropouts with the 24/192 files, but the ND5 buffer was not sitting at 100% but between 50% to 70%, occasionally dropping to 30%.

 

Now there isn't much else on my 8 port switch - a Cisco Wireless AP with a Gigabit connection and a backup NAS (an old Linksys NSLU2 with USB disks and a 10/100 interface, with backup jobs running from the ReadyNAS Duo, as predetermined times during the weekdays).

 

So now the backup traffic is at lowest priority, normal internet access via WiFi is at normal, and access to the NAS, the ND5 connection and Pi is given the highest priority.

 

So I can only conclude that some network/processing element is at the edge of its processing throughtput capability when trying to transcode the FLAC 24/192 files. It could be the NAS, as the Duo is well known for not being powerful with the SPARC Marvell processor. Which was another reason for having a dedicated UPnP server with the Pi, so the NAS is just serving files. Or the I/O bandwidth in Pi or the I/O bandwidth of the Mains Plug. Or the combination of all 3.

 

So is it better to have the audio files served without any network stress, so that the input buffer on the ND5 can do its job properly and there is no chance of audio dropout, over the not-so-audible difference between FLAC and WAV?

 

I know I will have to change the NAS once I have filled the current 2TB disks up, as it doesn't support anything larger, and soon 4TB disks will be commonplace and NAS enclosures will have better performance given the take-up of streamed media. And are there plans for a 'Type C' Pi with more CPU processing and RAM, given its success?

 

However I still prefer Asset over Twonky Server in terms of the UPnP Server.

Posted on: 03 January 2014 by maccaa

Just thought I'd check back in whilst listening to a bit of Marley, with Asset running very well on my pi, I would like to thank everyone thus far and am sure will have more questions in future, just the one for now, how do you transcode to WAV ( yes Simon that PDF would be useful) I am currently 0% compression FLAC ripped via DBpoweramp, I assumed that you changed "Audio format streaming" in the Asset setup and changed the drop down menu next to FLAC to play as WAV Then save. Which I have done, but the ipad still tells me it's playing a FLAC, any pointers?

Posted on: 03 January 2014 by maccaa

"Patients my young padawan" it now appears that I am transcoding to WAV 

 

Simon, I am playing meet me in London 24/192, no drop outs thus far.

 

Maccaa

Posted on: 03 January 2014 by simes_pep

Hi,

Does this link work?

https://www.dropbox.com/sh/bu8etep76nu4v5z/aMw624ZA5U

 

Thanks,

Simon.

 

Posted on: 03 January 2014 by Foxman50
Originally Posted by simes_pep:

Hi,

Does this link work?

https://www.dropbox.com/sh/bu8etep76nu4v5z/aMw624ZA5U

 

Thanks,

Simon.

 

Thats great Simon, works a treat. Think you could have added a bit more detail though 

Posted on: 03 January 2014 by simes_pep
Originally Posted by Foxman50:
Originally Posted by simes_pep:

Hi,

Does this link work?

https://www.dropbox.com/sh/bu8etep76nu4v5z/aMw624ZA5U

 

Thanks,

Simon.

 

Thats great Simon, works a treat. Think you could have added a bit more detail though 

It's just a 'Work-in-progress' so far!

Posted on: 03 January 2014 by Foxman50
Originally Posted by simes_pep:
Originally Posted by Foxman50:
Originally Posted by simes_pep:

Hi,

Does this link work?

https://www.dropbox.com/sh/bu8etep76nu4v5z/aMw624ZA5U

 

Thanks,

Simon.

 

Thats great Simon, works a treat. Think you could have added a bit more detail though 

It's just a 'Work-in-progress' so far!

I was jesting, reading through it now to see if i missed anything while setting mine up. Great bit of work, well done. Im sure Mr Spoon will be happy to receive this.

Posted on: 03 January 2014 by maccaa
Originally Posted by simes_pep:

Hi,

Does this link work?

https://www.dropbox.com/sh/bu8etep76nu4v5z/aMw624ZA5U

 

Thanks,

Simon.

 

Simon, i hope you don't mind, I have downloaded, it's a great read and very very useful.

 

Another small query which I can't seem to find the answer for:

 

i conected  the pi via cable to the router to set the static ip, i had to remove the sky on demand cable as I have run out of ports, if I install a wireless USB , will the ip remain the same and is this wireless connection just to control the pi ( it's running headless currently) ie no detriment to sound quality?

Posted on: 03 January 2014 by simes_pep
Originally Posted by maccaa:
Originally Posted by simes_pep:

Hi,

Does this link work?

https://www.dropbox.com/sh/bu8etep76nu4v5z/aMw624ZA5U

 

Thanks,

Simon.

 

Simon, i hope you don't mind, I have downloaded, it's a great read and very very useful.

 

Another small query which I can't seem to find the answer for:

 

i conected  the pi via cable to the router to set the static ip, i had to remove the sky on demand cable as I have run out of ports, if I install a wireless USB , will the ip remain the same and is this wireless connection just to control the pi ( it's running headless currently) ie no detriment to sound quality?

Perfectly happy to have as many access and comment. I just wanted to capture all the steps required in a one place, rather than dotted around on different forums and web-sites etc.

Plus I had an afternoon spare, and was thinking through the transcoding issue, and rechecking my installation/configuration steps just incase I had got something wrong.

 

In terms of moving the Pi to a Wireless connection, you would need to reproduce the Static IP process for the interface wlan0 instead of eth0.

Another words, insert the USB Wifi dongle, let it get a DHCP address for the wlan0 interface, which you can view with ifconfig and netstat, then make the adjustments to the /etc/network/interfaces file to assign this interface a static IP address. It could be a different address to the one assigned to the Ethernet interface, just incase you go back to a wired connection. The static-IP address is just to make it easier to connect to in headless mode, through WinSCP/Putty or a SSH command.

 

In terms of performance, I'm not sure. I used a Squeezebox SB3 with a wireless connection for a few years, but this was limited to a max 24/48 format and that sometimes dropped out, particularly if there was other wireless traffic on the network. So not really recommended for HiRes.

A new switch would be better option. I had to move to a 8-port switch earlier this year, to accommodate the additional devices, as my Cable Modem Router only has 4 LAN connections. Plus I wanted a separate Wireless AP and a faster backplate for all this streaming.

 

Simon. 

Posted on: 03 January 2014 by Simon-in-Suffolk

Simon, I do think your ethernet over mains devices are most likely causing the issues. I have yet to get my Pi to stutter in normal mode of operation. I am working on it, but I am using wired duplex sessions. Being duplex is probably the most important aspect.. As remember there are many TCP/UDP sessions open rather than just the TCP one transferring the media.

thinking of options why not remove istatd,  I simply use 'top'  to get the performance stats. Is your istatd writing to a local file?

BTW if you hammer the Pi when it's streaming and/or raise the nice value (lower priority) of the main upnp process on the Pi, when transcoding I get a crackle rather than a drop in buffer.

Your buffer issue does tend to imply TCP challenges between the Pi and your Naim network player.

But as I said streaming a 192/24 WAV source file on your setup should be enlightening.. Ie does it make any difference? Another idea, when you browse the library with Nstream and do a search across the track titles for example, does the buffer run out, or the search fail to happen or take a ridiculous amount of time to happen ? If not again it suggests your buffer issue is not linked to Pi resources.

Simon