Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[device-port] [suzu] Sony Xperia X #98

Open
fredldotme opened this issue Sep 7, 2018 · 18 comments

Comments

Projects
None yet
6 participants
@fredldotme
Copy link

commented Sep 7, 2018

Tree: halium-7.1

  • Create manifest Halium/halium-devices#116
  • Boot image and system image build successfully
  • Device boots into rootfs, usb: Manufacturer: GNU/Linux Device appears in dmesg on host.
  • LXC container starts and does not crash
  • libhybris tests
    • test_gps
    • test_hwcomposer
    • test_lights
    • test_vibrator
    • test_wifi
    • test_sensors
    • test_audio
    • test_camera
    • test_input
    • test_nfc
    • test_recorder

The EGL_PLATFORM=hwcomposer environment variable is required for test_hwcomposer to succeed.

Kernel Support

This Halium abstraction uses a 4.4 kernel provided by Sony and CodeAurora,
thus has the benefit of taking advantage of upstream kernel patches
and follows Ubuntu's Xenial kernel series for AppArmor updates.
This opens the door for potentially decade-long support of kernel patches.
The Halium suzu device platform is determined to support Snap packages
and is well positioned to do so long term.

Areas of improvements

Usability:

  • Calling
  • SMS
  • Performance
  • Audio
  • AppArmor (Kernel side)
  • AppArmor Click Support
  • Bluetooth
  • Video Decoding
  • Camera
  • Rotation (using Ubuntu Touch Platform API)
  • GPS/Location services (using Ubuntu Touch Platform API)

Fix Android init service start issues related to:

  • vold

Possible improvements through use of FLOSS-compliant components

Upstreaming:

  • halium-devices
  • lxc-android

Build instructions

Build tests (even if you don't have the device) are welcome!
The resulting image is arm64 and armhf multilib compatible.

Tested on Ubuntu 18.04 inside an LXD container:

# Install build prerequisites for Halium
PROJECT_ROOT=$HOME/Projects/Halium-7.1
DEVICE=suzu
BREAKFAST_DEVICE=aosp_f5121-userdebug
HALIUM_VER=halium-7.1

export LC_ALL=C

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install git gnupg flex bison gperf build-essential \
  zip bzr curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw-w64-i686-dev tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386 schedtool \
  repo liblz4-tool bc lzop wget libssl-dev imagemagick

# Fetch & build
mkdir -p $PROJECT_ROOT
cd $PROJECT_ROOT

repo init -u https://github.com/Halium/android -b $HALIUM_VER --depth=1
repo sync

# Setup local_manifest repo xml
$PROJECT_ROOT/halium/devices/setup $DEVICE
repo sync --force-sync

# Optional workaround
# Upside is using the prebuilt gcc compiler
# Downside is using the prebuilt gcc compiler
# TL;DR: Install a decently recent compiler on your host.
#
# Setup build environment using prebuilt compiler (uncomment exports to use the workaround):
# export CC=$PROJECT_ROOT/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8/bin/x86_64-linux-gcc
# export CXX=$PROJECT_ROOT/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8/bin/x86_64-linux-g++
# export LD=$PROJECT_ROOT/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8/bin/x86_64-linux-ld
# export CXX_INCLUDE_PATH=$PROJECT_ROOT/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8/sysroot/usr/include
# export C_INCLUDE_PATH=$CXX_INCLUDE_PATH

# Boot and system image creation
source build/envsetup.sh
breakfast $BREAKFAST_DEVICE
mka halium-boot && mka systemimage

Flashing images

Prerequisites:

The OEM binaries need to be flashed onto the oem partition:

sudo apt install unzip android-tools-fastboot || true
unzip SW_binaries_for_Xperia_AOSP_N_MR1_5.7_r1_v08_loire.zip
if [ -f SW_binaries_for_Xperia_AOSP_N_MR1_5.7_r1_v08_loire.img ]; then
fastboot flash oem SW_binaries_for_Xperia_AOSP_N_MR1_5.7_r1_v08_loire.img
fi

Flashing boot and system images:
Edit 2018-09-13: switch to xenial-edge UBPorts rootfs
Edit 2019-05-16: switch to xenial (devel) UBPorts rootfs

PROJECT_ROOT=$HOME/Projects/Halium-7.1
HALIUM_INSTALL_ROOT=$HOME/Projects/Halium-7.1/halium/halium-install
DEVICE=suzu

rm -r $HALIUM_INSTALL_ROOT || true
git clone https://github.com/JBBgameich/halium-install.git $HALIUM_INSTALL_ROOT

# Fetch latest successful armhf rootfs build
cd $PROJECT_ROOT
wget https://ci.ubports.com/job/xenial-rootfs-armhf/lastSuccessfulBuild/artifact/out/ubports-touch.rootfs-xenial-armhf.tar.gz

# At this point the device is expected to be in recovery mode
$HALIUM_INSTALL_ROOT/halium-install -p ut $PROJECT_ROOT/ubports-touch.rootfs-xenial-armhf.tar.gz $PROJECT_ROOT/out/target/product/$DEVICE/system.img
adb reboot bootloader
fastboot flash boot $PROJECT_ROOT/out/target/product/$DEVICE/halium-boot.img
fastboot reboot

Post-installation steps

The most current xenial rootfs (devel) build from ci.ubports.com is used in the following steps (2019-05-16).

# Mount rootfs read-write
sudo mount -o remount,rw /

sudo apt install pulseaudio-modules-droid-24

sync && sudo mount -o remount,ro / && sudo reboot

@lnjX lnjX changed the title [device-port] Sony Xperia X [device-port] [suzu] Sony Xperia X Sep 7, 2018

@lnjX lnjX added the Ports label Sep 7, 2018

@fredldotme

This comment has been minimized.

Copy link
Author

commented Sep 13, 2018

If you try a build by yourself and encounter problems, please specify your build environment (GNU/Linux distribution, changing default compiler, etc.) to help track down issues.

@mdehollander

This comment has been minimized.

Copy link

commented Sep 19, 2018

All right. I gave it a try. Thanks for providing the instructions. I got until the part building the systemimage, failing on something with checkpolicy on selinux.

More details:

  • OS: Ubuntu 16.04 LTS
  • Compiler: system provided gcc 5.4.0
  • I had to ignore the compiler related exports
  • For me the setup script is included in the devices directory: $PROJECT_ROOT/halium/devices/setup $DEVICE
  • Checkpolicy fails with:
checkpolicy -M -c 30 -o /home/mattias/Projects/Halium-7.1/out/target/product/suzu/obj/ETC/sepolicy_intermediates/sepolicy.tmp /home/mattias/Projects/Halium-7.1/out/target/product/suzu/obj/ETC/sepolicy_intermediates/policy.confcheckpolicy:  loading policy configuration from /home/mattias/Projects/Halium-7.1/out/target/product/suzu/obj/ETC/sepolicy_intermediates/policy.conf
system/sepolicy/untrusted_app.te:210:ERROR 'unknown type exfat' at token ';' on line 19511:
#line 210
}:{ dir { { chr_file blk_file } { file lnk_file sock_file fifo_file } } } { create unlink };
checkpolicy:  error(s) encountered while parsing configuration

