Halium 9 - ubports/porting-notes GitHub Wiki

This page attempts to collect information regarding current Halium 9 development which is not integrated into Halium documentation yet. Porters are expected to partly follow Halium documentation with changes described here.

Basic steps

Current status

  • Only UBPorts rootfs has been tested and it needs modifications:
    • pull in packages compiled against Android 8/9 header files
    • mount scripts and custom LXC android container config (more to follow)
  • More info on to-do list.

UBPorts rootfs

The changes needed to UBPorts rootfs with Halium 9 are collected as debos tool configuration in the following repo:
https://gitlab.com/ubports/core/rootfs-builder-debos/-/blob/master/android9-generic.yaml

Prebuilt rootfs tarballs can be downloaded from UBPorts CI.

At the time of writing this, @erfanoabdi's fork has more patches, and may work better. Please submit PR upstream if you find this to be the case.

Implementation notes

Currently all hybris/halium specific patches to LineageOS repos are kept in https://github.com/Halium/hybris-patches and need to be applied manually instead of forking individual repositories as before. An attempt was made to deviate as little as possible from mer-hybris setup to keep changes small system/core has ueventd reenabled to run inside LXC, but otherwise keeps many Mer patches and would not mount core filesystems by itself, so LXC config has to be adjusted to do that Large part of former LXC pre-start.sh script is not relevant anymore as system image is read-only and becomes root of container instead of unpacked ramdisk as before

Generating udev rules

DEVICE=lavender # replace with your device codename
cat /var/lib/lxc/android/rootfs/ueventd*.rc /vendor/ueventd*.rc | grep ^/dev | sed -e 's/^\/dev\///' | awk '{printf "ACTION==\"add\", KERNEL==\"%s\", OWNER=\"%s\", GROUP=\"%s\", MODE=\"%s\"\n",$1,$3,$4,$2}' | sed -e 's/\r//' >/etc/udev/rules.d/70-$DEVICE.rules

Troubleshooting common issues

Build errors when doing make systemimage

  • If you get an error like ninja: error: '<build>/out/soong/host/linux-x86/framework/turbine.jar', needed by..., then it's because there are still some Android Java packages in the image. You should remove them, but the difficult part is to find out which packages they are. One possible shortcut is to look at the Halium device tree of a similar already ported device (from the same vendor) and try applying the same changes you'll find in there.

  • Look for and eventually grep for telephony-ext in your device.mk configuration file and comment it out, as follows:

PRODUCT_BOOT_JARS += \
#    telephony-ext

or another example is:

PRODUCT_BOOT_JARS += \
#    WfdCommon
  • To avoid EasterEggs.jar errors you need to comment out any occurrency of .jar/.apk needed libraries or files. In particular, check in your device lineage_{devicename, platformname}.mk (at device/your_vendor/{devicename, platformname}) and assure to comment out #$(call inherit-product, vendor/lineage/config/common_full_phone.mk) and #$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)

  • If the build fails with an error like

      File "build/make/tools/check_radio_versions.py", line 56
        print "*** Error opening \"%s.sha1\"; can't verify %s" % (fn, key)
            ^
    SyntaxError: invalid syntax
    

    it's because your Linux distribution ships python3 as the default python interpreter, while Halium still uses python2. You can workaround this by creating a virtual environment:

    virtualenv --python 2.7 ~/python27  # adjust the path to your prefs
    source ~/python27/bin/activate

    You'll have to run the second line every time you want to setup your build environment (that is, everytime you run breakfast).

    As an alternative, you can:

      $ sudo update-alternatives --config python
      There are 2 choices for the alternative python (providing /usr/bin/python).
    
      Selection    Path                Priority   Status
      ------------------------------------------------------------
      * 0            /usr/bin/python3.7   2         auto mode
        1            /usr/bin/python2.7   1         manual mode
        2            /usr/bin/python3.7   2         manual mode
    
      Press <enter> to keep the current choice[*], or type selection number: 1
      update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode
      $
    

Qualcomm devices with Linux kernel 4.4 panic with CONFIG_VT enabled

Apply these patches in this particular order:

  1. tty: check before stopping kthread (link)
  2. tty: move tty_port workqueue to be a kthread (link)
  3. tty: add tty_port_set_policy function (link)
  4. Revert "serial: msm_serial_hs: Protect spurious irqs after wakeup irq enablement" (link)
  5. msm_serial_hs: make the Bluetooth tty thread RT (link)
  6. Make msm_serial_hs RT to improve bluetooth performance (link)

Qualcomm devices with Linux kernel 3.18 panic with CONFIG_VT enabled

Apply these patches in this particular order:

  1. tty: move tty_port workqueue to be a kthread (link)
  2. tty: add tty_port_set_policy function (link)
  3. msm_serial_hs: make the Bluetooth tty thread RT (link)

Allow creation of a SYSTEM_ROOT (android-rootfs.img) image instead of system.img

You need to add in BoardConfig.mk or BoardConfigCommon.mk the following lines:

# To enable system image
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true

During your porting, unless you use GSI images, if you would like to specify it in your installation with halium-install, you need to specify -s option, as follows:

$ halium-install -v -s -p ut your_rootfs.targz your_system.img

Treblerizing your not-treble device

Although it might pose at risk you device, you might need to treblerize your device by creating a vendor partition, previously not foreseen in other device. For instance, in device msm8953, you can convert an oem partition into a vendor as follows: https://github.com/Sohamlad7/android_kernel_motorola_msm8937/commit/cbe246c5f38ae7743311849ff64edfdbf2419e06#diff-10d64499f13f6f9b8be9d3a43b5250983234dede9d3bca038f25788c51923d0a

In this case, it might usefull to force the system to create a vendor image with mka vendorimage command, by adding in BoardConfig.mk (as in device LG V20) the following lines:

# Require for treble
BOARD_VENDORIMAGE_PARTITION_SIZE := 665845760
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
PRODUCT_FULL_TREBLE_OVERRIDE := true
TARGET_COPY_OUT_VENDOR := vendor
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true

# VNDK
# PRODUCT_USE_VNDK_OVERRIDE := false
BOARD_VNDK_VERSION := current
BOARD_VNDK_RUNTIME_DISABLE := true

keeping in mind that the partition dimension must be adapted to your device. You also need to add or integrate in device.mk

# VNDK
PRODUCT_PACKAGES += \
    libstdc++.vendor \
    vndk_package
⚠️ **GitHub.com Fallback** ⚠️