b3f2cd8127afccc44d335aecac15f8ed1d2a41a4
[openwrt/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 $(CP) ./ubinize.cfg $(KDIR)
18 endef
19
20 define Build/append-dtb
21 cat $(KDIR)/$(DT).dtb >> $@
22 endef
23
24 define Build/lzma-d16
25 $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) $@.new
26 @mv $@.new $@
27 endef
28
29 define Build/mkfs/squashfs
30 ( cd $(KDIR); $(STAGING_DIR_HOST)/bin/ubinize -p 128KiB -m 2048 -o $(KDIR)/root-block-0x20000-min-0x800.ubi ubinize.cfg )
31 endef
32
33 define Build/trx-nand
34 # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
35 # if it grows up between releases
36 $(STAGING_DIR_HOST)/bin/trx \
37 -o $@ \
38 -m 33554432 \
39 -f $(word 1,$^) -a 0x20000 -b 0x400000 \
40 -f $(KDIR)/root-block-0x20000-min-0x800.ubi -a 0x20000 \
41 -A $(KDIR)/fs_mark
42 endef
43
44 define Build/netgear-chk
45 $(STAGING_DIR_HOST)/bin/mkchkimg \
46 -o $@.new -k $@ -b $(BOARD_ID) -r $(REGION)
47 mv $@.new $@
48 endef
49
50 DEVICE_VARS += DT BOARD_ID REGION
51
52 define Device/Default
53 # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
54 # extract the full dtb name based on the device info
55 DT := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
56 KERNEL := kernel-bin | append-dtb | lzma-d16
57 FILESYSTEMS := squashfs
58 KERNEL_NAME := zImage
59 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
60 IMAGES := trx
61 IMAGE/trx := trx-nand
62 endef
63
64 define Device/netgear
65 IMAGES := chk
66 IMAGE/chk := trx-nand | netgear-chk
67 REGION := 1
68 endef
69
70 define Device/netgear-r6250
71 $(Device/netgear)
72 BOARD_ID := U12H245T00_NETGEAR
73 endef
74
75 define Device/netgear-r6300-v2
76 $(Device/netgear)
77 BOARD_ID := U12H240T00_NETGEAR
78 endef
79
80 define Device/netgear-r8000
81 $(Device/netgear)
82 BOARD_ID := U12H315T00_NETGEAR
83 endef
84
85 TARGET_DEVICES += \
86 asus-rt-ac56u asus-rt-ac68u asus-rt-ac87u asus-rt-n18u \
87 netgear-r6250 netgear-r6300-v2 netgear-r8000 \
88 buffalo-wzr-1750dhp buffalo-wzr-600dhp2 buffalo-wzr-900dhp \
89 buffalo-wxr-1900dhp
90
91 $(eval $(call BuildImage))