-
Notifications
You must be signed in to change notification settings - Fork 1
/
kernel.mk
143 lines (114 loc) · 5.66 KB
/
kernel.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#if use probuilt kernel or build kernel from source code
-include device/hardkernel/common/media_modules.mk
-include device/hardkernel/common/wifi_modules.mk
KERNEL_ROOTDIR := common
KERNEL_KO_OUT := $(PRODUCT_OUT)/obj/lib_vendor
USE_PREBUILT_KERNEL := false
INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
BOARD_MKBOOTIMG_ARGS := --kernel_offset $(BOARD_KERNEL_OFFSET)
DTB_OUT := $(PRODUCT_OUT)/obj/KERNEL_OBJ/arch/$(KERNEL_ARCH)/boot/dts/amlogic
DTBO_OUT := $(DTB_OUT)/overlays/odroidc4
KERNEL_DTBO += $(DTBO_OUT)/*.dtbo
INTERMEDIATES_DTBS := $(PRODUCT_OUT)/dtbs
KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
KERNEL_CONFIG := $(KERNEL_OUT)/.config
INTERMEDIATES_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/Image.gz
TARGET_AMLOGIC_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/uImage
TARGET_AMLOGIC_INT_RECOVERY_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/Image_recovery
BOARD_VENDOR_KERNEL_MODULES += \
$(PRODUCT_OUT)/obj/lib_vendor/spidev.ko \
$(PRODUCT_OUT)/obj/lib_vendor/spi-meson-spicc.ko
BOARD_VENDOR_KERNEL_MODULES += $(DEFAULT_MEDIA_KERNEL_MODULES)
BOARD_VENDOR_KERNEL_MODULES += $(DEFAULT_WIFI_KERNEL_MODULES)
BOARD_VENDOR_KERNEL_MODULES += $(PRODUCT_OUT)/obj/lib_vendor/cp210x.ko
BOARD_VENDOR_KERNEL_MODULES += $(PRODUCT_OUT)/obj/lib_vendor/ch341.ko
BOARD_VENDOR_KERNEL_MODULES += $(PRODUCT_OUT)/obj/lib_vendor/ftdi_sio.ko
BOARD_VENDOR_KERNEL_MODULES += $(PRODUCT_OUT)/obj/lib_vendor/pl2303.ko
BOARD_VENDOR_KERNEL_MODULES += $(PRODUCT_OUT)/obj/lib_vendor/btrtl.ko
BOARD_VENDOR_KERNEL_MODULES += $(PRODUCT_OUT)/obj/lib_vendor/btusb.ko
BOARD_VENDOR_KERNEL_MODULES += $(PRODUCT_OUT)/obj/lib_vendor/hid-multitouch.ko
BOARD_VENDOR_KERNEL_MODULES += $(PRODUCT_OUT)/obj/lib_vendor/dwav-usb-mt.ko
WIFI_OUT := $(TARGET_OUT_INTERMEDIATES)/hardware/wifi
PREFIX_CROSS_COMPILE=aarch64-linux-gnu-
KERNEL_KO_OUT := $(PRODUCT_OUT)/obj/lib_vendor
define cp-modules
mkdir -p $(PRODUCT_OUT)/root/boot
mkdir -p $(KERNEL_KO_OUT)
# cp $(WIFI_OUT)/broadcom/drivers/ap6xxx/broadcm_40181/dhd.ko $(TARGET_OUT)/lib/
# cp $(KERNEL_OUT)/../hardware/amlogic/pmu/aml_pmu_dev.ko $(TARGET_OUT)/lib/
# cp $(shell pwd)/hardware/amlogic/thermal/aml_thermal.ko $(TARGET_OUT)/lib/
# cp $(KERNEL_OUT)/../hardware/amlogic/nand/amlnf/aml_nftl_dev.ko $(PRODUCT_OUT)/root/boot/
endef
$(KERNEL_OUT):
mkdir -p $(KERNEL_OUT)
$(KERNEL_CONFIG): $(KERNEL_OUT)
$(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) $(KERNEL_DEFCONFIG)
BOARD_MKBOOTIMG_ARGS := --kernel_offset $(BOARD_KERNEL_OFFSET)
$(INTERMEDIATES_KERNEL): $(KERNEL_OUT) $(KERNEL_CONFIG)
@echo "make Image"
$(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE)
$(MAKE) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) -f device/hardkernel/common/wifi_driver.mk $(WIFI_MODULE)
$(cp-modules)
$(media-modules)
mkdir -p $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/lib/modules/
find $(KERNEL_OUT) -name *.ko | xargs -i cp {} $(KERNEL_KO_OUT)/
cp $(KERNEL_KO_OUT)/* $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/lib/modules/
kerneltags: $(KERNEL_OUT)
$(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) tags
kernelconfig: $(KERNEL_OUT) $(KERNEL_CONFIG)
env KCONFIG_NOTIMESTAMP=true \
$(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) menuconfig
savekernelconfig: $(KERNEL_OUT) $(KERNEL_CONFIG)
env KCONFIG_NOTIMESTAMP=true \
$(MAKE) -C $(KERNEL_ROOTDIR) O=../$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) savedefconfig
@echo
@echo Saved to $(KERNEL_OUT)/defconfig
@echo
@echo handly merge to "$(KERNEL_ROOTDIR)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_DEFCONFIG)" if need
@echo
build-modules-quick:
$(media-modules)
$(INTERMEDIATES_DTBS): $(INTERMEDIATES_KERNEL)
mkdir -p $(INTERMEDIATES_DTBS)
cp $(DTB_OUT)/$(KERNEL_DEVICETREE_C4).dtb $(KERNEL_DTBO) \
$(INTERMEDIATES_DTBS)
cp $(DTB_OUT)/$(KERNEL_DEVICETREE_HC4).dtb $(KERNEL_DTBO) \
$(INTERMEDIATES_DTBS)
$(PRODUCT_OUT)/dtbs.img: $(INTERMEDIATES_DTBS)
mkfs.cramfs $^ $@
$(INSTALLED_KERNEL_TARGET): $(INTERMEDIATES_KERNEL) $(PRODUCT_OUT)/dtbs.img | $(ACP)
@echo "Kernel installed"
$(transform-prebuilt-to-target)
-include device/hardkernel/common/gpu/dvalin-kernel.mk
$(BOARD_VENDOR_KERNEL_MODULES): $(INSTALLED_KERNEL_TARGET)
@echo "BOARD_VENDOR_KERNEL_MODULES: $(BOARD_VENDOR_KERNEL_MODULES)"
.PHONY: bootimage-quick
bootimage-quick: $(INTERMEDIATES_KERNEL)
cp -v $(INTERMEDIATES_KERNEL) $(INSTALLED_KERNEL_TARGET)
out/host/linux-x86/bin/mkbootfs $(PRODUCT_OUT)/root | \
out/host/linux-x86/bin/minigzip > $(PRODUCT_OUT)/ramdisk.img
out/host/linux-x86/bin/mkbootimg --kernel $(INTERMEDIATES_KERNEL) \
--base 0x0 \
--kernel_offset 0x1080000 \
--ramdisk $(PRODUCT_OUT)/ramdisk.img \
$(BOARD_MKBOOTIMG_ARGS) \
--output $(PRODUCT_OUT)/boot.img
ls -l $(PRODUCT_OUT)/boot.img
echo "Done building boot.img"
.PHONY: recoveryimage-quick
recoveryimage-quick: $(INTERMEDIATES_KERNEL)
cp -v $(INTERMEDIATES_KERNEL) $(INSTALLED_KERNEL_TARGET)
out/host/linux-x86/bin/mkbootfs $(PRODUCT_OUT)/recovery/root | \
out/host/linux-x86/bin/minigzip > $(PRODUCT_OUT)/ramdisk-recovery.img
out/host/linux-x86/bin/mkbootimg --kernel $(INTERMEDIATES_KERNEL) \
--base 0x0 \
--kernel_offset 0x1080000 \
--ramdisk $(PRODUCT_OUT)/ramdisk-recovery.img \
$(BOARD_MKBOOTIMG_ARGS) \
--output $(PRODUCT_OUT)/recovery.img
ls -l $(PRODUCT_OUT)/recovery.img
echo "Done building recovery.img"
.PHONY: kernelconfig
.PHONY: savekernelconfig
$(PRODUCT_OUT)/ramdisk.img: $(INSTALLED_KERNEL_TARGET)
$(PRODUCT_OUT)/system.img: $(INSTALLED_KERNEL_TARGET)