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