Compile LineageOS for Oneplus 3 on Fedora 25


https://uwot.eu/blog/compile-lineageos-for-oneplus-3-on-fedora-25/


Android community is one big cancerous clusterfuck, it is no wonder that finding a decent guide on how to compile Android from source written in a somewhat comprehensible english is pretty much mission impossible.
Cyanogenmod Inc. shutting down their wiki and services overnight surely didn’t help either.
Required packages on Fedora 25 are (rpmfusion repo must be previously installed):

1
$ sudo dnf install screen java-1.8.0-openjdk-devel git schedtool ncurses-devel ncurses-libs ncurses-compat-libs ImageMagick-devel libstdc++-devel bison gnupg lzma

For some reason the compilation process stores some temporary files in /tmp which, in Fedora 25, is mounted on a tmpfs ramdisk.
In case the ramdisk runs out of space for some retarded reason the build process instead of halting will go on like nothing happens and produce borked binaries as output.
To keep /tmp mounted on HDD run:

1
systemctl mask tmp. mount

Download the SDK and extract the files, if building on an headless machine just get the command line tools: https://developer.android.com/studio/index.html#downloads

1
2
3
4
5
6
7
8
9
10
11
$ mkdir android-sdk-linux
$ mv tools_r25.2.3-linux.zip android-sdk-linux
$ cd android-sdk-linux
$ unzip tools_r25.2.3-linux.zip
$ vi ~/.bash_profile
---
export ANDROID_HOME= /home/user/android-sdk-linux
export PATH=$PATH:$ANDROID_HOME /tools
export PATH=$PATH:$ANDROID_HOME /platform-tools
---
$ source .bash_profile

Download the latest version of “Android SDK Tools”, “Android SDK Platform-tools”, “Android SDK Build-tools” and “SDK Plattform Android”:

1
2
3
### list available downloads
$ android list sdk
$ android update sdk --no-ui --filter 1,2,3,33

Get repo utility and create a directory where Android’s source code will be downloaded.
Screen utility might come in handy since the download will likely take some time (it is around 60 GB).

1
2
3
4
5
6
7
$ curl https: //storage .googleapis.com /git-repo-downloads/repo > ~ /bin/repo
$ chmod a+x ~ /bin/repo
$ mkdir -p ~ /android/system
$ cd android /system
### replace cm-14.1 with the desired branch
$ repo init -u git: //github .com /LineageOS/android .git -b cm-14.1
$ repo sync

Now it is time to download the source code needed to compile for a specific device, which is a Oneplus 3 in my case.
Before actually compiling it is a good idea to run “make clobber” to clean the system from all the temp files created the previous time Android was compiled.
While this should not be necessary and makes the compilation procedure much longer it should ensure that everything is recompiled correctly every time even if some binary blobs have changed:

1
2
3
$ make clobber
$ source build /envsetup .sh
$ breakfast oneplus3

Double check that all the needed repository are actually present in roomservice.xml file:

/android/system/.repo/local_manifests/roomservice.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<? xml version = "1.0" encoding = "UTF-8" ?>
< manifest >
   < project name = "LineageOS/android_device_oneplus_oneplus3" path = "device/oneplus/oneplus3" remote = "github" />
   < project name = "LineageOS/android_device_oppo_common" path = "device/oppo/common" remote = "github" />
   < project name = "LineageOS/android_kernel_oneplus_msm8996" path = "kernel/oneplus/msm8996" remote = "github" />
   < project name = "LineageOS/android_packages_resources_devicesettings" path = "packages/resources/devicesettings" remote = "github" />
   < project name = "LineageOS/android_vendor_nxp-nfc_opensource_frameworks" path = "vendor/nxp-nfc/opensource/frameworks" remote = "github" />
   < project name = "LineageOS/android_vendor_nxp-nfc_opensource_libnfc-nci" path = "vendor/nxp-nfc/opensource/libnfc-nci" remote = "github" />
   < project name = "LineageOS/android_vendor_nxp-nfc_opensource_Nfc" path = "vendor/nxp-nfc/opensource/Nfc" remote = "github" />
   < project name = "LineageOS/android_device_qcom_common" path = "device/qcom/common" remote = "github" />
   < project name = "LineageOS/android_external_sony_boringssl-compat" path = "external/sony/boringssl-compat" remote = "github" revision = "cm-14.1" />
   < project name = "LineageOS/android_external_stlport" path = "external/stlport" remote = "github" revision = "cm-14.1" />
   < project name = "TheMuppets/proprietary_vendor_oneplus" path = "vendor/oneplus" remote = "github" revision = "cm-14.1" />
   < project name = "TheMuppets/proprietary_vendor_qcom_binaries" path = "vendor/qcom/binaries" remote = "github" revision = "cm-14.1" />