Could the error I get be related to Halium/android_build#4 (comment)?

@fredldotme

This comment has been minimized.

Copy link
Author

commented Sep 19, 2018

@mdehollander To get past the checkpolicy error you need to use the following sepolicy repo:

https://github.com/beidl/android_system_sepolicy/tree/halium-7.1

You can remove-project the original and pull in my version within the device-specific repo manifest.
EDIT: Now in the upstream PR.

@fredldotme

This comment has been minimized.

Copy link
Author

commented Sep 19, 2018

A repo sync is suggested now to gain proper AppArmor/click & snap support.

Still missing:

  • Audio (Mostly ALSA kernel issues, though could be worked around using pulseaudio-module-droid, which is not loaded)
  • Camera
  • Bluetooth
  • Location (Hybris test passes)
  • Rotation detection in Unity8

Using systemd as the init manager and avoiding running into trouble
whlie running /init on the lxc-confg-android container might require
workarounds suggested in these cgmanager and lxc issues:
lxc/cgmanager#32
lxc/lxc#1554

Specifically, the upstream lxc-android-config service shouldn't require cgmanager anymore.

@mdehollander

This comment has been minimized.

Copy link

commented Sep 23, 2018

I guess this is related to the not yet working audio. I get this error when making the systemimage:

ninja: error: '/home/mattias/Projects/Halium-7.1/out/target/product/suzu/obj_arm/SHARED_LIBRARIES/libaudiopolicymanager_intermediates/export_includes', needed by '/home/mattias/Projects/Halium-7.1/out/target/product/suzu/obj_arm/SHARED_LIBRARIES/libaudiopolicyservice_intermediates/import_includes', missing and no known rule to make it

Setting USE_CUSTOM_AUDIO_POLICY to 0 in device/sony/common/CommonConfig.mk brings me to:

ninja: error: 'out/target/product/suzu/symbols/system/vendor/lib/librmnetctl.so', needed by '/home/mattias/Projects/Halium-7.1/out/target/product/suzu/system/vendor/lib/librmnetctl.so', missing and no known rule to make it

Is there a part I did not configure correctly?

@z3ntu

This comment has been minimized.

Copy link

commented Sep 23, 2018

@mdehollander Looks like you don't have the vendor repo added (or the vendor repo doesn't contain librmnetctl.so).

@fredldotme

This comment has been minimized.

Copy link
Author

commented Sep 23, 2018

I guess this is related to the not yet working audio. I get this error when making the systemimage:

