imx6: add support for more then one nand type per profile
[openwrt/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 $(CP) $(LINUX_DIR)/arch/arm/boot/dts/$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
16
17 $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000)
18 $(CP) $(KDIR)/fit-$(1).itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb
19
20 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
21 $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage-initramfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000,-initramfs)
22 $(CP) $(KDIR)/fit-$(1)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage-initramfs.itb
23 endif
24
25 $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
26 $(call Image/BuildKernel/MkuImage, \
27 none, 0x10008000, 0x10008000, \
28 $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
29 $(BIN_DIR)/$(IMG_PREFIX)-uImage \
30 )
31
32 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
33 $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
34 $(call Image/BuildKernel/MkuImage, \
35 none, 0x10008000, 0x10008000, \
36 $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
37 $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
38 )
39 endif
40 endef
41
42 define Image/InstallKernel/Template
43
44 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
45 $(INSTALL_DIR) $(TARGET_DIR)/boot
46 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE),)
47 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
48 ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
49 endif
50 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
51 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
52 ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
53 endif
54 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_FIT),)
55 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb $(TARGET_DIR)/boot/
56 ln -sf $(IMG_PREFIX)-$(1)-fit-uImage.itb $(TARGET_DIR)/boot/uImage.itb
57 endif
58 endif
59
60 ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
61 $(INSTALL_DIR) $(TARGET_DIR)/boot
62 ifneq ($(1),)
63 $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/
64 ln -sf $(IMG_PREFIX)-$(1).dtb $(TARGET_DIR)/boot/$(1).dtb
65 endif
66 endif
67 endef
68
69 define Image/Build/squashfs
70 $(call prepare_generic_squashfs,$(KDIR)/root.$(1))
71 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin bs=128k conv=sync
72 ( \
73 dd if=$(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-uImage.itb bs=2048k conv=sync; \
74 dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
75 ) > $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-$(1).bin
76 endef
77
78 define Image/mkfs/targz
79
80 $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
81 endef
82
83 define ubifs_imx_gateworks_ventana
84 # Micron MT29F1G08ABAD/MT29F2G08ABAE/MT29F4G08ABAD/MT29F8G08ADAD NAND
85 $(eval IMX6Q_GW54XX_UBIFS_OPTS:="-m 2048 -e 124KiB -c 8124")
86 $(eval IMX6Q_GW54XX_UBI_OPTS:="-m 2048 -p 128KiB -s 2048")
87 $(call Image/mkfs/ubifs)
88 $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_normal.ubifs
89 $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_normal.ubi
90
91 # Micron MT29F8G08ABAC/MT29F16G08ADAC 1GB/2GB NAND
92 $(eval IMX6Q_GW54XX_UBIFS_OPTS:="-m 4096 -e 248KiB -c 8124")
93 $(eval IMX6Q_GW54XX_UBI_OPTS:="-m 4096 -p 256KiB -s 4096")
94 $(call Image/mkfs/ubifs)
95 $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_large.ubifs
96 $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_large.ubi
97 endef
98
99 define Image/Build/ubifs
100 true
101 endef
102
103 define Image/Build/ubi
104 true
105 endef
106
107
108 Image/BuildKernel/Template/generic=$(call Image/BuildKernel/Template)
109 Image/InstallKernel/Template/generic=$(call Image/InstallKernel/Template)
110
111 Image/BuildKernel/Template/IMX6DL_WANDBOARD=$(call Image/BuildKernel/Template,imx6dl-wandboard)
112 Image/InstallKernel/Template/IMX6DL_WANDBOARD=$(call Image/InstallKernel/Template,imx6dl-wandboard)
113
114 Image/BuildKernel/Template/IMX6Q_GW5400_A=$(call Image/BuildKernel/Template,imx6q-gw5400-a)
115 Image/InstallKernel/Template/IMX6Q_GW5400_A=$(call Image/InstallKernel/Template,imx6q-gw5400-a)
116
117 Image/BuildKernel/Template/IMX6Q_GW54XX=$(call Image/BuildKernel/Template,imx6q-gw54xx)
118 Image/InstallKernel/Template/IMX6Q_GW54XX=$(call Image/InstallKernel/Template,imx6q-gw54xx)
119 Image/ubifs/IMX6Q_GW54XX=$(call ubifs_imx_gateworks_ventana)
120
121
122 define Image/BuildKernel
123 $(call Image/BuildKernel/Template/$(PROFILE))
124 endef
125
126 define Image/InstallKernel
127 $(call Image/InstallKernel/Template/$(PROFILE))
128 $(if $(Image/ubifs/$(PROFILE)), \
129 $(call Image/ubifs/$(PROFILE))
130 )
131 endef
132
133 define Image/Build
134 $(if $(Image/Build/$(1)), \
135 $(call Image/Build/$(1),$(1)), \
136 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
137 )
138 endef
139
140 $(eval $(call BuildImage))