bcm53xx: append only 1 block (with erasing mark) to UBI
[openwrt/svn-archive/archive.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-nand
38 # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
39 # if it grows up between releases
40 # root: UBI with one extra block containing UBI mark to trigger erasing
41 # rest of partition
42 $(STAGING_DIR_HOST)/bin/trx \
43 -o $@ \
44 -m 33554432 \
45 -f $(word 1,$^) -a 0x20000 -b 0x400000 \
46 -f $(KDIR)/root-block-0x20000-min-0x800.ubi \
47 -A $(KDIR)/ubi_mark -a 0x20000
48 endef
49
50 define Build/netgear-chk
51 $(STAGING_DIR_HOST)/bin/mkchkimg \
52 -o $@.new -k $@ -b $(BOARD_ID) -r $(REGION)
53 mv $@.new $@
54 endef
55
56 DEVICE_VARS += DT BOARD_ID REGION
57
58 define Device/Default
59 # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
60 # extract the full dtb name based on the device info
61 DT := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
62 KERNEL := kernel-bin | append-dtb | lzma-d16
63 FILESYSTEMS := squashfs
64 KERNEL_NAME := zImage
65 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
66 IMAGES := trx
67 IMAGE/trx := trx-nand
68 endef
69
70 define Device/netgear
71 IMAGES := chk
72 IMAGE/chk := trx-nand | netgear-chk
73 REGION := 1
74 endef
75
76 define Device/netgear-r6250
77 $(Device/netgear)
78 BOARD_ID := U12H245T00_NETGEAR
79 endef
80
81 define Device/netgear-r6300-v2
82 $(Device/netgear)
83 BOARD_ID := U12H240T00_NETGEAR
84 endef
85
86 define Device/netgear-r8000
87 $(Device/netgear)
88 BOARD_ID := U12H315T00_NETGEAR
89 endef
90
91 TARGET_DEVICES += \
92 asus-rt-ac56u asus-rt-ac68u asus-rt-ac87u asus-rt-n18u \
93 netgear-r6250 netgear-r6300-v2 netgear-r8000 \
94 buffalo-wzr-1750dhp buffalo-wzr-600dhp2 buffalo-wzr-900dhp \
95 buffalo-wxr-1900dhp
96
97 $(eval $(call BuildImage))