How to compile ONLY a kernel
doniks last edited by doniks
While trying to build the whole system for my N7, I'm looking for a way of ONLY building a kernel, preferably outside of the whole gigantic source tree checked out by
However, I think I'm stuck with two (hopefully) simple questions:
- how to set the kernel config file
- how to do the cross compilation
What I've tried so far:
- clone the kernel I want to try ( git://github.com/freedreno/kernel-msm.git, branch mako-kernel)
- copy the config I want to use into
- but when I try to run
makeit will always insist on going through an endless series of questions what to configure and how to update the config instead of just using it
- looking at this: https://stackoverflow.com/questions/41885015/what-exactly-does-linux-kernels-make-defconfig-do#41886394 I have now copied my config into
- when I now run
make ARCH=arm myconfig_defconfigit says it copied the config, OK
- However afterwards I run
make ARCH=armit fails quickly (error below). I think this is because I'm using the wrong compiler. Which would make sense because I'm on my laptop and I guess I need an arm crosscompiler, but I don't know how to do this.
CHK include/linux/version.h CHK include/generated/utsrelease.h make: 'include/generated/mach-types.h' is up to date. CC kernel/bounds.s gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’ gcc: note: valid arguments to ‘-mabi=’ are: ms sysv gcc: error: unrecognized command line option ‘-mlittle-endian’ gcc: error: unrecognized command line option ‘-mapcs’ gcc: error: unrecognized command line option ‘-mno-sched-prolog’ gcc: error: unrecognized command line option ‘-mno-thumb-interwork’ /media/peter/share2/data/freedreno/kernel-msm/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
Can someone help me? Am I just approaching this the wrong way?
doniks last edited by doniks
I think I figured it out - the compiler is happily chugging along - let's see.
What I did was: Following this: https://www.acmesystems.it/arm9_toolchain , https://wiki.ubuntu.com/KernelTeam/ARMKernelCrossCompile I did
sudo apt install gcc-arm-linux-gnueabihf export CROSS_COMPILE=arm-linux-gnueabihf- export CC=/usr/bin/arm-linux-gnueabihf-gcc export $(dpkg-architecture -aarmhf) make clean make ARCH=arm myconfig_defconfig make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf-
That got me one step further, but then make was complaining about something with gcc 5, so I assume that I was using a too new compiler version, so I installed 4.8. Afterwards it seemed as if still the wrong compiler was picked up at some steps, so I created a couple of symlinks to make sure it uses the right one:
sudo apt install gcc-4.8-arm-linux-gnueabihf
mkdir ~/bin-gcc-4.8 cd ~/bin-gcc-4.8 ln -s /usr/bin/arm-linux-gnueabihf-gcc-4.8 . ln -s arm-linux-gnueabihf-gcc-4.8 arm-linux-gnueabihf-gcc ln -s /usr/bin/arm-linux-gnueabihf-ld . ln -s /usr/bin/arm-linux-gnueabihf-ar .
export PATH=~/bin-gcc-4.8:$PATH export CC=/usr/bin/arm-linux-gnueabihf-gcc-4.8 export CROSS_COMPILE=arm-linux-gnueabihf- export $(dpkg-architecture -aarmhf) make clean make ARCH=arm myconfig_defconfig make ARCH=arm CROSS_COMPILE=~/bin-gcc-4.8/arm-linux-gnueabihf-
Maybe there are more straight forward ways to achieve this ... Whatever, it seems to work
Yes, that is exactly how you do it. Generally the Android build system will use its own customized versions of gcc automagically, so you need to specify any alternatives yourself in a single build.
I was able to use update-alternatives to swap out my compilers once upon a time, though I don't recommend that unless you're building in a container. https://forums.ubports.com/topic/129/solution-building-ubuntu-touch-source-on-ubuntu-16-10