赞
踩
硬件环境:x86 PC
软件环境:Windows; Ubuntu20.04; AOSP12; AOSP14
目标:Glodfish,Cuttlefish,Trout三种Android Automotive模拟环境
#建议在Ubuntu20.04环境,安装AOSP12安卓编译依赖包,无需安装jdk
sudo apt-get install -y python git zip unzip curl wget llvm git-core gnupg bison flex gperf build-essential make zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc libssl-dev libbz2-dev libreadline-dev libsqlite3-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl libncurses5
#1. 若可以访问外网,下载谷歌repo
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
#2. 若无外网,下载清华repo
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
PATH=/repo-path:$PATH
#3. 下载aosp12源码
#a. 能访问外网,下载谷歌仓库
repo init -u https://android.googlesource.com/platform/manifest -b master --depth=1
#b. 不能访问外网下载清华仓
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-12.1.0_r8 --depth=1 --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
#c. 网络不好直接下载清华的最新初始化包,约190G
wget -U -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar
#解压初始化包
tar xvf aosp-latest.tar
#解压得到的 AOSP工程目录,ls啥也没有,只有一个隐藏的.repo目录
#3. 下载代码,清华服务器建议并发小于4
repo sync -j4
source build/envsetup.sh
#goldfish模拟器版本
lunch sdk_car_x86_64-userdebug
#开始编译,有问题的话减少-j并发数,可以减少CPU和内存压力
make -j4
#启动模拟器,显示/音频功能OK
emulator &
上面用源码编译AOSP,emulator是二进制的,现在介绍源码编译emulator
#先安装依赖
pip install absl-py
pip install urlfetch
sudo apt-get install crossbuild-essential-arm64
#清华源
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b emu-master-dev
#谷歌源
repo init -u https://android.googlesource.com/platform/manifest -b emu-master-dev --depth=1
repo sync -qcj 4
#编译emulator
cd external/qemu
python android/build/python/cmake.py --noqtwebengine --noshowprefixforinfo --target linux_aarch64
Cuttlefish相比于Goldfish Virtio更加彻底,用于模拟测试ASOP。
ls /dev/kvm
或者grep -c -w "vmx\|svm" /proc/cpuinfo
sudo apt install -y git devscripts config-package-dev debhelper-compat curl golang;
git clone https://github.com/google/android-cuttlefish;
cd android-cuttlefish;
for dir in base frontend; do
cd $dir
debuild -i -us -uc -b -d
cd ..done
此步骤可能包依赖问题,参考后面编译问题
sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f
sudo dpkg -i ./cuttlefish-user_*_*64.deb || sudo apt-get install -f;
sudo usermod -aG kvm,cvdnetwork,render $USER;
sudo reboot
1)安装repo
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/repo
chmod +x ~/repo
PATH=~:$PATH
2)初始化repo
#a. 外网方便的,下载谷歌android-12.1.0_r11.
repo init -u https://android.googlesource.com/platform/manifest -b android-12.1.0_r11 --depth=1
#b. 不能翻墙情况下,下载清华 android-12.1.0_r11,并设置深度为 1,加快代码拉取
# --repo-url: 指定 repo 下载地址为 tuna 网址,默认在 google 仓库拉,有网络问题
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-12.1.0_r11 --repo-branch=stable --depth=1 --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
#c. 不能翻墙情况下,下载清华 android-14.0.0_r17 ,并设置深度为 1,加快代码拉取
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-14.0.0_r17 --depth=1 --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
3)sync代码
repo sync -j4
source build/envsetup.sh
#1. cultfish模拟器,编译X86或者Arm64
lunch aosp_cf_x86_auto-userdebug
#lunch aosp_cf_arm64_auto-userdebug
#2. 编译安卓
#若本地编译,生产镜像位于out,可直接运行
make -j8
#若打包编译,DIST_DIR目录下aosp_trout_x86_64-img-eng.user.zip和cvd-host_package.tar.gz
make dist DIST_DIR=cf_x86
#源码工程中直接启动
launch_cvd #启动一个CVD实例
#其他启动命令
#HOME=$PWD ./bin/launch_cvd -daemon -display0=width=1920,height=720,dpi=160
#-console=true 通过screen ./cuttlefish_runtime.1/console查看串口
#-gpu_mode=drm_virgl 使能drm-virgl 3D加速支持
#-gpu_mode=gfxstream 使能gfxstream 3D支持,原生Ubuntu命令行中运行
#-display0=width=1920,height=720,dpi=160 -display1=width=720,height=1920,dpi=160 -display2=width=1920,height=720,dpi=160 使能3屏
#launch_cvd -start_vnc_server=true (android12还保留,master已经删掉了)
1. 下载tightvnc viewer (jar file):
https://www.tightvnc.com/download.php
2. 安装java:
sudo apt install openjdk-11-jre
3. 启动tightvnc ubuntu
java -jar tightvnc-jviewer.jar #use 127.0.0.1:6444
java -jar tightvnc-jviewer.jar -ScalingFactor=80 -Tunneling=no -host=localhost -port=6444
4. 或者启动tightvnc on windows ip::6444
#谷歌CI构建
http://ci.android.com/ -> aosp_master -> userdebug -> Artifacts. 有cf phone的镜像
下载cvd-host_package.tar.gz和aosp_cf_x86_64_phone-img-xxxxxx.zip
mkdir cf; cd cf
tar xvf /path/to/cvd-host_package.tar.gz
unzip /path/to/aosp_cf_x86_64_phone-img-xxxxxx.zip
#启动vm
HOME=$PWD ./bin/launch_cvd
#远程使用webrtc看界面,打开https://localhost:8443
# STEP 1 (Init repo sdk)
1. 7z x rk3588_repo_sdk_v1.0.2a.7z
2. cd rk3588_repo_sdk_v1.0.2a
3. .repo/repo/repo sync -l
4. .repo/repo/repo start rk3588/firefly --all
# STEP 2 (Update sdk)
1.mv bundle/* rk3588_repo_sdk_v1.0.2a/
2.cd rk3588_repo_sdk_v1.0.2a
3. sh update.sh
# STEP 3 (Compile)
参考: https://wiki.t-firefly.com/zh_CN/Core-3588J/linux_compile_gpt.html
1.下载跟文件系统
7z x Ubuntu20.04-Gnome_RK3588_v2.40-1_20230414.7z
mkdir ubuntu_rootfs
mv ubuntu-aarch64-rootfs.img ubuntu_rootfs/rootfs.img
2.全编,生成的完整固件会保存到 rockdev/pack/目录
./build.sh
#配置mac
ifconfig eth0 down
ifconfig eth0 hw mac-addr
ifconfig eth0 up
#修改firefly密码为firefly
sudo passwd firefly
#ssh可直接连接
#adb无法使用,root下kill占用5037的进程
netstat -tnlp | grep 5037
安装cuttlefish。只安装了cuttlefish-base.deb其余安失败了
安装VSOCK相关驱动
#编译ITX3588-J内核vsock驱动
#在config文件增加一行CONFIG_VSOCKETS=m将vsock相关驱动编成ko
kernel/arch/arm64/configs/firefly-linux.config
#编译驱动,ko生成在./drivers/vhost/ 和 ./net/vmw_vsock/
./build.sh extboot
#安装驱动
sudo insmod vsock.ko
sudo insmod vmw_vsock_virtio_transport_common.ko
sudo insmod vhost_vsock.ko
#启动cuttlefish成功,webrtc可访问
HOME=$PWD ./bin/launch_cvd -daemon
1)编译AOSP时,选择trout对应的product,
#AOSP12有问题,AOSP14无问题
lunch aosp_trout_x86_64-userdebug
a. ubuntu20.04 cuttlefish运行环境安装请参考上面章节
b. 使用webrtc查看图形界面请参考上面章节
# 1. 若用make -j4编译
# 可以直接在ubuntu20.04环境运行
launch_cvd
# 2. 若make dist编译
# 复制trout_x86/aosp_trout_x86_64-img-eng.bstcd.zip trout_x86/cvd-host_package.tar.gz到trout运行目录并解压
unzip aosp_trout_x86_64-img-eng.bstcd.zip
tar xvf trout_x86/cvd-host_package.tar.gz
# 运行trout 2D模式支持2屏
HOME=$PWD ./bin/launch_cvd -daemon -display0=width=1920,height=720,dpi=160 -display1=width=720,height=1920,dpi=160
#1. 2D模式下三屏显示
HOME=$PWD ./bin/launch_cvd -daemon -display0=width=1920,height=720,dpi=160 -display1=width=720,height=1920,dpi=160 -display2=width=1920,height=720,dpi=160
# 设置hwcomposer为drm
-hwcomposer=drm
# 设置gpu模式为下面之一
-gpu_mode=auto/guest_swiftshader/drm_virgl/gfxstream
# 设置虚拟机管理器为qemu
-vm_manager=qemu_cli
# 启动串口,screen ./cuttlefish_runtime.1/console
-console=true
# host启动adb服务和设置串口
adb -a -P 5037 nodaemon server &
export ANDROID_SERIAL=0.0.0.0:6520
chrome浏览器打开 https://ubuntu-host-IP:8443/
sudo vim /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/ubuntu/ focal main restricted
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted
deb http://mirrors.ustc.edu.cn/ubuntu/ focal universe
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-updates universe
deb http://mirrors.ustc.edu.cn/ubuntu/ focal multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-updates multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-security universe
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-security multiverse
sudo apt update
sudo apt-get upgrade
sudo dpkg -i ../cuttlefish-base_0.9.24_amd64.deb || sudo apt-get install -f;
sudo dpkg -i ../cuttlefish-user_0.9.24_amd64.deb || sudo apt-get install -f;
#编译scrcpy
sudo apt install ffmpeg libsdl2-2.0-0 adb wget gcc git pkg-config meson ninja-build libsdl2-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libusb-1.0-0 libusb-1.0-0-dev
git clone https://github.com/Genymobile/scrcpy
cd scrcpy/
./install_release.sh
#设备起来后,运行
scrcpy --tcpip=0.0.0.0:6520
#0.使能repo环境变量
PATH=~/bin:$PATH
#0 使用清华源方法:
#导入repo 链接,因为repo 默认使用google 的仓库
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
#init repo
repo init -u https://aosp.tuna.tsinghua.edu.cn/kernel/manifest -b common-android12-5.10 --depth=2
#同步代码
repo sync
#1编译bzImage.Android12后cuttlefish和goldfish共享virtual_device配置
BUILD_CONFIG=common/build.config.gki.x86_64 build/build.sh
#2 编译initramfs
BUILD_CONFIG=common-modules/virtual-device/build.config.virtual_device.x86_64 build/build.sh
#将initramfs.img和bzImage覆盖替换,能够正常启动AAOS Cuttlefish
HOME=${PWD} ./bin/launch_cvd -initramfs_path initramfs.img -kernel_path bzImage -daemon
https://blog.csdn.net/linkwj/article/details/119902108?spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-5-119902108-blog-117474587.pc_relevant_default&depth_1-utm_source=distribute.pc_r
清华AOSP
Goldfish内核调试
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。