查看: 3845|回复: 0

采用ESPRESSOBIN开发板运行OpenWRT建立家用小型媒体服务器

[复制链接]

该用户从未签到

发表于 2018-6-8 10:04:27 | 显示全部楼层 |阅读模式
分享到:
[url=]1介绍[/url]
[url=]1.1范围
[/url]


本文描述在espressobin开发板上实现家用小型Media服务器的系统和简明过程。
[url=]1.2参考
[/url]


https://espressobin.net/
https://openwrt.org/
[url=]1.2.1Board Specification
[/url]


官方资料来源于https://espressobin.net/tech-spec/
SoCMarvell Armada 3700LP (88F3720) dual core ARM Cortex   A53 processor up to 1.2GHz
System Memory1 GB DDR3 or optional 2GB DDR3
Storage1x SATA interface
   1x micro SD card slot with footprint for an optional 4GB EMMC
Network Connectivity1x Topaz Networking Switch
   2x GbE Ethernet LAN
   1x Ethernet WAN
   1x MiniPCIe slot for Wireless/BLE periphereals
USB1x USB 3.0
   1x USB 2.0
   1x micro USB port
Expansion2x 46-pin GPIO headers for accessories and shields with   I2C, GPIOs, PWM, UART, SPI, MMC, etc.
MiscReset button, JTAG interface
Power supply12V DC jack or 5V via micro USB port
Power consumptionLess than 1W thermal dissipation at 1 GHz
从上表中可以看出,各类接口和扩展口丰富,略感美中不足的是WIFI也需要外接。
[url=]2OpenWRT系统
[/url]


OpenWrt项目早期是无线路由器的开源项目,是开源社区通过GPL许可证怼赢了C公司之后慢慢发展壮大起来。采用OpenWRT开源项目,工程师可以自由定制各种相关的内核和应用,基本上最新和最经典网络应用软件,都有集成在系统里面供开发人员自由选择。OpenWRT中间也经历了各种分分合合,前不久刚刚和LEDE宣布合并,并即将推出稳定版v18.06,本文即在最新的v18.06的RC版本上测试通过。
[url=]2.1源代码
[/url]


下载源码命令:
$ git clone https://git.openwrt.org/openwrt/openwrt.git
$ scripts/feeds update -a
$ scripts/feeds install -a
[url=]2.2配置和编译
[/url]


在开始Build之前需要做一些最基本系统(包括Kernel和网络应用层)的配置,配置明细和界面首页如下:
$ make menuconfig

和SoC系统相关的配置基本上就是上述截图前面3选项搞定,其它的应用相关的配置项就自己随意了。一般来说SSH服务(本人习惯CLI远程管理和socks转发)、DDNS服务(使得家里的动态IP可以远程接入)是常用选项,另外我需要作为Media服务器,所以这里也选择了minidlna等package。
接下来编译系统,命令如下:
$ make -j $(nproc) V=s
上面-j $(nproc)是至多核多任务编程,提高速度;V=s是提供详细的下载和编译过程日志,便于调查编译过程中的错误。
整个Build过程(含下载文件)大概2~4个小时,视网络速度和主机性能而异。编译完成了之后,输出文件如下:

