软件环境:ubuntu20.04 aosp
硬件环境:x86 PC
目标:在host ubuntu20.04和Android虚拟机间测试virtio-console
介绍
virtio-console模拟一个uart串口设备,不过没法设置波特率,用于蓝牙,keymaster,logcat,gatekeeper,audio等模块虚拟化,
以ACRN Virtio-console为例,前端可以实现为hvc节点,后端可以实现为TTY/PTY/File等多种方式。
测试
以cuttlefish启动virtio-console为例进行测试,其中hvc5是前端virtio-console驱动创建的uart节点,类似ttyS0。
为避免权限问题,android执行setenfore 0关闭Selinux权限
测试方法为:读写串口,类似于RK3588串口指导测试文档:https://wiki.t-firefly.com/zh_CN/Core-3588J/usage_uart.html
host -> android虚拟机
#host侧写数据
echo "virtio-console" > /home/cuttlefish_runtime.1/internal/bt_fifo_vm.in
#android侧读数据
cat /dev/hvc5
android虚拟机 -> host
#android侧写数据
echo "virtio-console" > /dev/hvc5
#host侧读数据
cat /home/cuttlefish_runtime.1/internal/bt_fifo_vm.in
参考
https://projectacrn.github.io/latest/developer-guides/hld/virtio-console.html