1、继续沿用以前liteos_a虚拟桥配置手动添加IP
sudo modprobe tun tap
sudo ip link add br0 type bridge
sudo ip address add 10.0.2.2/24 dev br0
sudo ip link set dev br0 up
#启动后手工指定IP
2、使用ubuntu自带组件自动配置虚拟桥 安装组件
sudo apt -y install libvirt-daemon bridge-utils virt-manager
#重启后,后台有一个virbr0守候,ifconfig可见,ip默认为192.168.122.1(ip段可修改,个人认为没必要)。
qemu启动网络参数改为
-netdev bridge,id=net0,br=virbr0 -device virtio-net-device,netdev=net0,mac=12:22:33:44:55:66
自动获取IP,-append参数最后添加 ip=dhcp
-append "console=ttyAMA0,115200 init=/bin/init hardware=qemu.arm.linux default_boot_device=a003e00.virtio_mmio root=/dev/ram0 rw ip=dhcp"
固定IP尝试
#下面好像可以配置固定ip
#ip=192.168.122.10:192.168.122.1:192.168.122.1:255.255.255.0::eth0:on
#下面可以配置dns
#echo "nameserver 8.8.8.8" >/etc/resolv.conf
1、现有kernel配置
https://gitee.com/openharmony/kernel_linux_config/blob/master/linux-5.10/arch/arm/configs/qemu-arm-linux_standard_defconfig
2、已经修改好的
https://gitee.com/wawanala/ohos/blob/master/qemu-arm-mini-selinux.config
add audio
Device Drivers > Sound card support > Advanced Linux Sound Architecture > PCI sound devices->
<*> (Creative) Ensoniq AudioPCI 1370
add rtc
Device Drivers > Real Time Clock
<*> ARM AMBA PL031 RTC
#讨论:
1、可以在原有的基础上添加。
2、直接用已经配置好的,两种方均可。\
(一)现在直接增加启动参数即可(暂不确定什么原因,以前不行,qemu版本?)
-device virtio-gpu-pci,xres=480,yres=960,addr=08.0,max_outputs=1
启动时命令行可见
[drm] pci: virtio-gpu-pci detected at 0000:00:08.0
[drm] features: -virgl +edid
[drm] number of scanouts: 1
[drm] number of cap sets: 0
[drm] Initialized virtio_gpu 0.1.0 0 for virtio6 on minor 0
Console: switching to colour frame buffer device 60x60
virtio_gpu virtio6: [drm] fb0: virtio_gpudrmfb frame buffer device
(二)以前需要增加QEMU固件使能drm
#1、精简写法,直接添加启动-bios参数
-bios edk2-arm-code.fd
#文件路径在/usr/local/share/qemu/edk2-arm-code.fd,qemu会自动找到,若找不到,可以手动直接指定。
#2、常见的通用方法
#制作flash0.img
dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/local/share/qemu/edk2-arm-code.fd bs=1M of=flash0.img conv=notrunc
#添加启动参数
-drive if=pflash,file=flash0.img,format=raw,readonly=on
前期测试
#目前ohos环境下es1370 AC97 ich9-intel-hd intel-hda usb-audio经测试均可以使用,以后启用hdf可以选取一个通用,暂时使用es1370
#kernel 使能es1370
#qemu 编译时增加音频组件
#qemu 添加参数
-device es1370
文档
https://gitee.com/openharmony/build
https://gitee.com/xfan1024
下载
https://www.alsa-project.org/files/pub/lib/alsa-lib-1.2.5.1.tar.bz2
https://www.alsa-project.org/files/pub/utils/alsa-utils-1.2.5.1.tar.bz2
https://travis-ci.org/github/tinyalsa/tinyalsa
#下面地址应该也行,不过最近未测试。
# https://gitee.com/openharmony-sig/alsa-lib
# https://gitee.com/openharmony-sig/alsa-utils
# https://gitee.com/openharmony-sig/third_party_tinyalsa
说明
#作为测试,将applications/standard作为编译目录
#将上面下载的三个压缩包解压到applications/standard
#文件夹改名后为“alsa-lib" "alsa-utils“ ”tiny-alsa“
修复错误
vi applications/standard/alsa-lib/src/control/control_empty.c
const char *_snd_module_control_empty = "";
初始配置
cd applications/standard/alsa-lib
./configure --prefix=/system/usr
#以后可改为ohos_build自动配置
添加编译组件
vi build/subsystem_config.json
"alsa-lib": {
"path": "applications/standard/alsa-lib",
"name": "alsa-lib"
},
"alsa-utils": {
"path": "applications/standard/alsa-utils",
"name": "alsa-utils"
},
"tiny-alsa": {
"path": "applications/standard/tiny-alsa",
"name": "tiny-alsa"
},
#qemu-linux可以直接添加,下面以3751为例
vi vendor/hisilicon/hispark_phoenix/config.json
{
"subsystem": "alsa-utils",
"components": [
{
"component": "alsa-utils",
"features": []
}
]
},
{
"subsystem": "alsa-lib",
"components": [
{
"component": "alsa-lib",
"features": []
}
]
},
{
"subsystem": "tiny-alsa",
"components": [
{
"component": "tiny-alsa",
"features": []
}
]
},
拉取编译配置文件
https://gitee.com/wawanala/ohos/blob/master/qemu-alsa/alsa-lib/BUILD.gn
https://gitee.com/wawanala/ohos/blob/master/qemu-alsa/alsa-lib/ohos.build
#上面两个文件放到applications/standard/alsa-lib目录下
https://gitee.com/wawanala/ohos/blob/master/qemu-alsa/alsa-utils/BUILD.gn
https://gitee.com/wawanala/ohos/blob/master/qemu-alsa/alsa-utils/ohos.build
#上面两个文件放到applications/standard/alsa-utils目录下
https://gitee.com/wawanala/ohos/blob/master/qemu-alsa/tiny-alsa/BUILD.gn
https://gitee.com/wawanala/ohos/blob/master/qemu-alsa/tiny-alsa/ohos.build
#上面两个文件放到applications/standard/tiny-alsa目录下
添加audio权限
老版本需要。主线最新已经集成,无需修改。
vi base/startup/init_lite/services/etc/group
audio:x:0:audio
重新编译
#按正常编译命令进行
播放音频测试
# 编译打包或复制wav文件,启动到命令行后,执行
aplay /etc/demo.wav
tinyplay /etc/dynamic.wav
测试tinyalsa接口
编译音频测试组件
./build.sh --product-name hispark_taurus_standard --build-target audio_unit_test
使能音频tinyalsa接口
vi vendor/hisilicon/hispark_taurus_standard/hals/audio/product.gni
enable_audio_alsa_mode = true
#添加audio驱动接口
vi drivers/peripheral/audio/supportlibs/tinyalsa_adapter/src/audio_hw.c
{"AudioPCI", NULL},
{"AudioPCI", "ES1370/1"},
{"AudioPCI", "ES1370/2"},
#复制测试文件
cp /test/tassel.wav /data/test_44100_2.wav
#开始跑示例: [run ok] 期间正常会输出声音
audio_renderer_unit_test
测试alsa接口(主线代码正在更新,更新后再测)
附:自动提取配置conf辅助shell脚本,大批量配置conf可使用。
#!/bin/bash
#write by wawanala <wawanala@163.com>
#find src/conf -name "*.conf" | sort >> temp.txt
while read file_full_name
do
file_full_name_length=${#file_full_name}
file_name=${file_full_name: 9}
file_split_num=`echo $file_name |grep -b -o "/" | cut -d: -f1 | tail -n 1`
file_dir_name=${file_name: 0:$file_split_num}
file_name_to_etc=${file_name//\//-}
file_name_length=${#file_name_to_etc}-5
echo "ohos_prebuilt_etc(\"alsa-lib-${file_name_to_etc: 0:$file_name_length}\") {"
echo "source = \"$file_full_name\""
echo 'install_enable = true'
echo "module_install_dir = \"usr/share/alsa/$file_dir_name\""
echo 'subsystem_name = "applications"'
echo 'part_name = "alsa-lib"'
echo "}"
echo ""
done < ./temp.txt
#!/bin/bash
#write by wawanala <wawanala@163.com>
#find src/conf -name "*.conf" | sort >> temp.txt
while read file_full_name
do
file_full_name_length=${#file_full_name}
file_name=${file_full_name: 9}
file_split_num=`echo $file_name |grep -b -o "/" | cut -d: -f1 | tail -n 1`
file_dir_name=${file_name: 0:$file_split_num}
file_name_to_etc=${file_name//\//-}
file_name_length=${#file_name_to_etc}-5
echo " \"//applications/standard/alsa-lib:alsa-lib-${file_name_to_etc: 0:$file_name_length}\","
done < ./temp.txt
kernel配置加上即可,推荐两个。
1、efi-rtc
2、qemu-virt-Pl031
使用方法,qemu添加启动参数
-rtc base=localtime,clock=host
#启动后可见/dev/rtc0设备
#date显示时间与主机同步。
#参照虚拟屏幕大小制作,如:480x960
https://gitee.com/openharmony/graphic_graphic_2d/tree/master/frameworks/bootanimation/data/bootanimation_tool
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。