华为AR502H二次开发笔记

本文详细介绍了AR502H设备的调试步骤,包括IP地址配置、端口映射使用nftables进行设置,查看系统日志,串口配置以及编译环境的说明。同时,文章还涵盖了容器的相关操作,如安装、卸载LXC容器,管理LXC应用以及驱动的映射。
摘要由CSDN通过智能技术生成

AR502H设备调试

一、设备相关

1.IP配置

ip addr add  192.168.1.10/24 dev GE4 //配置GE4口的ip
ip addr show dev GE4 //查看GE4口ip
ip route add default via 192.168.1.1 dev GE4 //配置路由
route -n //查看路由
    
ip addr del 192.168.1.10/24 dev GE4 //删除ip

2. 端口映射

//查看总表
nft list tables
//查看某张表
nft list table dnat1
//创建表
nft add table dnat1
//添加端口映射 192.168.100.2为容器ip 192.168.1.10为GE4口ip
nft add chain ip dnat1 pre {  type nat hook prerouting priority " -110" \; }
nft add chain ip dnat1 post { type nat hook postrouting priority 90 \; }
nft add rule dnat1 pre ip daddr 192.168.1.10 tcp dport 8080 iif GE4 dnat 192.168.100.2:8080
nft add rule dnat1 post ip saddr 192.168.1.0 /24 oif "GE4" masquerade
    
//查看表的handle
nft list table dnat1 -a
//删除某条映射 4为对应的序号
nft delete rule ip dnat1 pre handle 4

3.查看日志

//查看实时log
journalctl -fa
//查看n行
journalctl -n 200

4.串口

  • RX1/TX1 为232接口1,RX2/TX2 为232接口2,可配置为485接口,对应的设备驱动文件为/dev/ttyRS1/dev/ttyRS2

    //配置1口为232 2口为485
    serialportctl RS232/RS485 1/2
    //配置串口1为232
    serialportctl -m RS232 -p 1
    //配置窗口二为485
    serialportctl -m RS485 -p 2
        
    //查看串口1配置,可在容器中操作
    stty -F /dev/ttyRS1 
    //配置串口波特率等信息
    stty -F /dev/ttyRS1 speed 9600 cs8 -parenb -cstopb
    
  • 测试串口

    //连接窗口助手,串口1输出hello
    echo "hello" > /dev/ttyRS1
    

5. 编译环境

  • 交叉编辑工具 aarch64-linux-gnu-gcc

二、容器相关

1. 容器操作

//容器安装
container install lxc test.ova disk 50 memory 100
container install lxc test.ova
//卸载容器
container uninstall lxc
//停止容器运行
container stop lxc
//启动容器
container start lxc
//查看容器
container status
//查看容器日志
journalctl CONTAINER_NAME=lxc

2.驱动

映射串口设备

container add-dev lxc01(容器名称)

3. lxc应用操作

//安装lxc应用包lxc为容器名称
appm -i -C lxc -f /mnt/internal_storage/wgapp.ova
//R21版本
appm -i -c lxc -f /mnt/internal_storage/wgapp.ova  
//卸载lxc容器
appm -u -c lxc -n wgapp.ova
//查看lxc包
appm -I -c lxc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值