Porting Replicant to Android 9

This page contains old build instructions for Replicant 9. The source code is kept to do regression testing. Active development has moved into Replicant 10.

LineageOS 16 (Android 9)

Repositories and changes for LineageOS 16

Building LineageOS 16 version

Source code

$ repo init -u https://git.replicant.us/contrib/replicant-9/manifest.git -b replicant-9
$ repo sync

Alternatively a shallow copy of the source tree can be fetched in order to save on disk space:

$ repo init -u https://git.replicant.us/replicant-9/manifest.git -b replicant-9 --depth=1
$ repo sync -c

To `unshallow` a specific module:

$ cd path/to/module
$ git fetch --unshallow <remote>

For Trisquel 8

sudo apt-get install bc bison build-essential bsdmainutils ccache curl flex g++-multilib gcc-multilib gettext git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop python-mako pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev
sudo apt-get install gcc-5-arm-linux-gnueabi

Launching the build

Follow the i9300 manifest instructions:

$ subject='/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
$ mkdir .android-certs
$ for x in releasekey platform shared media testkey; do \
  ./development/tools/make_key .android-certs/$x "$subject"; \
  done
$ parallel_tasks=$(echo "$(grep 'processor' /proc/cpuinfo | wc -l ) + 1" | bc)
$ source build/envsetup.sh
$ lunch lineage_i9305-eng
$ make -j${parallel_tasks} bacon

The images can then be flashed with heimdall. They are then in:

  out/target/product/i9305/obj/PACKAGING/target_files_intermediates/lineage_i9305-target_files-eng.replicant/IMAGES/

Getting lastest changes

Install the images

$ sudo heimdall flash --BOOT out/target/product/i9305/obj/PACKAGING/target_files_intermediates/lineage_i9305-target_files-eng.replicant/IMAGES/boot.img --USERDATA out/target/product/i9305/obj/PACKAGING/target_files_intermediates/lineage_i9305-target_files-eng.replicant/IMAGES/userdata.img --SYSTEM out/target/product/i9305/obj/PACKAGING/target_files_intermediates/lineage_i9305-target_files-eng.replicant/IMAGES/system.img 

Get adb

As the device IDs are the ones given by the Linux kernel, they are not in the adb udev rules, so for now it requires to run adb as root:

$ sudo adb shell
* daemon not running; starting now at tcp:5037
* daemon started successfully
i9305:/ #                                 
$ sudo adb kill-server
$ adb shell
* daemon not running; starting now at tcp:5037
* daemon started successfully
error: no devices/emulators found

So make sure to kill the adb-server and run it as root:
$ adb kill-server
$ sudo adb shell
* daemon not running; starting now at tcp:5037
* daemon started successfully
i9305:/ # 

Booting

At some point during boot, the device goes into suspend, so you will need to press some buttons like the power or volume button to make the boot continue until the graphical interface.

You can also follow the boot progress with adb:

adb logcat
adb logcat -b main

Note that the device can go into suspend at any time, so adb might be interrupted. That looks like that:
First you get a shell

$ sudo adb shell
i9305:/ #

Then the connection is interrupted:

$ adb shell
i9305:/ # [randomdev@fullyfreelaptop ]$                                                                                                     

The effect with adb logcat is similar.

cleanups to be done

Using SwiftShader instead of Mesa3D llvmpipe for software rendering

To use SwifShader you need a kernel that supports UDIV/SDIV emulation, you can checkout the branch GNUtoo/udiv-emulation for kernel/replicant/linux. After doing that that run the following commands to use SwiftShader:

$ adb remount
$ adb shell
i9305:/ # rm vendor/lib/egl/libGLES_mesa.so # or move it somewhere safe meanwhile you test SwiftShader
i9305:/ # nano system/build.prop # set ro.hardware.hwcomposer=ranchu and ro.hardware.gralloc=default
$ adb reboot

AOSP 9

Status with AOSP 9

Repositories and changes

Building AOSP version

Source code

First get the source code:

$ repo init -u git://git.putti.eu/aosp/manifest_i9305.git -b android-9.0.0

For Trisquel 8

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 libgl1-mesa-dev libxml2-utils xsltproc unzip bc python-mako gcc-5-arm-linux-gnueabi

Building it

Once this is done, see the device/putti/i9305/README.md for the build instructions.