วันเสาร์ที่ 3 ธันวาคม พ.ศ. 2559

Insatall Ubuntu on the Sony Xperia Z1

minato


Bring-up of Sony Xperia line of devices based on AOSP 5.1.1 tree. Tested on Z1, Z2 tablet, Z3 Tablet Compact, Z5, Z5 Compact but not limited to.

Useful key combinations


Before you attempt flashing an Ubuntu image to your device, these key combinations should help you switch between phone modes.
  • Vol UP pressed + insert USB cable -> fastboot mode
  • Vol DOWN pressed + insert USB cable -> flash mode (used by Sony tools)
  • Vol UP + POWER, both pressed during 30 seconds -> hard reboot
  • Vol DOWN + POWER, no USB cable, stop pressing POWER after vibration -> recovery mode when it has been enabled and has a proper image (see below)
  • Small red button next to SIM, press it for a few seconds (you need a clip) until you get 3 vibrations -> power off

Current images


Built images ready to flash on a device are here. Ensure you download the boot.img and ubuntu.img files and then follow the flashing instructions below.

Flashing Ubuntu


1. Unlock the boot loader following Sony's instructions
2. Make sure that you have Android 5.1.1 in your Z1. Otherwise, flash it using the Sony official tools or unofficial tools that run in Ubuntu.
3. After that you can use fastboot to flash the images, by running these commands on the terminal:
sudo fastboot -S 256M flash boot boot.img
sudo fastboot -S 256M flash system ubuntu.img

Compiling from scratch


Alternatively, in addition to the ready-made images, if you want to contribute to development or modify those images, you can build them yourself following these instructions. These assume you've got knowledge of building software and you are familiar with the Ubuntu and Android source code. Current source tree is compatible with Sony’s binary blobs version 19a
Toggle line numbers
   1  Download Sony binaries (current tested version is AOSP L v19a)
   2  repo init -u https://code-review.phablet.ubuntu.com/aosp/platform/manifest -b personal/w-ondra/xperia-5.1.1_r36 -g all,-darwin,-qcom_msm8x26,-qcom_msm8x27,-qcom_msm8x74,-x86,-omap3,-omap4,-omap4-aah,-manta,-grouper
   3  repo sync
   4  . build/envsetup.sh
   5  lunch  -> Select desired target e.g Z5 aosp_e6653-userdebug
   6  make -j8
   7  this is optional step, if you want to use specific channel to build ubuntu root from, for example . ubuntu/prebuilts/prepare-ubuntu-packages-for-build -d generic -c rc-proposed/ubuntu-pd
   8  make ubunturootfsimage  -j8 -> build will downloads ubuntu rootfs and custom packages for default channel rc-proposed/ubuntu channel

Optional steps:
  • Use custom channel to build Ubuntu rootfs from:
    • after step 6 run: . ubuntu/prebuilts/prepare-ubuntu-packages-for-build -d generic -c rc-proposed/ubuntu-pd
    For 64bit devices (Z5, Z5c, Z4 tablet) custom build of libhyrbis needs to be used, to fix GPU crash
    • Run following after step 6
Toggle line numbers
   1  git clone https://code-review.phablet.ubuntu.com/ubuntu/libhybris-prebuilt ubuntu/libhybris-prebuilt -b personal/w-ondra/phabket-5.x-kitakami
   2   mmm ubuntu/libhybris-prebuilt/
   3   make snod

Port status


The port is in its early steps and feature set differs between devices, there are many things that do not work. Some of the stuff that does work is:
Device
what is working
known issues

Z1 (honami)
Unity8/wifi/SMS/data/audio
Power handling/BT/camera/MHL/phone calls

Z Ultra (togari)
Unity8/wifi/SMS/data/audio
Power handling/BT/camera/MHL/phone calls

Z2 Tablet(castor)
Unity8/audio
Power handling/BT/camera/MHL

Z3 Tablet compact(scrorpion)
Unity8/audio
Power handling/BT/camera/MHL

