Build Android kernel from source


New Member
Jun 28, 2023
Reaction score

Nice to be here.
I try to compile android kernel from source, but every time got errors.

I found kernel here:
Samsung kernel for SM A510F

I downloaded tools from here:

tar xf gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu.tar.xz

Tools is located in source folder (inside kernel folder)

export ARCH=arm64

export CROSS_COMPILE=./source/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-


make exynos7580-a5xelte_defconfig

make -j$(nproc –all)

I open kernel folder and compile the sources:

I got a few errors: tools not found etc.

Where is my mistake?
Any help will be greatly appreciated!
Last edited:

Welcome to the Forums, @Lena10.

This forum is not affiliated with Samsung or any other downstream kernel, nor even with the Linux Kernel itself --it's a community forum. For that, probably the best place to ask is to the maintainer of the sources you're trying to compile.

However, from this part of your message:

I got a few errors: tools not found etc

... it seems that you're missing some packages installed. Can you list the missing tools and the distribution you're using to build the kernel? You may be able to get some help in that regard.
@Lena10 : If you could post the exact error messages that were output by, it would make it a lot easier for us to help you fix the problem.

Create a new reply in this thread and copy/paste the errors from the script inside a set of [code][/code] BB tags and we should be able to give you exact steps to take, in order to fix the problem.
Thank all of you for help!

gvisoc, I installed packages:

dpkg --add-architecture i386
apt install build-essential ncurses-dev gcc-multilib

I try to build official Samsung 3.10 kernel on my laptop with OS Debian.


when I execute ./ I got errors:

user@domen:~/Samsung_Kernel$ ./
# configuration written to .config
scripts/kconfig/conf --silentoldconfig Kconfig
INFO: CC is ./source/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      scripts/mod/empty.o
  HOSTLD  scripts/dtc/dtc
/usr/bin/ld: scripts/dtc/ multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
  CC      scripts/mod/devicetable-offsets.s
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/ scripts/dtc/dtc] Error 1
make[1]: *** [scripts/ scripts/dtc] Error 2
make[1]: *** Waiting for unfinished jobs....
  HOSTCC  scripts/mod/sumversion.o
  CC      kernel/bounds.s
  GEN     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  GEN     include/generated/bounds.h
  CC      arch/arm64/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/
  HOSTLD  scripts/mod/modpost
make: *** [Makefile:544: scripts] Error 2
make: *** Waiting for unfinished jobs....

OK, it looks like the build is failing during linking, due to the redefinition of a symbol called yylloc - ld doesn't know which of the definitions is the correct one and is just failing.
Now that you have all of the relevant tools and libraries installed, perhaps try building again with a clean version of the source-code.
Maybe your earlier attempts to build the kernel caused the code-base to end up in a weird state. So after you installed all of the relevant tools and libraries, perhaps there were some artifacts leftover from the previous build attempts, which are causing the problem.
So perhaps delete the source-code you're using and unzip/untar the original source archive again and try doing a clean build with a fresh copy of the source code. With any luck, that will fix the problem.
@JasKinasis :-


It's astonishing how many folks forget that one, simple step. Once your build-process has quit/stalled/hung - for whatever reason - that particular copy of the source code is then corrupted, and any further attempts to use it are doomed to failure.

Lesson to learn:- Never throw away your source-code tarball until you are absolutely certain you won't be wanting it any more!

Took me several attempts when I first tried my hand at this stuff before I realised what was going on.....but the lesson was, indeed, thoroughly learnt.

Mike. ;)
Thank you!
I solved problems step by step:

1. I did clean build with a fresh copy of the source code.
2. Use absolute path to compiler
export CROSS_COMPILE=/home/user/kernel folder/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

3. Add "extern" keyword to YYLTYPE yylloc in scripts/DTC/

I got new error:
file not found: unit/vmm.elf
scripts /Make init vmm.o Error1

In internet I found that it can be missing header mistake. But I didn't find how it can be solved.

If possible point me to the right direction!
I followed this article How to compile Android kernel for Samsung A8

I could compile the kernel from this article without any errors. But I have Samsung A5 2016 (A510F) and this kernel causes bootloop for my phone.
I try to compile kernel for my model from lineage os githup page but got errors (see above). Why linaro compiler didn't work properly for kernel I try to build?

Lineage OS kernel 7580
Last edited:
Almost all problems solved. But one thing I can't understand.
I compile 3.10 kernel
I use Android 12 custom ROM on my smartphone. What should I write in


Without this I got message while compiling the kernel:

Makefile 155: Not found Android version file. Set none.
If it’s Android 12, then ANDROID_MAJOR_VERSION should be set to 12.

Staff online

Members online