基于恩智浦LS1012A的入门OpenWRT之Software Router方案

OpenWrt 是针对嵌入式设备的Linux作业系统,并且拥有软件包管理功能。
OpenWrt 提供了一个完全可写的文件系统,可让使用者从应用程序的供应商所提供的选择来配置,并允许使用者来自定义的设备,以适应任何应用程序。
对于开发人员而言,OpenWrt 是建构应用程序的框架,而无需重新建立该应用程序完整的固件,所以对于使用者而言,这意味着可以进行完全自行定制的能力。

接下来,品佳 SAC提供建构 OpenWRT 的方法,并于基 NXP LS1012A RDB实现软路由的应用。

硬件规格: 选用恩智浦的: LS1012 的 参考设计版(LS1012A-RDB)

  • 64-bit Arm® Cortex®-A53, Speed up to 1.0 GHz
  • One 16-bit DDR3L SDRAM memory controller, Up to 1.0 GT/s
  • High-speed peripheral interfaces:
  • One PCIe 2.0 controller, supporting x1 operation
  • One Serial ATA (SATA 3.0) controller
  • One USB 3.0/2.0 controller with integrated PHY
  • One USB 2.0 controller with ULPI interface
  • Two quad-speed Ethernet MACs supporting 2.5G, 1G, 100M, 10M
  • Support for RGMII, SGMII, 2.5G SGMII
  • Additional peripheral interfaces:
  • One Quad Serial Peripheral Interface (QSPI) controller for serial Flash
  • One Serial Peripheral Interface (SPI) controller
  • Two enhanced secure digital host controllers (SD, SDIO, eMMC)



软件建置:

第一部分: 搭建编译环境
1. 安装 Ubuntu (编译需要 Linux 环境),可到其官网下载,版本根据自己所需做选择即可。可以选择安装到虚拟机(VMware),或是实体机(Desktop/laptop)。
2. 下载编译所需要工具包 sudo apt-get install gcc binutils bzip2 flex python3 perl make find grep diff unzip gawk getopt subversion libz-dev libc-dev rsync


第二部分: 下载 OpenWrt源码并编译
1. 于本地端创建文件夹
       mkdir sac_openwrt
       cd sac_openwrt

2. 下载源码
      git clone https://git.openwrt.org/openwrt/openwrt.git

3. 运行脚本以获取所有最新的程序包
       ./scripts/feeds update -a
       ./scripts/feeds install -a

4. 选择工具链、要编译的固件平台(MPU类型)、型号,还能选择固件中要添加的功能和组件,配置好后保存并退出菜单即可。
       sac@ubuntu:~/sac_openwrt$ make menuconfig

                                                            Target System -->NXP Layerscape
                                                            Subtarget -->RMv8 64-bit based boards
                                                            Target Profile -->NXP LS1012A-RDB
                                                            Boot Loaders -->NXP LS1012ARDB Trusted Firmware & U-Boot for NXP LS1012ARDB
                                                            Luci -->enable

5. 开始编译
     make -j1 V=s
     make是编译命令,V=s目的在提供更多详细信息以进行故障排除, V一定要大写。
     在编译过程需保持网路连接,因为会下载一些源代码,如果处于断网的情况下执行编译,会造成中断。编译完成后会在档案目录中产生 bin 资料。

     ubuntu@ubuntu:~/sac_openwrt/LS1012_openwrt/bin/targets/layerscape/armv8_64b$ ls
     config.buildinfo
     feeds.buildinfo
     openwrt-sac-snapshot-ls1012a-layerscape-armv8_64b-fsl_ls1012a-rdb.manifest
     openwrt-sac-snapshot-ls1012a-layerscape-armv8_64b-fsl_ls1012a-rdb-squashfs-firmware.bin
     packages
     sha256sums
     version.buildinfo
     ubuntu@ubuntu:~/sac_openwrt/LS1012_openwrt/bin/targets/layerscape/armv8_64b$

     更新固件的方法一般有三种,本编使用的是第2种
     1. Web 上传固件更新
     2. TFTP上传固更更新
     3. 烧录器写入固件

6. 使用预先编译的固件包并由 NOR flash 开机进到 u-boot
     firmware_ls1012afrwy_uboot_qspiboot.img

7. 配置 TFTP IP 和本地端 IP,并下载固件和烧写进 NOR flash.
     setenv serverip 192.168.1.1
     setenv ipaddr 192.168.1.5
     tftp a0000000 openwrt-sac-snapshot-ls1012a-layerscape-armv8_64b-fsl_ls1012a-rdb-squashfs-firmware.bin
     i2c mw 0x24 0x7 0xfc;i2c mw 0x24 0x3 0xf5
     sf probe 0:0
     sf erase 0 +$filesize
     sf write a0000000 0 $filesize
     reset

