Building kernel inline with rom

702 views
Skip to first unread message

Clienthax

unread,
Sep 8, 2019, 4:41:45 PM9/8/19
to Android Building
Hi,

In pie it seems that the kernel source gets compiled by aosp, this doesn't seem to be the case with 10, which breaks some assumptions in the qcom device trees (mainly where to find the kernel headers etc).
Is there a way to restore this functionality?

The Glitchh

unread,
Sep 8, 2019, 8:18:43 PM9/8/19
to Android Building
Use prebuilt kernel , compile the kernel separately and then push the Image.gz-dtb to the device tree and use the preceding flags to define the prebuilt kernel

# Prebuilt \kernel
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/Image.gz-dtb:kernel

Paste this in device.mk makkefile of your device tree

Clienthax

unread,
Sep 8, 2019, 9:23:23 PM9/8/19
to Android Building
Problem with that is that the kernel headers won't get 'installed', breaking qcom msm kernel header locations, https://android.googlesource.com/platform/hardware/qcom/display/+/refs/heads/master/msm8994/common.mk#48

Viacheslav Krenev

unread,
Sep 9, 2019, 2:47:13 PM9/9/19
to Android Building
I'm doing it like that (my case is Marlin (Pixel, Pixel XL), AOSP 8.1), don't know anything about Pie and later.

1. Download the kernel for msm, checkout the proper branch
2. Rename the kernel checkout directory to "marlin" and place it to kernel/google/ in the AOSP tree,
3. Open AndroidKernel.mk and find lines:
TARGET_KERNEL := msm-$(TARGET_KERNEL_VERSION)
ifeq ($(TARGET_KERNEL),$(current_dir))
    # New style, kernel/msm-version
    BUILD_ROOT_LOC := ../../
    TARGET_KERNEL_SOURCE := kernel/$(TARGET_KERNEL)
    KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/kernel/$(TARGET_KERNEL)
    KERNEL_SYMLINK := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
    KERNEL_USR := $(KERNEL_SYMLINK)/usr
else
    # Legacy style, kernel source directly under kernel
    KERNEL_LEGACY_DIR := true
    BUILD_ROOT_LOC := ../
    TARGET_KERNEL_SOURCE := kernel
    KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
endif

and change them to 

TARGET_KERNEL := google/marlin

BUILD_ROOT_LOC := ../../../

4. In device/google/marlin make a new file called AndroidBoard.mk with the following content:

#ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
#KERNEL_DEFCONFIG := marlin-debug_defconfig
#else
KERNEL_DEFCONFIG := marlin_defconfig
#endif

KERNEL_DIR := kernel/google/marlin
TARGET_KERNEL_APPEND_DTB := true

include $(TOP)/$(KERNEL_DIR)/AndroidKernel.mk

.PHONY: $(PRODUCT_OUT)/kernel
$(PRODUCT_OUT)/kernel: $(TARGET_PREBUILT_KERNEL)
cp $(TARGET_PREBUILT_KERNEL) $(PRODUCT_OUT)/kernel
uncomment the condition on the top if you need.

5. In device/google/marlin/device-common.mk find lines: 

ifeq ($(TARGET_PREBUILT_KERNEL),)
    LOCAL_KERNEL := device/google/marlin-kernel/Image.lz4-dtb
else
LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
endif

PRODUCT_COPY_FILES += \
    $(LOCAL_KERNEL):kernel

and delete them.

6. In device/google/marlin/marlin and device/google/marlin/sailfish make a symlink AndroidBoard.mk -> device/google/marlin/AndroidBoard.mk

7. I don't know exactly, but if you really need, you can try to uncomment the line in BoardConfig.mk

# TARGET_COMPILE_WITH_MSM_KERNEL := true

to make your condition work. I never did that so can't say if it works.

BTW: Personally I don't know if Pie is different about compiling kernels. I see the same conditions about prebuilt kernels as in Oreo.

понедельник, 9 сентября 2019 г., 4:23:23 UTC+3 пользователь Clienthax написал:
Reply all
Reply to author
Forward
0 new messages