2 # Copyright (C) 2013 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR
)/rules.mk
8 include $(INCLUDE_DIR
)/image.mk
10 define sanitize_profile_name
11 $(shell echo
$(PROFILE
) | tr
'[:upper:]' '[:lower:]' | sed
's/_/-/g')
14 define Image
/BuildKernel
/Template
17 $(CP
) $(DTS_DIR
)/$(1).dtb
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).dtb
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
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
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 \
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 \
45 define Image
/InstallKernel
/Template
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
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
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
/
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
; \
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
82 define Image
/mkfs
/targz
84 $(TAR
) -czpf
$(BIN_DIR
)/$(IMG_PREFIX
)-$(call sanitize_profile_name
)-rootfs.
tar.gz
--numeric-owner
--owner
=0 --group
=0 -C
$(TARGET_DIR
)/ .
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
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
103 define Image
/Build
/ubifs
107 define Image
/Build
/ubi
112 Image
/BuildKernel
/Template
/Generic
=$(call Image
/BuildKernel
/Template
)
113 Image
/InstallKernel
/Template
/Generic
=$(call Image
/InstallKernel
/Template
)
115 Image
/BuildKernel
/Template
/IMX6DL_WANDBOARD
=$(call Image
/BuildKernel
/Template
,imx6dl-wandboard
)
116 Image
/InstallKernel
/Template
/IMX6DL_WANDBOARD
=$(call Image
/InstallKernel
/Template
,imx6dl-wandboard
)
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
)
123 define Image
/BuildKernel
124 $(call Image
/BuildKernel
/Template
/$(PROFILE
))
127 define Image
/InstallKernel
128 $(call Image
/InstallKernel
/Template
/$(PROFILE
))
129 $(if
$(Image
/ubifs
/$(PROFILE
)), \
130 $(call Image
/ubifs
/$(PROFILE
))
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 \
141 $(eval
$(call BuildImage
))