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 #################################################
12 #################################################
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)
24 define Build/ubi-boot-overlay
25 # ubi-boot-overlay $(DEVICE_NAME) $(word 1, $(1))
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; \
41 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
42 -n '$(DEVICE_ID) OpenWrt 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
54 rm -rf p $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))
55 mkdir -p $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))
57 $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))/
58 $(CP) $(KDIR)/boot-$(DEVICE_NAME)-bootfs_$(word 1, $(1)).ubifs \
59 $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))/boot.ubifs
60 $(CP) ./ubinize-$(DEVICE_NAME).cfg \
61 $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1))/ubinize.cfg
62 ( cd $(KDIR)/$(DEVICE_NAME)_$(word 1, $(1)); \
63 $(STAGING_DIR_HOST)/bin/ubinize \
64 -m $(word 2, $(1)) -p $(word 4, $(1)) -s $(word 2, $(1)) \
70 define Build/bootfs.tar.gz
72 rm -rf $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)
73 mkdir -p $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)
74 $(CP) $< $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(IMG_PREFIX)-uImage
75 ln -sf $(IMG_PREFIX)-uImage \
76 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/uImage
77 $(foreach dts,$(shell echo $(DEVICE_DTS)), \
78 $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
79 $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
80 $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
81 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(IMG_PREFIX)-$(dts).dtb; \
82 ln -sf $(IMG_PREFIX)-$(dts).dtb \
83 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/$(dts).dtb; \
85 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
86 -n '$(DEVICE_ID) OpenWrt bootscript' \
87 -d ./bootscript-$(DEVICE_NAME) \
88 $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)/6x_bootscript-$(DEVICE_NAME)
92 cd $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME); \
93 $(TAR) --numeric-owner --owner=0 --group=0 --transform "s,./,./boot/," \
94 -czvf $(BIN_DIR)/$(IMG_PREFIX)-$(DEVICE_NAME)-bootfs.tar.gz . ; \
98 #################################################
100 #################################################
102 KERNEL_LOADADDR=0x10008000
104 define Device/Default
106 FILESYSTEMS := squashfs ext4
108 KERNEL_SUFFIX := -uImage
109 KERNEL_NAME := zImage
110 KERNEL_PREFIX := $$(IMAGE_PREFIX)
111 KERNEL := kernel-bin | uImage none
112 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
116 DEVICE_VARS += DEVICE_DTS
118 define Device/ventana
119 PROFILES = Generic VENTANA
134 IMAGES := nand_normal.ubi nand_large.ubi bootfs.tar.gz
135 IMAGE/nand_normal.ubi := ubi-boot-overlay normal 2048 124KiB 128KiB 8124
136 IMAGE/nand_large.ubi := ubi-boot-overlay large 4096 248KiB 256KiB 8124
137 IMAGE/bootfs.tar.gz := bootfs.tar.gz
138 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
141 define Device/wandboard
142 PROFILES = Generic IMX6DL_WANDBOARD
143 DEVICE_DTS := imx6dl-wandboard
150 $(eval $(call BuildImage))