ninja: error: '/home/mattias/Projects/Halium-7.1/out/target/product/suzu/obj_arm/SHARED_LIBRARIES/libaudiopolicymanager_intermediates/export_includes', needed by '/home/mattias/Projects/Halium-7.1/out/target/product/suzu/obj_arm/SHARED_LIBRARIES/libaudiopolicyservice_intermediates/import_includes', missing and no known rule to make it

Setting USE_CUSTOM_AUDIO_POLICY to 0 in device/sony/common/CommonConfig.mk brings me to:

Interesting, I'll try a test with that flag, hasn't happened for me yet.

ninja: error: 'out/target/product/suzu/symbols/system/vendor/lib/librmnetctl.so', needed by '/home/mattias/Projects/Halium-7.1/out/target/product/suzu/system/vendor/lib/librmnetctl.so', missing and no known rule to make it

Is there a part I did not configure correctly?

You could comment out the manual copying of librmnetctl.so files to the system image (within device/sony/loire/platform.mk) and uncomment them later in case the PRODUCT_PACKAGES additions aren't enough.

@mdehollander

This comment has been minimized.

Copy link

commented Sep 23, 2018

Thanks @beidl. Commenting out the copying worked for me. At least it is compiling and now at 50%.

@fredldotme

This comment has been minimized.

Copy link
Author

commented Sep 27, 2018

Thanks @beidl. Commenting out the copying worked for me. At least it is compiling and now at 50%.

Great! Have you tried flashing the image onto your Xperia X? There's a chance it might require an additional apt repo which has already been removed.

@mdehollander

This comment has been minimized.

Copy link

commented Sep 29, 2018

I tried flashing the image to my device, but had to figure out how to do that. And I think I did not do it correctly since I got this error when running halium-install:

I: Unmounting images
I: Shrinking images
I: Pushing rootfs and android image to /data via ADB
error: device not found
Error: Couldn't copy the files to the device, is it connected?
I: Cleaning up host
I: Cleaning up device
error: device not found

I looked a bit at http://docs.halium.org/en/latest/supplementary/devices/nicki.html to find out how to get into fastboot and recovery mode. However, in recovery mode (green led), the device was not found with adb. Therefore I booted into TWRP recovery and then connected the device to the laptop to start halium-install. How did this work for you?

@fredldotme

This comment has been minimized.

Copy link
Author

commented Sep 30, 2018

@mdehollander it could be possible you're missing the udev device rules to establish adb and fastboot connections. You could try installing them using your distributions package manager or find a udev rules file on GitHub.

@fredldotme

This comment has been minimized.

Copy link
Author

commented Oct 27, 2018

Feel free to test a prebuilt image in case you cannot get the build up and running yourself:

https://drive.google.com/open?id=1OJjTosp7jFaYhEYYkB9Mxf3lA0HPIXY6

https://forums.ubports.com/topic/1669/ubuntu-touch-on-sony-xperia-x

@retro486

This comment has been minimized.

Copy link

commented Dec 18, 2018

The prebuilts don't seem to boot for me unless I'm missing a step (flash something else first?). I did flash the nougat OEM blob first. I also can't seem to get the build working but I'll need to try again to get the specific error as it was from a month ago... It would be great to see more Sony Open devices since Sony has been keeping the program up and releasing updated binaries and kernels.

@fredldotme

This comment has been minimized.

Copy link
Author

commented Jan 4, 2019

@retro486 how far along can the bootup process get? Are you able to get an active USB networking connection? You could check using dmesg if a networking device or similar shows up.

@retro486

This comment has been minimized.

Copy link

commented Jan 4, 2019

After booting TWRP and mounting the rootfs.img and changing the ssh init script to run at runlevel 1 (in addition to 2-5) I was able to ssh in. I'm seeing a lot of crashing services in dmesg but I haven't tried the extra sound in the guide above yet... This is using the latest UBports rootfs.

Edit: but it's booting which is awesome!

Edit 2: Woo! After your post-installation fixes listed above I've got Ubuntu Touch on my Xperia X. Holy smokes that's awesome!

Edit 3: I still had to perform a strange fix in that after using halium-install-standalone.sh I booted into TWRP, mounted rootfs.img and changed /etc/init/ssh.conf:

start on runlevel [2345]
stop on runlevel [!2345]

to:

start on runlevel [12345]
stop on runlevel [!12345]

I confirmed I was booting into runlevel 2 so I don't know why I had to add runlevel 1...

@retro486

This comment has been minimized.

Copy link

commented Jan 5, 2019

Final comment then I'll move this to the UT forums but I'm using the stock UT rootfs tarball from their custom Halium wiki. I couldn't get the halium reference rootfs to open SSH.

@fredldotme

This comment has been minimized.

Copy link
Author

commented Jan 9, 2019

Tbf there's still an issue with attaching to an already running LXC container, seems to be a kernel-side issue. Among other things this seems to be the root cause of Plasma Mobile refusing to successfully boot into a graphical session.

@mauricioduarte01

This comment has been minimized.

Copy link

commented May 31, 2019

Can't wait to try this. I am looking to buy a new phone and I think this is the best candidate. Thank you for the hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.