Halium-7.1 - Building#

For Halium-7.1 porting it is necessary to build both halium-boot.img and system.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 will look like 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, 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 需要设置 console=tty0#

halium-boot initramfs 希望 /dev/console``是一个控制台设备,如果它不存在,就不会启动 init。这种情况通常发生在最近的设备上,因为它们要么禁用了 UART,要么默认没有指定 `console=``(为空)。这可以通过提供 ``console=tty0 作为内核 cmdline 的最后一个参数来解决。要做到这一点,请按以下步骤操作:

这应该在一个在你的设备树根目录下名为 BoardConfig.mk (or BoardConfigCommon.mk) 的 makefile 文件中完成,例如 ~/halium/device/<vendor>/<model_codename>/BoardConfig.mk

添加如下行:

BOARD_KERNEL_CMDLINE += console=tty0

如果你的 makefile 已经包含了 BOARD_KERNEL_CMDLINE 开头的行,你可以把它加在下面,以保持整洁。

备注

上述方法虽然是首选,但对某些三星设备可能不适用。其结果是,启动后你无法通过ssh访问设备,Unity 8也无法启动。如果你遇到这个问题,你可以在设备的内核配置文件中指定设置来代替。添加以下几行:

CONFIG_CMDLINE="console=tty0"
CONFIG_CMDLINE_EXTEND=y

备注

在极少数情况下,bootloader会覆盖内核命令行参数,使上面的设置失去作用。谷歌Pixel 3a(sargo)就属于这种情况。要处理这个问题,请依照`这个commit <https://github.com/fredldotme/android_kernel_google_bonito/commit/d0741dded3907f2cf4ecdc02bfcb74fc252763ff>`_ 。

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.

I 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)#

Once you have successfully built halium-boot.img you can proceed to directly to building system.img:

mka systemimage

Likelier than not, you will run into one or more errors along the way when building the system image. A number of possible errors are documented in the Halium guide. If yours is not listed, seek community help.