全志T113双核异构处理器的使用基于Tina Linux5.0——异构双核通信验证
6、双核通信验证
6.1、C906小核创建通讯节点
在C906小核串口终端建立两个通讯节点用于监听数据,输入eptdev_bind test 2
cpu0 >eptdev_bind test 2
查看监听节点,输入rpmsg_list_listen
cpu0 >rpmsg_list_listen
name listen alive
test 2 0
console 100 0
6.2、大核创建通讯节点
在Tina Linux下也创建两个通讯监听节点,输入以下两个命令
echo test > /sys/class/rpmsg/rpmsg_ctrl-c906_rproc@0/open
echo test > /sys/class/rpmsg/rpmsg_ctrl-c906_rproc@0/open
输入后,如下所示:
root@TinaLinux:/sys/class/rpmsg# echo test > /sys/class/rpmsg/rpmsg_ctrl-c906_rp
roc@0/open
[ 946.762321] virtio_rpmsg_bus virtio0: creating channel sunxi,rpmsg_client addr 0x403
root@TinaLinux:/sys/class/rpmsg# echo test > /sys/class/rpmsg/rpmsg_ctrl-c906_rp
roc@0/open
[ 951.246499] virtio_rpmsg_bus virtio0: creating channel sunxi,rpmsg_client addr 0x404
root@TinaLinux:/sys/class/rpmsg#
在大核TIna Linux中也创建了两个监听节点,输入ls /dev/rpmsg*查看节点信息
root@TinaLinux:~# ls /dev/rpmsg*
/dev/rpmsg0 /dev/rpmsg1 /dev/rpmsg_ctrl-c906_rproc@0
创建完成后,可以在C906小核终端中查看自动输出的信息
cpu0 >ctrldev: Rx 44 Bytes
client: Rx 8 Bytes
rpmsg0: binding
send 0x13131411 to rpmsg0
create rpmsg0 client success
ctrldev: Rx 44 Bytes
client: Rx 8 Bytes
rpmsg1: binding
send 0x13131411 to rpmsg1
create rpmsg1 client success
6.3、大核传输至C906小核
在Tina Linux下输入
echo "hello Embfly SBC-T113S Board" > /dev/rpmsg0
echo "hello Tina Linux" > /dev/rpmsg1
将Linux Message 0信息通过创建的监听节点传输到C906小核,例如:
root@TinaLinux:~# echo "hello Embfly SBC-T113S Board" > /dev/rpmsg0
root@TinaLinux:~# echo "hello Tina Linux" > /dev/rpmsg1
输入后,打开C906串口终端可以发现,大核传输过来的信息。
rpmsg0: Rx 22 Bytes
Data:hello Embfly SBC-T113S Board
rpmsg1: Rx 17 Bytes
Data:hello Tina Linux
6.4、C906小核传输至大核
在小核端需要使用命令 eptdev_send 用法 eptdev_send ,这里的id号从0开始,我们设置有两个通信节点,所以id号分别为0和1。
在小核的串口终端输入以下命令:
eptdev_send 0 "hello C906"
eptdev_send 1 "hello C906"
例如:
cpu0 >eptdev_send 0 "hello C906"
will send hello C906 to rpmsg0
cpu0 >eptdev_send 1 "hello C906"
will send hello C906 to rpmsg1
输入完成后,小核会将信息分别传入rpmsg0和rpmsg1两个通讯节点。可以在大核Tina Linux端输入
cat /dev/rpmsg0
cat /dev/rpmsg1
可查看从C906小核传输过来的信息。例如:
root@TinaLinux:~# cat /dev/rpmsg0
hello C906
^C
root@TinaLinux:~# cat /dev/rpmsg1
hello C906
^C
按下Crtl+C结束监听前持续监听该节点。
您可以在小核端多次传输信息到该节点,该节点支持持续接受小核传输的信息,例如:
在C906小核,多次传输信息到监听节点rpmsg0
cpu0 >eptdev_send 0 "hello C906 "
will send hello C906 to rpmsg0
cpu0 >eptdev_send 0 "hello C906 "
will send hello C906 to rpmsg0
cpu0 >eptdev_send 0 "hello C906 "
will send hello C906 to rpmsg0
cpu0 >eptdev_send 0 "hello C906 "
will send hello C906 to rpmsg0
cpu0 >eptdev_send 0 "hello C906 "
will send hello C906 to rpmsg0
cpu0 >eptdev_send 0 "hello C906 "
will send hello C906 to rpmsg0
cpu0 >eptdev_send 0 "hello C906 "
will send hello C906 to rpmsg0
在大核端则会一直接收到小核传输过来的信息
root@TinaLinux:~# cat /dev/rpmsg0
hello C906 hello C906 hello C906 hello C906 hello C906 hello C906 hello C906
6.5、关闭相互通讯
要关闭通信,只要在大核Tina Linux端操作节点即可。输入以下命令,echo 给到rpmsg的控制关闭节点即可。
echo 0 > /sys/class/rpmsg/rpmsg_ctrl-c906_rproc@0/close
echo 1 > /sys/class/rpmsg/rpmsg_ctrl-c906_rproc@0/close
例如:
root@TinaLinux:~# echo 0 > /sys/class/rpmsg/rpmsg_ctrl-c906_rproc@0/close
[ 6783.156899] virtio_rpmsg_bus virtio0: destroying channel sunxi,rpmsg_client addr 0x403
root@TinaLinux:~# echo 1 > /sys/class/rpmsg/rpmsg_ctrl-c906_rproc@0/close
root@TinaLinux:~# [ 6784.224740] virtio_rpmsg_bus virtio0: destroying channel sunxi,rpmsg_client addr 0x404
此时C906小核端也会自动关闭通信节点,自动输出以下信息
send 0x13131411 to rpmsg0
rpmsg0: unbinding
ctrldev: Rx 44 Bytes
send 0x13131411 to rpmsg1
rpmsg1: unbinding