Halium-9.0 - Building#

When doing a Halium 9.0 port, you first need to build halium-boot.img. This boot image can then either be combined with the GSI, or you can build your own, device-specific system.img as well.

Building the boot image (halium-boot.img)#

Initializing the build environment#

First you need to initialize the environment using the envsetup.sh tool included in your source tree. Enter your BUILDDIR and issue the command:

source build/envsetup.sh

The output should resemble this:

including device/lge/bullhead/vendorsetup.sh
including vendor/cm/vendorsetup.sh
including sdk/bash_completion/adb.bash
including vendor/cm/bash_completion/git.bash
including vendor/cm/bash_completion/repo.bash

The breakfast command is used to set up the build environment for a specific device. From the root of your BUILDDIR run the following command, replacing [CODENAME] with your device’s specific codename:

breakfast [CODENAME]

Breakfast will attempt to find your device, set up all of the environment variables needed for building, and give you a summary at the end.

Modify the kernel configuration#

The default LineageOS/Halium kernel configuration file needs modifications as Ubuntu Touch requires a slightly different kernel config than Halium, including enabling Apparmor. A script that does this job is provided in your Halium source tree: BUILDDIR/halium/halium-boot/check-kernel-config.

Locate your configuration file. It should be at arch/arm/configs/<CONFIG> or arch/arm64/configs/<CONFIG> depending on the architecture of your device. If you have trouble finding it, run grep "TARGET_KERNEL_CONFIG" device/<VENDOR>/<CODENAME>/BoardConfig.mk to determine the location.

Then, from the root of your BUILDDIR, run:

./halium/halium-boot/check-kernel-config path/to/my/defconfig -w

Может быть, скрипт придётся запустить дважды. Скорее всего, только за два раза будут сделаны необходимые изменения. Затем запустите скрипт без флага `` -w``, чтобы увидеть, есть ли еще ошибки. Если есть, исправьте их вручную. После завершения запустите скрипт без флага `` -w`` еще раз, чтобы убедиться, что все правильно.

Ubuntu Touch требует настроить консоль в режиме tty0#

Образ Initramfs с halium-boot предполагает, что /dev/console будет консольным устройством, и не запустит init, если он недоступен. Это обычно случается с недавно выпущенными устройствами, потому что у них либо отключен UART, либо значение ``console=``по умолчанию не указано (null). Это можно исправить, указав в последнем аргументе console = tty0 в командной строке ядра:

Это должно быть сделано в make-файле BoardConfig.mk (или BoardConfigCommon.mk), который находится в корневом каталоге дерева устройства, например ~/halium/device/<vendor>/<model_codename>/BoardConfig.mk

Добавьте следующую строку:

BOARD_KERNEL_CMDLINE += console=tty0

Если в make-файле уже есть строчка, начинающуюся с BOARD_KERNEL_CMDLINE, вы можете добавить ее чуть ниже, чтобы текс выглядел аккуратно.

Примечание

Вышеупомянутый метод, хотя и является предпочтительным, может не работать на некоторых устройствах Samsung. В результате не удастся получить доступ к устройству через ssh после загрузки, и Unity 8 не сможет запуститься. Если вы столкнулись с этой проблемой, то вместо этого можно указать параметр в файле конфигурации ядра устройства. Добавьте следующие строки:

CONFIG_CMDLINE="console=tty0"
CONFIG_CMDLINE_EXTEND=y

Примечание

В редких случаях загрузчик перезаписывает аргумент командной строки ядра, что делает бесполезной указанную выше настройку. Так обстоит дело со смартфоном Google Pixel 3a (sargo). Чтобы решить эту проблему, скопируйте этот коммит <https://github.com/fredldotme/android_kernel_google_bonito/commit/d0741dded3907f2cf4ecdc02bfcb74fc252763ff> _.

Setting system as root#

For Halium 9, we need the system image to be built as system-as-root (for treble devices it should already be there). Please check your boardconfig.mk for the following line, if it’s there you can skip this step:

BOARD_BUILD_SYSTEM_ROOT_IMAGE := true

If the above is not there, we have to add it.

As this change makes the android root read-only, we may have to ship mount points for some important partitions like firmware, persist with the system image, for this we can use the line:

BOARD_ROOT_EXTRA_FOLDERS := \
 /firmware \
 /dsp \
 /persist

Примечание

For now this is enough, but you may need to add more mount points depending on your device. After successful boot do ls -la / and add folders corresponding to broken symlinks.

These changes may also bring in some context errors,please refer this commit to fix them.

Build#

Halium will use the mkbootimg tool for creating the boot image. In most cases it is not on the local harddisk, so it can be built by issuing:

mka mkbootimg

Now build the halium-boot.img using the commands:

export USE_HOST_LEX=yes
mka halium-boot

Примечание

If you prefer make instead of mka you should set -j[num] for parallel building, which reduces build time. Replace [num] with the number of threads in your system plus 2.

Build errors#

There are a number of known build errors which you might encounter, depending first of all upon how rigorous you have been in following the steps outlined, but you may also run into unforeseen issues. If your build fails at first, make sure you have done exactly as described, then go through the list of known errors in the Halium guide.

If your particular error is not listed, you will need to do some research of your own. If you end up here, know that there is a community of porters, developers and enthusiasts who might be able to help you. Refer to Обращение за помощью к сообществу пользователей.

Building the system image (system.img)#

If you are using the Halium-boot method, you can skip this step. If you are following the Full system image method, this step is required.

Halium will use the e2fsdroid tool for creating the system image. In most cases it is not on the local harddisk, so it can be built by issuing:

mka e2fsdroid

To build the system image:

mka systemimage

It’s likely that you will run into one or more errors when building the system image. A number of possible errors and known solutions are documented in the Halium guide. If yours is not listed, seek community help.