summaryrefslogtreecommitdiff
path: root/Kernel.mk (plain)
blob: 633442cd7a54e74cd103b49c6d6d4c3ea97b35c6
1#if use probuilt kernel or build kernel from source code
2KERNEL_ROOTDIR := common
3KERNEL_KO_OUT := $(PRODUCT_OUT)/obj/lib_vendor
4
5INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
6
7BOARD_MKBOOTIMG_ARGS := --second $(PRODUCT_OUT)/dtb.img --kernel_offset $(BOARD_KERNEL_OFFSET)
8
9ifneq ($(USE_USB_AS_HOST),true)
10BOARD_MKBOOTIMG_ARGS += --cmdline "otg_device=1"
11endif
12
13ifneq ($(TARGET_KERNEL_BUILT_FROM_SOURCE), true)
14TARGET_PREBUILT_KERNEL := device/amlogic/ampere-kernel/Image.gz
15INSTALLED_BOARDDTB_TARGET := $(PRODUCT_OUT)/dtb.img
16LOCAL_DTB := device/amlogic/ampere-kernel/ampere.dtb
17
18$(TARGET_PREBUILT_KERNEL): $(INSTALLED_BOARDDTB_TARGET)
19 @echo "cp kernel modules"
20 mkdir -p $(PRODUCT_OUT)/root/boot
21 mkdir -p $(PRODUCT_OUT)/vendor/lib/firmware/video
22 mkdir -p $(PRODUCT_OUT)/obj/lib
23 mkdir -p $(PRODUCT_OUT)/recovery/root/boot
24 mkdir -p $(KERNEL_KO_OUT)
25 cp device/amlogic/ampere-kernel/lib/mali.ko $(PRODUCT_OUT)/vendor/lib/
26 cp device/amlogic/ampere-kernel/lib/modules/* $(KERNEL_KO_OUT)/
27 cp device/amlogic/ampere-kernel/tdk/* $(PRODUCT_OUT)/obj/lib/
28 cp device/amlogic/ampere-kernel/tdk/* $(PRODUCT_OUT)/root/boot/
29 cp device/amlogic/ampere-kernel/tdk/* $(PRODUCT_OUT)/recovery/root/boot/
30 cp device/amlogic/ampere-kernel/lib/firmware/video/* $(PRODUCT_OUT)/vendor/lib/firmware/video/
31 mkdir -p $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/lib/modules/
32 cp $(KERNEL_KO_OUT)/* $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/lib/modules/
33ifeq (,$(wildcard hardware/arm/gpu))
34 mkdir -p $(PRODUCT_OUT)/vendor/lib/egl
35 mkdir -p $(PRODUCT_OUT)/vendor/lib64/egl
36 cp device/amlogic/ampere-kernel/lib/egl/* $(PRODUCT_OUT)/vendor/lib/egl/
37 cp device/amlogic/ampere-kernel/lib64/egl/* $(PRODUCT_OUT)/vendor/lib64/egl/
38endif
39
40$(INSTALLED_KERNEL_TARGET): $(TARGET_PREBUILT_KERNEL) | $(ACP)
41 @echo "Kernel installed"
42 $(transform-prebuilt-to-target)
43
44$(INSTALLED_BOARDDTB_TARGET): $(LOCAL_DTB) | $(ACP)
45 @echo "dtb installed"
46 $(transform-prebuilt-to-target)
47
48else
49
50-include device/amlogic/common/gpu.mk
51-include device/amlogic/common/media_modules.mk
52-include device/amlogic/common/wifi_modules.mk
53
54KERNEL_DEVICETREE := gxl_p212_1g gxl_p212_2g
55KERNEL_DEFCONFIG := meson64_defconfig
56KERNEL_ARCH := arm64
57
58WIFI_MODULE := multiwifi
59
60KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
61KERNEL_CONFIG := $(KERNEL_OUT)/.config
62INTERMEDIATES_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/Image.gz
63TARGET_AMLOGIC_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/uImage
64TARGET_AMLOGIC_INT_RECOVERY_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/Image_recovery
65
66BOARD_VENDOR_KERNEL_MODULES := \
67 $(PRODUCT_OUT)/obj/lib_vendor/audio_data.ko \
68 $(PRODUCT_OUT)/obj/lib_vendor/ddr_window_64.ko
69
70BOARD_VENDOR_KERNEL_MODULES += $(DEFAULT_MEDIA_KERNEL_MODULES)
71BOARD_VENDOR_KERNEL_MODULES += $(DEFAULT_WIFI_KERNEL_MODULES)
72
73WIFI_OUT := $(TARGET_OUT_INTERMEDIATES)/hardware/wifi
74
75PREFIX_CROSS_COMPILE=/opt/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
76
77define cp-modules
78 mkdir -p $(PRODUCT_OUT)/root/boot
79 mkdir -p $(KERNEL_KO_OUT)
80 -cp $(KERNEL_OUT)/drivers/usb/dwc3/dwc3.ko $(KERNEL_KO_OUT)/
81 -cp $(KERNEL_OUT)/drivers/amlogic/usb/dwc_otg/310/dwc_otg.ko $(KERNEL_KO_OUT)/
82# cp $(WIFI_OUT)/broadcom/drivers/ap6xxx/broadcm_40181/dhd.ko $(TARGET_OUT)/lib/
83# cp $(KERNEL_OUT)/../hardware/amlogic/pmu/aml_pmu_dev.ko $(TARGET_OUT)/lib/
84# cp $(shell pwd)/hardware/amlogic/thermal/aml_thermal.ko $(TARGET_OUT)/lib/
85# cp $(KERNEL_OUT)/../hardware/amlogic/nand/amlnf/aml_nftl_dev.ko $(PRODUCT_OUT)/root/boot/
86endef
87
88$(KERNEL_OUT):
89 mkdir -p $(KERNEL_OUT)
90
91$(KERNEL_CONFIG): $(KERNEL_OUT)
92 $(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) $(KERNEL_DEFCONFIG)
93
94$(INTERMEDIATES_KERNEL): $(KERNEL_OUT) $(KERNEL_CONFIG) $(INSTALLED_BOARDDTB_TARGET)
95 @echo "make Image"
96# $(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE)
97 $(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) modules Image.gz
98# $(MAKE) -C $(shell pwd)/$(PRODUCT_OUT)/obj/KERNEL_OBJ M=$(shell pwd)/hardware/amlogic/thermal/ ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) modules
99 #$(gpu-modules)
100 $(MAKE) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) -f device/amlogic/common/wifi_driver.mk $(WIFI_MODULE)
101 $(cp-modules)
102 $(media-modules)
103 mkdir -p $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/lib/modules/
104 cp $(KERNEL_KO_OUT)/* $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/lib/modules/
105
106kerneltags: $(KERNEL_OUT)
107 $(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) tags
108
109kernelconfig: $(KERNEL_OUT) $(KERNEL_CONFIG)
110 env KCONFIG_NOTIMESTAMP=true \
111 $(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) menuconfig
112
113savekernelconfig: $(KERNEL_OUT) $(KERNEL_CONFIG)
114 env KCONFIG_NOTIMESTAMP=true \
115 $(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) savedefconfig
116 @echo
117 @echo Saved to $(KERNEL_OUT)/defconfig
118 @echo
119 @echo handly merge to "$(KERNEL_ROOTDIR)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_DEFCONFIG)" if need
120 @echo
121
122build-modules-quick:
123 $(media-modules)
124
125$(INSTALLED_KERNEL_TARGET): $(INTERMEDIATES_KERNEL) | $(ACP)
126 @echo "Kernel installed"
127 $(transform-prebuilt-to-target)
128
129$(BOARD_VENDOR_KERNEL_MODULES): $(INSTALLED_KERNEL_TARGET)
130 @echo "BOARD_VENDOR_KERNEL_MODULES: $(BOARD_VENDOR_KERNEL_MODULES)"
131
132
133.PHONY: bootimage-quick
134bootimage-quick: $(INTERMEDIATES_KERNEL)
135 cp -v $(INTERMEDIATES_KERNEL) $(INSTALLED_KERNEL_TARGET)
136 out/host/linux-x86/bin/mkbootfs $(PRODUCT_OUT)/root | \
137 out/host/linux-x86/bin/minigzip > $(PRODUCT_OUT)/ramdisk.img
138 out/host/linux-x86/bin/mkbootimg --kernel $(INTERMEDIATES_KERNEL) \
139 --base 0x0 \
140 --kernel_offset 0x1080000 \
141 --ramdisk $(PRODUCT_OUT)/ramdisk.img \
142 $(BOARD_MKBOOTIMG_ARGS) \
143 --output $(PRODUCT_OUT)/boot.img
144 ls -l $(PRODUCT_OUT)/boot.img
145 echo "Done building boot.img"
146
147.PHONY: recoveryimage-quick
148recoveryimage-quick: $(INTERMEDIATES_KERNEL)
149 cp -v $(INTERMEDIATES_KERNEL) $(INSTALLED_KERNEL_TARGET)
150 out/host/linux-x86/bin/mkbootfs $(PRODUCT_OUT)/recovery/root | \
151 out/host/linux-x86/bin/minigzip > $(PRODUCT_OUT)/ramdisk-recovery.img
152 out/host/linux-x86/bin/mkbootimg --kernel $(INTERMEDIATES_KERNEL) \
153 --base 0x0 \
154 --kernel_offset 0x1080000 \
155 --ramdisk $(PRODUCT_OUT)/ramdisk-recovery.img \
156 $(BOARD_MKBOOTIMG_ARGS) \
157 --output $(PRODUCT_OUT)/recovery.img
158 ls -l $(PRODUCT_OUT)/recovery.img
159 echo "Done building recovery.img"
160
161.PHONY: kernelconfig
162
163.PHONY: savekernelconfig
164
165endif
166
167$(PRODUCT_OUT)/ramdisk.img: $(INSTALLED_KERNEL_TARGET)
168$(PRODUCT_OUT)/system.img: $(INSTALLED_KERNEL_TARGET)
169