盈鹏飞嵌入式T113-S4主板_Tina5.0通过Luci配置系统

SBC-T113S产品特性:

  • 采用Allwinner公司Cortex-A7双核T113-S3/S4处理器,运行最高速度为1.2GHZ;
  • 内置64-bit XuanTie C906 RISC-V协处理器(仅T113-S4支持);
  • 支持JPEG/MJPEG视频编码,最大分辨率1080p@60fps;支持多格式1080P@60fps视频解码 (H.265,H.264, MPEG-1/2/4);
  • 支持RGB666/LVDS/MIPI-DSI,分辨率最高1920x1080;
  • 支持128-256M Bytes DDR3 SDRAM,其中T113-S3内置128MB;T113-S4内置256MB;
  • 支持SPI NAND存储和启动(默认:256MB)或者EMMC启动(默认:4GB,最大32GB);
  • 支持一路USB2.0 OTG(设计为TYPE-A接口);支持二路USB2.0 HOST;
  • 支持七路RS232通信或者6路RS232和1路RS485(非隔离);
  • 支持一路CAN BUS通信(非隔离);
  • 支持一路10/100M以太网;
  • 稳定的操作系统的支持,可预装LINUX 5.4(Preempt)或者OpenWRT;
  • 经典尺寸主板,尺寸为120*100MM;

SBC-T113S产品功能评估图:

要想实现Tina5.0进行Luci系统配置,必须满足三个条件:

  1. Tina5.0的固件要定制为procd启动的固件,定制为busybox启动的固件是不行的。2)能够实现一个DHCP服务器,这个服务器可以分配给连接主板的计算机分配IP。在Tina5.0中,这个服务是dnsmasq;3)要实现http服务,这个服务器有很多,比如uhttpd,boa,Nginx等,默认Tina中默认使用的是uhttpd。相关资料也较多,容易配置。4,Luci组件。

1,如何定制固件为procd启动的固件

Tina系统定制手册中已经有了说明,见下图:

这个部分全志官方写的比较明确,不再赘述。

2,如何启用dnsmasq服务

什么是dnsmasq? dnsmasq是openwrt一个重要的进程,里面提供了两个重要的功能。一个是dhcp server,给lan口使用的,另一个是dns功能,维护路由器的dns信息,而且支持ipv4和ipv6,SBC-T113主板目的是为了方便主板的相关参数配置,所以只需要它作为DHCP服务器即可。

在tina中执行make menuconfig进行配置,进入Base System菜单找到dnsmasq进行配置

(我们目前选择的是dnsmasq-full)

配置完成后,该服务还不能正常运行,还需要进行启动参数的配置:

  • 根据/etc/config/dhcp生成/var/etc/dnsmasq.conf.cfg01411c配置文件。也可以同时在 /etc/dnsmasq.conf 文件里配置,一般在/etc/dnsmasq.conf配置DHCP服务。
  • 通过/etc/rc.d/S19dnsmasq进行启动 
/sbin/ujail -t 5 -n dnsmasq -u -l -r /bin/ubus -r /etc/TZ -r /etc/dnsmasq.conf -r /etc/ethers -r /etc/group -r /etc/hosts -r /etc/passwd -w /tmp/dhcp.leases -r /tmp/dnsmasq.d -r /tmp/hosts -r /tmp/resolv.conf.d -r /usr/bin/jshn -r /us
  /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01411c.pid

/etc/config/dhcp中关于dnsmasq配置如下:

config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option nonwildcard '1'
        option localservice '1'
        option ednspacket_max '1232'

生成的配置文件:

# auto-generated config file from /etc/config/dhcp
conf-file=/etc/dnsmasq.conf
dhcp-authoritative
domain-needed
localise-queries
read-ethers
enable-ubus=dnsmasq
expand-hosts
bind-dynamic
local-service
edns-packet-max=1232
domain=lan
local=/lan/
addn-hosts=/tmp/hosts
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/tmp/resolv.conf.d/resolv.conf.auto
stop-dns-rebind
rebind-localhost-ok
dhcp-broadcast=tag:needs-broadcast
conf-dir=/tmp/dnsmasq.d
user=dnsmasq
group=dnsmasq

dhcp-ignore-names=tag:dhcp_bogus_hostname
conf-file=/usr/share/dnsmasq/dhcpbogushostname.conf
bogus-priv
conf-file=/usr/share/dnsmasq/rfc6761.conf
dhcp-range=set:lan,192.168.1.100,192.168.1.249,255.255.255.0,12h

