Monday, May 21, 2018

Banana Pi DLNA media server

Couple of months back we decided to create our own media server to store our MP3s and digital photographs. But it gets postpone several months due to unavailability of main-boards and other resources. Finally, after reviewing several prototypes we decided to build our media server using Banana Pi (BPI) and MiniDLNA. Before finalize BPI we checked several main-boards which including Raspberry Pi B+, Orange Pi One and BeagleBone Black. Out of all above main-boards we choose BPI M1 because of its inbuilt SATA2.0 interface, Gigabit Ethernet port and availability in local market.

Final view of DLNA media server setup.

As an operating system we use Bananian Linux, which is Debian derivative for BPI platform. To sore all our content, we use Seagate 1TB SATA 3.5 inch hard disk drive. Bananian OS and other packages are loaded into 8GB SD card.

To power both BPI and SATA disk drive we design PSU using LM2576-5.0 step-down switching regulator IC. Also during the prototyping stages, we notice that both hard disk drive and BPI A20 CPU get heat-up during the long runs and to cool those components we decided to build simple fan controller with temperature monitor. After couple of designs we finally build BPI support board with above 5V regulator and LM311 based fan controller. To make it simple we construct above two components in 80mm × 53mm single side PCB. Both schematic and PCB design of this unit is available to download at Google drive.

5V regulator and fan controller board.
When constructing above switching regulator pay special attention to 100┬ÁH inductor (L1) and associated components in switch regulator stage. Specially if inductor is not up to the specification SATA interface may get fail with I/O errors. We got this problem while we testing this regulator in breadboard.

To monitor system temperature, we use LM35 temperature sensor with LM311 comparator. Fan trigger level can adjust using RV1 trimpot.

To drive this regulator and fan controller board, we use commonly available 12V 10A SMPS unit. Because we plan to run this server for 24×7 we choose quite reliable SMPS for this system.
After setting up all hardware components we configure and setup necessary software with following set of commands:

1.) We assign static IP address to eth0 by adding following lines to /etc/network/interfaces file:
auto eth0

iface eth0 inet static
 address 192.168.1.50
 netmask 255.255.255.0
 gateway 192.168.1.1
After above modification we restart networking service to apply changes to the system:
service networking restart
2.) Our SATA disk drive is available at /dev/sda1 and we mount it with following commands:
mkdir /data-disk
mount /dev/sda1 /data-disk
The problem with this option is that above mount point gets detached during system restarts. To made this mount point permanent we add following line to /etc/fstab :
/dev/sda1     /data-disk     ext4     defaults     0     1
(ext4 is the file system which we used in our disk drive. To get the disk format type use blkid command)

After above changes we restart the operating system to install MiniDLNA system.

3) To store all MiniDLNA data files and log we create following two directories in our sda1 mount point:
cd /data-disk
mkdir minidlna
cd minidlna
mkdir db
mkdir log
chmod 777 -r /data-disk/minidlna
Then we create directory call media in our sda1 mount point:
cd /data-disk
mkdir media
chmod a+w ./media
After creating above directory hierarchy, we modify MiniDLNA configuration file (/etc/minidlna.conf) as follows:
media_dir=/data-disk/media

db_dir=/data-disk/minidlna/db

log_dir=/data-disk/minidlna/log

friendly_name=home-dlna
After above changes we restart MiniDLNA service with following command:
service minidlna restart
Once all media files are copied to /data-disk/media directory we execute following command:
minidlnad -R
service minidlna restart
To copy media files, we use SCP.

Our DLNA server now loaded with approximately 7000 high resolution JPG files and 5000 MP3 files. With above payload it still works perfectly with all operating systems and media players. We mainly connecting with this server through VLC (Linux, Android and Windows), KODI (Android and Windows) and Windows Media Player.
Post a Comment