imx6: drop ventana kernel/rootfs hack
[openwrt.git] / target / linux / imx6 / image / Makefile
1 #
2 # Copyright (C) 2013 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 define sanitize_profile_name
11 $(shell echo $(PROFILE) | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')
12 endef
13
14 define Image/BuildKernel/Template
15
16         $(CP) $(DTS_DIR)/$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
17
18         $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000)
19         $(CP) $(KDIR)/fit-$(1).itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb
20
21  ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
22         $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage-initramfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000,-initramfs)
23         $(CP) $(KDIR)/fit-$(1)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage-initramfs.itb
24  endif
25
26         $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
27         $(call Image/BuildKernel/MkuImage, \
28                 none, 0x10008000, 0x10008000, \
29                 $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
30                 $(BIN_DIR)/$(IMG_PREFIX)-uImage \
31         )
32
33  ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
34         $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
35         $(call Image/BuildKernel/MkuImage, \
36                 none, 0x10008000, 0x10008000, \
37                 $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
38                 $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
39         )
40  endif
41 endef
42
43 define Image/InstallKernel/Template
44
45  ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
46         $(INSTALL_DIR) $(TARGET_DIR)/boot
47    ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE),)
48         $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
49         ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
50    endif
51    ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
52         $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
53         ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
54    endif
55    ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_FIT),)
56         $(foreach dts,$(shell echo $(1)), \
57                 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(dts)-fit-uImage.itb $(TARGET_DIR)/boot/
58         )
59    endif
60  endif
61
62  ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
63         $(INSTALL_DIR) $(TARGET_DIR)/boot
64         $(foreach dts,$(shell echo $(1)), \
65                 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb $(TARGET_DIR)/boot/ ; \
66                 ln -sf $(IMG_PREFIX)-$(dts).dtb $(TARGET_DIR)/boot/$(dts).dtb ; \
67         )
68  endif
69 endef
70
71 define Image/Build/squashfs
72         $(call prepare_generic_squashfs,$(KDIR)/root.$(1))
73         dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin bs=128k conv=sync
74         ( \
75                 dd if=$(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-uImage.itb bs=2048k conv=sync; \
76                 dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
77         ) > $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-$(1).bin
78 endef
79
80 define Image/mkfs/targz
81
82         $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
83 endef
84
85 define ubifs_imx_gateworks_ventana
86         # Micron MT29F1G08ABAD/MT29F2G08ABAE/MT29F4G08ABAD/MT29F8G08ADAD NAND
87         $(eval VENTANA_UBIFS_OPTS:="-m 2048 -e 124KiB -c 8124")
88         $(eval VENTANA_UBI_OPTS:="-m 2048 -p 128KiB -s 2048")
89         $(call Image/mkfs/ubifs)
90         $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_normal.ubifs
91         $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_normal.ubi
92
93         # Micron MT29F8G08ABAC/MT29F16G08ADAC 1GB/2GB NAND
94         $(eval VENTANA_UBIFS_OPTS:="-m 4096 -e 248KiB -c 8124")
95         $(eval VENTANA_UBI_OPTS:="-m 4096 -p 256KiB -s 4096")
96         $(call Image/mkfs/ubifs)
97         $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_large.ubifs
98         $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_large.ubi
99 endef
100
101 define Image/Build/ubifs
102         true
103 endef
104
105 define Image/Build/ubi
106         true
107 endef
108
109
110 Image/BuildKernel/Template/generic=$(call Image/BuildKernel/Template)
111 Image/InstallKernel/Template/generic=$(call Image/InstallKernel/Template)
112
113 Image/BuildKernel/Template/IMX6DL_WANDBOARD=$(call Image/BuildKernel/Template,imx6dl-wandboard)
114 Image/InstallKernel/Template/IMX6DL_WANDBOARD=$(call Image/InstallKernel/Template,imx6dl-wandboard)
115
116 Image/BuildKernel/Template/VENTANA=$(foreach dts,$(shell echo $(VENTANA_DTS)),$(call Image/BuildKernel/Template,$(dts)))
117 Image/InstallKernel/Template/VENTANA=$(call Image/InstallKernel/Template,$(VENTANA_DTS))
118 Image/ubifs/VENTANA=$(call ubifs_imx_gateworks_ventana)
119
120
121 define Image/BuildKernel
122         $(call Image/BuildKernel/Template/$(PROFILE))
123 endef
124
125 define Image/InstallKernel
126         $(call Image/InstallKernel/Template/$(PROFILE))
127         $(if $(Image/ubifs/$(PROFILE)), \
128                 $(call Image/ubifs/$(PROFILE))
129         )
130 endef
131
132 define Image/Build
133         $(if $(Image/Build/$(1)), \
134                 $(call Image/Build/$(1),$(1)), \
135                 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
136         )
137 endef
138
139 $(eval $(call BuildImage))