其他的DNS相关配置还包括:/etc/hosts和/etc/ethers。

通过什么办法判断dnsmasq是否正常工作呢?

通过tmp目录下.lastlog文件,该文件记录了系统中每个组件的运行状态。如果发现dnsmasq未启动,可以查看该记录文件查看问题所在。

我们需要知道dnsmasq一定是基于一个网络接口才能运行的。这个配置在/etc/dnsmasq.conf中,配置文件如下:

interface=eth0
listen-address=192.168.31.1
dhcp-range=192.168.31.2,192.168.31.255
dhcp-option=3,192.168.31.1
dhcp-option=6,192.168.31.1
dhcp-option=42,192.168.31.1

我们可以看到绑定了dnsmasq服务的网络接口是eth0,listen-address是dhcp服务监听的网络地址192.168.31.1,这个地址要记住,后续在其他配置文件中会用到。另外dhcp-range是192.168.31.2到192.168.31.255,也就是意味着如果一个主机连接到该网络接口后,被分配的第一个IP是192.168.31.2;

另外,如果要启动dnsmasq服务,那么网络接口是一定要正常工作的,网络接口的配置文件/etc/config/network:

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd20:3738:915a::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.31.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config interface 'wan'
        option device 'eth1'
        option proto 'dhcp'

config interface 'wan6'
        option device 'eth1'
        option proto 'dhcpv6'

我们可以看到eth0配置了一个固定的ip地址,这个地址是192.168.31.1。和/etc/dnsmasq.conf配置文件中listen-address地址是一致的。

3,Uhttpd服务的介绍和配置

uhttpd是一个功能全面、轻量级的Web服务器,是Web管理界面LuCI的默认服务器,支持SSL、CGI、Lua。

uhttpd是单线程,但支持多个实例。

3.1 配置uhttpd

在tina的sdk中执行make menuconfig进行uhttpd配置如下:

Network
    Web Servers/Proxies
        uhttpd
        uhttpd-mod-lua--Lua插件为uHTTPd提供了一个类似于 CGI  Lua 运行时接口,使得开发者可以在处理 HTTP 请求时执行 Lua 脚本。这种集成方式允许开发者利用 Lua 的灵活性和强大功能来增强 Web 应用程序的能力,同时保持了与现有 CGI 程序类似的使用模式。
        uhttpd-mod-ubus--提供ubus插件的功能。为 ubus 提供了一个基于 HTTP 协议和 JSON 格式的远程过程调用(RPC)代理。这意味着用户可以通过发送 HTTP 请求,并使用 JSON 格式编码数据,来远程调用 ubus 上的服务和函数。
       LuCI
    3. Application
        luci-app-uhttpd
Libraries
    Networking
      libuhttpd-openssl

3.2 uhttpd主要功能

uHTTPd 是 OpenWrt 项目中使用的轻量级 Web 服务器,专为嵌入式系统设计。以下是 uHTTPd 支持的一些关键功能:

  1. HTTP 和 HTTPS 服务:uHTTPd 可以提供标准的 HTTP 服务,并且通过配置支持 HTTPS(HTTP over TLS/SSL),以确保数据传输的安全性。
  2. CGI 脚本支持:uHTTPd 支持 CGI(Common Gateway Interface)脚本,允许执行外部程序或脚本,并返回其输出给客户端。
  3. Lua 脚本支持:uHTTPd 内置了对 Lua 脚本语言的支持,可以在服务器上执行 Lua 脚本来生成动态内容。
  4. 模板处理:uHTTPd 支持使用模板来生成 Web 页面,这在动态内容生成中非常有用。
  5. ubus 集成:uHTTPd 可以与 OpenWrt 的 ubus 消息总线系统集成,允许通过 Web 接口与系统服务进行交互。
  6. JSON-RPC 支持:uHTTPd 支持 JSON-RPC 协议,允许通过 JSON 格式进行远程过程调用。
  7. 多实例运行:uHTTPd 可以运行多个实例,每个实例可以监听不同的端口,拥有独立的配置和文档根目录。
  8. 配置文件:uHTTPd 使用配置文件(通常是/etc/httpd.conf)来定义服务器的行为,包括端口、根目录、日志记录等。
  9. 访问控制:uHTTPd 支持基本的访问控制,例如基于 IP 的访问限制。
  10. 目录列表:uHTTPd 可以自动为包含多个文件的目录生成目录列表。
  11. 日志记录:uHTTPd 支持日志记录功能,可以记录访问和错误信息。
  12. 静态内容服务:uHTTPd 可以高效地提供静态内容,如 HTML、CSS、JavaScript 文件和图片。
  13. 自定义错误页面:uHTTPd 允许定义自定义的 404(未找到)和其他 HTTP 错误页面。
  14. URL 重写:uHTTPd 支持 URL 重写规则,可以基于配置重定向请求。
  15. 文件上传:uHTTPd 支持通过 CGI 脚本进行文件上传。
  16. 代理服务器:uHTTPd 可以配置为代理服务器,转发请求到其他服务器。
  17. IPv4 和 IPv6 支持:uHTTPd 支持 IPv4 和 IPv6 协议,可以同时服务于两种类型的网络请求。

