Here are some common kernel compilation problems listed. For debugging a kernel that compiles, but does not boot, see Troubleshooting:boot.
- 1 How to create a patch
- 2 undefined reference to kgsl_iommu_sync_lock
- 3 How can I boot the kernel with some specific arguments?
- 4 MSM framebuffer doesn't work
- 5 PTY allocation request failed
- 6 Kernel compilation: (some header file): No such file or directory
- 7 Kernel compilation: BusyBox lzma compression fails
- 8 Android Kernel compilation fails on warnings (not on errors) (-Werror)
- 9 TLS (SSL/HTTPS) is broken!
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
Kernel compilation: (some header file): No such file or directory
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:
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 https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo # clone LineageOS cd ~/android/lineage ~/bin/repo init -u https://github.com/LineageOS/android.git -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/envsetup.sh 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)
The defconfig used is available at
Error: selected processor does not support ARM mode `smc #0'
Try this patch: https://github.com/imoseyon/leanKernel-galaxy-nexus/pull/6
TLS (SSL/HTTPS) is broken!
If you see messages like these, when trying to access HTTPS pages, read on:
Connecting to pastebin.com (126.96.36.199:443) ssl_client: pastebin.com: TLS connect failed wget: error getting response: Connection reset by peer
You are probably running an older kernel (pre 3.17), which does not yet have the "getrandom" syscall. This is required by modern openssl/libressl versions (Alpine was on libressl for a long time, then switched back to openssl). Check your kernel version, and if that is the case, and mainlining is not feasible for you, consider backporting the getrandom syscall like done in pmaports!69. This issue was discussed in pmaports#107.