20250609在荣品的PRO-RK3566开发板的Android13下解决串口可以执行命令但是脚本执行命令异常的问题
2025/6/9 20:54
缘起,为了跨网段推流,千辛万苦配置好了网络参数。
但是命令iptables -t filter -F tetherctrl_FORWARD可以在调试串口/DEBUG口正确执行。
一添加到自启动脚本中就出现各种异常!
/vendor/bin/autostart_test.sh
网络配置如下:
RK3566配置路由使D能PING通A
A:192.169.144.119
B:192.168.144.55
C:192.168.43.1
D:192.168.43.33
设备A和B是图传,在同一个网段,可以互相PING通。
【B和C】都接在RK3566【Android13】上。
C通过AP6256虚拟成为softAP。
D为笔记本电脑,通过softAP/以太网络共享接到C上。
现在,想让D来PING通A,改如何配置RK3566的路由表?
A的网关配置为B,D的网关配置为C。softAP通了。
但是以太网不通。
经过专家诊断:
需要执行:
iptables -t filter -F tetherctrl_FORWARD
至于执行:iptables -t filter -F tetherctrl_FORWARD的效果,
通过命令 iptables -t filter -L 可以查询到,
清除了网络规则:tetherctrl_FORWARD
经过艰难调试,后来怀疑是在shell脚本中需要使用完整的路径。
【偶然的原因,在init.rc中,发现别人都是使用完整的路径的^_】
搞定/办结问题!
【autostart_test.sh】
#!/vendor/bin/sh
echo "Forlinx::::::::::::::::::GNSS_CONFIG start!" > /dev/ttyFIQ0
echo "This is a test" > /dev/ttyFIQ0
echo $(date) > /data/date.txt
echo "Forlinx::::::::::::::::::GNSS_CONFIG end!" > /dev/ttyFIQ0
#/system/bin/rk3566_android_serial
sleep 180
/system/bin/iptables -t filter -F tetherctrl_FORWARD
/system/bin/uart2tcp