3.3 uhttpd相关概念

Lua:Lua 是 OpenWrt 中广泛使用的一种轻量级脚本语言,它以其简洁和高效而闻名,非常适合用于配置和扩展 OpenWrt 系统的功能。

ubus:OpenWrt 的 UBUS(OpenWrt RPC API Server)是一个远程过程调用(RPC)API服务器,它提供了一种机制,允许用户通过各种协议(如HTTP、WebSocket等)与OpenWrt系统进行交互。

openssl:是一个广泛使用的开源加密库,提供了全面的加密功能,包括SSL/TLS协议、证书管理、各种加密算法等。OpenSSL支持多种平台,广泛应用于服务器、桌面和移动设备。

  • 支持:OpenSSL拥有一个成熟的社区和广泛的支持,而mbedTLS和wolfSSL虽然社区较小,但也在增长中,并提供了专业的技术支持。

3.4 uhttpd启动

执行/etc/init.d/S50uhttpd中脚本,启动uhttpd:
/usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -l /cgi-bin/luci -L /usr/lib/lua/luci/sgi/uhttpd.lua -

uhttpd选项如下:

Usage: uhttpd -p [addr:]port -h docroot
    -f              Do not fork to background
    -c file         Configuration file, default is '/etc/httpd.conf'
    -p [addr:]port  Bind to specified address and port, multiple allowed
    -s [addr:]port  Like -p but provide HTTPS on this port
    -C file         ASN.1 server certificate file
    -K file         ASN.1 server private key file
    -P ciphers      Colon separated list of allowed TLS ciphers
    -q              Redirect all HTTP requests to HTTPS
    -h directory    Specify the document root, default is '.'
    -E string       Use given virtual URL as 404 error handler
    -b string       Use given charset for directory listings, default to UTF-8
    -I string       Use given filename as index for directories, multiple allowed
    -S              Do not follow symbolic links outside of the docroot
    -D              Do not allow directory listings, send 403 instead
    -R              Enable RFC1918 filter
    -n count        Maximum allowed number of concurrent script requests
    -N count        Maximum allowed number of concurrent connections
    -l string       URL prefix for Lua handler
    -L file         Path to Lua handler script, -l and -L may be repeated in pairs
    -o string       URL prefix for ucode handler
    -O file         Path to ucode handler script, -o and -O may be repeated in pairs
    -u string       URL prefix for UBUS via JSON-RPC handler
    -U file         Override ubus socket path
    -a              Do not authenticate JSON-RPC requests against UBUS session api
    -X        Enable CORS HTTP headers on JSON-RPC api
    -e        Events subscription reconnection time (retry value)
    -x string       URL prefix for CGI handler, default is '/cgi-bin'
    -y alias[=path]    URL alias handle
    -i .ext=path    Use interpreter at path for files with the given extension
    -t seconds      CGI, Lua and UBUS script timeout in seconds, default is 60
    -T seconds      Network timeout in seconds, default is 30
    -k seconds      HTTP keepalive timeout
    -A seconds      TCP keepalive timeout, default is unset
    -d string       URL decode given string
    -r string       Specify basic auth realm
    -m string       MD5 crypt given string

4增加Luci

默认的Tina是没有Luci的,就是个非常纯净的系统,如果需要的话,自己还得增加一下:使用常规Luci安装命令即可:

./scripts/feeds update -a
./scripts/feeds install –a

执行完毕后,还需要进行组件的选择,在Tina SDK根目录下执行make

menuconfig:

具体如何选择请参考相关Luci的说明。

5,SBC-T113主板Luci配置界面的登录及初步配置

  • 12
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值