</ manifest >

Google’s Android compilation guide suggest the user to enable gcc ccache, I prefer to keep it disabled because it can cause corrupted output (it already happened more than once to me).
Set jack server’s allocated memory (-Xmx flag) to as much RAM you can spare for it:

1
2
3
4
5
6
7
$ repo sync
#$ export USE_CCACHE=1
#$ prebuilts/misc/linux-x86/ccache/ccache -M 50G
$ export ANDROID_JACK_VM_ARGS= "-Xmx8192m -Dfile.encoding=UTF-8 -XX:+TieredCompilation"
#set this environmental variable to include su binaries
$ export WITH_SU= true
$ brunch oneplus3

The compiled binaries can be found in ~/android/system/out/target/product/oneplus3/, it will all be compressed in an archive named “lineage-version-date-UNOFFICIAL-oneplus3” that can then be flashed from recovery.
The recovery everyone suggest to use for oneplus3 can be found here: https://forum.xda-developers.com/oneplus-3/development/recovery-twrp-3-0-2-0-touch-recovery-t3402999
This procedure can be extended to any other device, the only thing that needs adjustment are the repositories present in roomservice.xml file.
To compile LineageOS for a LG G3 for the european market (codename: d855) run repo sync, breakfast d855 and add the correct binary blob repository to roomservice.xml:

1
< project name = "TheMuppets/proprietary_vendor_lge" path = "vendor/d855" remote = "github" revision = "cm-14.1" />

d855 for some reason also needs lzma to compress the Linux kernel.


Cross-compiling Parsec benchmark for ARM architecture involves setting up a build environment on your host machine (likely x86 or x64) that can generate code for ARM targets. Here's a general outline of the steps: 1. **Install required tools**: Ensure you have installed a compiler and toolchain that supports ARM, like `gcc-arm-none-eabi` or `clang-arm`. 2. **Set up target environment**: You'll need to configure the toolchain with the correct paths and settings for the ARM target. This may involve creating a separate configuration file or specifying flags when invoking the compiler. ```sh export CC=arm-none-eabi-gcc export CXX=arm-none-eabi-g++ ``` 3. **Download Parsec**: Download the latest version of Parsec, which is a benchmarking suite, and extract it to a suitable location. 4. **Configure Makefile**: If Parsec has a Makefile, modify it to specify the target architecture. Look for lines similar to `CC`, `CFLAGS`, or `LDFLAGS`. Add or update them as needed, using the ARM-specific versions. 5. **Build for ARM**: Run `make clean && make` in the Parsec directory, replacing `make` with the appropriate command for your build system (e.g., `ninja` if you're using Ninja). ```sh make TARGET=arm-linux-gnueabihf ``` 6. **Test on ARM device or emulator**: Copy the generated `.elf` (executable) file to an ARM device or use an emulator to run it. **Related questions:** 1. What specific version of the ARM toolchain do I need? 2. How can I deal with dependencies if they don't have ARM builds available? 3. Are there any libraries or patches I need to include for compatibility with Parsec on ARM?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值