From postmarketOS
Jump to: navigation, search

Here are some common kernel compilation problems listed. For debugging a kernel that compiles, but does not boot, see Troubleshooting:boot.

How to create a patch

Patching a kernel is as simple as putting a .patch file in your aports/device/linux-vendor-flavor folder and adding the patch name to the source variable in your APKBUILD file. See also: How to create a patch when packaging software.

undefined reference to kgsl_iommu_sync_lock

drivers/built-in.o:(.data.rel+0x68c): undefined reference to kgsl_iommu_sync_lock'
drivers/built-in.o:(.data.rel+0x690): undefined reference to kgsl_iommu_sync_unlock'

You need to apply the gpu-msm-fix-gcc5-compile.patch patch.

How can I boot the kernel with some specific arguments?

You can configure CONFIG_CMDLINE so that the arguments are permanent or change it in boot time using fastboot or pmbootstrap, for example:

fastboot boot -c "console=ttyHSL0,115200,n8" ...

pmbootstrap flasher boot --cmdline "PMOS_NO_OUTPUT_REDIRECT"

MSM framebuffer doesn't work

We found out that removing the 3D driver support makes the MSM framebuffer. See #66.


PTY allocation request failed

PTY allocation request failed on channel 0
-ash: a: unknown operand

Go to Common configurations, you have probably missed CONFIG_DEVTMPFS!

Kernel compilation: (some header file): No such file or directory

Busybox' zip implementation does not extract symlinks. There are two workarounds. One is to use another archive type (typically kernel sources are downloaded from GitHub, where you can also get the source as .tar.gz - simply by changing the extension in the URL).

The other workaround is to add unzip to the makedepends, so it uses the original unzip instead of the busybox version.

(This has been fixed in busybox in the meantime.)

Kernel compilation: BusyBox lzma compression fails

In case you get the following output:

LZMA    arch/arm/boot/compressed/piggy.lzma
lzma: unrecognized option: 9
BusyBox v1.26.2 (2017-06-11 06:37:13 GMT) multi-call binary.

Usage: lzma -d [-cf] [FILE]...

Decompress FILE (or stdin)

        -d      Decompress
        -c      Write to stdout
        -f      Force

In the BusyBox version shipped with Alpine Linux, only lower compression levels are enabled (to reduce the binary size). The kernel you're building is configured to compress with LZMA at the highest compression level. Pick one
of the following solutions:

  • Add xz to the makedepends= line. Then the "real" lzma binary will be used instead of the Busybox version. This is recommended, because then your kernel will get built most similar to how it is built elsewhere, so you have the

lowest risk of introducing a reason for the kernel not to boot (because the kernel is too big in size or something like that)

  • Reduce the compression ratio by adding this patch. This will not introduce any dependency, but increase the kernel size.
  • Use another compression algorithm (run pmbootstrap menuconfig linux-... and change it there). Gzip should work, but will produce a big kernel, because pmbootstrap currently installs a workaround to always use the fastest compression method (-1), when the most compressing one (-9) is chosen. This will increase the kernel size the most.

Android Kernel compilation fails on warnings (not on errors) (-Werror)

Don't even bother fixing all those warnings, there are too many of them and we don't want the outdated Android kernels in the long run anyway! When you generate your kernel APKBUILD with pmbootstrap init, then you should have code in the prepare() that automatically removes the -Werror parameter in all Makefiles.

Building the kernel with Android's build system

It might be useful for debugging to build Android's kernel with Android's build system.

You can follow the LineageOS building guide for your device (see this for titan device as example).

The process should be similar for other devices:

# make some directories
mkdir -p ~/bin
mkdir -p ~/android/lineage

# download the 'repo' tool
curl > ~/bin/repo
chmod a+x ~/bin/repo

# clone LineageOS
cd ~/android/lineage
~/bin/repo init -u -b cm-14.1

# Download the rest of dependencies (this will take a while and about *TODO* GB of disk space)
~/bin/repo sync

# now prepare the build for your device (replace 'titan' with the device you want to for the kernel for)
source build/
breakfast titan

# Now instead of following the rest of the guide (which will compile both Android and the kernel
#  for your device), simply compile the kernel:
mka kernel

# This command will also generate the device tree, initramfs and boot.img images
mka bootimage

You can check the $OUT environment variable and cd into it. In the case of titan the interesting generated files are:

  • ~/android/lineage/out/target/product/titan/boot.img (boot image ready to be flashed: kernel + initramfs)
  • ~/android/lineage/out/target/product/titan/dt.img (device trees)
  • ~/android/lineage/out/target/product/titan/kernel (linux image)
  • ~/android/lineage/out/target/product/titan/ramdisk.img (compressed initramfs)

The defconfig used is available at ~/android/lineage/kernel/motorola/msm8226/arch/arm/configs/titan_defconfig

Error: selected processor does not support ARM mode `smc #0'

Try this patch: