Wednesday, October 23, 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)
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
 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!


  1. Thanks, this is exactly how I want to use a Radxa Rock.

    1. may be you can write about the experience for us. will be much appreciated.

  2. I been running a MK808 and Tronsmart MK908 and now MK802IV As my Linux or Ubuntu server with 2 USB 3.0 WD mybook like 3TB each on it. I know the MK802IV is only USB 2.0 speed. But it been working good for me. Playing music from it and videos. I got the Odroid-XU now. still waiting to get it to boot from the hard drive but this has USB 3.0.

  3. cuibetruck( : 1 SATA2 + 1G Ethernet. Maybe you will say 1 SATA is not enough for NAS...

    1. This comment has been removed by the author.

    2. Most of them is Marvell CPU. And for NAS, the number of cpu core is not important, so rk3188 wouldn't fit this very well, maybe.

    3. Synology has great quality. But that comes at a price:

      Synology: The cheapest one I can find with >2 hdd bays is the DS413j at 300 EUR.
      DIY: Radxa Rock Lite for this project is 50 EUR + 5 EUR USB Hub + 55 EUR for 3 HD cases = 110 EUR

      So for about ONE THIRD THE PRICE :-O you get a fully open source solution that can be your NAS, as well as eMule/printer/web/mail/you_name_it server since it's a full PC with 4 cores and 2 GB RAM running awesome Linux :) can't beat that

  4. There is somethin called SATA port multiplier,

    And yes, it would work with A10/A20.

    1. That product seems to require a feature in the Allwinner's SATA port called "SATA Port Multiplier" or else it won't work.
      Does your saying "yes, it would work with A10/A20" mean that you know this feature is supported?

      And there is still the need of an external additional 5/12V power supply for the board and the hard disks.

      Otherwise, thanks for the info!

    2. Yes, it was tested by one of the members of the #arm-netbook Allwinner SATA enabled chips have all the needed features.

  5. can i install xbmc(openelec) for redxa rock ?

  6. Great article, thanks for sharing!
    But in your math you forgot to take in account the overhead every protocol has.
    USB is 480Mbps, but for disks the performance is exactly what you got: about 30MB/s
    In Wi-Fi, even if the theorical speed is 300Mbps, in real life if will be around 120Mbps of useful bandwidth. In 150Mbps you can get something around 70Mbps.
    I know, your point still stands, just to clarify.

    1. Hmmmm I have to disagree with regard to USB having a protocol overhead of 50% so that a 480 Mbps becomes 240 Mbps (30MB) with disks. If I remember right from a book on USB2 the protocol overhead was below 10%, the problem here is that something/s between each side are not capable of maintaining the full throughput.
      Same about Wifi, protocol overhead is not so high at all, however external factors like RF interference, distance, etc. may yield those numbers.

  7. what are the harddrive enclosures you are using?

    Is this compatible with most of the enclosures? I don't want to get enclosures and not have them compatible.

    1. CoolBox SlimChase 3530

      Others: Look for them to be Linux compatible, most are.

  8. Hello, Can you please mention which OS you used in this NAS project? I am trying to use Rabian and facing ethernet not getting IP issue.

    1. Xubuntu (see