Zach Zach - 16 days ago 8x
Android Question

Error while trying to compile android kernel in ubuntu

I'm trying to compile a Android Kernel from source and I believe I have downloaded all the right packages to do it but for some reason I get this error --->

arm-linux-androideabi-gcc: error: unrecognized command line option '-mgeneral-regs-only'
/home/livlogik/android/kernel/H901BK_L_Kernel/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:858: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2

I have the latest NDK and I'm using Ubuntu 15.10 64bit if this helps.

Here is where I have the NDK and kernel --->

NDK ---- /home/livlogik/android/ndk/

Kernel ---- /home/livlogik/android/kernel/H901bk_L_Kernel/

If someone could help me that would be great. Sorry if this was already posted I could find a answer to it.




As it can be seen from build error message:

drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c:20:27: fatal error: ./mh1/msm_mh1.h: No such file or directory

#include <./mh1/msm_mh1.h>

compiler just can't find msm_mh1.h file. This is because the path specified for #include directive isn't correct. Most probably it's typo: instead ./ there should be ../.

To fix that error, in drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c file change this line:

#include <./mh1/msm_mh1.h>

to this line

#include "../mh1/msm_mh1.h"

After this make command should work fine. Also, kernel image file will be available at arch/arm64/boot, and it's not zImage as stated in documentation, it's actually Image.gz. Uncompressed kernel image is Image file.


Answering your question in comments:

Is there any way to make it compress into a zImage?

From Documentation/arm64/booting.txt:

The AArch64 kernel does not currently provide a decompressor and therefore requires decompression (gzip etc.) to be performed by the boot loader if a compressed Image target (e.g. Image.gz) is used. For bootloaders that do not implement this requirement, the uncompressed Image target is available instead.

Basically zImage is just gzipped and self-extracted Image. So zImage file consists of program for unpacking gzip archive in the beginning, followed by gzipped Image, and when kernel is run by bootloader its unpacking itself (hense "self-extracted" term) and then start running.

...So I can make it flashable

In case of arm64, you don't have zImage, so most likely you need to use Image file (which acts in the same way, but only its size is bigger). You can create boot.img from Image file and built AFS ramdisk (using mkbootimg tool) and then just do fastboot flash boot boot.img. Refer to this documentation for example. Of course for your platform some things can be different, so try to find instructions for your platform.