1# Build and Run ART tests on ARM FVP
2
3This document describes how to build and run an Android system image targeting
4the ARM Fixed Virtual Platform and to use it as a target platform for running
5ART tests via ADB.
6
7This instruction was checked to be working for the AOSP master tree on
82021-01-13; the up-to-date instruction on how to build the kernel and firmware
9could be found here: device/generic/goldfish/fvpbase/README.md.
10
11## Configuring and Building AOSP
12
13First, an AOSP image should be configured and built, including the kernel and
14firmware.
15
16### Generating build system configs
17
18```
19cd $AOSP
20
21. build/envsetup.sh
22# fvp_mini target is used as we don't need a GUI for ART tests.
23lunch fvp_mini-eng
24
25# This is expected to fail; it generates all the build rules files.
26m
27```
28
29### Building the kernel
30
31```
32cd $SOME_DIRECTORY_OUTSIDE_AOSP
33
34mkdir android-kernel-mainline
35cd android-kernel-mainline
36repo init -u https://android.googlesource.com/kernel/manifest -b common-android-mainline
37repo sync
38BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh
39BUILD_CONFIG=common-modules/virtual-device/build.config.fvp build/build.sh
40```
41
42The resulting kernel image and DTB (Device Tree Binary) must then be copied into
43the product output directory:
44
45```
46cp out/android-mainline/dist/Image $ANDROID_PRODUCT_OUT/kernel
47cp out/android-mainline/dist/fvp-base-revc.dtb out/android-mainline/dist/initramfs.img $ANDROID_PRODUCT_OUT/
48```
49
50### Building the firmware (ARM Trusted Firmware and U-Boot)
51
52First, install ``dtc``, the device tree compiler. On Debian, this is in the
53``device-tree-compiler`` package.
54
55```
56sudo apt-get install device-tree-compiler
57```
58
59Then run:
60
61```
62mkdir platform
63cd platform
64repo init -u https://git.linaro.org/landing-teams/working/arm/manifest.git -m pinned-uboot.xml -b 20.01
65repo sync
66
67# The included copy of U-Boot is incompatible with this version of AOSP, switch to a recent upstream checkout.
68cd u-boot
69git fetch https://gitlab.denx.de/u-boot/u-boot.git/ master
70git checkout 18b9c98024ec89e00a57707f07ff6ada06089d26
71cd ..
72
73mkdir -p tools/gcc
74cd tools/gcc
75wget https://releases.linaro.org/components/toolchain/binaries/6.2-2016.11/aarch64-linux-gnu/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu.tar.xz
76tar -xJf gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu.tar.xz
77cd ../..
78
79build-scripts/build-test-uboot.sh -p fvp all
80```
81
82These components must then be copied into the product output directory:
83
84```
85cp output/fvp/fvp-uboot/uboot/{bl1,fip}.bin $ANDROID_PRODUCT_OUT/
86```
87
88## Setting up the FVP model
89
90### Obtaining the model
91
92The public Arm FVP could be obtained from https://developer.arm.com/; one would
93need to create an account there and accept EULA to download and install it.
94A link for the latest version:
95
96https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms/arm-ecosystem-models: "Armv8-A Base RevC AEM FVP"
97
98The AEMv8-A Base Platform FVP is a free of charge Fixed Virtual Platform of the
99latest Arm v8-A architecture features and has been validated with compatible
100Open Source software, which can be found on the reference open source software
101stacks page along with instructions for running the software
102
103### Running the model
104
105From a lunched environment:
106
107```
108export MODEL_PATH=/path/to/model/dir
109export MODEL_BIN=${MODEL_PATH}/models/Linux64_GCC-6.4/FVP_Base_RevC-2xAEMv8A
110./device/generic/goldfish/fvpbase/run_model
111```
112
113If any extra parameters are needed for the model (e.g. specifying plugins) they
114should be specified as cmdline options for 'run_model'. E.g. to run a model
115which support SVE:
116
117```
118export SVE_PLUGIN=${MODEL_PATH}/plugins/Linux64_GCC-6.4/ScalableVectorExtension.so
119$ ./device/generic/goldfish/fvpbase/run_model --plugin ${SVE_PLUGIN} -C SVE.ScalableVectorExtension.veclen=2
120```
121
122Note: SVE vector length is passed in units of 64-bit blocks. So "2" would stand
123for 128-bit vector length.
124
125The model will start and will have fully booted to shell in around 20 minutes
126(you will see "sys.boot_completed=1" in the log). It can be accessed as a
127regular device with adb:
128
129```
130adb connect localhost:5555
131```
132
133To terminate the model, press ``Ctrl-] Ctrl-D`` to terminate the telnet
134connection.
135
136## Running ART test on FVP
137
138The model behaves as a regular adb device so running ART tests could be done using
139the standard chroot method described in test/README.chroot.md; the steps are
140also described below. A separate AOSP tree (not the one used for the model
141itself), should be used - full or minimal.
142
143Then the regular ART testing routine could be performed; the regular "lunch"
144target ("armv8" and other targets, not "fvp-eng").
145
146
147```
148export ART_TEST_CHROOT=/data/local/art-test-chroot
149export OVERRIDE_TARGET_FLATTEN_APEX=true
150export SOONG_ALLOW_MISSING_DEPENDENCIES=true
151export TARGET_BUILD_UNBUNDLED=true
152export ART_TEST_RUN_ON_ARM_FVP=true
153
154. ./build/envsetup.sh
155lunch armv8-userdebug
156art/tools/buildbot-build.sh --target
157
158art/tools/buildbot-teardown-device.sh
159art/tools/buildbot-cleanup-device.sh
160art/tools/buildbot-setup-device.sh
161art/tools/buildbot-sync.sh
162
163art/test/testrunner/testrunner.py --target --64 --optimizing -j1
164
165```
166