完整的LOG:
执行前:
Microsoft Windows [版本 10.0.19045.5737]
(c) Microsoft Corporation。保留所有权利。
C:\Users\QQ>adb shell
rk3566_t:/ $ su
rk3566_t:/ #
rk3566_t:/ # iptables -t filter -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
bw_INPUT all -- anywhere anywhere
fw_INPUT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
oem_fwd all -- anywhere anywhere
fw_FORWARD all -- anywhere anywhere
bw_FORWARD all -- anywhere anywhere
tetherctrl_FORWARD all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
oem_out all -- anywhere anywhere
fw_OUTPUT all -- anywhere anywhere
st_OUTPUT all -- anywhere anywhere
bw_OUTPUT all -- anywhere anywhere
Chain bw_FORWARD (1 references)
target prot opt source destination
Chain bw_INPUT (1 references)
target prot opt source destination
bw_global_alert all -- anywhere anywhere
RETURN esp -- anywhere anywhere
RETURN all -- anywhere anywhere mark match 0x100000/0x100000
MARK all -- anywhere anywhere MARK or 0x100000
Chain bw_OUTPUT (1 references)
target prot opt source destination
bw_global_alert all -- anywhere anywhere
Chain bw_costly_shared (0 references)
target prot opt source destination
bw_penalty_box all -- anywhere anywhere
Chain bw_data_saver (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain bw_global_alert (2 references)
target prot opt source destination
all -- anywhere anywhere ! quota globalAlert: 2097152 bytes
Chain bw_happy_box (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere match bpf pinned /sys/fs/bpf/netd_shared/prog_netd_skfilter_allowlist_xtbpf
bw_data_saver all -- anywhere anywhere
Chain bw_penalty_box (1 references)
target prot opt source destination
REJECT all -- anywhere anywhere match bpf pinned /sys/fs/bpf/netd_shared/prog_netd_skfilter_denylist_xtbpf reject-with icmp-port-unreachable
bw_happy_box all -- anywhere anywhere
Chain fw_FORWARD (1 references)
target prot opt source destination
Chain fw_INPUT (1 references)
target prot opt source destination
Chain fw_OUTPUT (1 references)
target prot opt source destination
Chain oem_fwd (1 references)
target prot opt source destination
Chain oem_out (1 references)
target prot opt source destination
Chain st_OUTPUT (1 references)
target prot opt source destination
Chain st_clear_caught (2 references)
target prot opt source destination
Chain st_clear_detect (0 references)
target prot opt source destination
REJECT all -- anywhere anywhere connmark match 0x2000000/0x2000000 reject-with icmp-port-unreachable
RETURN all -- anywhere anywhere connmark match 0x1000000/0x1000000
CONNMARK tcp -- anywhere anywhere u32 "0x0>>0x16&0x3c@0xc>>0x1a&0x3c@0x0&0xffff0000=0x16030000&&0x0>>0x16&0x3c@0xc>>0x1a&0x3c@0x4&0xff0000=0x10000" CONNMARK or 0x1000000
CONNMARK udp -- anywhere anywhere u32 "0x0>>0x16&0x3c@0x8&0xffff0000=0x16fe0000&&0x0>>0x16&0x3c@0x14&0xff0000=0x10000" CONNMARK or 0x1000000
RETURN all -- anywhere anywhere connmark match 0x1000000/0x1000000
st_clear_caught tcp -- anywhere anywhere state ESTABLISHED u32 "0x0>>0x16&0x3c@0xc>>0x1a&0x3c@0x0&0x0=0x0"
st_clear_caught udp -- anywhere anywhere
Chain st_penalty_log (0 references)
target prot opt source destination
CONNMARK all -- anywhere anywhere CONNMARK or 0x1000000
NFLOG all -- anywhere anywhere
Chain st_penalty_reject (0 references)
target prot opt source destination
CONNMARK all -- anywhere anywhere CONNMARK or 0x2000000
NFLOG all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain tetherctrl_FORWARD (1 references)
target prot opt source destination
DROP all -- anywhere anywhere
Chain tetherctrl_counters (0 references)
target prot opt source destination
rk3566_t:/ # iptables -t filter -L

执行后:
Microsoft Windows [版本 10.0.19045.5737]
(c) Microsoft Corporation。保留所有权利。
C:\Users\QQ>adb shell
rk3566_t:/ $ su
rk3566_t:/ #
rk3566_t:/ # iptables -t filter -F tetherctrl_FORWARD
rk3566_t:/ # iptables -t filter -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
bw_INPUT all -- anywhere anywhere
fw_INPUT all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
oem_fwd all -- anywhere anywhere
fw_FORWARD all -- anywhere anywhere
bw_FORWARD all -- anywhere anywhere
tetherctrl_FORWARD all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
oem_out all -- anywhere anywhere
fw_OUTPUT all -- anywhere anywhere
st_OUTPUT all -- anywhere anywhere
bw_OUTPUT all -- anywhere anywhere
Chain bw_FORWARD (1 references)
target prot opt source destination
Chain bw_INPUT (1 references)
target prot opt source destination
bw_global_alert all -- anywhere anywhere
RETURN esp -- anywhere anywhere
RETURN all -- anywhere anywhere mark match 0x100000/0x100000
MARK all -- anywhere anywhere MARK or 0x100000
Chain bw_OUTPUT (1 references)
target prot opt source destination
bw_global_alert all -- anywhere anywhere
Chain bw_costly_shared (0 references)
target prot opt source destination
bw_penalty_box all -- anywhere anywhere
Chain bw_data_saver (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain bw_global_alert (2 references)
target prot opt source destination
all -- anywhere anywhere ! quota globalAlert: 2097152 bytes
Chain bw_happy_box (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere match bpf pinned /sys/fs/bpf/netd_shared/prog_netd_skfilter_allowlist_xtbpf
bw_data_saver all -- anywhere anywhere
Chain bw_penalty_box (1 references)
target prot opt source destination
REJECT all -- anywhere anywhere match bpf pinned /sys/fs/bpf/netd_shared/prog_netd_skfilter_denylist_xtbpf reject-with icmp-port-unreachable
bw_happy_box all -- anywhere anywhere
Chain fw_FORWARD (1 references)
target prot opt source destination
Chain fw_INPUT (1 references)
target prot opt source destination
Chain fw_OUTPUT (1 references)
target prot opt source destination
Chain oem_fwd (1 references)
target prot opt source destination
Chain oem_out (1 references)
target prot opt source destination
Chain st_OUTPUT (1 references)
target prot opt source destination
Chain st_clear_caught (2 references)
target prot opt source destination
Chain st_clear_detect (0 references)
target prot opt source destination
REJECT all -- anywhere anywhere connmark match 0x2000000/0x2000000 reject-with icmp-port-unreachable
RETURN all -- anywhere anywhere connmark match 0x1000000/0x1000000
CONNMARK tcp -- anywhere anywhere u32 "0x0>>0x16&0x3c@0xc>>0x1a&0x3c@0x0&0xffff0000=0x16030000&&0x0>>0x16&0x3c@0xc>>0x1a&0x3c@0x4&0xff0000=0x10000" CONNMARK or 0x1000000
CONNMARK udp -- anywhere anywhere u32 "0x0>>0x16&0x3c@0x8&0xffff0000=0x16fe0000&&0x0>>0x16&0x3c@0x14&0xff0000=0x10000" CONNMARK or 0x1000000
RETURN all -- anywhere anywhere connmark match 0x1000000/0x1000000
st_clear_caught tcp -- anywhere anywhere state ESTABLISHED u32 "0x0>>0x16&0x3c@0xc>>0x1a&0x3c@0x0&0x0=0x0"
st_clear_caught udp -- anywhere anywhere
Chain st_penalty_log (0 references)
target prot opt source destination
CONNMARK all -- anywhere anywhere CONNMARK or 0x1000000
NFLOG all -- anywhere anywhere
Chain st_penalty_reject (0 references)
target prot opt source destination
CONNMARK all -- anywhere anywhere CONNMARK or 0x2000000
NFLOG all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain tetherctrl_FORWARD (1 references)
target prot opt source destination
Chain tetherctrl_counters (0 references)
target prot opt source destination
rk3566_t:/ # iptables -t filter -L
