My Schematic

download schematic

Support

Selasa, 22 Oktober 2013

DIY NAS with a RK3188 device (Radxa Rock)

I currently have a full-blown Linux PC noisy tower serving 3 SATA hard disks full of multimedia as a home server... that is some 80 Watts of power consumption, plus the noise, for just a few hours of use per week.

There must be a better solution for my home network file-sharing (also called NAS) needs!

So, come the Radxa Rock board, equipped with a Quad Core ARM CPU, the Rockchip RK3188, and 2 GB RAM, quite a beast actually (I'm currently blogging from it, and use it for almost all my PC needs).

And here is today's proof-of-concept RK3188 NAS happily serving files from my desk:

1st rev.: RK3188 functioning as NAS home fileserver (using Radxa Rock board)
UPDATE:
2nd rev.: Radxa Rock as a 3 hard disks NAS (11W idle, 33W with 2 disks streaming)

Now, if you want to bear with me on the technical side... I've been doing the math about data bandwidths for some time already and taken into account the Rockchip datasheet briefs to guess the best I/Os for the task:


Hard disk interface:


Let's face it, Rockchip SoCs don't have SATA ports, and other ARM SoC have at most one SATA port, afaik, and that still means an external power for the SATA device is necessary. That is not a solution for NAS, unless you can fit everything in just one hard disk.

So let's get over it and find the second best solution: USB 2.0 ports are the highest bandwidth inputs (to connect the hard disks). The Radxa Rock board has:

- Two full sized USB 2.0 ports, and a third one in the pins of the expansion connector. All these ports are sharing, through an integrated hub, one single USB bus coming from the RK3188.
- One Micro USB 2.0 OTG  port that is directly wired to the RK3188.

Ideally USB 2.0 would mean up to 480 Mbps raw throughput so, to get the best, we don't want to share it with other devices. Hence, we will be plugging our hard disk/s to the USB OTG port.

Thankfully the market is full of external hard disk enclosures that do a very good job at converting SATA to USB. And let's see what that means:

- SATA is currently doing 3 Gbps
- USB 2.0 is "just" 480 Mbps, here is a bottleneck, certainly, but is it?


Why USB 2.0 is fine instead of SATA

Does this sound like a let down? Really? Let's do the math:

Are you going to be streaming 1080p content over Wifi? That really leaves you with <300 Mbps, and most probably <150 Mbps, if you can maintain that incredible wireless speed.

But, let's see what 150 Mbps really means in today's high compression world:

150 Mbps / 8 bits per byte = ~19 MB/s and let's say your content is a 1h30m long movie...
19 MB/second * 90 minutes * 60 seconds/minute = 100 GB movie!

Is your movie larger than that? Then this solution is clearly not for you. For the rest of the world, let's go on:

You may rightly object: movies have well and bad compressed parts, fast action may mean a bandwidth spike!

Well, you are right, and that's why multimedia players use a technique called buffering! This mostly rids us of the problem.

So once we accept that it's OK to stream things at Megabit speeds, we may stop worrying about using SATA hard disks over USB.



Network interface:


As I/O, the Radxa Rock board has an integrated Fast Ethernet, that is connected directly to the RK3188 (through the usual RMII PHY interface). This means 100 Mbps so... people with movies of >66 GB may stop reading now.  ;-)

For the sake of this proof-of-concept, we will be using this 100 Mbps Ethernet port, although a better solution would be to have a Gigabit Ethernet adapter attached to a full sized USB 2.0 port, which would give us up to 480 Mbps of actual bandwidth.

Do not share the USB OTG port with the hard disk/s! The RK3188 (and the RK3066) has two physical USB 2.0 buses: the OTG and the "full sized", so use both as much as possible, instead of cramming all devices onto just one's bandwidth.




File-sharing Speed Testing:


I am using a bare Xubuntu Linux on the Radxa board so it is possible to connect to the SATA hard disk through FTPS out of the box.

The SATA II hard disk is in a external USB 2.0 enclosure and has a 1.5 TB NTFS partition and we will be using a FTPS server (slower than FTP). Not the best case for speed, but will let us see how well it can do on this not ideal setup.

So, first of all, let's test how fast the RK3188 itself can read files from it, by running this command on the connected [but unmounted] drive:
sudo hdparm -t /dev/sda
/dev/sda:
 Timing buffered disk reads:  90 MB in  3.03 seconds =  29.74 MB/sec
The repeated tests result always around and very close to 30 MB/second. That is some 240 Mbps, or 50% the theoretical maximum USB 2.0 speed.
Who is to blame? I fear in this case it's my old USB2SATA's fault, since doing the same speed test on an i7 top of the line PC yields some 33 MB/s.

Good, more of a worst case then, so let's do real life tests with actual multimedia files on the SATA disk served over Fast Ethernet by the Radxa Rock RK3188 board:

Streaming an 11 GB action movie (1080p) requires an average of 2 MB/s and is perfectly watchable on the remote PC, as if it were a local file.

Transferring a large file over Ethernet to another PC maintains a speed of 6.7 MB/s, that is a bit over 50 Mbps.

I've also tested transferring a file from the MicroSD card where Xubuntu runs, just to do a test without USB and SATA, the result is a constant speed of 7.2 MB/s.

For the sake of completeness, I too have tried this same raw transfer (FTPS from MicroSD) using a Gigabit Ethernet to USB 2.0 adapter, the result is a constant speed of 8 MB/s.
Better and more than enough for our purposes, but still below my expectations. Next thing will be to test with an FTP server, without the FTPS encryption burden!

Further details about these tests: the "intermediary" is a Gigabit switch that has been thoroughly tested at 1 Gbps speeds.

So it seems the RK3188 is perfectly able to cope with the task, even using a heavy encrypted FTPS server.



Conclusions for a faster NAS file-sharing solution


1) Use a Gigabit Ethernet to USB 2.0 adapter (and from a reliable source or you'll find yourself with a ridiculous USB 1.1 device able of <11 Mbps) and connect it to the full size USB port on your Rockchip board/stick.

2) Set up a simple FTP server for file-sharing, that makes sure your RK3188 can concentrate on reading the hard-disks through USB and the network protocols, instead of the heavyweight encryption for the FTPS. Even if you go wireless, Wifi already encrypts everything on the air!

3) Use Linux-friendly EXT4 partitions. NTFS is not bad, but will require more CPU to read/write (you'll see a process called "mount.ntfs" often). FAT what?

4) If you want to have a 4-disk NAS or even an 8-disks NAS, no problem! Just know you should still plug them all, through a USB hub, to the same USB port.

5) And the final tip to make a nice NAS solution:
sudo hdparm -B 50 /dev/sda
This wonderful command at NAS startup will take care of turning-off your hard disks when they are unused, saving power and hard-disk life, while keeping a 100% silent environment!


UPDATE: If the drive answers with:
HDIO_DRIVE_CMD failed: Input/output error
 APM_level = not supported
Then try this similar command:
sudo hdparm -S 20 -K 1 /dev/sda

(substitute /dev/sda in these commands with your actual /dev/sdX device)


Next step: a quad hard-disk NAS solution based on Rockchip ARMs for all my file serving needs!




Tidak ada komentar:

Posting Komentar