imx6: use ubinize-image.sh to fix build with per-device rootfs
[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 # build a ubi for a specific flash geometry/layout which can contain
15 # volumes with the following data from ubinize-$(DEVICE_NAME).cfg:
16 # - 'boot.ubifs' volume: kernel+dtbs+bootscript
17 # - 'root.squashfs' volume: rootfs
18 # $(1): name (used for suffix)
19 # $(2): PAGESIZE (-m param to mkfs.ubifs/ubinize)
20 # $(3): ERASESIZE (logical eraseblock size: -e param to mkfs.ubifs)
21 # $(4): BLOCKSIZE (-p param to ubinize)
22 # $(5): MAXSIZE (maximum file-system size in LEB's -c param to mkfs.ubifs)
23 #
24 define Build/ubi-boot-overlay
25 # ubi-boot-overlay $(DEVICE_NAME) $(word 1, $(1))
26
27 # boot filesystem
28 rm -rf $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))
29 mkdir -p $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))
30 $(CP) $< $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(IMG_PREFIX)-uImage
31 ln -sf $(IMG_PREFIX)-uImage \
32 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/uImage
33 $(foreach dts,$(shell echo $(DEVICE_DTS)), \
34 $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
35 $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
36 $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
37 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(IMG_PREFIX)-$(dts).dtb; \
38 ln -sf $(IMG_PREFIX)-$(dts).dtb \
39 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(dts).dtb; \
40 )
41 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
42 -n '$(DEVICE_ID) LEDE bootscript' \
43 -d ./bootscript-$(DEVICE_NAME) \
44 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/6x_bootscript-$(DEVICE_NAME)
45 $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
46 --space-fixup --force-compr=zlib --squash-uids \
47 -m $(word 2, $(1)) -e $(word 3, $(1)) -c $(word 5, $(1)) \
48 -o $(KDIR)/boot-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs \
49 -d $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))
50 $(CP) $(KDIR)/boot-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs \
51 $(BIN_DIR)/$(IMG_PREFIX)-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs
52
53 # ubi
54 sh $(TOPDIR)/scripts/ubinize-image.sh \
55 --part boot=$(KDIR)/boot-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs=15 \
56 $(IMAGE_ROOTFS) $@ \
57 -m $(word 2, $(1)) -p $(word 4, $(1)) -s $(word 2, $(1))
58 endef
59
60 define Build/bootfs.tar.gz
61 # boot filesystem
62 rm -rf $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)
63 mkdir -p $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)
64 $(CP) $< $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(IMG_PREFIX)-uImage
65 ln -sf $(IMG_PREFIX)-uImage \
66 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/uImage
67 $(foreach dts,$(shell echo $(DEVICE_DTS)), \
68 $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
69 $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
70 $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
71 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(IMG_PREFIX)-$(dts).dtb; \
72 ln -sf $(IMG_PREFIX)-$(dts).dtb \
73 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(dts).dtb; \
74 )
75 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
76 -n '$(DEVICE_ID) OpenWrt bootscript' \
77 -d ./bootscript-$(DEVICE_NAME) \
78 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/6x_bootscript-$(DEVICE_NAME)
79
80 # tar and zip
81 ( \
82 cd $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME); \
83 $(TAR) --numeric-owner --owner=0 --group=0 --transform "s,./,./boot/," \
84 -czvf $(BIN_DIR)/$(IMG_PREFIX)-$(DEVICE_NAME)-bootfs.tar.gz . ; \
85 )
86 endef
87
88 #################################################
89 # Devices
90 #################################################
91
92 KERNEL_LOADADDR=0x10008000
93
94 define Device/Default
95 PROFILES := Generic
96 FILESYSTEMS := squashfs ext4
97 KERNEL_INSTALL := 1
98 KERNEL_SUFFIX := -uImage
99 KERNEL_NAME := zImage
100 KERNEL_PREFIX := $$(IMAGE_PREFIX)
101 KERNEL := kernel-bin | uImage none
102 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
103 IMAGES :=
104 endef
105
106 define Device/ventana
107 DEVICE_TITLE := Gateworks Ventana family
108 DEVICE_DTS:= \
109 imx6dl-gw51xx \
110 imx6dl-gw52xx \
111 imx6dl-gw53xx \
112 imx6dl-gw54xx \
113 imx6dl-gw551x \
114 imx6dl-gw552x \
115 imx6q-gw51xx \
116 imx6q-gw52xx \
117 imx6q-gw53xx \
118 imx6q-gw54xx \
119 imx6q-gw5400-a \
120 imx6q-gw551x \
121 imx6q-gw552x
122 DEVICE_PACKAGES := kmod-thermal-imx kmod-sky2 kmod-usb-chipidea-imx kmod-usb-mxs-phy \
123 kmod-sound-core kmod-sound-soc-imx kmod-sound-soc-imx-sgtl5000 \
124 kmod-can kmod-can-flexcan kmod-can-raw \
125 kmod-rtc-ds1672 kmod-gpio-pca953x kmod-hwmon-gsc kmod-eeprom-at24 \
126 kmod-leds-gpio kmod-pps-gpio kmod-gw16083 \
127 kobs-ng
128 IMAGES := nand_normal.ubi nand_large.ubi bootfs.tar.gz
129 IMAGE/nand_normal.ubi := ubi-boot-overlay normal 2048 124KiB 128KiB 8124
130 IMAGE/nand_large.ubi := ubi-boot-overlay large 4096 248KiB 256KiB 8124
131 IMAGE/bootfs.tar.gz := bootfs.tar.gz
132 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
133 endef
134
135 define Device/wandboard
136 DEVICE_TITLE := Wandboard Dual
137 DEVICE_DTS := imx6dl-wandboard
138 DEVICE_PACKAGES := kmod-thermal-imx kmod-usb-chipidea-imx kmod-usb-mxs-phy
139 endef
140
141 TARGET_DEVICES += \
142 ventana \
143 wandboard
144
145 $(eval $(call BuildImage))