c9987dddc78aedadbe78ea45215418073825ea1f
[openwrt.git] / target / linux / bcm53xx / 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 define Image/Prepare
11         $(CP) $(DTS_DIR)/*.dtb $(KDIR)/
12
13         rm -f $(KDIR)/fs_mark
14         echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
15         $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
16
17         # For UBI we want only one extra block
18         rm -f $(KDIR)/ubi_mark
19         echo -ne '\xde\xad\xc0\xde' > $(KDIR)/ubi_mark
20
21         $(CP) ./ubinize.cfg $(KDIR)
22 endef
23
24 define Build/append-dtb
25         cat $(KDIR)/$(DT).dtb >> $@
26 endef
27
28 define Build/lzma-d16
29         $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) $@.new
30         @mv $@.new $@
31 endef
32
33 define Build/mkfs/squashfs
34         ( cd $(KDIR); $(STAGING_DIR_HOST)/bin/ubinize -p 128KiB -m 2048 -o $(KDIR)/root-block-0x20000-min-0x800.ubi ubinize.cfg )
35 endef
36
37 define Build/trx-serial
38         $(STAGING_DIR_HOST)/bin/trx \
39                 -o $@ \
40                 -f $(word 1,$^) -a 1024 \
41                 -f $(KDIR)/root.squashfs -a 0x10000 -A $(KDIR)/fs_mark
42 endef
43
44 define Build/trx-nand
45         # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
46         #         if it grows up between releases
47         # root: UBI with one extra block containing UBI mark to trigger erasing
48         #       rest of partition
49         $(STAGING_DIR_HOST)/bin/trx \
50                 -o $@ \
51                 -m 33554432 \
52                 -f $(word 1,$^) -a 0x20000 -b 0x400000 \
53                 -f $(KDIR)/root-block-0x20000-min-0x800.ubi \
54                 -A $(KDIR)/ubi_mark -a 0x20000
55 endef
56
57 define Build/asus-trx
58         $(STAGING_DIR_HOST)/bin/asustrx \
59                 -p $(PRODUCTID) -i $@ -o $@.new
60         mv $@.new $@
61 endef
62
63 DEVICE_VARS += DT PRODUCTID NETGEAR_BOARD_ID NETGEAR_REGION
64
65 define Device/Default
66   # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
67   # extract the full dtb name based on the device info
68   DT := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
69   KERNEL := kernel-bin | append-dtb | lzma-d16
70   FILESYSTEMS := squashfs
71   KERNEL_NAME := zImage
72   IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
73   IMAGES := trx
74   IMAGE/trx := trx-nand
75 endef
76
77 define Device/asus
78   IMAGES := trx
79   IMAGE/trx := trx-nand | asus-trx
80 endef
81
82 define AsusDevice
83   define Device/asus-$(1)
84         $$(Device/asus)
85         PRODUCTID := $(2)
86   endef
87   TARGET_DEVICES += asus-$(1)
88 endef
89
90 define Device/linksys
91   IMAGES := trx
92   IMAGE/trx := trx-nand
93 endef
94
95 define LinksysDevice
96   define Device/linksys-$(1)
97         $$(Device/linksys)
98   endef
99   TARGET_DEVICES += linksys-$(1)
100 endef
101
102 define Device/netgear
103   IMAGES := chk
104   IMAGE/chk := trx-nand | netgear-chk
105   NETGEAR_REGION := 1
106 endef
107
108 define NetgearDevice
109   define Device/netgear-$(1)
110         $$(Device/netgear)
111         NETGEAR_BOARD_ID := $(2)
112   endef
113   TARGET_DEVICES += netgear-$(1)
114 endef
115
116 define Device/netgear-r6250
117   $(Device/netgear)
118   NETGEAR_BOARD_ID := U12H245T00_NETGEAR
119 endef
120
121 define Device/netgear-r6300-v2
122   $(Device/netgear)
123   NETGEAR_BOARD_ID := U12H240T00_NETGEAR
124 endef
125
126 define Device/netgear-r8000
127   $(Device/netgear)
128   NETGEAR_BOARD_ID := U12H315T00_NETGEAR
129 endef
130
131 define Device/smartrg-sr400ac
132   IMAGES := trx
133   IMAGE/trx := trx-serial
134 endef
135
136 TARGET_DEVICES += \
137         buffalo-wzr-1750dhp buffalo-wzr-600dhp2 buffalo-wzr-900dhp \
138         buffalo-wxr-1900dhp \
139         netgear-r6250 netgear-r6300-v2 netgear-r8000 \
140         smartrg-sr400ac
141
142 $(eval $(call AsusDevice,rt-ac56u,RT-AC56U))
143 $(eval $(call AsusDevice,rt-ac68u,RT-AC68U))
144 $(eval $(call AsusDevice,rt-ac87u,RT-AC87U))
145 $(eval $(call AsusDevice,rt-n18u,RT-N18U))
146 $(eval $(call LinksysDevice,ea6300-v1))
147 $(eval $(call NetgearDevice,r7000,U12H270T00_NETGEAR))
148
149 $(eval $(call BuildImage))