我们需要采用的是openwrt-mvebu-cortexa53-globalscale-espressobin-squashfs-sdcard.img.gz作为刷机镜像文件。
为方便爱好者参考,现把二进制image共享在网盘(链接: https://pan.baidu.com/s/1CC707JXvg-XjMUKmKhi__Q 密码: 8wed),仅供参考而已哈,不提供支持和服务。
[url=]2.3刷机Reflash
[/url]


ESPRESSOBIN支持TF卡启动和USB盘启动,不用担心刷坏了变砖——这个特点必须点赞的。
刷机当然需要刷机工具,在此顺便安利一个USB启动盘制作工具rufus(Linux/Windos镜像都支持哈),用法如下图:

刷好了之后,插入TF卡,就可以启动了。通常你需要接一个串口查看IP地址等信息,如果你通过别的方式知道开发板的IP地址,甚至串口都可以不用接。
2.4 U-BOOT环境设置

多数情况下,还是需要检查和设置一下U-BOOT的环境变量的(当然这个需要连接串口才行)。加电之后连续按回车键,就可以让U-BOOT停在引导界面如下。
参考WIKI的U-BOOT ENV参数,因为版本有更新,要做一点点的调整,主要是文件名和位置更新了。具体命令参考以下LOG中红色标记部分:
R6:
  00~3F 1F
  +:1F
  -:1F
  
  Booting Trusted Firmware
  BL1: v1.2(debug):armada-17.02.0:
  BL1: Built : 10:56:45, Feb 24 2NOTICE:  BL2: v1.2(debug):armada-17.02.0:
  NOTICE:  BL2: Built : 10:56:45, Feb 24 20NOTICE:  BL31: v1.2(debug):armada-17.02.0:
  NOTICE:  BL31:
  
  U-Boot 2015.01-armada-17.02.0-01546-g98aa0c8 (Mar 02 2017 - 09:49:08)
  
  I2C:  ready
  DRAM:  1 GiB
  Board: DB-88F3720-ESPRESSOBin
    CPU  @ 1000 [MHz]
    L2  @ 800 [MHz]
    TClock @ 200 [MHz]
    DDR  @ 800 [MHz]
  Comphy-0: PEX0  2.5 Gbps
  Comphy-1: USB3  5 Gbps
  Comphy-2: SATA0  5 Gbps
  Now running in RAM - U-Boot at: 3ff2b000
  U-Boot DT blob at : 000000003fa18168
  MMC:  XENON-SDHCI: 0
  SF: Detected W25Q32DW with page size 256 Bytes, erase size 4 KiB, total 4 MiB
  PCIE-0: Link down
  SCSI:  SATA link 0 timeout.
  AHCI 0001.0300 32 slots 1 ports 6 Gbps 0x1 impl SATA mode
  flags: ncq led only pmp fbss pio slum part sxs
  Net:  neta0
  Hit any key to stop autoboot:  0
  Marvell>>
  Marvell>> setenv fdt_name 'armada-3720-espressobin.dtb'
  Marvell>> setenv image_name Image
  Marvell>> setenv ethact 'neta0'
  Marvell>> setenv set_bootargs 'setenv bootargs $console'
  Marvell>> setenv bootmmc 'mmc dev 0; ext4load mmc 0:1 $kernel_addr $image_name; ext4load mmc 0:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/mmcblk0p2 rw rootwait; booti $kernel_addr - $fdt_addr'
  Marvell>> setenv bootcmd 'run bootmmc'
  Marvell>> saveenv

  Saving Environment to SPI Flash...
  SF: Detected W25Q32DW with page size 256 Bytes, erase size 4 KiB, total 4 MiB
  Erasing SPI flash...Writing to SPI flash...done
  Marvell>> boot
  switch to partitions #0, OK
  mmc0 is current device
  7428104 bytes read in 2333 ms (3 MiB/s)
  7854 bytes read in 42 ms (182.6 KiB/s)
  ## Flattened Device Tree blob at 01000000
    Booting using the fdt blob at 0x1000000
    Using Device Tree in place at 0000000001000000, end 0000000001004ead
  
  Starting kernel ...
[url=]2.5 运行
[/url]


OpenWRT跑起来之后,可以查看一些CPU等基本的信息,如下:
BusyBox v1.28.3 () built-in shell (ash)
  
    _______  ________  __
   |  |.-----.-----.-----.|  |  |  |.----.|  |_
   |  -  ||  _  |  -__|  ||  |  |  ||  _||  _|
   |_______||  __|_____|__|__||________||__|  |____|
    |__| W I R E L E S S  F R E E D O M
   -----------------------------------------------------
  OpenWrt 18.06-SNAPSHOT, r0-5083842
   -----------------------------------------------------
  === WARNING! =====================================
  There is no root password defined on this device!
  Use the "passwd" command to set up a new password
  in order to prevent unauthorized SSH logins.
  --------------------------------------------------
  root@OpenWrt:/# [  19.141822] random: crng init done
  [  19.145255] random: 2 urandom warning(s) missed due to ratelimiting
  
  root@OpenWrt:/# uname -a
  Linux OpenWrt 4.14.43 #0 SMP Fri May 25 18:36:46 2018 aarch64 GNU/Linux
  
  root@OpenWrt:/# uptime
   18:40:16 up 0 min,  load average: 0.11, 0.03, 0.00
  
  root@OpenWrt:/# lscpu
  Architecture:   aarch64
  Byte Order:  Little Endian
  CPU(s):  2
  On-line CPU(s) list: 0,1
  Thread(s) per core:  1
  Core(s) per socket:  2
  Socket(s):  1
  Vendor ID:  ARM
  Model:  4
  Model name:  Cortex-A53
  Stepping:   r0p4
  CPU max MHz:  1000.0000
  CPU min MHz:  200.0000
  BogoMIPS:  25.00
  Flags:  fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
[url=]3 DLNA服务器
[/url]


OpenWRT启动好了,接下来就可以配置DLNA服务器作为我们的家用小型MEDIA 服务器了。这里采用前面提到的、OpenWRT支持的miniDLNA服务器。
[url=]2.1minidlna
[/url]


简单说明一下,OpenWRT支持或者集成的应用或者服务程序,都对其配置文件格式进行过统一的UCI格式的改造,以便于实现WEB LUCI页面配置。
[url=]2.1.1配置文件/etc/config/minidlna
[/url]


以下配置实验可用,列出来仅供参考:
config minidlna config
    option 'enabled' '1'
    option port '8200'
    option interface 'wan'
    option friendly_name 'OpenWrt DLNA Server'
    option db_dir '/var/run/minidlna'
    option log_dir '/var/log'
    option inotify '1'
    option enable_tivo '0'
    option wide_links '0'
    option strict_dlna '0'
    option presentation_url ''
    option notify_interval '900'
    option serial '12345678'
    option model_number '1'
    option root_container '.'
    list media_dir '/mnt'
    option album_art_names 'Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg'
[url=]3.1.2启动服务minidlna
[/url]


命令如下:
BusyBox v1.28.3 () built-in shell (ash)
  
    _______  ________  __
   |  |.-----.-----.-----.|  |  |  |.----.|  |_
   |  -  ||  _  |  -__|  ||  |  |  ||  _||  _|
   |_______||  __|_____|__|__||________||__|  |____|
    |__| W I R E L E S S  F R E E D O M
   -----------------------------------------------------
   OpenWrt 18.06-SNAPSHOT, r0-5083842
   -----------------------------------------------------
  === WARNING! =====================================
  There is no root password defined on this device!
  Use the "passwd" command to set up a new password
  in order to prevent unauthorized SSH logins.
  --------------------------------------------------
  root@OpenWrt:~# /etc/init.d/minidlna start
[url=]3.2手机端测试
这里采用VLC客户端软件。
3.2.1从本地网络找到DLNA服务器

这里我们可以看到OpenWRT DLNA Server已经跑起来啦啦啦。。。
3.2.2找到电影Video清单

当然,它也支持音乐和图片共享服务,这里以电影为例。
3.2.3看电影

[/url]
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /2 下一条

手机版|小黑屋|与非网

GMT+8, 2024-4-18 18:54 , Processed in 0.126851 second(s), 17 queries , MemCache On.

ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

苏公网安备 32059002001037号

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.