(AVD) Compilation and Installation Guide
-
Upload
others
-
View
10
-
Download
0
Embed Size (px)
Citation preview
Compilation and Installation Guide (AVD)Issue 16
Date 2021-08-17
Copyright © Huawei Technologies Co., Ltd. 2021. All rights
reserved.
No part of this document may be reproduced or transmitted in any
form or by any means without prior written consent of Huawei
Technologies Co., Ltd. Trademarks and Permissions
and other Huawei trademarks are trademarks of Huawei Technologies
Co., Ltd. All other trademarks and trade names mentioned in this
document are the property of their respective holders. Notice The
purchased products, services and features are stipulated by the
contract made between Huawei and the customer. All or part of the
products, services and features described in this document may not
be within the purchase scope or the usage scope. Unless otherwise
specified in the contract, all statements, information, and
recommendations in this document are provided "AS IS" without
warranties, guarantees or representations of any kind, either
express or implied.
The information in this document is subject to change without
notice. Every effort has been made in the preparation of this
document to ensure accuracy of the contents, but all statements,
information, and recommendations in this document do not constitute
a warranty of any kind, express or implied.
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
i
Contents
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) Contents
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
ii
3.4.1 Modifying the Maximum Number of Files
Accessed............................................................................................
24 3.4.2 Configuring the SSH
Service..........................................................................................................................................
25 3.4.3 Updating the
APT..............................................................................................................................................................
25 3.5 Setting Up Android
SDK.....................................................................................................................................................
26 3.6 Running and Verifying the
AVD.......................................................................................................................................27
3.6.1 Before You Start
(GPU)...................................................................................................................................................
27 3.6.2 Creating and Running AVD Using the
CLI................................................................................................................
27 3.6.2.1 Starting the Desktop
Service......................................................................................................................................28
3.6.2.2 Creating an
AVD.............................................................................................................................................................30
3.6.2.3 Starting an
AVD..............................................................................................................................................................32
3.6.2.4 Improving AVD
Performance.....................................................................................................................................
36 3.6.3 Creating and Running AVDs in Batches by Using a
Script..................................................................................36
3.6.3.1 Batch Starting AVDs with the start_qemu.sh
Script..........................................................................................
36 3.6.3.2 Changing the AVD
Resolution...................................................................................................................................
38 3.6.3.3 Deleting an
AVD.............................................................................................................................................................38
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) Contents
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
iii
4.5.18 Enabling Server
Ports.....................................................................................................................................................56
4.6 Setting Up Android
SDK.....................................................................................................................................................
57 4.7 Running and Verifying the
AVD.......................................................................................................................................58
4.7.1 Creating and Running AVD Using the
CLI................................................................................................................
58 4.7.1.1 Creating an
AVD.............................................................................................................................................................58
4.7.1.2 Starting an
AVD..............................................................................................................................................................58
4.7.1.3 Improving AVD
Performance.....................................................................................................................................
60 4.7.2 Creating and Running AVDs in Batches by Using a
Script..................................................................................61
4.7.2.1 Batch Starting AVDs with the start_qemu.sh
Script..........................................................................................
61 4.7.2.2 Changing the AVD
Resolution...................................................................................................................................
62 4.7.2.3 Deleting an
AVD.............................................................................................................................................................63
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) Contents
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
iv
1 AVD Security Description
1.1 Overview 1.2 Security Description
1.1 Overview The Android virtual device (AVD) is a virtualization
solution that enables the Android system based on the Quick
EMUlator (QEMU). This document provides security instructions for
using the AVD. Read this document carefully before using the
AVD.
1.2 Security Description In the AVD, the open-source patch files
and script files provided by Huawei are for reference only. No
commercial commitment is made. In addition, customers or
independent software vendors (ISVs) are responsible for the
development and maintenance of other components involved in the
solution, such as the OS on the host side, QEMU, and Android
OS.
To ensure the trusted and secure running of the AVD in commercial
scenarios, it is strongly recommended that customers or ISVs
install and use the latest security patches and security hardening
measures for the open-source software involved in the solution,
including but not limited to the following suggestions.
1.2.1 OS Security Update When using Ubuntu or CentOS, ensure that
the latest security updates are used in a timely manner. Using the
latest security updates to repair the system in a timely manner can
prevent the OS from being affected by vulnerabilities and attacked
by malicious software, and ensure the proper running of QEMU on the
system.
You can periodically run the apt-get command in Ubuntu and the yum
update command in CentOS to check whether security updates are
available in the OS. If yes, install the updates in a timely
manner. For details, see the description on the official websites
of Ubuntu and CentOS.
In addition to installing the latest security patches in a timely
manner, you also need to perform security hardening on the OS of
the server, for example,
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 1 AVD Security Description
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
1
configuring strong passwords and disabling unnecessary service
ports. For details, see the description on the official websites of
Ubuntu and CentOS.
1.2.2 QEMU Security Hardening QEMU security hardening measures
include but not limited to: hardening the OS of the host,
configuring strict access control policies, controlling QEMU
resource configuration, prohibiting untrusted images, periodically
performing security scanning, and updating patches.
Periodically perform security check and hardening for QEMU to
ensure proper running. For details, see the description on the
official website of QEMU.
1.2.3 Android Security Update The Android ecosystem is supported by
Google, which not only provides system updates with improved
functionality and stability, but also provides users with security
updates that ensure device security. Security update patches are
mainly provided by the Android Open Source Project (AOSP) and the
upstream Linux kernel and system on a chip (SOC) manufacturers to
ensure that Android devices are not affected by the latest security
vulnerabilities of hardware and software. Google periodically
pushes security updates to devices and releases security update
notices.
Use the source code provided by the AOSP and the patch link
provided in the security update notice to perform security update
in a timely manner based on the site requirements to ensure the
proper running of the AVD.
Periodically update and harden the open-source software involved in
the solution. For details, see the official documents of the
open-source software.
1.2.4 Security Statement About the VNC and ADB The Android
virtualization solution provided by the AVD is constructed based on
QEMU. Due to the characteristics of QEMU and Android OS, the
virtual network console (VNC) and Android debug bridge (ADB) ports
are enabled by default. It is strongly recommended that security
hardening measures, such as port authentication, be taken when
customers or ISVs provide VNC or ADB port services for external
systems.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 1 AVD Security Description
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
2
2 AVD Compilation Guide
2.6 Preparing the Target Arm Running Environment
2.1 Introduction
Overview This document describes how to build an Android virtual
device (AVD) solution based on the Kunpeng computing framework. The
compilation environments require two servers, one for the Kunpeng
computing platform (using Kunpeng 920 or 916 processors), and one
for the x86 platform. An android-sdk-linux software package is
built and finally runs on the Kunpeng platform.
Recommended Version
Software Version
AOSP source code
android-7.0.0_r35 or android-9.0.0_r10
Kunpeng 920 processors are not compatible with 32-bit instructions.
Select one of the following solutions to resolve the compatibility
problem of 32-bit programs:
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
3
Apply the 32-bit transcoding software ExaGear during Android
compilation and building. When a 32-bit program is running, the
32-bit instruction is automatically translated into a 64-bit
instruction for execution.
Build a pure 64-bit Android image, which is applicable to the pure
64-bit application environment.
NO TE
This document is only used as a compilation guide for the AVD
environment and does not guarantee the container running
performance.
2.2 Usage Statement 1. Before setting up and deploying the
environment, read the AVD Security
Description carefully to ensure that the security risks of the
solution are acceptable.
2. The OS on the host side is not within the delivery scope of this
solution. Therefore, security hardening measures related to the OS
need to be implemented by the customer or independent software
vendor (ISV). This document does not provide related
description.
3. To quickly deploy the AVD, the scripts mentioned in this
document are run by the root user by default. The script files
provided by the AVD are for reference only, and no commercial
commitment is made. To avoid OS security risks, it is recommended
that customers or ISVs implement defense measures such as file
access control and minimum authorization in commercial deployment
scenarios.
2.3 Environment Requirements
Table 2-2 Hardware requirements
CPU 1 Huawei Kunpeng 920 or 916 processor
Drive partition 1 No requirement for drive partitions
Server 2 x86 server
CPU 2 x86 processor
Drive partition 2 No requirement for drive partitions
Note: If server 1 is a TaiShan 200 server, the processor model of
CPU 1 must be Huawei Kunpeng 920. If server 1 is a TaiShan 100
server, the processor model of CPU 1 must be Huawei Kunpeng
916.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
4
OS Requirements
Table 2-3 OS requirements
Virtual machine (VM) OS on server 1
Ubuntu 16.04.4
NO TE
Click the following links to download the Ubuntu versions listed in
the preceding table:
Server 1: Ubuntu 18.04.1 image package, Ubuntu 16.04.4 image
package
Server 2: Ubuntu 16.04.3 image package
During the OS installation, select only the OpenSSH server from the
software list. For details, contact Huawei engineers.
If server 1 is a TaiShan 200 server, the supported BIOS and BMC are
listed in Table 2-4.
Table 2-4 BIOS and BMC requirements for TaiShan 200 servers
Item Version
NO TE
1. In this BIOS version, the memory of a single CPU cannot exceed
256 GB.
2. Use the Computing Product Memory Configuration Assistant to
configure the memory.
3. Load the BIOS version during the BMC firmware upgrade. After the
upgrade is complete, choose Advanced > MISC Config in the BIOS
setup, and set Support Smmu to Disable and Support 40Bit to
Enable.
2.4 Preparing the Kunpeng Compilation Environment and Building
Components
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
5
Step 1 Install the OS on server 1.
Download the ISO file of Ubuntu 18.04.1 from the following
website:
http://old-releases.ubuntu.com/releases/18.04.1/ubuntu-18.04.1-server-
arm64.iso
Guide for installing Ubuntu 18.04.1 on server 1:
For details about how to install the OS on a Kunpeng 920 server,
contact Huawei engineers.
For details about how to install the OS on a Kunpeng 916 server,
contact Huawei engineers.
Step 2 Install a Ubuntu 16.04.4 VM on server 1.
Download the image from the following website:
http://mirrors.huaweicloud.com/ubuntu-cdimage/ubuntu/releases/16.04/
release/ubuntu-16.04.4-server-arm64.iso
Install the VM. For details, contact Huawei engineers or search for
related information on the Internet.
Step 3 Install compilation dependencies. apt update apt -y install
build-essential autoconf xfce4 xubuntu-desktop xrdp openjdk-8-jre
ccache apt -y install libxt-dev libx11-dev libssl-dev
libgl1-mesa-dev libpulse-dev apt -y install libswt-gtk-4-java
libswt-gtk-4-jni libswt-cairo-gtk-4-jni libswt-glx-gtk-4-jni
libswt-gnome-gtk-4- jni libswt-webkit-gtk-4-jni apt -y install
libtool libgbm-dev gettext-doc libepoxy-dev libfdt-dev libpng++-dev
apt -y install llvm-3.5 clang flex bison scons libedit-dev ant
libudev-dev apt -y install git git-core curl repo
openjdk-8-jdk-headless ln -sf
/usr/lib/aarch64-linux-gnu/libedit.so.2
/usr/lib/aarch64-linux-gnu/libedit.so ln -sf
/usr/bin/llvm-config-3.5 /usr/bin/llvm-config
----End
2.4.2 Building Components in the android-sdk-linux/tools
Directory
Step 1 Obtain the aosp-on-qemu folder from the code repository at
the following URL and upload it to the Ubuntu 16.04.4 VM of server
1:
https://code.opensource.huaweicloud.com/Kunpeng/Native/home
Step 2 Copy the code repository root directory to the
android-sdk-linux project directory for compilation. This directory
is used to store all the compiled target binary files. cp -r
aosp-on-qemu /home/$(YOUR_USER)/ mkdir -p
/home/$(YOUR_USER)/android-sdk-linux //Create a target directory,
which is mentioned as $ (ANDROID_SDK_LINUX_DIR) in the subsequent
steps. cd $(ANDROID_SDK_LINUX_DIR) mkdir tools //The tools
directory stores components related to the emulator. mkdir
platforms //The platforms directory stores the API components of
the Android platform.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
6
Step 4 Download the emulator code (version: emu-master-dev). mkdir
-p /home/$(YOUR_USER)/$(YOUR_EmuMasterDev_DIR) //Home directory of
the AVD source code. cd $(YOUR_EmuMasterDev_DIR) repo init -u
https://android.googlesource.com/platform/manifest -b
emu-master-dev repo sync -j32
Step 5 Copy the
aosp-on-qemu/binaryAndFiles/snapshot_qemu_emu_B630.xml snapshot
file in the code repository root directory to the .repo/manifests/
directory to roll back the code of all Git repositories of QEMU. cp
snapshot_qemu_emu_B630.xml
/home/$(YOUR_USER)/$(YOUR_EmuMasterDev_DIR)/.repo/manifests/ cd
/home/$(YOUR_USER)/$(YOUR_EmuMasterDev_DIR) repo init -m
snapshot_qemu_emu_B630.xml repo sync -d -j32
NO TE
In the preceding repo commands, the code may fail to be obtained
because the user name and email address are not set for Git.
Configure Git before using it.
Step 6 Roll back to the specified submission branch. cd
external/qemu git reset --hard
0e8e684fba9eadcc112067359f9f1027659f3918 git log //View submission
records. The commit ID of the last submission is
0e8e684fba9eadcc112067359f9f1027659f3918.
Step 7 Build the emulator dependency library.
1. Delete the x86 library files mesa, qt, and ANGLE in prebuilts.
cd $(YOUR_EMUMASTERDEV_DIR)/prebuilts/android-emulator-build rm -rf
qt mesa cd common rm -rf ANGLE
2. Run scripts to install compilation dependencies.
a. Obtain aosp-on-qemu/patchForEmuMasterDev/0002_prebuilds.patch
from the code repository root directory. cd
$(YOUR_EMUMASTERDEV_DIR)/external/qemu/ patch -p1 <
0002_prebuilds.patch
b. Run the script files. cd
$(YOUR_EMUMASTERDEV_DIR)/external/qemu/android/scripts/
./build-curl.sh ./build-qemu-android-deps.sh ./build-e2fsprogs.sh
./build-ffmpeg.sh ./build-lz4.sh ./build-libvpx.sh
./build-libxml2.sh ./build-libusb.sh chmod +x build-x264.sh
./build-x264.sh ./build-virglrenderer.sh
3. Install the library files protobuf and breakpad. a. Run the
build_protobuf.sh script in the aosp-on-qemu/oneKey/ directory to
install protobuf.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
7
./build_protobuf.sh $(YOUR_EMUMASTERDEV_DIR)
//$(YOUR_EMUMASTERDEV_DIR) is an input parameter.
b. Run the build_breakpad.sh script in the aosp-on-qemu/oneKey/
directory to install breakpad. ./build_breakpad.sh
$(YOUR_EMUMASTERDEV_DIR) //$(YOUR_EMUMASTERDEV_DIR) is an input
parameter.
4. Download the Qt 5.6.1 source code. URL:
http://download.qt.io/new_archive/qt/5.6/5.6.1/single/qt-
everywhere-opensource-src-5.6.1.tar.xz
5. Decompress the qt-everywhere-opensource-src-5.6.1.tar.xz
package. tar -xvJf qt-everywhere-opensource-src-5.6.1.tar.xz
6. Go to the qt-everywhere-opensource-src-5.6.1 directory. cd
qt-everywhere-opensource-src-5.6.1
7. Comment out line 68 in the
qtimageformats/src/3rdparty/libwebp/src/dsp/ dsp.h file. //#define
WEBP_USE_NEON
8. Run the configure command to generate Makefile. ./configure -v
-opensource -confirm-license -force-debug-info -release -no-rpath
-shared -nomake examples -nomake tests -no-strip -qt-xcb -c++std
c++11 -qt-pcre -no-glib
NO TICE
When Makefile is generated, the messages "Makefile:177: recipe for
target 'xxx' failed" and "make: *** [xxx] Error 1" are displayed.
This is normal.
9. Perform compilation and installation. make -j64 & make
install
10. Create the Qt dependency library directory. cd
$(YOUR_EMUMASTERDEV_DIR)/prebuilts/android-emulator-build mkdir -p
qt/linux-aarch64/plugins mkdir -p qt/linux-aarch64/lib mkdir -p
qt/linux-aarch64/bin mkdir -p qt/common/include cd qt/linux-aarch64
ln -sf ../common/include include
11. Copy Qt 5.6.1 to the prebuilts directory of the emulator. cd
$(YOUR_EMUMASTERDEV_DIR)/prebuilts/android-emulator-build cp -r
/usr/local/Qt-5.6.1/lib/* qt/linux-aarch64/lib/ cp -r
/usr/local/Qt-5.6.1/bin/* qt/linux-aarch64/bin/ cp -r
/usr/local/Qt-5.6.1/plugins/* qt/linux-aarch64/plugins/ cp -r
/usr/local/Qt-5.6.1/include/* qt/common/include/
Step 8 Compile the Mesa source code.
Apply the patch. The patch package is stored in the code repository
root directory:
aosp-on-qemu/patchForEmuMasterDev/0003_build_mesa.patch.
cd $(YOUR_EMUMASTERDEV_DIR)/external/qemu patch -p1 <
0003_build_mesa.patch ./android/scripts/build-mesa-deps.sh
./android/scripts/build-mesa.sh
Step 9 Compile the ANGLE source code.
1. Compile and install the Ninja tool.
a. Download the Ninja source code to the /root/ directory. URL:
https://github.com/ninja-build/ninja/archive/v1.7.2.tar.gz
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
8
2. Run the build-ANGLE.sh script. cd
$(YOUR_EMUMASTERDEV_DIR)/external/qemu/android/scripts/
./build-ANGLE.sh
3. After the execution is complete, roll back the ANGLE code. cd
/tmp/root-build-ANGLE-xxx/build-linux-aarch64/angle git reset
--hard c37c696b94bd7ddecc12a2c3192f5e48eae7842e ninja -C out/Debug
mkdir /home/angle cp -r
/tmp/root-build-ANGLE-xxx/build-linux-aarch64/angle/out/Debug/obj
/home/angle cp -r
/tmp/root-build-ANGLE-xxx/build-linux-aarch64/angle/out/Debug/lib
/home/angle cd
$(YOUR_EMUMASTERDEV_DIR)/external/qemu/android/scripts/
CA UTION
In the root-build-ANGLE-xxx command, root is the user name of the
compiler. Replace root based on the site requirements.
4. In the ANGLE script build-ANGLE.sh, add the following line under
run ninja - C out/Debug: cp -r /home/angle/*
$PKG_BUILD_DIR/out/Debug/
5. Run the build-ANGLE.sh script again. ./build-ANGLE.sh
Step 10 Apply the patch to the emulator code.
1. Find the emulator patch in the code repository root directory
aosp-on-qemu/ patchForEmuMasterDev.
2. Copy the patches to the qemu directory and apply them. cp
0001_emuMasterDev_qemu.patch $(YOUR_EMUMASTERDEV_DIR)/external/qemu
cp 0004_webview_FrameBuffer.patch
$(YOUR_EMUMASTERDEV_DIR)/external/qemu cd
$(YOUR_EMUMASTERDEV_DIR)/external/qemu git checkout. //Ensure that
the code is clean before the patches are applied. patch -p1 <
0001_emuMasterDev_qemu.patch patch -p1 <
0004_webview_FrameBuffer.patch
Step 11 Use the emulator to compile and generate objs, and copy the
content in the objs directory to the tools directory.
1. (Important) Set environment variables. export
LD_LIBRARY_PATH=$(YOUR_EMUMASTERDEV_DIR)/prebuilts/android-emulator-build/qt/linux-
aarch64/lib/
CA UTION
If the objs directory exists, the code has been compiled. Delete
the compilation information of other users. If the objs directory
does not exist, skip the following two commands.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
9
make clean rm -rf objs
– Compilation without a symbol table ./android/configure.sh make
-j64
– Compilation with a symbol table (easy for debugging)
./android/configure.sh --symbols make -j64
3. After the compilation is successful, copy the content in the
objs directory to the tools directory in the android-sdk-linux
directory. rm -rf $(YOUR_EMUMASTERDEV_DIR)/external/qemu/objs/build
cp -r $(YOUR_EMUMASTERDEV_DIR)/external/qemu/objs/*
$(ANDROID_SDK_LINUX_DIR)/tools/
Step 12 Compile the swt.jar source code and copy the compiled
swt.jar to the tools directory.
1. Create a temporary directory. mkdir -p
/home/$(YOUR_USER)/TEMP
2. Obtain the swt-build.sh script from aosp-on-qemu/oneKey/ in the
code repository root directory and save the script to the TEMP
directory. cd TEMP ./swt-build.sh //Run the script to build swt.jar
in TEMP/swt_dir/swt.jar.
3. Copy swt.jar to a specified directory. mkdir
$(ANDROID_SDK_LINUX_DIR)/tools/lib/aarch64 cp swt.jar
$(ANDROID_SDK_LINUX_DIR)/tools/lib/aarch64/
Step 13 Compile the mksdcard source code and copy the generated
mksdcard to the tools directory. cd
$(YOUR_EMUMASTERDEV_DIR)/sdk/emulator/mksdcard/src/source gcc -o
mksdcard mksdcard.c cp mksdcard
$(ANDROID_SDK_LINUX_DIR)/tools
Step 14 Replace the following four .so libraries: libicui18n.so,
libicui18n.so.52, libicui18n.so.52.1, and libpng12.so.0.
1. Obtain the icu-libpng12-build.sh script from
aosp-on-qemu/oneKey/ in the code repository root directory and save
the script to the TEMP directory. cd /home/$(YOUR_USER)/TEMP
./icu-libpng12-build.sh
2. Copy the libicui18n.so, libicui18n.so.52, and libicui18n.so.52.1
library files generated in build-dir/icu/source/lib to
$(ANDROID_SDK_LINUX_DIR)/ tools/lib64/qt/lib/. cp -r
build-dir/icu/source/lib/*
$(ANDROID_SDK_LINUX_DIR)/tools/lib64/qt/lib/
3. Copy a file in
build-dir/icu/source/libpng-1.2.50/.libs/libpng12.so.0 to $
(ANDROID_SDK_LINUX_DIR)/tools/lib64/. cp -r
build-dir/icu/source/libpng-1.2.50/.libs/*
$(ANDROID_SDK_LINUX_DIR)/tools/lib64/
Step 15 Copy the Android image package and .jar package.
Download the android-sdk-linux.tgz package applicable to x86 and
decompress it to the user directory (YOUR_USER).
URL:
http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
mkdir -p /home/$(YOUR_USER)/TEMP_DIR cd TEMP_DIR wget
http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz tar -xf
android-sdk_r24.4.1-linux.tgz
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
10
2.4.3 Building Components in the android-sdk-linux/platform- tools
Directory
Step 1 Copy the /aosp-on-qemu/adb_build directory in the code
repository to the specified directory and run the oneKey script. cp
-r adb_build $(PATH_TO_AS_YOU_LIKE) cd
$(PATH_TO_AS_YOU_LIKE)/adb_build sh oneKey.sh
Step 2 Copy the adb file in the /aosp-on-qemu/adb_build directory
of the code repository to the android-sdk-linux/platform-tools/
directory. cp adb android-sdk-linux/platform-tools/
----End
NO TE
2.5.1 Preparing the Compilation Environment Prepare an x86-based
Ubuntu 16.04.3 server for compiling the AOSP and related
components.
Step 1 Download Ubuntu 16.04.3 from the following website:
http://old-releases.ubuntu.com/releases/16.04.3/ubuntu-16.04.3-server-
amd64.iso
----End
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
11
Step 1 Download Android Studio
(android-studio-ide-183.5522156-linux.tar.gz) and decompress it to
the /home/$(YOUR_USER) directory. cd /home/$(YOUR_USER) tar xvf
android-studio-ide-183.5522156-linux.tar.gz cd
$(USER)/android-studio/bin ./studio.sh
Step 2 Download and adapt to Android SDK. Adapt to Android 7.0
(android-24). (Perform this step if Android 7.0 is used.)
a. Start Android Studio, choose File > Settings, and select
Appearance & Behavior > System Settings > Android SDK.
Then choose SDK Platforms, select Android 7.0 (Nougat), and click
OK to download.
b. On the Appearance & Behavior > System Settings >
Android SDK page, set Android SDK Location to a specified
directory, which is mentioned as (YOUR_ANDROID_SDK_LOCATION) in the
subsequent steps. There are the following files or folders:
android-stubs-src.jar, android.jar, build.prop, data,
framework.aidl, optional, sdk.properties, skins, source.properties,
templates, uiautomator.jar, and package.xml.
c. Copy the entire android-24 directory in the
YOUR_ANDROID_SDK_LOCATION/platforms/ directory to the android-
sdk-linux/platforms/ directory on the compilation server that uses
Huawei Kunpeng 920 processors.
Adapt to Android 9.0 (android-28). (Perform this step if Android
9.0 is used.)
a. Start Android Studio, choose File > Settings, choose
Appearance & Behavior > System Settings > Android SDK,
select SDK Platforms, select Android 9.0 (Pie), and click OK.
b. On the Appearance & Behavior > System Settings >
Android SDK page, set Android SDK Location to a specified
directory, which is mentioned as (YOUR_ANDROID_SDK_LOCATION) in the
subsequent steps. There are the following files or folders:
android-stubs-src.jar, android.jar, build.prop, data,
framework.aidl, optional, sdk.properties, skins, source.properties,
templates, uiautomator.jar, and package.xml.
c. Copy the entire android-28 directory in the
YOUR_ANDROID_SDK_LOCATION/platforms/ directory to the android-
sdk-linux/platforms/ directory on the server that uses Huawei
Kunpeng 920 processors.
Step 3 Compile the Android kernel.
1. Download ndk. URL:
https://developer.android.google.cn/ndk/downloads/
older_releases.html
2. Download android-ndk-r16b-linux-x86_64.zip and decompress it to
(YOUR_DIR)/android-ndk-r16b. mkdir -p
/home/$(YOUR_DIR)/AndroidToolChain/arm64 cd
/home/$(YOUR_DIR)/android-ndk-r16b/
./build/tools/make_standalone_toolchain.py --arch arm64 --api 24
--install /home/$(YOUR_DIR)/ AndroidToolChain/arm64 --force
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
12
3. Download the Android kernel source code. mkdir -p
/home/$(YOUR_KERNEL) cd /home/$(YOUR_KERNEL) git clone
https://android.googlesource.com/kernel/goldfish cd goldfishgit
checkout android-goldfish-4.4-dev
4. Ensure that the branch is used. The patch will be applied based
on this branch: f4355abac45a608dbe0e7d87fd50c349b90d6928. git
checkout f4355abac45a608dbe0e7d87fd50c349b90d6928
NO TE
If the processor model of CPU 1 is Huawei Kunpeng 920, go to Step
3.5. If the processor model of CPU 1 is Huawei Kunpeng 916, go to
Step 3.6.
5. Apply the patch for the 32-bit transcoding kernel.
Copy the patch file (aosp-on-qemu/patchForExagear/aosp7_r35/kernel/
goldfish-4.4-dev.patch) to /home/$(YOUR_KERNEL)/goldfish/ and apply
the patch. cp -r goldfish-4.4-dev.patch
/home/$(YOUR_KERNEL)/goldfish/ cd /home/$(YOUR_KERNEL)/goldfish/
patch -p1 -m < goldfish-4.4-dev.patch //Install the 32-bit
transcoding patch.
6. Compile the kernel. make ranchu64_defconfig make -j64
7. Copy the kernel binary file. cd arch/arm64/boot
The Image file is the required Android kernel. Rename it
kernel-ranchu and copy it to the operating environment.
8. Create a directory for storing the image in the
android-sdk-linux directory in the Kunpeng compilation
environment.
NO TICE
– Perform the following operations for Android 7.0: cd
$(ANDROID_SDK_LINUX_DIR) mkdir -p
system-images/android-24/default/arm64-v8a
Save kernel-ranchu to the $(ANDROID-SDK-LINUX_DIR)/system-
images/android-24/default/arm64-v8a directory.
– Perform the following operations for Android 9.0: cd
$(ANDROID_SDK_LINUX_DIR) mkdir -p
system-images/android-28/default/arm64-v8a
Save kernel-ranchu to the $(ANDROID-SDK-LINUX_DIR)/system-
images/android-28/default/arm64-v8a directory.
----End
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
13
2.5.3 Building Components in the android-sdk-linux/system- images
Directory
2.5.3.1 Building the system-images Directory of
aosp-7.0.0_r35
This section describes how to build the system-images directory for
Android 7.0. For details about how to build the system-images
directory for Android 9.0, see 2.5.3.2 Building the system-images
Directory of aosp9.0.0_r10.
Step 1 Download the Repo tool and ensure that it is executable.
mkdir ~/bin PATH=~/bin:$PATH curl
https://storage.googleapis.com/git-repo-downloads/repo >
~/bin/repo chmod a+x ~/bin/repo
Step 2 Download the AOSP source code (android-7.0.0_r35). mkdir -p
/home/$(AOSP_DIR) cd /home/$(AOSP_DIR) repo init -u
https://android.googlesource.com/platform/manifest -b
android-7.0.0_r35 repo sync
Step 3 Copy the aosp-on-qemu/binaryAndFiles/snapshot_aosp7_B630.xml
snapshot file in the code repository root directory to the
.repo/manifests/ directory to roll back the code of all Git
repositories of AOSP 7.0. cp snapshot_aosp7_B630.xml
/home/$(AOSP_DIR)/.repo/manifests/ cd /home/$(AOSP_DIR) repo init
-m snapshot_aosp7_B630.xml repo sync -d -j32 cd /home/$(AOSP_DIR)
source build/envsetup.sh lunch aosp_arm64-eng
NO TE
The execution of the preceding repo commands may fail because the
upgraded Repo version does not match the Python version. Use a soft
link or specify a proper Python version.
In the preceding repo commands, the code may fail to be obtained
because the user name and email address are not set for Git.
Configure Git before using it.
Step 4 Modify the patch file.
Patch location:
aosp-on-qemu/patchForAosp7.0.0r35/0002_framework_wifi.patch
1. In lines 253 to 258, set the accessible network parameters
(including info.ipAddress, info.netmask, info.gateway, info.dns,
which respectively indicate the IP address, mask, gateway, and
DNS). That is, change xx.xx.xx.xx in each line to the corresponding
parameter value.
The values of info.serverAddress and info.ipAddress must be the
same.
2. Change XX: XX: XX: XX: XX: XX in line 132 to any MAC
address.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
14
Step 5 Apply the AOSP 7.0 patches.
Patch location: aosp-on-qemu/patchForAosp7.0.0r35/
patch -p1 <0001_patchForAosp7r35.patch patch -p1
<0002_framework_wifi.patch
NO TE
If the processor model of CPU 1 is Huawei Kunpeng 920, go to Step
6. If the processor model of CPU 1 is Huawei Kunpeng 916, go to
Step 7.
Step 6 Apply the transcoding patch.
1. Obtain the transcoding patch file from
aosp-on-qemu/patchForExagear/
aosp7_r35/android/android-7.0.0_r35.patch and apply
android-7.0.0_r35.patch. cp -r android-7.0.0_r35.patch
/home/$(AOSP_DIR) cd /home/$(AOSP_DIR) patch -p1 <
android-7.0.0_r35.patch
2. Copy aosp-on-qemu/patchForExagear/aosp7_r35/android/vendor to $
(AOSP_DIR). cp -r
aosp-on-qemu/patchForExagear/aosp7_r35/android/vendor
/home/$(AOSP_DIR)
3. Contact Huawei frontline engineers to obtain the ExaGear_ARM32-
ARM64_V1.5.tar.gz patch at
https://support.huawei.com/enterprise/en/
kunpeng-computing/kunpeng-computing-media-pid-251431619/
software/253129399/?idAbsPath=fixnode01|23710424|251364417|
9856629|251431619
4. Decompress the transcoding binary package and copy ubt_a32a64 to
$ (AOSP_DIR)/vender/huawei/exagear/prebuilts/. tar zxvf
ExaGear_ARM32-ARM64_V1.5.tar.gz cp -r
ExaGear_ARM32-ARM64_V1.5/ExaGear_ARM32-ARM64_V1.5/ubt_a32a64
/home/$(AOSP_DIR)/ vender/huawei/exagear/prebuilts/
Step 7 Compile the aosp-7.0.0_r35 image. cd /home/$(AOSP_DIR) make
clean make -j64
After the compilation is successful, the following four .img files
are generated in $
(AOSP_DIR)/out/target/product/generic_arm64:
cache.img, ramdisk.img, system.img, and userdata.img
Step 8 Create the system-images directory and copy the .img
files.
1. Copy the four .img files (cache.img, ramdisk.img, system.img,
and userdata.img) compiled on the x86 server to the $
(ANDROID_SDK_LINUX_DIR)/system-images/android-24/default/arm64-
v8a/ directory on the Kunpeng 920 server.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
15
----End
2.5.3.2 Building the system-images Directory of aosp9.0.0_r10
This section describes how to build the system-images directory for
Android 9.0. For details about how to build the system-images
directory for Android 7.0, see 2.5.3.1 Building the system-images
Directory of aosp-7.0.0_r35.
Step 1 Download the Repo tool and ensure that it is executable.
mkdir ~/bin PATH=~/bin:$PATH curl
https://storage.googleapis.com/git-repo-downloads/repo >
~/bin/repo chmod a+x ~/bin/repo
Step 2 Download and compile the AOSP source code
(android-9.0.0_r10).
1. In the AOSP9.0SOURCE directory, download the AOSP source code of
the android-9.0.0_r10 version. repo init -u
https://android.googlesource.com/platform/manifest -b
android-9.0.0_r10 repo sync
2. Copy the aosp-on-qemu/binaryAndFiles/snapshot_aosp9_B630.xml
snapshot file in the code repository root directory to the
.repo/manifests/ directory to roll back the code of all Git
repositories of AOSP 9.0. cp snapshot_aosp9_B630.xml
/home/$(AOSP_DIR)/.repo/manifests/ cd /home/$(AOSP_DIR) repo init
-m snapshot_aosp9_B630.xml repo sync -d -j32
NO TE
– The execution of the preceding repo commands may fail because the
upgraded Repo version does not match the Python version. Use a soft
link or specify a proper Python version.
– In the preceding repo commands, the code may fail to be obtained
because the user name and email address are not set for Git.
Configure Git before using it.
3. Modify the patch file. Patch location: aosp-on-qemu/
patchForAosp9.0.0r10/0002_framework_wifi.patch
a. Change XX: XX: XX: XX: XX: XX in line 91 to any MAC
address.
b. In line 124, change the Wi-Fi IP address XX.XX.XX.XX to an
accessible IP address that is not in use.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
16
c. Change XX: XX: XX: XX: XX: XX in line 146 to the MAC address in
line 103.
d. In lines 315 to 320, set the accessible network parameters
(including info.ipAddress, info.netmask, info.gateway, info.dns,
which respectively indicate the IP address, mask, gateway, and
DNS). That is, change xx.xx.xx.xx in each line to the corresponding
parameter value.
The value of info.ipAddress must be the same as that in line 138,
and the same as the value of info.serverAddress.
4. Apply AOSP 9.0 patches (totally seven patches). Patch location:
aosp-on-qemu/patchForAosp9.0.0r10/ Patch list: –
0001_ril_network_and_adb_forward.patch – 0002_frameworks_wifi.patch
– 0003_frameworks_telephony.patch – 0004_native_gles.patch –
0005_system_core_sdcard.patch – 0006_frameworks_content.patch –
0007_system_settings.patch
a. Go to the AOSP 9.0 source code directory. cd AOSP9.0SOURCE
b. Install all patches. (The following command use
0001_ril_network_and_adb_forward.patch as an example.) patch -p1
< 0001_ril_network_and_adb_forward.patch
NO TE
If the processor model of CPU 1 is Huawei Kunpeng 920, go to Step
2.5. If the processor model of CPU 1 is Huawei Kunpeng 916, go to
Step 2.6.
5. Apply the transcoding patch.
a. Obtain the transcoding patch file from
aosp-on-qemu/patchForExagear/
aosp9_r10/android/android-9.0.0_r10.patch and apply
android-9.0.0_r10.patch. cp -r android-9.0.0_r10.patch
AOSP9.0SOURCE cd AOSP9.0SOURCE patch -p1 <
android-9.0.0_r10.patch
b. Copy the aosp-on-qemu/patchForExagear/aosp9_r10/android/vendor
directory to the AOSP9.0SOURCE directory. cp -r
aosp-on-qemu/patchForExagear/aosp9_r10/android/vendor
AOSP9.0SOURCE
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
17
c. Contact Huawei frontline engineers to obtain the ExaGear_ARM32-
ARM64_V1.5.tar.gz patch at https://support.huawei.com/
enterprise/en/kunpeng-computing/kunpeng-computing-media-
pid-251431619/software/253129399/?idAbsPath=fixnode01|23710424|
251364417|9856629|251431619
d. Decompress the transcoding binary package and copy ubt_a32a64 to
AOSP9.0SOURCE/vender/huawei/exagear/prebuilts/: tar zxvf
ExaGear_ARM32-ARM64_V1.5.tar.gz cp -r
ExaGear_ARM32-ARM64_V1.5/ExaGear_ARM32-ARM64_V1.5/ubt_a32a64
AOSP9.0SOURCE/ vender/huawei/exagear/prebuilts/
6. Compile the AOSP. source build/envsetup.sh lunch aosp_arm64-eng
make clean make -j32
Step 3 Modify and copy image files.
1. Create the system-images/android-28/default/arm64-v8a directory
in the android-sdk-linux directory in the Kunpeng compilation
environment.
2. After the compilation is successful, copy the six .img files
(system-qemu.img, userdata.img, ramdisk.img, cache.img, vbmeta.img,
and vendor- qemu.img) newly generated in
/home/$(AOSP_DIR)/out/target/product/ generic_arm64 and the
advancedFeatures.ini file to the directory created in 1..
3. Copy the aosp-on-qemu/patchForEmuMasterDev/source.properties
file in the code repository to the directory created in 1.. In
addition, copy the Android kernel file kernel-ranchu compiled in
3.7 in 2.5.2 Building Components in the android-sdk-linux/platforms
Directory to this directory.
4. Modify the following contents in the source.properties file:
Pkg.Revision=7 ---> Pkg.Revision=9 AndroidVersion.ApiLevel=24
---> AndroidVersion.ApiLevel=28
5. Change the names of the vendor-qemu.img and system-qemu.img
files. mv system-qemu.img system.img mv vendor-qemu.img
vendor.img
----End
NO TICE
Build the strace binary file when the processor model of CPU 1 is
Huawei Kunpeng 920.
strace is a Linux user space tracker that can be used for
diagnosis, debugging, and teaching. When the Android Virtual Device
(AVD) is running on the Kunpeng 920, if a 32-bit application is
running and strace is used to trace the process, the system call
cannot be properly displayed, as shown in the following figure. If
you need to use the strace tracing process, rebuild the strace
file.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
18
2.5.4.1 Obtaining the strace File Compile the strace binary file.
For details about the compilation method, see Kunpeng BoostKit for
ARM Native FAQs.
2.5.4.2 Replacing the strace File When an exception occurs in the
system call of the strace tracing process, compile the strace
binary to replace the current strace file.
The procedure is as follows:
Step 1 Upload the strace binary file to the directory of the
running server. For example, the /home directory. cd /home
Step 2 Run the adb command to copy the strace binary file to the
current AVD to replace the strace file in /system/bin/. The
following uses emulator-5554 as an example. adb -s emulator-5554
shell remount adb -s emulator-5554 push strace /system/bin/
----End
2.5.4.3 Verification
Step 1 Install the 32-bit APK in the AVD whose strace binary has
been replaced. The following describes how to install the TikTok in
emulator-5554. adb -s emulator-5554 install --abi armeabi-v7a
com.ss.android.ugc.aweme.apk
Step 2 Run the TikTok and run the adb command to view the progress
number. adb -s emulator-5554 shell ps -ef
Step 3 Run the strace command to trace the running status. strace
-p 12646
The following figure shows the running status. The name of the
system call function can be displayed normally.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
19
2.6 Preparing the Target Arm Running Environment
2.6.1 Building the AVD Environment on the Kunpeng Server Package $(
ANDROID_SDK_LINUX_DIR) on the Kunpeng compilation environment and
send it to the server where the other Huawei Kunpeng processor is
located. For details about how to set up the environment, see AVD
Installation Guide (Ubuntu 18.04.1).
CA UTION
The models of the processors on the two Kunpeng servers must be the
same. AVD Installation Guide (Ubuntu 18.04.1) is only a reference
for establishing
the AVD environment based on Huawei Kunpeng processors. The
software provided in this document is non-commercial standard
software. Do not use it for commercial purposes. You shall assume
any liability for any loss caused by using this document as a
commercial deliverable without permission. Huawei has the right to
claim compensation for any loss caused to Huawei.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 2 AVD Compilation Guide
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
20
3.1 Introduction
3.6 Running and Verifying the AVD
3.1 Introduction The Android virtual device (AVD) is the Android
emulator that runs the Android OS on a server. With the AVD, you
can design, develop, and test Android applications without using
real mobile phones.
The AVD provides basic functions, such as running Android
applications, connection by using the Android debug bridge (ADB),
access to the Internet, screen display, GPS positioning, battery
information display, and remote connection by using the virtual
network console (VNC).
3.2 Usage Statement 1. Before setting up and deploying the
environment, read the AVD Security
Description carefully to ensure that the security risks of the
solution are acceptable.
2. The OS on the host side is not within the delivery scope of this
solution. Therefore, security hardening measures related to the OS
need to be implemented by the customer or independent software
vendor (ISV). This document does not provide related
description.
3. To quickly deploy the AVD, the scripts mentioned in this
document are run by the root user by default. The script files
provided by the AVD are for reference only, and no commercial
commitment is made. To avoid OS security risks, it is recommended
that customers or ISVs implement defense measures such as
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
21
file access control and minimum authorization in commercial
deployment scenarios.
3.3 Environment Requirements
Table 3-1 Hardware requirements
Item Description
Server TaiShan 100 server (model 2280 powered by Huawei Kunpeng 916
processors) or TaiShan 200 server (model 2280 powered by Huawei
Kunpeng 920 processors)
GPU GPU card
PCIe riser card
NO TE
Determine whether to configure the GPU based on the service type.
If the application does not have strong requirements for rendering
(such as background computing services, services without UI
interaction, and non-game services), you can use CPUs for
rendering.
Typical Configuration
Table 3-2 Typical configuration for an AVD on a server
Item CPU Memory Internal Storage
SD Card
Recommen ded Configurati on
2 cores 4 GB 4 GB 4 GB (adjustable based on the size of the
APK)
Table 3-3 Typical configuration for an 80-socket server (only for
the Kunpeng 920)
Item CPU Memory Drive BIOS Version
Recomme nded Configura tion
128 cores 512 GB 2 TB TS200-2180_2280_5280_BIOS_ V163
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
22
OS Requirements
NO TE
If the Ubuntu OS is not installed, download and install the Ubuntu
image.
When selecting the software during the OS installation process,
select only OpenSSH server. For details, contact Huawei
engineers.
Table 3-4 Version requirements (only for the Kunpeng 920)
Item Version
NO TE
In this BIOS version, the memory of a single CPU cannot exceed 256
GB.
Use the Computing Product Memory Configuration Assistant to
configure the memory.
Load the BIOS version during the BMC firmware upgrade. After the
upgrade is complete, choose Advanced > MISC Config in the BIOS
setup, and set Support Smmu to Disable and Support 40Bit to
Enable.
Tools 1. Install remote tools such as MobaXterm
(recommended).
2. Install VNC Viewer
Software Packages
Before setting up the AVD environment, download the software
package source code and dependencies listed in Table 3-5.
Table 3-5 Software packages
Contains Xfce4 desktop environment, Java runtime environment, and
numactl tool required for running the AVD.
Log in to the server as the root user in SSH mode and run the
following command on the CLI: apt-get install xfce4 numactl
openjdk-8-jdk xrdp
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
23
Description How to Obtain
GPU driver dependen cies
GPU rendering dependency tools.
Log in to the server as the root user in SSH mode and run the
following command on the CLI: apt-get install mesa-utils x11vnc
vainfo apt-get install libglvnd-dev
Android SDK image package
Used to set up Android SDK. For Android 7.0, obtain the Android SDK
image package as follows: Kunpeng 920: android-sdk-
linux_920.tar.gz Kunpeng 916: android-sdk- linux_916.tar.gz Test
SDK image package of Android 9.0 for Kunpeng 920 compilation
environment: android-sdk-9-linux_920 NOTE
The binary packages available at the Kunpeng mirror site are
compiled and packaged based on the open source code, and do not
involve vulnerability or bug fixes.
When using open source software, comply with the applicable license
agreements.
3.4 Configuring the Installation Environment
3.4.1 Modifying the Maximum Number of Files Accessed Step 1 Log in
to the server CLI by using SSH as the root user.
Step 2 Open the configuration file. vi
/etc/security/limits.conf
Step 3 Modify the maximum number of files that can be opened.
Add the following four lines to the file:
root soft nofile 65535 root hard nofile 65535 * soft nofile 65535 *
hard nofile 65535
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
24
----End
3.4.2 Configuring the SSH Service Step 1 Use the iBMC KVM to log in
to the CLI of the target server as the root user.
Step 2 In the /etc/ssh/sshd_config file, change #PermitRootLogin
prohibit-password to PermitRootLogin yes. sed -i
"s/#PermitRootLogin prohibit-password / PermitRootLogin yes/g"
/etc/ssh/sshd_config
The changed content is shown in the following figure.
Step 3 Restart the SSH service. systemctl restart sshd
The SSH service is configured. You can use SSH to connect to this
server.
----End
Procedure NO TE
You need to use a remote tool, such as MobaXterm, to connect to the
server using SSH.
Step 1 If the server is configured with the SSH service, use SSH to
log in to the server CLI as the root user.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
25
Step 2 In the /etc/apt/sources.list, delete the comment tag (#)
from each # deb-src line in /etc/apt/sources.list.
Run the following command:
The file after modification is as follows:
Step 3 Update the Advanced Packaging Tools (APT). apt-get
update
Wait until the update is complete.
----End
3.5 Setting Up Android SDK
Prerequisites You have obtained the Android SDK image package and
uploaded it to the /home directory on the server using MobaXterm.
For details about how to obtain the Android SDK image package, see
Software Packages.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
26
Procedure
Step 1 Log in to the server CLI by using SSH as the root
user.
Step 2 Switch to the /home directory where the Android SDK image
package is stored. cd /home
Step 3 Decompress the Android SDK image package. tar xvf
android-sdk-linux.tar.gz
NO TE
Step 4 Open the /etc/profile file. vi /etc/profile
Step 5 Add the environment variables required for running the AVD
to the configuration file. export
ANDROID_SDK_ROOT=/home/android-sdk-linux export
LD_LIBRARY_PATH=${ANDROID_SDK_ROOT}/tools/lib64/qt export
QT_QPA_PLATFORM_PLUGIN_PATH=${LD_LIBRARY_PATH}/plugins/platforms
export
PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools
The file after modification is as follows:
NO TICE
ANDROID_SDK_ROOT specifies the Android SDK directory, which must be
the same as the actual directory.
Step 6 Press Esc, enter :wq!, and press Enter to save the file and
exit.
Step 7 Add the following content to the ~/.bashrc file for the
environment variables to take effect: echo "source /etc/profile"
>> ~/.bashrc
----End
3.6 Running and Verifying the AVD
3.6.1 Before You Start (GPU) If GPUs are used, you need to install
the GPU driver before running the AVD. You can contact Huawei
frontline engineers to obtain the AMD driver setup
documentation.
3.6.2 Creating and Running AVD Using the CLI
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
27
3.6.2.1 Starting the Desktop Service
Starting the Remote Desktop Service
Step 1 Log in to the server CLI by using SSH as the root
user.
Step 2 Start the desktop service. If the GPU is configured, run the
startx command to start the desktop service.
Information similar to the following is displayed:
If no GPU is configured (CPUs are used for rendering), run the
startx -- :0 - config /etc/X11/xrdp/xorg.conf command to start the
desktop service. Information similar to the following is
displayed:
Step 3 Open a new CLI and log in to the server using SSH as the
root user.
Step 4 Start the x11vnc service.
Run the following commands:
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
28
export DISPLAY=:0 x11vnc
The operation is successful if the VNC port number 5900 is
displayed.
Set the DISPLAY environment variable to the port number of Xorg
that you start. Generally, the port number is 0 when Xorg is
started for the first time. You can run the ps -ef | grep Xorg
command to check the port number.
----End
Connecting to a Remote Desktop from a Local PC
Step 1 Open VNC Viewer on the local PC.
Step 2 Enter the IP address and port number of the server and press
Enter. (In the following example, XX.XX.XX.XX stands for the IP
address.)
The remote desktop of the server is displayed.
----End
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
29
3.6.2.2 Creating an AVD You can create an AVD using a desktop
service or using the Shell command line.
Creating an AVD Using a Desktop Service
Step 1 Right-click on the VNC remote desktop and choose Open
Terminal Here to start the terminal simulation tool.
Step 2 Run the android avd command to open the AVD Manager.
Step 3 Create an AVD.
Click Create and select the device type (resolution), version,
architecture, skin, memory size, and SD card size as required, and
click OK.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
30
----End
Creating an AVD Using the Shell CLI Step 1 Log in to the server CLI
by using SSH as the root user.
Step 2 Run the following command to create an AVD: Create an AVD
for Android 7.0.
android create avd --name test_2 --target android-24 --abi
arm64-v8a --device "Nexus 4" --skin 720x1280 --sdcard 500M
--force
Create an AVD for Android 9.0. android create avd --name test_2
--target android-28 --abi arm64-v8a --device "Nexus 4" --skin
720x1280 --sdcard 500M --force
Step 3 Query the AVD created. android list avd
Information about the AVD created is displayed as follows:
----End
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
31
3.6.2.3 Starting an AVD You can start an AVD using a desktop
service or using the Shell command line.
Starting an AVD Using a Desktop Service
Step 1 On the x11vnc desktop, right-click and choose Open Terminal
Here from the shortcut menu.
Step 2 Run the following command to start the AVD: If GPUs are
configured, run the following command:
emulator -avd test_1 -no-window -cores 2 -writable-system -gpu host
-qemu --enable-kvm -m 1024 - vnc :1
If no GPU is configured, run the following command: emulator -avd
test_1 -no-window -cores 2 -writable-system -gpu mesa -qemu
--enable-kvm -m 1024 -vnc :1
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
32
Table 3-6 emulator command parameters
Parameter Description
-no-window Do not start the emulator on the desktop.
-cores Specifies the number of CPUs of the emulator to be
started.
-writable- system
-gpu host Enables the hardware GPU for rendering.
-gpu mesa Enables software rendering in the CPU.
-qemu Transmits parameters to QEMU.
--enable- kvm
Enables KVM.
-vnc Uses VNC to connect to the emulator.
For details about other parameters, run emulator –help.
Step 3 Open VNC Viewer on the local PC and enter IP address of the
service port:5901, as shown in the following figure.
Step 4 Click Continue. If the following page is displayed, the AVD
is started successfully.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
33
----End
Starting an AVD Using the Shell CLI Step 1 Log in to the server CLI
by using SSH as the root user.
Step 2 Set the DISPLAY environment variable. export
DISPLAY=:0
Set the DISPLAY environment variable to the port number of Xorg
that you start. Generally, the port number is 0 when Xorg is
started for the first time. You can run the ps -ef | grep Xorg
command to check the port number.
Step 3 Start the AVD. If GPUs are configured, run the following
command:
emulator -avd test_2 -no-window -cores 2 -writable-system -gpu host
-qemu --enable-kvm -m 1024 - vnc :2
If no GPU is configured, run the following command: emulator -avd
test_2 -no-window -cores 2 -writable-system -gpu mesa -qemu
--enable-kvm -m 1024 -vnc :2
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
34
Step 4 Open VNC Viewer on the local PC and enter IP address of the
service port:5902, as shown in the following figure.
Step 5 Click Continue. If the following page is displayed, the AVD
is started successfully.
----End
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
35
3.6.2.4 Improving AVD Performance
To improve the AVD performance, you need to add the numactl
parameter before the startup parameter to bind the CPU and memory
to the same memory node. Example:
numactl -N 0 -m 0 emulator -avd test_2 -no-window -cores 2
-writable-system -gpu host -qemu --enable- kvm -m 1024 -vnc
:2
To limit the AVD to specific cores, run the following
command:
numactl -C 0-7 -m 0 emulator -avd test_2 -no-window -cores 2
-writable-system -gpu host -qemu --enable- kvm -m 1024 -vnc
:2
The numactl parameters include:
-N: binds CPU nodes.
-m: binds memory nodes.
-C: binds CPU cores.
You can run the numactl --show command to query the NUMA
information of the current system.
In this example, there are four NUMA nodes and 64 cores in total.
Each CPU node has 16 cores.
numactl -N 0 -m 0 binds the program to CPU node 0 and memory node
0. numactl -C 0-7 -m 0 binds the program to cores 0 to 7 and bind
the memory
to mem node 0. In this case, the program can use a maximum of eight
cores.
3.6.3 Creating and Running AVDs in Batches by Using a Script
3.6.3.1 Batch Starting AVDs with the start_qemu.sh Script
Huawei provides the start_qemu.sh script for starting AVDs in
batches. (The example script applies to the AMD GPU scenario and is
for reference only.)
Step 1 Obtain the script from the following URL:
https://code.opensource.huaweicloud.com/Kunpeng/Native/files?
ref=master&tab=content&filePath=aosp-on-qemu%2FrefForStartQemuScripts
%2Fstart_qemu.sh&isFile=true
Step 2 Modify the script based on the site requirements.
This script is used by Android 9.0 by default. To start Android
7.0, change android-28 in the VM creation command in line 188 to
android-24.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
36
Step 3 Start AVDs. Start a single AVD.
Enter the VNC number of the AVD to be started when running
start_qemu.sh. Example: ./start_qemu.sh 1
Run the following command to view the running AVD process. The VNC
number is the specified number. ps -aux | grep qemu
Start multiple AVDs. Enter the start and end VNC numbers of the
AVDs to be started when running start_qemu.sh. Example:
./start_qemu.sh 4 7
You can also run the following command to view the started AVD
processes: ps -aux | grep qemu
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
37
----End
Step 1 Open the AVD resolution configuration file out.config in the
Android image directory. vi
/root/android-sdk-linux/system-images/android-24/default/arm64-v8a/out.config
Step 2 Change the resolution.
Modify the values of wxh and dpi to change the AVD
resolution.
For example, to change the resolution to 720p, modify the values as
follows: wxh = 720 x 1280, dpi = 320
For example, to change the resolution to 1080p, modify the values
as follows: wxh = 1080 x 1920, dpi = 320
NO TE
If there is no special requirement for the resolution, a smaller
resolution is recommended to reduce resource consumption.
Step 3 Press Esc, type :wq!, and press Enter to save the file and
exit.
Step 4 Create the AVD again for the modification to take
effect.
----End
3.6.3.3 Deleting an AVD In principle, you do not need to manually
delete the AVD. The newly created AVD automatically overwrites the
old one. ANDROID_AVD_HOME is the directory in which the AVD is
stored. You can delete the AVD from the directory. You can also
change the AVD creation directory to another directory.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
38
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 3 AVD Installation Guide (Ubuntu 18.04)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
39
4 AVD Installation Guide (CentOS 7.6)
4.1 Introduction
4.7 Running and Verifying the AVD
4.1 Introduction The Android virtual device (AVD) is the Android
emulator that runs the Android OS on a server. With the AVD, you
can design, develop, and test Android applications without using
real mobile phones. The AVD provides basic functions, such as
running Android applications, connection by using the Android debug
bridge (ADB), access to the Internet, screen display, GPS
positioning, battery information display, and remote connection by
using the virtual network console (VNC).
This document describes how to set up the AVD running environment
on the TaiShan server running CentOS 7.6.
4.2 Usage Statement 1. Before setting up and deploying the
environment, read the AVD Security
Description carefully to ensure that the security risks of the
solution are acceptable.
2. The OS on the host side is not within the delivery scope of this
solution. Therefore, security hardening measures related to the OS
need to be implemented by the customer or independent software
vendor (ISV). This document does not provide related
description.
3. To quickly deploy the AVD, the scripts mentioned in this
document are run by the root user by default. The script files
provided by the AVD are for reference
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
40
only, and no commercial commitment is made. To avoid OS security
risks, it is recommended that customers or ISVs implement defense
measures such as file access control and minimum authorization in
commercial deployment scenarios.
4.3 Environment Requirements
Table 4-1 Hardware requirements
Processor Kunpeng 920 4826
NO TE
Determine whether to configure a GPU based on the service type. If
the application does not have strong requirements for rendering
(such as background computing services, services without UI
interaction, and non-game services), you do not need to use a GPU.
In such cases, CPUs can meet rendering requirements.
Typical Configuration
Table 4-2 Typical configuration for an AVD on a server
Item CPU Memory Internal Storage
SD Card
Recommen ded Configurati on
2 cores 4 GB 4 GB 4 GB (adjusted based on the size of the
APK)
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
41
Table 4-3 Typical configuration for 80 AVDs on a server
Item CPU Memory Drive BIOS Version
Recomme nded Configura tion
OS Requirements OS: CentOS 7.6
NO TE
If the CentOS OS is not installed, download and install the CentOS
image. When selecting the software during the OS installation
process, select only Server with GUI and Development Tools only.
For details, contact Huawei engineers.
Table 4-4 Version requirements
NO TE
1. In this BIOS version, the memory of a single CPU cannot exceed
256 GB. 2. Use the Computing Product Memory Configuration Assistant
to configure the
memory. 3. Load the BIOS version during the BMC firmware upgrade.
After the upgrade is complete,
choose Advanced > MISC Config in the BIOS setup, and set Support
Smmu to Disable and Support 40Bit to Enable.
Tools 1. Xshell or MobaXterm (recommended) 2. VNC Viewer
Software Packages Before setting up the AVD environment, download
the software package source code and dependencies listed in Table
4-5.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
42
Usage How to Obtain
Android SDK image package
Used to set up Android SDK. Test SDK image package of Android 9.0
for Kunpeng 920 compilation environment: android-sdk-9-linux_920
NOTE
The binary package available at the Kunpeng mirror site is compiled
and packaged based on the open source code. It does not contain
vulnerabilities or bugs.
When using open source software, comply with the applicable license
agreements.
4.4 Configuring the Installation Environment
4.4.1 Modifying the Maximum Number of Files Accessed Step 1 Log in
to the server CLI by using SSH as the root user.
Step 2 Open the configuration file. vi
/etc/security/limits.conf
Step 3 Modify the maximum number of files that can be opened.
Add the following four lines to the file:
root soft nofile 65535 root hard nofile 65535 * soft nofile 65535 *
hard nofile 65535
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
43
----End
4.4.2 Configuring the SSH Service Step 1 Use the iBMC KVM to log in
to the CLI of the target server as the root user.
Step 2 In the /etc/ssh/sshd_config file, delete the comment tag (#)
from #PermitRootLogin yes.
The changed content is shown in the following figure.
Step 3 Restart the SSH service. systemctl restart sshd
----End
CA UTION
If the system time is inconsistent with the actual time, the GNU
Compiler Collection (GCC) repeats compilation cyclically and cannot
exit normally.
Step 1 View the local system time. date
Step 2 View the hardware time. hwclock --show
NO TICE
If the local system time and hardware time are the same as the
actual time, you do not need to perform the following steps.
Otherwise, go to Step 3.
Step 3 Set the hardware time. hwclock --set --date '2020-11-26
16:14:40'
Step 4 Configure synchronization between the local system time and
hardware time. hwclock --hctosys
Step 5 Save the clock. clock -w
Step 6 Restart the system for the modification to take effect.
reboot
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
44
Step 7 Check whether the modification is successful.
Run the following commands to view the local system time and
hardware time:
date hwclock --show
Prerequisites
CA UTION
Use the default Yum source. Otherwise, the AVD may fail to
start.
Procedure NO TE
You need to use a remote tool, such as MobaXterm, to connect to the
server using SSH.
Step 1 If the server is configured with the SSH service, use SSH to
log in to the server CLI as the root user.
Step 2 Update the local Yum cache. yum clean all yum
makecache
Wait until the update is complete.
----End
4.5 Configuring the Operating Environment
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
45
4.5.1 Preinstalling Compilation Dependencies Install basic software
libraries for subsequent compilation.
yum -y install xorg-x11-util-macros xorg-x11-drv* llvm-devel
lm_sensors-devel wayland-protocols-devel libva-devel
mesa-libgbm-devel yum -y install openssl-libs.aarch64 bzip2 numactl
libffi-devel zlib-devel.aarch64 libdrm-devel.aarch64 m4.aarch64 yum
-y install glx-utils freeglut-devel libva-devel.aarch64
expat-devel.aarch64 libxshmfence-devel.aarch64 libXrandr-devel
elfutils-libelf-devel
4.5.2 Upgrading GCC The setup of the AVD running environment
depends on GCC 5.5 or later. If the GCC version is earlier than
5.5, the mesa compilation will fail. If the used GCC version is GCC
5.5 or later, skip this section.
Step 1 Check the GCC version. gcc --version
Step 2 Download the GCC source code. mkdir gcc_src cd gcc_src/ wget
http://mirror.hust.edu.cn/gnu/gcc/gcc-5.5.0/gcc-5.5.0.tar.xz tar xf
gcc-5.5.0.tar.xz
Step 3 Download precompilation dependencies. cd gcc-5.5.0/
./contrib/download_prerequisites
Step 4 Compile GCC. cd .. mkdir -p gcc_build-5.5.0 cd
gcc_build-5.5.0/ ../gcc-5.5.0/configure --enable-checking=release
--enable-languages=c,c++ --disable-multilib --prefix=/usr make -j64
make install
Step 5 Check the GCC version.
----End
4.5.3 Installing OpenSSL Step 1 Download the OpenSSL source
code.
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz tar -zxvf
openssl-1.1.1a.tar.gz cd openssl-1.1.1a/
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
46
Step 2 Compile the source code and install OpenSSL. ./config
--prefix=/usr/local/openssl no-zlib make -j32 make install
Step 3 Delete the original file. rm -rf /usr/bin/openssl rm -rf
/usr/include/openssl
Step 4 Create soft links. ln -s /usr/local/openssl/include/openssl
/usr/include/openssl ln -s /usr/local/openssl/lib/libssl.so.1.1
/usr/local/lib64/libssl.so ln -s /usr/local/openssl/bin/openssl
/usr/bin/openssl ln -s /usr/local/openssl/lib/libcrypto.so.1.1
/usr/local/lib64/libcrypto.so
Step 5 Update library links. echo "/usr/local/openssl/lib" >>
/etc/ld.so.conf ldconfig -v
Step 6 Check the version. [root@localhost ~]# openssl version
OpenSSL 1.1.1a 20 Nov 2018
----End
NO TE
By default, the emulator source code uses the 4 KB page size, while
the default CentOS 7.6 kernel uses the 64 KB page size. If the page
size is not changed, the AVD will break down when the allocated
Android RAM exceeds 2 GB.
Step 1 Check the default page size of the system. [root@localhost
~]# getconf PAGE_SIZE 65536
CA UTION
If the page size is 4096, skip the following steps. Otherwise,
perform the following steps to recompile the kernel.
Step 2 Download the kernel source code. wget
https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.3.tar.xz
--no-check-certificate tar xf linux-5.3.tar.xz cd linux-5.3/
Step 3 Create the .config file. make menuconfig
Step 4 Set PAGE_SIZE to 4KB.
1. Select Kernel Features.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
47
2. Select Page size.
3. Select 4KB.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
48
Step 5 Modify the .config file.
Comment out the line where certs/centos.pem is located.
Step 6 Compile the source code and install the kernel.
CA UTION
Do not perform other operations when compiling the kernel.
Otherwise, the compilation may fail, and you need to compile the
kernel again.
make -j64 make modules -j64 make modules_install -j64 make
install
Step 7 Replace the default startup kernel.
1. Obtain the existing kernel versions. cat
/boot/efi/EFI/centos/grub.cfg | grep menuentry
2. Set a kernel version to the default startup kernel.
grub2-set-default "CentOS Linux (5.3.0) 7 (AltArch)"
3. Check whether the default startup kernel version has been
replaced. grub2-editenv list
Step 8 Restart the system for the modification to take effect.
reboot
----End
4.5.5 Installing x11vnc Step 1 Download the x11vnc source
code.
wget
http://sourceforge.net/projects/libvncserver/files/x11vnc/0.9.13/x11vnc-0.9.13.tar.gz
tar xvf x11vnc-0.9.13.tar.gz cd x11vnc-0.9.13/
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
49
Step 2 Compile the source code and install x11vnc. ./configure
--build=arm make -j32 make install
----End
4.5.6 Installing CMake Step 1 Download the CMake source code.
wget https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz tar zxvf
cmake-3.9.2.tar.gz cd cmake-3.9.2
Step 2 Compile the source code and install CMake. ./bootstrap make
-j32 make install
----End
llvm-config --version
CA UTION
Ensure that the LLVM version is between 10.0.0 and 11.0.0.
Step 2 Obtain the LLVM source code. wget
https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-10.0.1.src.tar.xz
wget
https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang-10.0.1.src.tar.xz
wget
https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/compiler-rt-10.0.1.src.tar.xz
Step 4 Compile the source code and install LLVM. mkdir build cd
build cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release
-DLLVM_BUILD_LLVM_DYLIB=yes - DLLVM_ENABLE_RTTI=yes
--enable-optimized --enable-targets=host-only ../ cmake --build .
-- -j64 make install
Step 5 Update library links. echo "/usr/local/lib" >>
/etc/ld.so.conf ldconfig -v
----End
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
50
4.5.8 Upgrading Python Step 1 Check the Python version, which must
be Python 3.
python --version
Step 3 Compile the source code and install Python. ./configure
--prefix=/usr/local/python3.7.0 --with-openssl=/usr/local/openssl
make -j64 make install
Step 4 Update the soft link. cd /usr/bin rm -rf python ln -s
/usr/local/python3.7.0/bin/python3 /usr/bin/python
Step 5 Modify the script files that depend on Python by default in
the system.
CA UTION
The Mesa upgrade requires Python 3.0 or later. However, after
Python version is upgraded to Python 3.0, you need to explicitly
specify Python 2 for certain original files that depend on Python
in the system.
The script files include /usr/sbin/firewalld,
/usr/bin/firewall-cmd, and Yum parsing command files such as
/usr/bin/yum and /usr/libexec/urlgrabber-ext- down.
----End
4.5.9 Installing pip Step 1 Remove the pip provided by the
system.
cd /usr/bin/ rm -rf pip rm -rf pip2*
Step 2 Uninstall the pip provided by Python 3. python -m pip
uninstall pip
Step 3 Obtains pip of the specified version. wget
--no-check-certific ate
https://pypi.python.org/packages/source/p/pip/pip-20.0.1.tar.gz
Step 4 Decompress the package and compile the source code. tar
-zxvf pip-20.0.1.tar.gz cd pip-20.0.1/ python setup.py build python
setup.py install
Step 5 Update the soft link. ln -s /usr/local/python3.7.0/bin/pip3
/usr/bin/pip
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
51
CA UTION
Software installed using pip is stored in /usr/local/python3.7.0 by
default. You need to create a soft link to system environment
variables.
----End
pip install --trusted-host pypi.org --trusted-host
files.pythonhosted.org meson ln -s /usr/local/python3.7.0/bin/meson
/usr/bin/meson
Step 2 Install Mako. pip install --trusted-host pypi.org
--trusted-host files.pythonhosted.org mako
----End
4.5.11 Installing re2c Step 1 Download the re2c source code.
wget
https://github.com/skvadrik/re2c/releases/download/2.0.3/re2c-2.0.3.tar.xz
tar xf re2c-2.0.3.tar.xz cd re2c-2.0.3
Step 2 Compile the source code and install re2c. autoreconf -i -W
all ./configure make -j32 make install
----End
4.5.12 Installing Ninja Step 1 Obtain the Ninja source code.
git clone git://github.com/ninja-build/ninja.git cd ninja
Step 2 Compile the source code and install Ninja. ./configure.py
--bootstrap cp ninja /usr/bin/
CA UTION
If the error message "ninja: error: manifest 'build.ninja' still
dirty after 100 tries" is displayed during compilation, check the
system time and ensure that it is the same as the actual
time.
----End
4.5.13 Installing libdrm Step 1 Obtain the libdrm source
code.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
52
wget https://dri.freedesktop.org/libdrm/libdrm-2.4.103.tar.xz tar
-xf libdrm-2.4.103.tar.xz cd libdrm-2.4.103
Step 2 Compile the source code and install libdrm. mkdir build cd
build meson --prefix=/usr --libdir=/usr/lib64 ninja install
----End
glxinfo | grep OpenGL
CA UTION
If the OpenGL version is earlier than 3.0, upgrade OpenGL by
referring to the following steps.
Step 2 Obtains the source code of the specified Mesa version. wget
https://archive.mesa3d.org//mesa-19.3.5.tar.xz tar -xf
mesa-19.3.5.tar.xz cd mesa-19.3.5
Step 3 Adapt to the source code.
1. Add the Radeon driver compilation option to line 42 in the
meson_options.txt file.
2. Comment out lines 246–248 in the meson.build file. 3. Change
llvm::TargetMachine::CGFT_ObjectFile in line 195 of the
src/amd/
llvm/ac_llvm_helper.cpp file to llvm::CGFT_ObjectFile.
Step 4 Compile the source code and install Mesa.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
53
mkdir build cd build meson --prefix=/usr -Dtexture-float=true
-Dgallium-drivers=radeonsi,swrast -Ddri-drivers=radeon,swrast -
Dplatforms=drm,x11 -Dglx-tls=true -Dshared-glapi=true -Ddri3=true
-Dlmsensors=true -Dgbm=true - Dxa=true -Dosmesa=gallium
-Dvdgpu=true -Dnine=true -Dva=true -Dlibglvnd=true -Dllvm=true -
DCFLAGS="-fsigned-char -O2" -DCPPFLAGS="-fsigned-char -O2"
-DCXXFLAGS="-fsigned-char -O2" - Dautotools=true ninja
install
Step 5 Check the OpenGL version. glxinfo | grep OpenGL
----End
4.5.15 Installing the GPU Driver Step 1 Download the GPU driver
source code.
git clone
git://anongit.freedesktop.org/xorg/driver/xf86-video-amdgpu cd
xf86-video-amdgpu/
----End
4.5.16 Configuring Xorg Files Step 1 Go to the /etc/X11 directory
and create the xorg0.conf file.
cd /etc/X11/ vim xorg0.conf
CA UTION
If the configuration file is stored in another directory, the AVD
may not use hardware for rendering.
Step 2 Copy the following content to the xorg0.conf file. Section
"ServerFlags" Option "DontVTSwitch" "on" Option "AutoAddDevices"
"off" Option "AutoEnableDevices" "off" Option "AutoAddGPU" "off"
Option "AutoBindGPU" "off" EndSection
Section "Device" Identifier "AMD" Driver "amdgpu" BusID
"pci:2:00:00" EndSection
Section "Monitor" Identifier "monitor0" Option "enable" "true"
#Modeline "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053
1059 1089 -hsync +vsync #Modeline "1024x768_60.00" 63.50 1024 1072
1176 1328 768 771 775 798 -hsync +vsync EndSection
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
54
Section "Screen" Identifier "screen0" Device "AMD" Monitor
"monitor0" DefaultDepth 24 SubSection "Display" Depth 24 #Modes
"1680x1050_60.00" #Modes "1024x768_60.00" EndSubSection
EndSection
Step 3 Change the values of Identifier and Device based on the GPU
type. For example, if the GPU type is AMD, set Identifier and
Device to AMD.
Step 4 Change the value of Driver based on the GPU type. For
example, if the GPU type is AMD, set Driver to amdgpu.
Step 5 Change the value of BusID based on the actual position of
the GPU. Convert the hexadecimal bus/device/function (B/D/F) number
of the GPU into a decimal number.
NO TICE
For example, if the B/D/F number is 85:00.0, set BusID to
pci:133:00:00.
Files such as xorg0.conf and xorg1.conf can be created in sequence
based on the number of GPUs.
----End
4.5.17 Verifying the Operating Environment Perform the following
operations to check whether the AMD GPU can run properly.
CA UTION
The values of Driver, BusID, and Device in the xorg0.conf file must
match the actual GPU type and location.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
55
Step 1 Disable the GDM service. systemctl stop gdm.service
systemctl disable gdm.service
Step 2 Run Xorg. rm -f /tmp/.X*lock Xorg :0 -config
/etc/X11/xorg0.conf -sharevts & export DISPLAY=:0
Step 3 Verify the running of the AMD GPU. glxinfo | grep
Device
If the AMD GPU model is displayed, the AMD GPU is running
properly.
----End
4.5.18 Enabling Server Ports The ports enabled in this section are
used for VNC connections. A port number is the sum of the start
port number (5900) and the port number specified by -vnc. For
example, if the port number specified by -vnc is 1, the port number
to be enabled is 5901.
Step 1 List the enabled ports. firewall-cmd --list-ports
Step 2 Enable a specified port. firewall-cmd --zone=public
--add-port=5901/tcp --permanent
Step 3 Restart the system for the configuration to take effect.
reboot
Step 4 Check whether the port is enabled. firewall-cmd
--list-ports
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
56
NO TE
You can run the firewall-cmd --zone=public --remove-port=5901/tcp
--permanent command to disable a specified port.
----End
Prerequisites
You have obtained the Android SDK image package and uploaded it to
the /home directory on the server using MobaXterm. For details
about how to obtain the Android SDK image package, see Software
Packages.
Procedure
Step 1 Log in to the server CLI by using SSH as the root
user.
Step 2 Switch to the /home directory where the Android SDK image
package is stored. cd /home
Step 3 Decompress the Android SDK image package. tar xvf
android-sdk-linux.tar.gz
Step 4 Open the /etc/profile file. vi /etc/profile
Step 5 Add the environment variables required for running the AVD
to the configuration file. export
ANDROID_SDK_ROOT=/home/android-sdk-linux export
LD_LIBRARY_PATH=${ANDROID_SDK_ROOT}/tools/lib64/qt export
QT_QPA_PLATFORM_PLUGIN_PATH=${LD_LIBRARY_PATH}/plugins/platforms
export
PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools
The file after modification is as follows:
NO TICE
ANDROID_SDK_ROOT specifies the Android SDK directory, which must be
the same as the actual directory.
Step 6 Save the modification and exit the vi editor.
Step 7 Make the environment variables take effect.
Kunpeng BoostKit for ARM Native Compilation and Installation Guide
(AVD) 4 AVD Installation Guide (CentOS 7.6)
Issue 16 (2021-08-17) Copyright © Huawei Technologies Co., Ltd.
57
source /etc/profile
4.7.1 Creating and Running AVD Using the CLI
4.7.1.1 Creating an AVD
Step 1 Log in to the server CLI by using SSH as the root
user.
Step 2 Create an AVD. android create avd --name qemu_android_1
--target android-28 --abi arm64-v8a --device "Nexus 4" --skin
720x1280 --sdcard 4096M --force
Step 3 Query the AVD created. andro