316e0d3cebabb2e29ddaac16b6867412c7787443
[openwrt/openwrt.git] / target / linux / ipq806x / image / Makefile
1 # Copyright (c) 2014 The Linux Foundation. All rights reserved.
2 #
3 include $(TOPDIR)/rules.mk
4 include $(INCLUDE_DIR)/image.mk
5
6 UBIFS_OPTS = -m 2048 -e 124KiB -c 4096 -U -F
7 UBINIZE_OPTS = -m 2048 -p 128KiB
8
9 KERNEL_LOADADDR := 0x42208000
10
11 define Image/Prepare
12 $(CP) $(LINUX_DIR)/vmlinux $(KDIR)/$(IMG_PREFIX)-vmlinux.elf
13 mkimage -A arm -O linux -T filesystem -C none \
14 -a $(KERNEL_LOADADDR) -e $(KERNEL_LOADADDR) \
15 -n 'ARM OpenWrt fakeroot' \
16 -s $(KDIR_TMP)/root.dummy-uImage.tmp
17 echo -ne '\xff' > $(KDIR_TMP)/root.dummy
18 cat $(KDIR_TMP)/root.dummy $(KDIR_TMP)/root.dummy-uImage.tmp > $(KDIR)/root.dummy
19 endef
20
21 define Image/BuildKernel
22 $(CP) $(KDIR)/$(IMG_PREFIX)-vmlinux.elf $(BIN_DIR)
23 endef
24
25 define Image/Build/squashfs
26 cp $(KDIR)/root.squashfs $(KDIR)/root.squashfs-raw
27 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
28 endef
29
30 define Image/Build
31 $(call Image/Build/$(1),$(1))
32 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1)-root.img bs=2k conv=sync
33 endef
34
35 define Build/append-dtb
36 cat $(DTS_DIR)/$(DEVICE_DTS).dtb >> $@
37 endef
38
39 define Build/append-file
40 cat $(1) >> $@
41 endef
42
43 define Device/Default
44 PROFILES := Default
45 KERNEL_INITRAMFS_PREFIX := $$(IMG_PREFIX)-$(1)-initramfs
46 DEVICE_DTS :=
47 KERNEL_PREFIX := $$(IMAGE_PREFIX)
48 IMAGES :=
49 KERNEL_IN_UBI :=
50 endef
51 DEVICE_VARS += DEVICE_DTS KERNEL_IN_UBI
52
53 define Device/LegacyImage
54 KERNEL_SUFFIX := -uImage
55 KERNEL = kernel-bin | append-dtb | uImage none
56 KERNEL_NAME := zImage
57 endef
58
59 define Device/FitImage
60 KERNEL_SUFFIX := -fit-uImage.itb
61 KERNEL = kernel-bin | gzip | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb
62 KERNEL_NAME := Image
63 endef
64
65 define Device/UbiFit
66 KERNEL_IN_UBI := 1
67 IMAGES := nand-factory.ubi nand-sysupgrade.tar
68 IMAGE/nand-factory.ubi := append-ubi
69 IMAGE/nand-sysupgrade.tar := sysupgrade-nand
70 endef
71
72 define Device/DniImage
73 PROFILES += $$(DEVICE_NAME)
74 FILESYSTEMS := squashfs
75 KERNEL_SUFFIX := -uImage
76 KERNEL_INITRAMFS := kernel-bin | append-dtb | uImage none
77 KERNEL = kernel-bin | append-dtb | pad-to $$$$(($$(KERNEL_SIZE)-2*64-1)) | append-file $(KDIR)/root.dummy | uImage none
78 KERNEL_NAME := zImage
79 NETGEAR_BOARD_ID :=
80 NETGEAR_HW_ID :=
81 BOARD_NAME :=
82 IMAGES := factory.img sysupgrade.tar
83 IMAGE/factory.img := append-kernel | append-ubi | netgear-dni
84 IMAGE/sysupgrade.tar = sysupgrade-nand
85 endef
86 DEVICE_VARS += KERNEL_SIZE NETGEAR_BOARD_ID NETGEAR_HW_ID DEVICE_BLOCK_SIZE DEVICE_PAGE_SIZE BOARD_NAME
87
88 define Device/AP148
89 $(call Device/FitImage)
90 $(call Device/UbiFit)
91 DEVICE_DTS := qcom-ipq8064-ap148
92 BLOCKSIZE := 128KiB
93 PAGESIZE := 2048
94 endef
95
96 define Device/AP148-legacy
97 $(call Device/LegacyImage)
98 $(call Device/UbiFit)
99 DEVICE_DTS := qcom-ipq8064-ap148
100 BLOCKSIZE := 128KiB
101 PAGESIZE := 2048
102 BOARD_NAME := AP148
103 endef
104
105 define Device/DB149
106 $(call Device/FitImage)
107 DEVICE_DTS := qcom-ipq8064-db149
108 KERNEL_INSTALL := 1
109 endef
110
111 define Device/R7500
112 $(call Device/DniImage)
113 DEVICE_DTS := qcom-ipq8064-r7500
114 KERNEL_SIZE := 2097152
115 NETGEAR_BOARD_ID := R7500
116 NETGEAR_HW_ID := 29764841+0+128+256+3x3+4x4
117 BLOCKSIZE := 128KiB
118 PAGESIZE := 2048
119 BOARD_NAME := r7500
120 endef
121
122 TARGET_DEVICES += AP148 AP148-legacy DB149 R7500
123
124 $(eval $(call BuildImage))