b6885eff608714cb1d1063606f907e4b0c9b6c51
[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-sdcard
62 rm -rf $@.boot
63 mkdir -p $@.boot
64
65 $(CP) $(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.img $@.boot/u-boot.img
66 $(CP) $(IMAGE_KERNEL) $@.boot/uImage
67
68 $(foreach dts,$(DEVICE_DTS), \
69 $(CP) \
70 $(DTS_DIR)/$(dts).dtb \
71 $@.boot/;
72 )
73
74 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
75 -n '$(DEVICE_ID) OpenWrt bootscript' \
76 -d $(BOOT_SCRIPT) \
77 $@.boot/boot.scr
78
79 cp $@ $@.fs
80
81 $(SCRIPT_DIR)/gen_image_generic.sh $@ \
82 $(CONFIG_TARGET_KERNEL_PARTSIZE) \
83 $@.boot \
84 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
85 $@.fs \
86 1024
87
88 dd if=$(STAGING_DIR_IMAGE)/$(UBOOT)-SPL of=$@ bs=1024 seek=1 conv=notrunc
89
90 rm -rf $@.boot $@.fs
91 endef
92
93 #################################################
94 # Devices
95 #################################################
96
97 KERNEL_LOADADDR=0x10008000
98
99 define Device/Default
100 PROFILES := Generic
101 FILESYSTEMS := squashfs ext4
102 KERNEL_INSTALL := 1
103 KERNEL_SUFFIX := -uImage
104 KERNEL_NAME := zImage
105 KERNEL_PREFIX := $$(IMAGE_PREFIX)
106 KERNEL := kernel-bin | uImage none
107 IMAGES :=
108 endef
109
110 define Device/ventana
111 DEVICE_TITLE := Gateworks Ventana family (normal NAND flash)
112 DEVICE_DTS:= \
113 imx6dl-gw51xx \
114 imx6dl-gw52xx \
115 imx6dl-gw53xx \
116 imx6dl-gw54xx \
117 imx6dl-gw551x \
118 imx6dl-gw552x \
119 imx6dl-gw553x \
120 imx6dl-gw5904 \
121 imx6q-gw51xx \
122 imx6q-gw52xx \
123 imx6q-gw53xx \
124 imx6q-gw54xx \
125 imx6q-gw5400-a \
126 imx6q-gw551x \
127 imx6q-gw552x \
128 imx6q-gw553x \
129 imx6q-gw5904
130 DEVICE_PACKAGES := kmod-sky2 kmod-sound-core kmod-sound-soc-imx kmod-sound-soc-imx-sgtl5000 \
131 kmod-can kmod-can-flexcan kmod-can-raw \
132 kmod-hwmon-gsc \
133 kmod-leds-gpio kmod-pps-gpio \
134 kobs-ng
135 KERNEL += | boot-overlay
136 IMAGES := nand.ubi bootfs.tar.gz
137 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
138 UBINIZE_PARTS = boot=$$(KDIR_KERNEL_IMAGE).boot.ubifs=15
139 IMAGE/nand.ubi := append-ubi
140 IMAGE/bootfs.tar.gz := bootfs.tar.gz | install-dtb
141 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
142 PAGESIZE := 2048
143 BLOCKSIZE := 128k
144 MKUBIFS_OPTS := -m $$(PAGESIZE) -e 124KiB
145 endef
146 TARGET_DEVICES += ventana
147
148 define Device/ventana-large
149 $(Device/ventana)
150 DEVICE_NAME := ventana
151 DEVICE_TITLE := Gateworks Ventana family (large NAND flash)
152 IMAGES := nand.ubi
153 PAGESIZE := 4096
154 BLOCKSIZE := 256k
155 MKUBIFS_OPTS := -m $$(PAGESIZE) -e 248KiB
156 endef
157 TARGET_DEVICES += ventana-large
158
159 define Device/wandboard
160 DEVICE_TITLE := Wandboard Dual
161 DEVICE_DTS := imx6dl-wandboard
162 endef
163 TARGET_DEVICES += wandboard
164
165 define Device/cubox-i
166 KERNEL := kernel-bin | install-dtb
167 UBOOT := mx6cuboxi
168 BOOT_SCRIPT = bootscript-cubox
169 DEVICE_NAME := cubox
170 DEVICE_TITLE := SolidRun CuBox-i
171 DEVICE_PACKAGES := u-boot-mx6cuboxi kmod-drm-imx kmod-drm-imx-hdmi kmod-usb-hid
172 DEVICE_DTS := imx6q-cubox-i imx6dl-cubox-i imx6q-hummingboard imx6dl-hummingboard
173 IMAGES := combined.bin
174 FILESYSTEMS := squashfs
175 IMAGE/combined.bin := append-rootfs | pad-extra 128k | imx6-sdcard
176 endef
177 TARGET_DEVICES += cubox-i
178
179 $(eval $(call BuildImage))