Sep 22, 2021
TechnologySteps
Install ubuntu21.04 live server(90 Core, 16G Memory, 1T SSD)
# sudo apt-get update -y
# sudo apt-get upgrade -y
# sudo apt-get install -y nethogs iotop
# sudo add-apt-repository ppa:openjdk/ppa
# sudo apt-get update && upgrade
# sudo apt-get install openjdk-8-jdk
# sudo apt-get install -y repo pypy-enum34
# sudo apt-get install git gnupg flex bison maven gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip squashfs-tools libssl-dev ninja-build lunzip syslinux syslinux-utils gettext genisoimage gettext bc xorriso libncurses5 xmlstarlet build-essential git imagemagick lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libxml2 lzop pngcrush rsync schedtool python3-mako libelf-dev
# sudo apt-get install -y shadowsocks-libev libevent-dev
Install sslocal configuration and redsocks for syncing source code
# git config --global user.email "xxx@gmail.com"
# git config --global user.name "xxx"
Repo sync(This will take so long~long~long time, depending on your network speed):
$ mkdir ~/BuildBlissV14.x && cd ~/BuildBlissV14.x
$ repo init -u https://github.com/BlissRoms-x86/manifest.git -b r11-r36
$ repo sync -c --force-sync --no-tags --no-clone-bundle -j$(nproc --all) --optimized-fetch --prune
Sep 20, 2021
TechnologyAIM
Enable libndk_translation
in waydroid.
Steps
Disable the waydroid-container
and reboot the machine:
systemctl disable waydroid-container
reboot
Now you could make a backup for your origin system.img
and vendor.img
file:
cp /var/lib/waydroid/images/system.img /root
cp /var/lib/waydroid/images/vendor.img /root
Clone the repository :
$ git clone https://github.com/newbit1/libndk_translation_Module.git
$ cd libndk_translation_Module
$ tar czvf native-bridge.tar.gz system
Copy the native-bridge.tar.gz
to some place(For example /root), later we will use it.
Resize the img file(enlarge them):
qemu-img resize -f raw system.img +512M
losetup -f system.img
losetup -l
e2fsck -f /dev/loop5
resize2fs /dev/loop5
losetup -d /dev/loop5
qemu-img resize -f raw vendor.img +100M
losetup -f vendor.img
e2fsck -f /dev/loop6
resize2fs /dev/loop6
losetup -d /dev/loop6
Mount the img file in rw
mode:
mount -o rw /var/lib/waydroid/images/system.img /var/lib/waydroid/rootfs
mount -o rw /var/lib/waydroid/images/vendor.img /var/lib/waydroid/rootfs/vendor
Inject libndk_translation_Module
:
# cd /var/lib/waydroid/rootfs
# cp /root/native-bridge.tar.gz .
# tar xzvf native-bridge.tar.gz
Enable nativebridge.rc
:
# vim /var/lib/waydroid/rootfs/vendor/etc/init/nativebridge.rc
on early-init
setprop ro.odm.product.cpu.abilist x86_64,x86,arm64-v8a,armeabi-v7a,armeabi
setprop ro.odm.product.cpu.abilist32 x86,armeabi-v7a,armeabi
setprop ro.odm.product.cpu.abilist64 x86_64,arm64-v8a
setprop ro.product.cpu.abilist x86_64,x86,arm64-v8a,armeabi-v7a,armeabi
setprop ro.product.cpu.abilist32 x86,armeabi-v7a,armeabi
setprop ro.product.cpu.abilist64 x86_64,arm64-v8a
setprop ro.vendor.product.cpu.abilist x86_64,x86,arm64-v8a,armeabi-v7a,armeabi
setprop ro.vendor.product.cpu.abilist32 x86,armeabi-v7a,armeabi
setprop ro.vendor.product.cpu.abilist64 x86_64,arm64-v8a
setprop ro.dalvik.vm.native.bridge libndk_translation.so
setprop ro.enable.native.bridge.exec 1
setprop ro.ndk_translation.version 0.2.2
setprop ro.dalvik.vm.isa.arm x86
setprop ro.dalvik.vm.isa.arm64 x86_64
Enable native.bridge
in prop.default
:
# vim /var/lib/waydroid/rootfs/system/etc/prop.default
native.bridge=0 --> native.bridge=1
?
native.bridge=0 --> native.bridge=libndk_translation.so
trancode not OK…… lots of issues.
Sep 15, 2021
TechnologySys Info
idv hardware, Ubuntu 18.04 server:
Intel(R) Core(TM) i5-8265UC CPU @ 1.60GHz
16 G Memory
256 G nvme ssd
dash@redroid:~$ cat /etc/issue
Ubuntu 18.04.5 LTS \n \l
dash@redroid:~$ uname -r
4.15.0-156-generic
Kernel Preparation
Kernel module preparation:
$ sudo apt-get upgrade -y
$ sudo reboot
$ sudo apt-get install -y dkms linux-headers-generic
$ mkdir Code
$ cd Code && git clone https://github.com/remote-android/redroid-modules.git
$ cd redroid-modules/
$ sudo cp redroid.conf /etc/modprobe.d/
$ sudo cp 99-redroid.rules /lib/udev/rules.d/
$ sudo cp -rT ashmem/ /usr/src/redroid-ashmem-1
$ sudo cp -rT binder /usr/src/redroid-binder-1
$ sudo dkms install redroid-ashmem/1
$ sudo dkms install redroid-binder/1
Check via:
dash@redroid:~$ grep binder /proc/filesystems
nodev binder
dash@redroid:~$ grep ashmem /proc/misc
55 ashmem
Docker
Install docker via:
$ sudo apt-get install -y docker.io
$ sudo systemctl start docker
$ sudo systemctl enable docker
Prepare the image via docker pull xxxx
:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redroid/redroid 12.0.0-amd64 3000c3e2a297 5 weeks ago 1.52GB
redroid/redroid 9.0.0-latest a38ac26defd9 5 weeks ago 1.55GB
Start Android Docker
Start 2 android docker session via:
docker run -itd --rm --memory-swappiness=0 --privileged --pull always -v ~/data:/data -p 5555:5555 redroid/redroid:9.0.0-latest
docker run -itd --rm --memory-swappiness=0 --privileged --pull always -v ~/data1:/data -p 5556:5555 redroid/redroid:12.0.0-amd64
Connect(Archlinux client):
$ yay scrcpy
$ adb connect 192.168.1.119:5555
$ adb connect 192.168.1.119:5556
$ scrcpy --serial 192.168.1.119:5555
$ scrcpy --serial 192.168.1.119:5556
Sep 9, 2021
Technology目的
透传sg1卡给虚拟机,同时支撑多个环境。
环境
物理机: 192.168.89.108
, 待开辟虚拟机192.168.89.23~27
.
[root@intel ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@intel ~]# uname -a
Linux intel 4.14.105-6477750+ #1 SMP Mon May 17 10:31:49 CST 2021 x86_64 x86_64 x86_64 GNU/Linux
需透传的卡信息(8086:4907
):
[root@intel ~]# lspci -nn | grep -i vga
0000:05:00.0 VGA compatible controller [0300]: ASPEED Technology, Inc. ASPEED Graphics Family [1a03:2000] (rev 41)
0000:b3:00.0 VGA compatible controller [0300]: Intel Corporation Device [8086:4907] (rev 01)
0000:b8:00.0 VGA compatible controller [0300]: Intel Corporation Device [8086:4907] (rev 01)
0000:bd:00.0 VGA compatible controller [0300]: Intel Corporation Device [8086:4907] (rev 01)
0000:c2:00.0 VGA compatible controller [0300]: Intel Corporation Device [8086:4907] (rev 01)
开启vfio
修改内核参数并重启:
# vim /etc/default/grub
...
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet i915.force_probe=* modprobe.blacklist=ast,snd_hda_intel i915.enable_guc=2 intel_iommu=on vfio-pci.ids=8086:4907"
...
修改modprobe.d规则:
vim /etc/modprobe.d/vfio.conf
options vfio-pci ids=8086:4907
更新grub:
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
### 配置网桥
安装:
yum install -y bridge-utils
### Ubuntu20.04 changes
Switch back to Ubuntu20.04 then do following:
$ sudo vim /etc/modprobe.d/vfio.conf
$ sudo systemctl set-default multi-user
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/multi-user.target.
$ sudo reboot
Change the
$ sudo vim /etc/initramfs-tools/scripts/init-top/vfio.sh
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
for dev in 0000:b3:00.0 0000:b8:00.0 0000:bd:00.0 0000:c2:00.0
do
echo "vfio-pci" > /sys/bus/pci/devices/$dev/driver_override
echo "$dev" > /sys/bus/pci/drivers/vfio-pci/bind
done
exit 0
$ sudo chmod +x /etc/initramfs-tools/scripts/init-top/vfio.sh
$ sudo vim /etc/initramfs-tools/modules
And add the following lines:
options kvm ignore_msrs=1
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
Update the initramfs:
# update-initramfs -c -k all
Examine the vfio driver usage(before vfio):
lspci -v -s 0000:b8:00.0
0000:b8:00.0 VGA compatible controller: Intel Corporation Device 4907 (rev 01) (prog-if 00 [VGA controller])
Subsystem: Hangzhou H3C Technologies Co., Ltd. Device 4000
Flags: bus master, fast devsel, latency 0, IRQ 892, NUMA node 1
Memory at e7000000 (64-bit, non-prefetchable) [size=16M]
Memory at 386c00000000 (64-bit, prefetchable) [size=8G]
Expansion ROM at e8000000 [disabled] [size=2M]
Capabilities: [40] Vendor Specific Information: Len=0c <?>
Capabilities: [70] Express Endpoint, MSI 00
Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable+ 64bit+
Capabilities: [d0] Power Management version 3
Capabilities: [100] Latency Tolerance Reporting
Kernel driver in use: i915
Kernel modules: i915
Sep 2, 2021
TechnologyReferences
Refers to :
https://github.com/elliott-wen/anbox-direct-gpu-access
This project could run android in lxc, with a modified UI for accessing the android UI.
Environment
Hardware and OS information is listed as:
# cat /proc/cpuinfo | grep 'model name'
model name : Intel(R) Core(TM) i5-8265UC CPU @ 1.60GHz
$ free -m
total used free shared buff/cache available
Mem: 15765 336 14602 182 826 14960
Swap: 4095 0 4095
$ cat /etc/issue
Ubuntu 18.04.5 LTS \n \l
Steps
Initialize the environment via:
$ sudo apt-get install -y
$ sudo apt-get upgrade -y
$ sudo apt-get install -y lubuntu-desktop
$ sudo apt-get install lxc uidmap dkms
$ sudo usermod --add-subuids 100000-165536 dash
$ sudo usermod --add-subgids 100000-165536 dash
$ sudo chmod +x $HOME
$ cd ~/.config/
$ mkdir lxc
$ cd lxc/
$ vim default.conf
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536
$ sudo vim /etc/lxc/lxc-usernet
# USERNAME TYPE BRIDGE COUNT
dash veth lxcbr0 10
$ git clone https://github.com/anbox/anbox-modules.git
$ cd anbox-modules
$ ./INSTALL.sh
$ sudo reboot
$ mkdir -p /home/dash/emugui/disk
$ mkdir -p /home/dash/emugui/disk/data
$ mkdir -p /home/dash/emugui/disk/cache
$ git clone https://github.com/elliott-wen/anbox-direct-gpu-access.git
$ cd anbox-direct-gpu-access
$ sudo apt-get install -y clang libxcb1-devel libx11-xcb-dev libxcb-xinput-dev libxcb-present-dev libxcb-dri3-dev libxcb-icccm4-dev libpulse-dev
$ ./build.sh
$ cd ~/.local/share/lxc
$ lxc-create -t busybox -n android
$ cd android
$ mv rootfs/ rootfs.back
$ tar xvf ~/rootfs.tar -C .
$ sudo /home/dash/anbox-direct-gpu-access-master/nsexex -b ~/.local/share/lxc/android/rootfs 0 100000 65536
$ mv config config.back
$ vim config
The config file for lxc is listed as:
# Template used to create this container: /usr/share/lxc/templates/lxc-busybox
# Parameters passed to the template:
# Template script checksum (SHA-1): 21abc1440b73cdb95d96d5459b27c3a87df9976f
# For additional config options, please look at lxc.container.conf(5)
lxc.include = /etc/lxc/default.conf
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536
#lxc.rootfs.path = dir:/home/elliott/.local/share/lxc/android/rootfs
lxc.rootfs.path = dir:/home/dash/.local/share/lxc/android/rootfs
lxc.mount.entry = /home/dash/emugui/disk/data data none bind,optional 0 0
lxc.mount.entry = /home/dash/emugui/disk/cache cache none bind,optional 0 0
lxc.mount.entry = /dev/dri/card0 dev/dri/card0 none bind,optional,create=file 0 0
lxc.mount.entry = /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file 0 0
lxc.mount.entry = /dev/binder dev/binder none bind,optional,create=file 0 0
lxc.mount.entry = /dev/uinput dev/uinput none bind,optional,create=file 0 0
lxc.mount.entry = /dev/ashmem dev/ashmem none bind,optional,create=file 0 0
lxc.mount.entry = /tmp/android-dbus host none bind,optional,create=dir 0 0
lxc.mount.entry = /tmp/android-dbus/input dev/input none bind,optional,create=dir 0 0
lxc.mount.entry = /dev/fuse dev/fuse none bind,optional,create=file 0 0
lxc.signal.halt = SIGUSR1
lxc.signal.reboot = SIGTERM
lxc.uts.name = "android"
lxc.tty.max = 0
lxc.pty.max = 1024
lxc.tty.dir = ""
lxc.net.0.type="veth"
lxc.net.0.flags="up"
lxc.net.0.link="lxcbr0"
# When using LXC with apparmor, uncomment the next line to run unconfined:
lxc.apparmor.profile = unconfined
lxc.mount.auto = proc:mixed sys:mixed cgroup:mixed
lxc.autodev = 1
lxc.environment = PATH=/system/bin:/system/sbin:/system/xbin:/bin
lxc.init.cmd=/init
Change the mode for dev files:
sudo chmod 0600 -R /dev/binder /dev/ashmem /dev/dri/*
Then start the lxc instance via:
lxc-start -F -n android
adb connection
Install adb via:
# sudo apt-get install -y adb
# adb root
# adb connect 10.0.3.174
# adb shell
# adb push ~/F-Droid.apk
# adb push ..... ....
Stop the intance:
# lxc -stop -n android -k