Troubleshooting:kernel
Here are some common kernel compilation problems listed. For debugging a kernel that compiles, but does not boot, see Troubleshooting:boot.
Patching the kernel
In many cases, the issue that you're experiencing with kernel compilation can be fixed by a patch. Sometimes, other kernels already in pmOS might've had the same issue; for example, if you get a specific error, you can look for patches that mention it in pmaports with grep -iR "error message" ~/.local/var/pmbootstrap/cache_git/pmaports/device
.
To apply a patch to a kernel, place the .patch
file containing the patch in your device/category/linux-vendor-flavor
folder and add the patch name to the source
variable in your APKBUILD
file.
Making patches from commits
If you want to apply a commit from a git repository as a patch, you have multiple options:
- If it's a GitHub or GitLab commit, you can get a patch file by appending
.patch
to the URL of the commit.- This also works with pull requests/merge requests.
- You can also clone the git repository, then run
git format-patch -1 <commit>
(replace<commit>
with the commit ID; you can also get multiple patches preceeding the given patch by changing the number from1
).
Booting the kernel with specific arguments
You can configure CONFIG_CMDLINE
so that the arguments are permanent (you may also need to set CONFIG_CMDLINE_EXTEND
to append the cmdline to the one provided by the bootloader, or CONFIG_CMDLINE_FORCE
to overwrite it (alternatively, unset CONFIG_CMDLINE_FROM_BOOTLOADER
)).
On some devices, you can change it at boot time using fastboot or pmbootstrap, for example:
$ fastboot boot -c "console=ttyHSL0,115200,n8"
...
$ pmbootstrap flasher boot --cmdline "quiet"
TLS (SSL/HTTPS) is broken!
If you see messages like these, when trying to access HTTPS pages, read on:
Connecting to pastebin.com (104.20.209.21: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.
Kernel compilation issues
PTY allocation request failed
PTY allocation request failed on channel 0 -ash: a: unknown operand
Go to kernel configuration, you have probably missed CONFIG_DEVTMPFS
!
CROSS_COMPILE_ARM32 not defined or empty
Try unset CONFIG_COMPAT_VDSO from your kernel config.
(some header file): No such file or directory
Busybox's 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.)
linux/types.h: No such file or directory
Add linux-headers
to makedepends of linux-* APKBUILD.
thumb conditional instruction should be in IT block
arch/arm/crypto/aesbs-core.S:449: Error: thumb conditional instruction should be in IT block -- `addeq r6,r6,#0x10' arch/arm/crypto/aesbs-core.S:904: Error: thumb conditional instruction should be in IT block -- `addeq r6,r6,#0x10' arch/arm/crypto/aesbs-core.S:2100: Error: thumb conditional instruction should be in IT block -- `subne r9,#0x10'
You can fix it by disabling CONFIG_CRYPTO_AES_ARM_BS
with:
pmbootstrap kconfig edit
Then go to Cryptographic API
and disable Bit sliced AES using NEON instructions
.
On some other devices, like Huawei P7, you might also need to disable all CRYPTO flags containing ARM (CONFIG_CRYPTO_{algorithm name}_ARM
), which are ARM NEON optimizations.
This was first noticed in pmaports!144.
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 themakedepends=
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.
xz: not found
If you see something like this in the logs:
XZKERN arch/arm/boot/compressed/piggy.xzkern /home/pmos/build/src/android_kernel_samsung_msm8226-3fa1853ed5d6c3a8ef5a2fda9822705243bbc256/scripts/xz_wrap.sh: exec: line 23: xz: not found
It's similar to the "BusyBox lzma compression fails" issue above: some things are compressed with LZMA and will need xz
installed. Add it to the makedepends
of your APKBUILD
.
Error: .err encountered in assembler messages
If compilation errors out on something like this in logs:
/tmp/ccmAkEIJ.s: Assembler messages: /tmp/ccmAkEIJ.s:2280: Error: .err encountered
Then older version of GCC should be used for compilation.
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.
Example from linux-asus-z00vd:
# Remove -Werror from all makefiles
local i
local makefiles="$(find . -type f -name Makefile)
$(find . -type f -name Kbuild)"
for i in $makefiles; do
sed -i 's/-Werror-/-W/g' "$i"
sed -i 's/-Werror//g' "$i"
done
Error: selected processor does not support ARM mode `smc #0'
Try this patch: https://github.com/imoseyon/leanKernel-galaxy-nexus/pull/6
Downstream kernel issues by manufacturer
Mediatek
../tools/dct/DrvGen: No such file or directory
This error is specific to Mediatek kernels and it occures when DrvGen tries to load libc6.so library it has been linked against but Alpine chroot doesn't support libc. One of the solutions is to copy python3dct.patch to your linux-... directory and activate it in the APKBUILD. This patch replaces precompiled DrvGen with a python3 version.
Qualcomm
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.
X11 does not work on Qualcomm devices
Try apply this patch.
MSM framebuffer doesn't work
We found out that removing the 3D driver support makes the MSM framebuffer work. See !66.
CONFIG_MSM_KGSL=n
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)~/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