8. 在信息端看到开机信息
 

    NOTICE:  DDR Init Done
NOTICE: BL2: v1.5(release):reboot-15448-g980dca6b7f
NOTICE: BL2: Built : 01:38:57, Jan 7 2021
NOTICE: BL31: v1.5(release):reboot-15448-g980dca6b7f
NOTICE: BL31: Built : 01:38:57, Jan 7 2021
NOTICE: Welcome to LS1012 BL31 Phase

U-Boot 2019.10 (Jan 07 2021 - 01:38:57 +0000)
SoC: LS1012AE Rev1.0 (0x87040010)
Clock Configuration:
CPU0(A53):1000 MHz
Bus: 250 MHz DDR: 1000 MT/s
Reset Configuration Word (RCW):
00000000: 0800000a 00000000 00000000 00000000
00000010: 35080000 c000000c 40000000 00001800
00000020: 00000000 00000000 00000000 00014571
00000030: 00000000 18c2a120 00000096 00000000
DRAM: 958 MiB
Using SERDES1 Protocol: 13576 (0x3508)
WARNING: Calling __hwconfig without a buffer and before environment is ready
MMC: FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from SPI Flash... SF: Detected s25fl512s with page size 256 Bytes, erase size 256 KiB, total 64 MiB
OK
In: serial
Out: serial
Err: serial
Model: LS1012A RDB Board
Board: LS1012ARDB Version: RevB, boot from QSPI: bank2
Net: PFE class pe firmware
PFE tmu pe firmware

Warning: pfe_eth0 (eth0) using random MAC address - ba:2f:1e:c3:0d:cf, eth0: pfe_eth0
Warning: pfe_eth1 (eth1) using random MAC address - ca:71:dd:5d:fc:15, eth1: pfe_eth1
Hit any key to stop autoboot: 0
starting openwrt ...


[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 5.4.86 (ubuntu@ubuntu) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r15448-980dca6b7f)) #0 SMP PREEMPT Thu Jan 7 01:38:57 2021
[ 0.000000] Machine model: LS1012A RDB Board
[ 0.000000] earlycon: uart8250 at MMIO 0x00000000021c0500 (options '')
[ 0.000000] printk: bootconsole [uart8250] enabled
[ 0.000000] cma: Reserved 16 MiB at 0x00000000bac00000
[ 0.000000] NUMA: No NUMA configuration found
[ 0.000000] NUMA: Faking a node at [mem 0x0000000080000000-0x00000000bbdfffff]
[ 0.000000] NUMA: NODE_DATA [mem 0xbbc09800-0xbbc0afff]
[ 0.000000] Zone ranges:
[ 0.000000] DMA32 [mem 0x0000000080000000-0


_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| N X P – L S 1 0 1 2 A R D B
-----------------------------------------------------
SAC LS1012ARDB, SACg
-----------------------------------------------------
=== 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:/#



9. 启动网站服务器
     /etc/init.d/uhttpd enable
     /etc/init.d/uhttpd start

10. 使用浏览器 登入 路由器
     
http://192.168.1.1


到此,OpenWrt的建构已完成。接下来,可以开始尝试利用OpenWrt实现更多智能应用,比如FTP、个人网站/服务器。



补充 LUCI 相关安装软件包:
uhttpd, liblua, libuci-lua, lua, luci-lib-core, luci-lib-ipkg, luci-lib-sys, luci-lib-nixio, luci-sgi-cgi, luci-lib-lmo,
luci-lib-web, luci-i18n-ennglish, luci-mod-admin-core, luci-mod-admin-full, luci-theme-base, luci-theme-openwrt,
luci-app-firewall, libiwinfo, luci-theme-openwrt.



►场景应用图

►展示板照片

►方案方块图

►核心技术优势

NXP LS1012A:  64-bit Arm® Cortex®-A53, Speed up to 1.0 GHz  One 16-bit DDR3L SDRAM memory controller, Up to 1.0 GT/s  High-speed peripheral interfaces: PCIe2.0 x1, SATA 3.0, USB3.0/2.0, Ethernet MACs(2.5G, 1G, 100M, 10M)  Additional peripheral interfaces: QSPI for series Flash, SPI controller , SDIO for eMMC/SD

►方案规格

 处理器(MPU): NXP LS1012A  网路接口 : 有线网路 RJ45 x2 (RGMII), 无线网路(SDIO WIFI module)  存储装置: SATA硬盘  作业系统: OpenWRT

技术文档

类型标题档案
硬件Schematics
硬件Layout