fa10b756a174911583308a7efa3e441baf1c8581
[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 #################################################
11 # Images
12 #################################################
13
14 DEVICE_VARS += MKUBIFS_OPTS UBOOT BOOT_SCRIPT
15
16 define Build/boot-overlay
17 rm -rf $@.boot
18 mkdir -p $@.boot
19
20 $(CP) $@ $@.boot/$(IMG_PREFIX)-uImage
21 ln -sf $(IMG_PREFIX)-uImage $@.boot/uImage
22
23 $(foreach dts,$(DEVICE_DTS), \
24 $(CP) \
25 $(DTS_DIR)/$(dts).dtb \
26 $@.boot/$(IMG_PREFIX)-$(dts).dtb; \
27 ln -sf \
28 $(IMG_PREFIX)-$(dts).dtb \
29 $@.boot/$(dts).dtb; \
30 )
31 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
32 -n '$(DEVICE_ID) OpenWrt bootscript' \
33 -d ./bootscript-$(DEVICE_NAME) \
34 $@.boot/6x_bootscript-$(DEVICE_NAME)
35
36 $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
37 --space-fixup --compr=zlib --squash-uids \
38 $(MKUBIFS_OPTS) -c 8124 \
39 -o $@.boot.ubifs -d $@.boot
40
41 $(TAR) -C $@.boot -cf $@.boot.tar .
42 endef
43
44 define Build/bootfs.tar.gz
45 rm -rf $@.boot
46 mkdir -p $@.boot
47
48 $(TAR) -C $@.boot -xf $(IMAGE_KERNEL).boot.tar
49 $(TAR) -C $@.boot \
50 --numeric-owner --owner=0 --group=0 --transform "s,./,./boot/," \
51 -czvf $@ .
52 endef
53
54 define Build/boot-scr
55 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
56 -n '$(DEVICE_ID) OpenWrt bootscript' \
57 -d ./bootscript-$(DEVICE_NAME) \
58 $(BIN_DIR)/boot.scr
59 endef
60
61 define Build/imx6-combined-image-prepare
62 rm -rf $@.boot
63 mkdir -p $@.boot
64 endef
65
66 define Build/imx6-combined-image-clean
67 rm -rf $@.boot $@.fs
68 endef
69
70 define Build/imx6-combined-image
71 $(CP) $(IMAGE_KERNEL) $@.boot/uImage
72
73 $(foreach dts,$(DEVICE_DTS), \
74 $(CP) \
75 $(DTS_DIR)/$(dts).dtb \
76 $@.boot/;
77 )
78
79 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
80 -n '$(DEVICE_ID) OpenWrt bootscript' \
81 -d $(BOOT_SCRIPT) \
82 $@.boot/boot.scr
83
84 cp $@ $@.fs
85
86 $(SCRIPT_DIR)/gen_image_generic.sh $@ \
87 $(CONFIG_TARGET_KERNEL_PARTSIZE) \
88 $@.boot \
89 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
90 $@.fs \
91 1024
92 endef
93
94 define Build/imx6-sdcard
95 $(Build/imx6-combined-image-prepare)
96
97 $(CP) $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.img $@.boot/u-boot.img
98 $(Build/imx6-combined-image)
99 dd if=$(STAGING_DIR_IMAGE)/$(UBOOT)-SPL of=$@ bs=1024 seek=1 conv=notrunc
100
101 $(Build/imx6-combined-image-clean)
102 endef
103
104 endef
105
106 #################################################
107 # Devices
108 #################################################
109
110 KERNEL_LOADADDR=0x10008000
111
112 define Device/Default
113 PROFILES := Generic
114 FILESYSTEMS := squashfs ext4
115 KERNEL_INSTALL := 1
116 KERNEL_SUFFIX := -uImage
117 KERNEL_NAME := zImage
118 KERNEL_PREFIX := $$(IMAGE_PREFIX)
119 KERNEL := kernel-bin | uImage none
120 IMAGES :=
121 endef
122
123 define Device/ventana
124 DEVICE_TITLE := Gateworks Ventana family (normal NAND flash)
125 DEVICE_DTS:= \
126 imx6dl-gw51xx \
127 imx6dl-gw52xx \
128 imx6dl-gw53xx \
129 imx6dl-gw54xx \
130 imx6dl-gw551x \
131 imx6dl-gw552x \
132 imx6dl-gw553x \
133 imx6dl-gw5904 \
134 imx6q-gw51xx \
135 imx6q-gw52xx \
136 imx6q-gw53xx \
137 imx6q-gw54xx \
138 imx6q-gw5400-a \
139 imx6q-gw551x \
140 imx6q-gw552x \
141 imx6q-gw553x \
142 imx6q-gw5904
143 DEVICE_PACKAGES := kmod-sky2 kmod-sound-core kmod-sound-soc-imx kmod-sound-soc-imx-sgtl5000 \
144 kmod-can kmod-can-flexcan kmod-can-raw \
145 kmod-hwmon-gsc \
146 kmod-leds-gpio kmod-pps-gpio \
147 kobs-ng
148 KERNEL += | boot-overlay
149 IMAGES := nand.ubi bootfs.tar.gz
150 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
151 UBINIZE_PARTS = boot=$$(KDIR_KERNEL_IMAGE).boot.ubifs=15
152 BOOT_SCRIPT := bootscript-ventana
153 IMAGE/nand.ubi := append-ubi
154 IMAGE/bootfs.tar.gz := bootfs.tar.gz | install-dtb
155 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
156 PAGESIZE := 2048
157 BLOCKSIZE := 128k
158 MKUBIFS_OPTS := -m $$(PAGESIZE) -e 124KiB
159 endef
160 TARGET_DEVICES += ventana
161
162 define Device/ventana-large
163 $(Device/ventana)
164 DEVICE_NAME := ventana
165 DEVICE_TITLE := Gateworks Ventana family (large NAND flash)
166 IMAGES := nand.ubi
167 PAGESIZE := 4096
168 BLOCKSIZE := 256k
169 MKUBIFS_OPTS := -m $$(PAGESIZE) -e 248KiB
170 endef
171 TARGET_DEVICES += ventana-large
172
173 define Device/wandboard
174 DEVICE_TITLE := Wandboard Dual
175 DEVICE_DTS := imx6dl-wandboard
176 endef
177 TARGET_DEVICES += wandboard
178
179 define Device/cubox-i
180 KERNEL := kernel-bin | install-dtb
181 UBOOT := mx6cuboxi
182 BOOT_SCRIPT = bootscript-cubox
183 DEVICE_NAME := cubox
184 DEVICE_TITLE := SolidRun CuBox-i
185 DEVICE_PACKAGES := kmod-drm-imx kmod-drm-imx-hdmi kmod-usb-hid
186 DEVICE_DTS := imx6q-cubox-i imx6dl-cubox-i imx6q-hummingboard imx6dl-hummingboard
187 IMAGES := combined.bin
188 FILESYSTEMS := squashfs
189 IMAGE/combined.bin := append-rootfs | pad-extra 128k | imx6-sdcard
190 endef
191 TARGET_DEVICES += cubox-i
192
193 $(eval $(call BuildImage))