AOSP build and emulator - Miscellaneous Android Development

Hello,
I have modified the source code of android (master branch) and I would like to validate my change on emulator
I have done the repo init -u https://android.googlesource.com/platform/manifest
the repo sync
. build/envsetup.sh
lunch asp_x86-eng
make -j 8
and I start the emulator. The interface is an android 4.0, but some part of applications is in android 8.0
How can I have an emulator on android 8.0, based on my compilation ?
Thanks

Related

[Q] Galaxy tab 2.7.0 (p3100) building CM11. First time user question.

Hello,
I am trying to build CM11 for my p3100 from source for first time.
I am following http://wiki.cyanogenmod.org/w/Build_for_p3100. But I guess it is bit old.
I setup a virtualbox with ubuntu 13.10 64 bit server edition and created the folders as in the instructions.
Then I created another folder cm11 (mkdir -p ~/cm11) and I cd to cm11.
Now here is the confusion, should I be doing repo init as below,
Code:
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
or
Code:
repo init -u git://github.com/CyanogenMod/android_device_samsung_p3100.git -b cm-11.0
Note: This question came to me after initiated the repo with android.git and its downloaded some GBs of data already.
Thanks,
Simon Mandy

How To Compile Rom From Source full guide step by step by Jai Sharma

How To Compile Rom From Source
We need following things to compile ROM from source
A Computer( Linux or Mac)
Java JDK
Some required Package for building Rom
Rules for Accessing USB devices
Choosing a Branch
Installing Java on the Machine
Here i am using Ubuntu(14.04 LTS) as a Linux machine but it should work for other Linux variant
Open a terminal and type following
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
This command will remove other existing openjdk installation
2. Once java is uninstalled use following command for installing correct version of java
sudo apt-get update
sudo apt-get install openjdk-s8-jdk
Check java version by typing following command
java -version
2. Installing some required packages
Type following in terminal to install some required packages
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc unzip
3. Downloading Repo Tool and setting PATH
mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Now open the bashrc file and so we can include the repo tool:
sudo nano ~/.bashrc
Add following in the end of the file
export PATH=~/bin:$PATH
Now we need to reload bash variables to include the new path:
source ~/.bashrc
4. Initializing a Repo client
Now we need to create a directory where our source code will be downloaded. I am creating a directory AOSP here
mkdir AOSP
cd AOSP
In the following command insert your name and email address
git config --global user.name "Your_Name"
git config --global user.email "Your_EMail"
Now care fully select your branch whether you are downloading aosp or Cyanogenmod
repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.0_r7
type your desired branch name after the -b. This also applies to Cyanogenmod
5. Downloading source code
Now start downloading source code by typing following
repo sync
Note: this may take some time depending upon your internet speed and also please make sure you have enough storage
6. Configuring USB Access
type your username in following command and type enter
wget -S -O - http://source.android.com/source/51-android.rules | sed "s/<username>/$USER/" | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules; sudo udevadm control --reload-rules
7. Now building Rom for your device
To build rom we need following
Device tree
Vendor tree
kernel
Finding device tree and Vendor Tree
To find your device tree search on Github or similar sources with your device code name. If you are lucky you will find it there and believe me it is the easiest way to build your rom rather than creating device tree and vendor tree from scratch
Your device tree will go on following location
device/device_manufacturer_name/device_codename
Same for vendor tree
vendor/device_manufacturer_name/device_codename
If you find device tree and vendor tree then how to download it
For device tree
git clone “Github url” -b (branch_tag) device/device_manufacturer_name/device_codename
2. For vendor tree
git clone “Github url” -b (branch_tag) vendor/device_manufacturer_name/device_codename
Note1: You may need to change some files if everything is not working or giving you some error in rom compiling. Look into output to find out error. You can use Google if you can't correct it
Note2: You may be not found your device tree and vendor tree then what to do?. You may need to create them. Please follow my guide
Creating Device tree and vendor tree from scratch
For creating device tree
http://azodik.com/how-to-create-device-tree-for-android-rom-building/
2. For creating Vendor tree
“Coming Soon”
Kernel
For kernel part if you are lucky than you can find your kernel source from Github or similar sources. If not you can use your prebuilt kernel Foolow this to extract your kernel http://azodik.com/how-to-create-device-tree-for-android-rom-building/
Kernel location
/kernel/device_manufacturer_name/device_codename
Downloading your kernel
Manually download it and extract to kernel location or use following command
git clone “Github url” kernel/device_manufacturer_name/device_codename
Note1: You can use your prebuilt kernel. To use your prebuilt kernel edit BoardConfig.mk file in your device tree.
Note2: If you created device tree from scratch following my guide. Use of prebuilt kernel set to default
How to build
Use following command for building your rom
Source build/envsetup.sh
lunch
Now select your device from menu
3. make or mka
I hope you found it usefull. Please follow my website for interesting guide. Please comment here if you face any error.
Thank You
Really a great guide bro!
Can you please post a rom porting guide? easy to understand and effective
sohamsen said:
Really a great guide bro!
Can you please post a rom porting guide? easy to understand and effective
Click to expand...
Click to collapse
Thank you very much. Sure i will post soon.
jai44 said:
Thank you very much. Sure i will post soon.
Click to expand...
Click to collapse
Nice tutor.. But it looks need an enormous data usage to do that. If i wanna porting rom for example slim rom nougat to my device (kenzo) can you give me some info how many data should i provide and how to do that? Thanks
thanks
elanglangit said:
Nice tutor.. But it looks need an enormous data usage to do that. If i wanna porting rom for example slim rom nougat to my device (kenzo) can you give me some info how many data should i provide and how to do that? Thanks
Click to expand...
Click to collapse
You can follow this guide. Read it again and again. I hope soon you will build your own Rom. You can comment here if you face any problem
While compiling pure nexus. I got this error. How to solve thishttp://cloud.tapatalk.com/s/589b479597bc0/tapatalk_1486571095280.jpeg?
@jai44 wow! you make it look so easy! :') I have subscribed to this thread. When I get free time, Ill build my own rom
Thank you so much!
not able to sync rr source...
After i type repo sync it doesnt do anything. I double checked my site direction and it appears to be fine. Any hints??
could you please spare some time and make a post about how to create vendor tree?
can anyone help with this error while porting dotos rom for lenovo a700
/home/ubuntu/android/dotos/out/build-dot_aio_row.ninja is missing, regenerating...
device/lenovo/aio_row/board/ril.mk:4: error: cannot assign to readonly variable: PRODUCT_PROPERTY_OVERRIDES
10:14:07 ckati failed with: exit status 1
and ril.mk script
# RIL
BOARD_PROVIDES_RILD := true
BOARD_RIL_CLASS := ../../../device/lenovo/aio_row/ril
PRODUCT_PROPERTY_OVERRIDES += ro.telephony.sim.count=2
Hy I'm building lineage os 14.1 for SM-J250F
Samsung Galaxy J2 Pro 2018 (SM-J250F) but im not going to giveup .. so I'm started to build roms my self .. fixed some build errors and successfully compiled but it stuck on Samsung logo(no bootanimation) also took pstore logs but it only store recovery logs .. sir can you please help to make it boot? Can u kindly tell me what changes i need to do in sources to make it boot? Or can u fix the issue in my tree? Please I'm hoping your feedback
Source android base : Android 7.1.1
Tried compilation : Lineage OS 14.1
I cant post my tree links due to new account please pm
jai44 said:
How To Compile Rom From Source
We need following things to compile ROM from source
A Computer( Linux or Mac)
Java JDK
Some required Package for building Rom
Rules for Accessing USB devices
Choosing a Branch
Installing Java on the Machine
Here i am using Ubuntu(14.04 LTS) as a Linux machine but it should work for other Linux variant
Open a terminal and type following
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
This command will remove other existing openjdk installation
2. Once java is uninstalled use following command for installing correct version of java
sudo apt-get update
sudo apt-get install openjdk-s8-jdk
Check java version by typing following command
java -version
2. Installing some required packages
Type following in terminal to install some required packages
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc unzip
3. Downloading Repo Tool and setting PATH
mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Now open the bashrc file and so we can include the repo tool:
sudo nano ~/.bashrc
Add following in the end of the file
export PATH=~/bin:$PATH
Now we need to reload bash variables to include the new path:
source ~/.bashrc
4. Initializing a Repo client
Now we need to create a directory where our source code will be downloaded. I am creating a directory AOSP here
mkdir AOSP
cd AOSP
In the following command insert your name and email address
git config --global user.name "Your_Name"
git config --global user.email "Your_EMail"
Now care fully select your branch whether you are downloading aosp or Cyanogenmod
repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.0_r7
type your desired branch name after the -b. This also applies to Cyanogenmod
5. Downloading source code
Now start downloading source code by typing following
repo sync
Note: this may take some time depending upon your internet speed and also please make sure you have enough storage
6. Configuring USB Access
type your username in following command and type enter
wget -S -O - http://source.android.com/source/51-android.rules | sed "s/<username>/$USER/" | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules; sudo udevadm control --reload-rules
7. Now building Rom for your device
To build rom we need following
Device tree
Vendor tree
kernel
Finding device tree and Vendor Tree
To find your device tree search on Github or similar sources with your device code name. If you are lucky you will find it there and believe me it is the easiest way to build your rom rather than creating device tree and vendor tree from scratch
Your device tree will go on following location
device/device_manufacturer_name/device_codename
Same for vendor tree
vendor/device_manufacturer_name/device_codename
If you find device tree and vendor tree then how to download it
For device tree
git clone “Github url” -b (branch_tag) device/device_manufacturer_name/device_codename
2. For vendor tree
git clone “Github url” -b (branch_tag) vendor/device_manufacturer_name/device_codename
Note1: You may need to change some files if everything is not working or giving you some error in rom compiling. Look into output to find out error. You can use Google if you can't correct it
Note2: You may be not found your device tree and vendor tree then what to do?. You may need to create them. Please follow my guide
Creating Device tree and vendor tree from scratch
For creating device tree
http://azodik.com/how-to-create-device-tree-for-android-rom-building/
2. For creating Vendor tree
“Coming Soon”
Kernel
For kernel part if you are lucky than you can find your kernel source from Github or similar sources. If not you can use your prebuilt kernel Foolow this to extract your kernel http://azodik.com/how-to-create-device-tree-for-android-rom-building/
Kernel location
/kernel/device_manufacturer_name/device_codename
Downloading your kernel
Manually download it and extract to kernel location or use following command
git clone “Github url” kernel/device_manufacturer_name/device_codename
Note1: You can use your prebuilt kernel. To use your prebuilt kernel edit BoardConfig.mk file in your device tree.
Note2: If you created device tree from scratch following my guide. Use of prebuilt kernel set to default
How to build
Use following command for building your rom
Source build/envsetup.sh
lunch
Now select your device from menu
3. make or mka
I hope you found it usefull. Please follow my website for interesting guide. Please comment here if you face any error.
Thank You
Click to expand...
Click to collapse
how much storage is used to sync sir?
BryanHafidz said:
how much storage is used to sync sir?
Click to expand...
Click to collapse
depend on rom for me los17 took almost 70gb

