OpenWRT系統(tǒng)為嵌入式設(shè)備的Linux作業(yè)系統(tǒng),并且擁有龐大的軟件包管理功能。它提供了一個完全可寫的文件系統(tǒng),可讓伙伴們從應(yīng)用程序的供應(yīng)商所提供的清單來配置。并允許使用者來自定義的設(shè)備,以適任任何應(yīng)用程序。對于即將進行開發(fā)的伙伴們而言,OpenWRT系統(tǒng)能快速建構(gòu)應(yīng)用程序的框架,而無需重新建立該應(yīng)用程序完整的固件。這也意味著可以進行完全自行定制的能力。
接下來,為伙伴們提供 基于Nuvoton MA35D1 IoT平臺上,建構(gòu) OpenWRT 的方法,并搭載UVC Camera 來實現(xiàn) IP CAM 監(jiān)控的基本應(yīng)用。
A. 硬件環(huán)境 : NuMaker-IoT-MA35D1EVB
NuMaker-IoT-MA35D1
主要核心MA35D1 規(guī)格如下:
MA35D16F987C with DDR3L (128 MB)
# Dual Cortex-A35 core running up to 800 MHz
# Cortex-M4 processor core running up to 180 MHz
# Real-Time Clock (RTC)
# Ethernet Poart : RGMII x1 and RMIIx1
# USB2.0: Host x1 and OTG x1
# QSPI : QSPI FLASH
# NAND: NAND Flash
B. 軟體建置, 建議使用 Ubuntu 20.04-LTS 的設(shè)備來架設(shè)
1. 安裝 Docker
sudo apt-get update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
sudo apt install build-essential ccache ecj fastjar file g++ gawk gettext git java-propose-classpath libelf-dev libncurses5-dev libncursesw5-dev libssl-dev python python2.7-dev python3 unzip wget python-distutils-extra python3-setuptools python3-dev rsync subversion swig time xsltproc zlib1g-dev libssl-dev device-tree-compiler
pip3 install pycryptodomex pyelftools pyusb usb crypto ecdsa crcmod tqdm pycryptodome
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
git clone https://github.com/OpenNuvoton/MA35D1_Docker_Script.git
./build.sh
./join.sh
2. 新增并更換目錄
mkdir shared/openwrt
cd shared/openwrt
3. 配置git 環(huán)境
git config –global user.email
sac_test@sacsys.com.tw
git config –global user.name ‘sac_test”
4. 下載 NUVOTON Openwrt 源代碼
sac@90440e70ea26:~/shared/openwrt$ git clone https://github.com/OpenNuvoton/MA35D1_OpenWrt.git
Cloning into 'MA35D1_OpenWrt'...
remote: Enumerating objects: 532695, done.
remote: Counting objects: 100% (61/61), done.
remote: Compressing objects: 100% (39/39), done.
remote: Total 532695 (delta 13), reused 44 (delta 9), pack-reused 532634
Receiving objects: 100% (532695/532695), 196.76 MiB | 1.19 MiB/s, done.
Resolving deltas: 100% (358529/358529), done.
Updating files: 100% (8566/8566), done.
sac@90440e70ea26:~/shared/openwrt$
5. 更新和安裝 OpenWRT原代碼
sac@312bc2ae8ba4:~/shared/openwrt/MA35D1_OpenWrt$ ./scripts/feeds update -a
Updating feed 'packages' from 'https://git.openwrt.org/feed/packages.git^78bcd00c13587571b5c79ed2fc3363aa674aaef7' ...
Create index file './feeds/packages.index'
Checking 'working-make'... ok.
Checking 'case-sensitive-fs'... ok.
Checking 'proper-umask'... ok.
Checking 'gcc'... ok.
Checking 'working-gcc'... ok.
Checking 'g++'... ok.
Checking 'working-g++'... ok.
Checking 'ncurses'... ok.
Checking 'perl-data-dumper'... ok.
Checking 'perl-findbin'... ok.
Checking 'perl-file-copy'... ok.
Checking 'perl-file-compare'... ok.
Checking 'perl-thread-queue'... ok.
sac@312bc2ae8ba4:~/shared/openwrt/MA35D1_OpenWrt$ ./scripts/feeds install -a
Installing package 'freeswitch-mod-bcg729' from telephony
Installing package 'freetdm' from telephony
Installing package 'kamailio' from telephony
Installing package 'libosip2' from telephony
Installing package 'miax' from telephony
Installing package 'pcapsipdump' from telephony
Installing package 'restund' from telephony
Installing package 'rtpengine' from telephony
Installing package 'rtpproxy' from telephony
Installing package 'sipgrep' from telephony
Installing package 'sipp' from telephony
Installing package 'siproxd' from telephony
Installing package 'sngrep' from telephony
Installing package 'yate' from telephony
sac@312bc2ae8ba4:~/shared/openwrt/MA35D1_OpenWrt$
6. 配置并導(dǎo)入預(yù)設(shè)的內(nèi)核設(shè)定文檔
sac@312bc2ae8ba4:~/shared/openwrt/MA35D1_OpenWrt$ make menuconfig
Collecting package info: done
configuration written to .config
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
sac@312bc2ae8ba4:~/shared/openwrt/MA35D1_OpenWrt$
sac@312bc2ae8ba4:~/shared/openwrt/MA35D1_OpenWrt$ make kernel_menuconfig
"Image/Build" squashfs
"Image/Build" ext4
time: target/linux/prereq#0.33#0.25#0.52
make[1] toolchain/install
make[2] tools/compile
make[3] -C tools/flock compile
make[3] -C tools/xz compile
make[3] -C tools/sed compile
make[3] -C tools/tar compile
make[3] -C tools/patch compile
make[3] -C tools/m4 compile
7. 配置完成開始編譯sac@312bc2ae8ba4:~/shared/openwrt/MA35D1_OpenWrt$ make
8. 編譯完成后,執(zhí)行燒錄,值得注意的是需離開 Docker 后才能正確的燒錄成功
user@ubuntu:~/MA35D1/MA35D1_NuWriter$ lsusb
Bus 001 Device 008: ID 0416:5963 Winbond Electronics Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 004: ID 0e0f:0008 VMware, Inc. VMware Virtual USB Mouse
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
user@ubuntu:~/MA35D1/MA35D1_NuWriter$ sudo python3 ./nuwriter.py -a ./ddrimg/enc_ddr3_winbond_512mb.bin
Successfully attached 1 device(s)
==== NAND ====
Page per block: 64
Page size: 2048
Block per flash: 4096
Bad block count: 0
Spare size: 64
Is uer config: 0
==== SPI NOR ====
ID: 0
Is uer config: 0
Quad read cmd: 0
Read sts cmd: 0
Write sts cmd: 0
Sts value: 0
Dummy byte: 0
==== eMMC ====
Block: 0
Reserved: 0
==== SPI NAND ====
Is uer config: 0
ID: 15710755
Page size: 2048
Spare size: 64
Quad read cmd: 107
Read sts cmd: 5
Write sts cmd: 1
Sts value: 2
Dummy byte: 1
Block per flash: 4096
Page per block: 64
Successfully get info from 1 device(s)
user@ubuntu:~/MA35D1/MA35D1_NuWriter$ sudo python3 ./nuwriter.py -e nand all
100%|##########
Successfully erased 1 device(s)
user@ubuntu:~/MA35D1/MA35D1_NuWriter$ sudo python3
python3 python3.8 python3.8-config python3-config
user@ubuntu:~/MA35D1/MA35D1_NuWriter$ sudo python3 ./nuwriter.py -w nand ../MA35D1_
MA35D1_Docker_Script/ MA35D1_NuWriter/
user@ubuntu:~/MA35D1/MA35D1_NuWriter$ sudo python3 ./nuwriter.py -w nand ../MA35D1_
MA35D1_Docker_Script/ MA35D1_NuWriter/
user@ubuntu:~/MA35D1/MA35D1_NuWriter$ sudo python3 ./nuwriter.py -w nand /home/user/openwrt/MA35D1_OpenWrt/bin/targets/ma35d1/iot/openwrt-ma35d1-iot-iot-
openwrt-ma35d1-iot-iot-128m-header-nand.bin
openwrt-ma35d1-iot-iot-128m.manifest
openwrt-ma35d1-iot-iot-128m-pack-nand.bin
openwrt-ma35d1-iot-iot-128m-rootfs.tar.gz
openwrt-ma35d1-iot-iot-128m-squashfs-firmware.bin
openwrt-ma35d1-iot-iot-128m-squashfs-sysupgrade.bin
openwrt-ma35d1-iot-iot-128m-uImage
openwrt-ma35d1-iot-iot-512m-header-nand.bin
openwrt-ma35d1-iot-iot-512m.manifest
openwrt-ma35d1-iot-iot-512m-pack-nand.bin
openwrt-ma35d1-iot-iot-512m-rootfs.tar.gz
openwrt-ma35d1-iot-iot-512m-squashfs-firmware.bin
openwrt-ma35d1-iot-iot-512m-squashfs-sysupgrade.bin
openwrt-ma35d1-iot-iot-512m-uImage
user@ubuntu:~/MA35D1/MA35D1_NuWriter$ sudo python3 ./nuwriter.py -w nand /home/user/openwrt/MA35D1_OpenWrt/bin/targets/ma35d1/iot/openwrt-ma35d1-iot-iot-512m-pack-nand.bin
Waiting for unpack Images ...
check pack file crc32 ...
Programming 1/7: 100%|########## Programming 2/7: 100%|########## Programming 3/7: 100%|########## Programming 4/7: 100%|########## Programming 5/7: 100%|########## Programming 6/7: 100%|########## Programming 7/7: 100%|########## Successfully programmed 1 device(s)
9. 執(zhí)行到此,伙伴們已經(jīng)可以看到開機的訊息了對吧?
INFO: ma35d1 config setup
INFO: 1.25V
WARNING: CA-PLL is 800000000 Hz without PSCI setting.
POR: 0x900
INFO: Boot from NAND
INFO: NAND: Size 1024MB, Page 2048, pages per block 64, oob size 64, bit correct 8
NOTICE: BL2: v2.3(release):OpenWrt v2.3-3 (ma35d1-cpu800-wb-512m)
…
…
接下來為了順利執(zhí)行攝相頭的應(yīng)用,需額外增設(shè)內(nèi)核的配置,小弟為大家整理出來所需要的清單如下。
CONFIG_PACKAGE_librt=y
CONFIG_PACKAGE_libstdcpp=y
CONFIG_PACKAGE_kmod-input-core=y
CONFIG_PACKAGE_kmod-nls-base=y
CONFIG_PACKAGE_kmod-dma-buf=y
CONFIG_PACKAGE_kmod-usb-core=y
CONFIG_PACKAGE_kmod-usb-ehci=y
CONFIG_PACKAGE_kmod-usb2=y
CONFIG_PACKAGE_kmod-video-core=y
CONFIG_PACKAGE_kmod-video-cpia2=y
CONFIG_PACKAGE_kmod-video-gspca-core=y
CONFIG_PACKAGE_kmod-video-pwc=y
CONFIG_PACKAGE_kmod-video-uvc=y
CONFIG_PACKAGE_kmod-video-videobuf2=y
CONFIG_PACKAGE_libjpeg-turbo=y
CONFIG_PACKAGE_libprotobuf-c=y
CONFIG_PACKAGE_libuuid=y
CONFIG_PACKAGE_libv4l=y
CONFIG_PACKAGE_libzmq-nc=y
CONFIG_PACKAGE_mjpg-streamer=y
CONFIG_MJPG_STREAMER_V4L2=y
CONFIG_PACKAGE_mjpg-streamer-input-file=y
CONFIG_PACKAGE_mjpg-streamer-input-http=y
CONFIG_PACKAGE_mjpg-streamer-input-uvc=y
CONFIG_PACKAGE_mjpg-streamer-output-file=y
CONFIG_PACKAGE_mjpg-streamer-output-http=y
CONFIG_PACKAGE_mjpg-streamer-output-rtsp=y
CONFIG_PACKAGE_mjpg-streamer-output-zmq=y
CONFIG_PACKAGE_mjpg-streamer-www-simple=y
接下來為伙伴們演示 OpenWRT軟路由的基本頁面,在使用 ifconfig -a 得知網(wǎng)關(guān)的位址為 192.168.0.175時,我們可以在熟悉的瀏覽器上鍵入 IP 位置,來登入軟路由的管理頁面。
如下圖所示,能得知 Nuvoton MA35D1-IoT的系統(tǒng)信息。
C. 再來為伙伴們演示如何透過軟路由的camera 來實現(xiàn) IP CAM的應(yīng)用。
1. 配置攝像頭輸入的資料所期望的分辦率和偵數(shù),也可同時配置輸出串口,本次演練是使用預(yù)設(shè)的串口 8080,并搭配方便又容易取得的 USB攝像頭。
root@OpenWrt:/# mjpg_streamer -i "input_uvc.so -r HD -f 30 -d /dev/video0" -o "output_http.so"
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 1280 x 720
i: Frames Per Second.: 30
i: Format............: JPEG
i: TV-Norm...........: DEFAULT
root@OpenWrt:/#
root@OpenWrt:/# /etc/init.d/mjpg-streamer enable
root@OpenWrt:/# /etc/init.d/mjpg-streamer start
root@OpenWrt:/#
此時我們已經(jīng)可以在同一網(wǎng)域下,使用行動裝置或是電腦的瀏覽器來透過網(wǎng)關(guān)的IP地址監(jiān)看串流的影像。
伙伴們一定很好奇,可以遠端查看監(jiān)控畫面,是否能將攝像頭畫面錄制下來呢?小弟再多新增一個方法讓來錄影
接上SD card
umount /dev/sda1
e2fsck /dev/sda1
mount /dev/sda1 /mnt
mjpg_streamer -i "input_uvc.so -d /dev/video0 " -o "output_http.so -p 8080 -o" -o "output_file12h.so -f /mnt -d 1000"
本次的演練就到此,有興趣的伙伴們,可以一起來探討和研究,謝謝。
?場景應(yīng)用圖
?產(chǎn)品實體圖
?展示板照片
?方案方塊圖
?核心技術(shù)優(yōu)勢
MA35D1 特色:
1. 核心為 A35與M4的集成,各司其職;
2. 獨立的加密島,系統(tǒng)更加安全;
3. 兩種封裝(LQFP與BGA),依照不同應(yīng)用,多種選擇;
4. 內(nèi)涵記憶體(128MB/256MB/512MB),不須外掛,簡化設(shè)計;
5. 界面豐富,應(yīng)用多樣;
?方案規(guī)格
處理器(MPU): NUVOTON MA35D1;
網(wǎng)路接口 : 有線網(wǎng)路 RJ45 x2 (RGMII), 無線網(wǎng)路(SDIO WIFI module);
相機規(guī)格: 720P @ 30;
作業(yè)系統(tǒng): OpenWRT。
-
嵌入式
+關(guān)注
關(guān)注
5082文章
19123瀏覽量
305143 -
系統(tǒng)
+關(guān)注
關(guān)注
1文章
1017瀏覽量
21339 -
MA35D1
+關(guān)注
關(guān)注
0文章
5瀏覽量
174
發(fā)布評論請先 登錄
相關(guān)推薦
評論