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