How to rebuild kernel only?

289 views
Skip to first unread message

ma...@xemi.net

unread,
Jul 18, 2018, 10:20:22 PM7/18/18
to Android-x86
Is there a command to rebuild kernel only?

Typically usually something like "make -j8 kernel" would work... but doesn't seem to rebuild kernel after making changes.

I suppose I could remove the kernel obj directory, but that would rebuild the entire kernel, not just the changes.

Chih-Wei Huang

unread,
Jul 18, 2018, 10:26:29 PM7/18/18
to Android-x86
The reason is the Androud build system won't parse
kernel's makefile directly so it won't see the changes
in the kernel tree.

To force to rebuild kernel, you can touch the kernel
config file (kernel/arch/x86/configs/android-x86_*)
or just remove the kernel image:

rm $OUT/kernel

Either way will trigger kernel rebuilding.

--
Chih-Wei
Android-x86 project
http://www.android-x86.org

Mauro Rossi

unread,
Jul 19, 2018, 12:46:56 AM7/19/18
to Android-x86
Hi Chih-Wei,

just a question, when I perform changes in kernel in order to force rebuild of kernel,
I tried to delete the .config file in out/target/product/{x86,x86_64}/obj/kernel
in this case kernel is also rebuilt, 

but I wanted to check is this way or other ways limiting the re-build only to changed parts in the sources,
or there some drawback (e.g. entire kernel is rebuilt) in some of these ways or all of them?
Thanks for comments

Mauro

Chih-Wei Huang

unread,
Jul 19, 2018, 1:18:52 AM7/19/18
to Android-x86
2018-07-19 12:46 GMT+08:00 Mauro Rossi <issor...@gmail.com>:
> Hi Chih-Wei,
> just a question, when I perform changes in kernel in order to force rebuild
> of kernel,
> I tried to delete the .config file in
> out/target/product/{x86,x86_64}/obj/kernel
> in this case kernel is also rebuilt,

Surely it's OK to do so.

> but I wanted to check is this way or other ways limiting the re-build only
> to changed parts in the sources,
> or there some drawback (e.g. entire kernel is rebuilt) in some of these ways
> or all of them?

As I've said, the reason is the Android build system doesn't parse
kernel's makefile (kbuild). That means the kernel tree is not on the
dependency path to build an Android image.
The current only dependency I set is

system.sfs -> $OUT/kernel -> $OUT/obj/kernel/.config ->
kernel/arch/x86/configs/android-x86_*

So if you want to rebuild kernel, you just need to change (touch)
any file on the the dependency path.

Basically speaking, Android build system is totally different
than kbuild. kbuild is a traditionally recursive make system,
(i.e., subfolders are made by submake)
while Android's is designed to be non-recursive.
It's very hard to integrate them together seamless.

Since Android build system is using ninja now,
I'm also looking at the Kninja project:

https://github.com/rabinv/kninja

It may give us an opportunity to integrate the two
build systems seamless.
But it's just a low priority task. I haven't try it yet.

youling 257

unread,
Jul 28, 2018, 8:09:41 PM7/28/18
to Android-x86
when you change kernel source tree,you need delete output kernel and modules,then under Android source tree,lunch command rebuild iso,
write iso to u-disk,run live mode on your test device .

you do that ?

在 2018年7月19日星期四 UTC+8下午12:46:56,Mauro Rossi写道:

youling 257

unread,
Jul 28, 2018, 8:13:17 PM7/28/18
to Android-x86
git clone kernel source,cd kernel source folder
make android-x86_64_defconfig -C . O=../64
cd ../64
time make targz-pkg -j8

在 2018年7月19日星期四 UTC+8上午10:20:22,ma...@xemi.net写道:

youling 257

unread,
Jul 28, 2018, 8:26:20 PM7/28/18
to Android-x86
$ cd 3
$ git am 0001-platform-x86-touchscreen_dmi-Add-info-for-the-Cube-K.patch
fatal: could not open '0001-platform-x86-touchscreen_dmi-Add-info-for-the-Cube-K.patch' for reading: No such file or directory
$ git am ../0001-platform-x86-touchscreen_dmi-Add-info-for-the-Cube-K.patch
Applying: platform/x86: touchscreen_dmi: Add info for the Cube KNote i1101 tablet
$


root@localhost:/home/youling257# cd /data/data/com.termux/files/home/64
root@localhost:/data/data/com.termux/files/home/64# time make targz-pkg -i -j8
make KBUILD_SRC=
  GEN ./Makefile
  DESCEND objtool
  Using /data/data/com.termux/files/home/3 as source for kernel
  CALL /data/data/com.termux/files/home/3/scripts/checksyscalls.sh
  CHK include/generated/compile.h
  CC drivers/platform/x86/touchscreen_dmi.o
  AR drivers/platform/x86/built-in.a
  AR drivers/platform/built-in.a
  AR drivers/built-in.a
  GEN .version
  CHK include/generated/compile.h
  UPD include/generated/compile.h
  CC init/version.o
  AR init/built-in.a
  AR built-in.a
  LD vmlinux.o
  MODPOST vmlinux.o
  KSYM .tmp_kallsyms1.o
  KSYM .tmp_kallsyms2.o
  LD vmlinux
  SORTEX vmlinux
  SYSMAP System.map
  Building modules, stage 2.
  CC arch/x86/boot/version.o
  AS arch/x86/boot/compressed/head_64.o
  VOFFSET arch/x86/boot/compressed/../voffset.h
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  RELOCS arch/x86/boot/compressed/vmlinux.relocs
  CC arch/x86/boot/compressed/kaslr.o
  CC arch/x86/boot/compressed/pgtable_64.o
  GZIP arch/x86/boot/compressed/vmlinux.bin.gz
  CC arch/x86/boot/compressed/misc.o
  MKPIGGY arch/x86/boot/compressed/piggy.S
  AS arch/x86/boot/compressed/piggy.o
  DATAREL arch/x86/boot/compressed/vmlinux
  LD arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  OBJCOPY arch/x86/boot/vmlinux.bin
  AS arch/x86/boot/header.o
  LD arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  BUILD arch/x86/boot/bzImage
Setup is 16156 bytes (padded to 16384 bytes).
System is 8657 kB
CRC 146a8cd6
Kernel: arch/x86/boot/bzImage is ready (#3)
Screenshot_20180729-081748.png
Screenshot_20180729-082254.png
Reply all
Reply to author
Forward
0 new messages