Building AOSP Emulator

Though it's not necessary to build AOSP to build AOSP emulator, but I will discuss it here anyway.
Note: From here on we are considering, $HOME/AOSP is our AOSP repo download folder.
Android Build:
-----------------
Everything are already explained in source.andorid clearly except some step. I am going to explain those.
1. Follow this url, "https://source.android.com/setup/build/requirements".
2. Replace branch name of,
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
by going "https://android.googlesource.com/platform/manifest" and select chosen branch. Download may take up to 20 hours or more.
3. If not sure what argument to choose from lunch command, just type lunch and a bunch of options will be shown. Then select the correct one.
4. Replace "make –jN" to the number of threads you have in your PC. For example for a 4 thread processor "make –j4" will be the command.
5. If jack server has any memory issue run following command,
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server
Remember to replace –Xmx4g accordingly, here 4g means 4GB. Total build may take up to 9hrs.
6. After that, for every incremental build, type source and lunch command then make command for fresh started terminal otherwise only make will do.
Adding Default Application to android Source:
--------------------------------------------------------
1. Create an application in Android Studio.
2. We don’t need any gradle related folders for AOSP build. Take only java, assets and res folder and copy that in a new folder. Then take that folder to "AOSP/packages/apps" folder.
3. Add "Android.mk" file to that folder and add following lines (replace AppName accordingly and if app has assets un-comment line starting with "LOCAL_ASSETS_DIR"),
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := AppName
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, java)
# Include libraries
#LOCAL_JAVA_LIBRARIES := <Java lib dependencies>
LOCAL_STATIC_JAVA_LIBRARIES := android-common
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
#LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat
include $(BUILD_PACKAGE)
4. Don't use newly introduced layouts, which may create run-time exception (use linear, relative or other old layouts). Also use properly scoped style. For example,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="50dp"
android:layout_height="30dp"
android:layout_weight="1"
android:text="Hello World!"
android:textAppearance="@android:style/TextAppearance.Large" />
</LinearLayout>
In andorid studio "android:layout_width" may be written as "layout_width" and "@android:style/TextAppearance.Large" may be written as "TextAppearance.Large". We've to add full scope to every item, as AOSP build doesn't use gradle build system.
5. Add app name to "PRODUCT_PACKAGES" variable of "AOSP/build/target/product/core.mk" and "AOSP/device/generic/armv7-a-neon/mini_common.mk" files.
6. Build app using make appName then use make –jN or make snod.
NOTE: In emulator, settings page might crash. To fix this, go to "AOSP/packages/apps/Settings/src/com/android/settings/wfd/WifiDisplaySettgins.java", replace existing code by code below,
public static boolean isAvailable(Context context) {
return false;
//return context.getSystemService(Context.DISPLAY_SERVICE) != null
// && context.getSystemService(Context.WIFI_P2P_SERVICE) != null;
}
Emulator Build:
------------------
1. Android emulator is build upon QEMU. Branch for QEMU on "https://android.googlesource.com" is named qemu and generic kernel is in goldfish branch. Note that though we can build goldfish kernel using simple make commands, we've used prebuilt kernel for our approach.
2. Emulator source:
git clone https://android.googlesource.com/platform/external/qemu
(note there is another branch named qemu-android, this branch is not used any more so avoid cloning that branch)
Goldfish source:
git clone https://android.googlesource.com/device/generic/goldfish
(not needed to build emulator)
3. Remember we've to use the appropriate branch after repo name for example for emulator we are using latest 2.8 version which is in branch, "emu-2.8-release". So our command will be,
git clone https://android.googlesource.com/platform/external/qemu-android -b emu-2.8-release
or we can switch to that branch after cloning for master.
4. After cloning, copy the whole directory to "$HOME/AOSP/external" folder, rename older to qemu (if we've cloned qemu into our chosen named folder). We need this because qemu build uses "AOSP/external" and "AOSP/prebuilt" folder for its dependencies. By doing this we can avoid copying multiple repos for emulator, as we've already pulled it during AOSP cloning.
5. Run,
./android/configure.sh
./configure
6. We need to clone some other branches to build the emulator. Below branches should be copied to external folder,
git clone https://android.googlesource.com/platform/external/gtest -b emu-2.8-release
git clone https://android.googlesource.com/platform/external/tinyobjloader -b emu-2.8-release
put below branches in prebuilts/android-emulator-build folder,
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/archive -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/common -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/curl -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/mesa -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/mesa-deps -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/protobuf -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/qemu-android-deps -b emu-2.8-release
git clone https://android.googlesource.com/platform/prebuilts/android-emulator-build/qt -b emu-2.8-release
also we may need below branch, (we've to put it in "prebuilts/clang/host/linux-x86" folder)
git clone https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86 -b emu-2.8-release
Note: if we look through git path of each branch they are same as AOSP folder structure. So we can get the hint, where to put them
If any ssl problem occures to download repo, run below command,
export GIT_SSL_NO_VERIFY=1
7. Run "make -jN". if any other things are missing we will be shown the message and please clone those items from googlesource and put it in the correct location.
8. If emulator build failed for warning the run this "./configure --disable-werror", then make again.
9. After successful build we will get obs folder. Replace contents of "$home/AOSP/prebuilts/android-emulator/linux-x86_64" by the contents of our built folder.
10. Go back to AOSP root folder, now if we run "emulator" command, our custom built emulator will be used from now on.
11. We can run "emulator -verbose" to see generated commands.
Note: to buid AOSP again, we need to remove qemu, gtest, tinyobjloader from AOSP source, as they interfere with AOSP prebuilt packages. So after buiding emulator remove those folders from AOSP source folder.
Some Commands:
----------------------
This commands may or may not be needed, depending on the status of Ubuntu or source code.
1. Adding qt library in path
export PATH=/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/gles_swiftshader:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle9:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/gles_angle11:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/libstdc++:/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/qt/lib:$PATH
export QT_QPA_PLATFORM_PLUGIN_PATH=/home/saikat/AOSP/prebuilts/android-emulator/linux-x86_64/lib64/qt/plugins
2. Library installation commands
apt-get install build-essential zlib1g-dev pkg-config libglib2.0-dev binutils-dev libboost-all-dev autoconf libtool libssl-dev libpixman-1-dev libpython-dev python-pip python-capstone virtualenv
sudo apt-get install libsdl1.2-dev libsdl1.2debian libsdl-gfx1.2-5 libsdl-gfx1.2-dev libsdl-gfx1.2-doc libsdl-image1.2 libsdl-image1.2-dbg libsdl-image1.2-dev libsdl-mixer1.2 libsdl-mixer1.2-dbg libsdl-mixer1.2-dev libsdl-net1.2 libsdl-net1.2-dbg libsdl-net1.2-dev libsdl-sound1.2 libsdl-sound1.2-dev libsdl-ttf2.0-0 libsdl-ttf2.0-dev
sudo apt-get install libgtk-3-dev libspice-server-dev libusb-1.0-0-dev libusbredirparser-dev
3. QEMU default command, (not working just given for reference)
qemu-system-x86_64 \
-enable-kvm -smp 2 \
-append "console=ttyS0 vt.global_cursor_default=0 androidboot.selinux=permissive debug drm.debug=0 -device VGA" \
-m 1024 \
-serial mon:stdio \
-kernel $HOME/AOSP/out/target/product/generic_x86_64/kernel-ranchu \
-initrd $HOME/AOSP/out/target/product/generic_x86_64/ramdisk.img \
-drive index=0,if=none,id=system,file=$HOME/AOSP/out/target/product/generic_x86_64/system.img \
-device virtio-blk-pci,drive=system \
-drive index=1,if=none,id=cache,file=$HOME/AOSP/out/target/product/generic_x86_64/cache.img \
-device virtio-blk-pci,drive=cache \
-drive index=2,if=none,id=userdata,file=$HOME/AOSP/out/target/product/generic_x86_64/userdata.img \
-device virtio-blk-pci,drive=userdata \
-netdev user,id=mynet,hostfwd=tcp::5400-:5555 -device virtio-net-pci,netdev=mynet \
-device virtio-mouse-pci -device virtio-keyboard-pci \
-d guest_errors \
-nodefaults \
-display gtk,gl=on
I will add an sample app later
Sample emulator app
shoaibsaikat said:
I will add an sample app later
Click to expand...
Click to collapse
Here is the emulator client app
https://github.com/shoaibsaikat/ScreenTransferFromAndroidEmulatorToPhone
Why the emulator repo isn't updates since 6 years ago? Where is the emulator app right now?

Why can't I compile the msm android kernel?

I've been stuck at this for more than a week, so I'd appreciate any help.
What am I trying to do? (you can skip this part if you want)
I'm trying to do android kernel exploitation. That's not my current problem though. To learn kernel exploitation, I need to be able to get a version of android that is vulnerable to a certain vulnerability. So here's what I'm doing:
1. Going here to select a CVE that I want to learn how to exploit
2. After selecting a CVE, I need to select a build that is vulnerable to that CVE from here
3. Now that I have chosen a build (QQ3A.200805.001 in my case), I note its branch name (android-10.0.0_r41 in my case)
4. Now I need to be able to run this build in the android emulator (qemu) once as a production build, and once with KASAN+KCOV+debugging symbols for gdb
Before I begin, I'm following these guides:
1. https://source.android.com/devices/tech/debug/kasan-kcov
2. https://source.android.com/setup/build/building-kernels-deprecated
3. Google
My Setup:
I did this to download everything I need:
Bash:
git clone https://android.googlesource.com/kernel/msm
cd msm
git fetch --all --tags --prune
git checkout remotes/origin/android-msm-coral-4.14-android10
cd ..
mkdir AOSP
cd AOSP
repo init -u https://android.googlesource.com/platform/manifest
repo sync -j`nproc`
repo init -b android-10.0.0_r41
repo sync -j`nproc`
cd ..
When I went to the AOSP directory and tried compiling with:
Bash:
source ./build/envsetup.sh
lunch aosp_flame-userdebug # For the Pixel 4
m
It compiled in 4 hours, but it worked.
My First Issue:
I then created this bash script in the main folder to try to compile the msm kernel normally (without KASAN/KCOV):
Bash:
###########
# Params: #
###########
ARCH=arm64
CONFIG=cuttlefish_defconfig
###########
# Script: #
###########
read -p "Compile with clang instead of gcc? [y/N] " USE_CLANG
if [ $USE_CLANG == y ] || [ $USE_CLANG == Y ]; then
COMPILER=clang
CC_PATH=$(pwd)/AOSP/prebuilts/clang/host/linux-x86/clang-r346389c/bin/
else
COMPILER=gcc
CC_PATH=$(pwd)/AOSP/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/
export CROSS_COMPILE=aarch64-linux-android-
fi
export ARCH=$ARCH
export PATH=$PATH:$CC_PATH
cd msm
make clean
make distclean
make $CONFIG
make CC=$COMPILER
When I run it with GCC, I get bombarded with depreciation warnings and I get an error:
Code:
Android GCC has been deprecated in favor of Clang, and will be removed from
Android in 2020-01 as per the deprecation plan in:
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/master/GCC_4_9_DEPRECATION.md
...
Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler
When I run it with clang, I also get a ton of warnings and this error:
Code:
./arch/arm64/include/asm/stack_pointer.h:8:51: error: register 'sp' unsuitable for global register variables on this target
register unsigned long current_stack_pointer asm ("sp");
...
In file included from ./include/linux/kvm_host.h:14:
./include/linux/signal.h:81:11: warning: array index 3 is past the end of the array (which contains 1 element) [-Warray-bounds]
return (set->sig[3] | set->sig[2] |
Full outputs for the script can be found here (for gcc) and here (for clang). Basically my first issue is that I don't know why I'm getting these compilation errors. So any suggestions would be greatly appreciated.
My Second Issue:
Now, I am checking out the remotes/origin/android-msm-coral-4.14-android10 branch in the msm repo, but I think this isn't the way to go because I need the kernel version that corresponds to a certain build/branch (QQ3A.200805.001 or android-10.0.0_r41 in my case). I think I need to build the exact version that is precompiled in the AOSP repository.
For example, if I go to the AOSP/device/google/coral directory, and run git log, I get something like this:
Code:
commit 62d311ad7cfc3e76a5278634427596462069b44d (HEAD, tag: android-10.0.0_r41, tag: m/android-10.0.0_r41, aosp/android10-qpr3-release)
Merge: 7b91fff 0657c80
Author: android-build-team Robot <[email protected]>
Date: Wed Jun 10 23:45:11 2020 +0000
Merge cherrypicks of [11827366, 11829660, 11829049, 11829662, 11829647, 11829300, 11826697, 11829719, 11829051, 11829663, 11829664, 11829838, 11829052, 11829472, 11829586] into qt-qpr3-release
Change-Id: Ic126de75c24133f8d43df7c9d8f09059a9ca8089
commit 0657c80f016720f70ed6f9618f928a30e71f2b79
Author: wenchangliu <[email protected]>
Date: Tue Mar 24 18:11:18 2020 +0800
coral: Add seccomp policy for Codec2 process
Add seccomp policy for Codec2 process.
Bug: 149511958
Test: adb shell killall media.hwcodec
Change-Id: Iab64bd42ead0c5a27769a757007282c2dddf911d
(cherry picked from commit 3628a510a808a52c4ebf69958a8343928e5df3f2)
(cherry picked from commit 45a6093f3d085ca2a531c2607bd12dbc1eff6bf9)
commit 7b91fffc14afb41cf14772566272c72b37c36785
Merge: 2e7f1a3 e8c9484
Author: android-build-team Robot <[email protected]>
Date: Wed Jun 10 00:37:23 2020 +0000
...
Link for this exact commit/tag can be found here. However, there is no android-10.0.0_r41 tag in the msm source repo, so I don't know which version of the msm repo corresponds to the prebuilt one in the AOSP directory. And.. I don't know where to start looking tbh.
Any help is greatly appreciated.

system.img - downloaded vs local build

I've created emulator on Windows using AVD manager:
Create Virtual Device -> Pixel 3a XL -> Next -> x86 Images -> I've choosen Android 12.0 (AOSP version without Google APIs)
Then (on Linux) I've sync and build following:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-12.0.0_r31
$ repo sync -c
$ . build/envsetup.sh
$ lunch aosp_x86_64-eng
$ make -j10
I thought that I should get exactly the same system.img. However, downloaded one has 4GB while the one I've built has 2GB.
I've tried replacing downloaded system.img with mine in:
(...)\android-sdk\system-images\android-31\default\x86_64
but the emulator doesn't boot (despite wipe user data and cold boot).
Am I missing something obvious?

Categories

Resources