OpenWRT系统为嵌入式设备的Linux作业系统,并且拥有庞大的软件包管理功能。它提供了一个完全可写的文件系统,可让伙伴们从应用程序的供应商所提供的清单来配置。并允许使用者来自定义的设备,以适任任何应用程序。对于即将进行开发的伙伴们而言,OpenWRT系统能快速建构应用程序的框架,而无需重新建立该应用程序完整的固件。这也意味着可以进行完全自行定制的能力。
接下来,为伙伴们提供 基于Nuvoton MA35D1 IoT平台上,建构 OpenWRT 的方法,并搭载UVC Camera 来实现 IP CAM 监控的基本应用。
A. 硬件环境 : NuMaker-IoT-MA35D1EVB
NuMaker-IoT-MA35D1
主要核心MA35D1 规格如下:
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 的设备来架设
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 环境
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. 配置并导入预设的内核设定文档
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. 编译完成后,执行烧录,值得注意的是需离开 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. 执行到此,伙伴们已经可以看到开机的讯息了对吧?
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)
…
…
接下来为了顺利执行摄相头的应用,需额外增设内核的配置,小弟为大家整理出来所需要的清单如下。
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 得知网关的位址为 192.168.0.175时,我们可以在熟悉的浏览器上键入 IP 位置,来登入软路由的管理页面。
如下图所示,能得知 Nuvoton MA35D1-IoT的系统信息。
C. 再来为伙伴们演示如何透过软路由的camera 来实现 IP CAM的应用。
1. 配置摄像头输入的资料所期望的分办率和侦数,也可同时配置输出串口,本次演练是使用预设的串口 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:/#
此时我们已经可以在同一网域下,使用行动装置或是电脑的浏览器来透过网关的IP地址监看串流的影像。
伙伴们一定很好奇,可以远端查看监控画面,是否能将摄像头画面录制下来呢?小弟再多新增一个方法让来录影
接上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"
本次的演练就到此,有兴趣的伙伴们,可以一起来探讨和研究,谢谢。
►场景应用图
►产品实体图
►展示板照片
►方案方块图
►核心技术优势
MA35D1 特色:
1. 核心为 A35与M4的集成,各司其职;
2. 独立的加密岛,系统更加安全;
3. 两种封装(LQFP与BGA),依照不同应用,多种选择;
4. 内涵记忆体(128MB/256MB/512MB),不须外挂,简化设计;
5. 界面丰富,应用多样;
►方案规格
处理器(MPU): NUVOTON MA35D1;
网路接口 : 有线网路 RJ45 x2 (RGMII), 无线网路(SDIO WIFI module);
相机规格: 720P @ 30;
作业系统: OpenWRT。
-
嵌入式
+关注
关注
5082文章
19126浏览量
305289 -
系统
+关注
关注
1文章
1017浏览量
21347 -
MA35D1
+关注
关注
0文章
5浏览量
180
发布评论请先 登录
相关推荐
评论