Z5 (sumire)
Unity8/wifi/SMS/data/audio
Power handling/BT/camera/MHL/phone calls

Z5 compact (suzuran)
Unity8/wifi/SMS/data/audio
Power handling/BT/camera/MHL/phone calls

Generic known issues


  • Power handling.
    • Device does not power off completely. When usb cable is plugged and unplugged, power button fails to switch off screen.
    • suspend does not works properly
  • MHL does not work
  • Camera does not work and eventually crashes device
  • phone calls do not work
  • generic stability

Development tips


  • (re)building boot image
Toggle line numbers
   1  $ make bootimage
   2  - repackage boot image without rebuilding dependencies
   3  $ make bootimage-nodeps

  • (re)build recovery image
Toggle line numbers
   1  $ make recoverytimage
   2  - repackage boot image without rebuilding dependencies
   3  $ make recoveryimage-nodeps

  • repackage android ramdisk. !! Android ramdisk is contained in Android system image
Toggle line numbers
   1  $ make ramdisk-nodeps

  • rebuild Android part without checking dependencies
Toggle line numbers
   1  $ make snod

  • Build Ubuntu image ( this will download latest rootfs and custom adds local Android image and packs all in image)
Toggle line numbers
   1  $ make ubunturootfsimage

  • re-build Ubuntu image without checking dependencies, use this to create image with local changes
Toggle line numbers
   1  $ make ubunturootfsimage-nodeps

  • build device package
Toggle line numbers
   1  $ make device package
   2  - without checking dependencies
   3  $ make devicepackage-nodeps

  • rebuilding Ubuntu image, with new changes contained in Android image
Toggle line numbers
   1   - build changes in Android code 
   2   $ make
   3   - copy updated Android image so it is picked when we are repacking Ubuntu image
   4   $ cp out/target/product//system.img out/target/product//ubuntu/rootfs/var/lib/lxc/android/system.img
   5   - repack Ubuntu rootfs without checking dependencies
   6  $ make ubunturootfsimage-nodeps

  • rapid development with adb sync
When doing changes on Android side, sometimes there is need for quick iterations, for this case best is to use adb sync feature. You will have to make sure to use eng build, as you will need to run adb daemon as root. You will also have to make sure to have enough spare space in Android system image.
Toggle line numbers
   1 Preconditions:
   2     - Preparation: prepare Android system image with 30MB padding space
   3     $ BOARD_SYSTEMIMAGE_PARTITION_PADDING=3145728 make -j8
   4     or without dependencies
   5     $ BOARD_SYSTEMIMAGE_PARTITION_PADDING=3145728 make snod -j8
   6     - Create Ubuntu image with new Android system image
   7     $ cp out/target/product//system.img out/target/product//ubuntu/rootfs/var/lib/lxc/android/system.img
   8     $ make ubunturootfsimage-nodeps -j8
   9 
  10     - Flash device with new Ubuntu image.
  11     - once device is booted, using adb add following two files:
  12     $ touch /userdata/.writable_image
  13     $ touch /userdata/.writable_device_image 
  14     - reboot
  15     - once device is booted, check that '/' and '/android/system' are mounted as 'rw'
  16 
  17 Iterating through  changes:
  18     - restart adb as root
  19     $ adb root
  20     - make and compile changes in Android, you do not need to run make in root, to recreate Android system image
  21     - e.g.
  22     $ mmm frameworks/av/media/libmedia
  23 
  24     - sync all changes with device. Be careful if you change is executable can you restart it, if it's shared lib, can you make system reload it, if it's config file can you make system reload it? Ultimately reboot is always safest option if you do not know
  25     $ adb sync

Touch/Devices/minato (last edited 2016-07-29 08:45:25 by w-ondra)

Credit : http://www.omgubuntu.co.uk/2016/02/ubuntu-phone-sony-xperia-oneplus-one

ไม่มีความคิดเห็น:

แสดงความคิดเห็น