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# 7include $(TOPDIR)/rules.mk 8include $(INCLUDE_DIR)/image.mk 9 10define 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 20endef 21 22define Build/append-dtb 23 cat $(KDIR)/$(DT).dtb >> $@ 24endef 25 26define Build/lzma-d16 27 $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) $@.new 28 mv $@.new $@ 29endef 30 31define Build/trx-serial 32 $(STAGING_DIR_HOST)/bin/trx \ 33 -o $@.new \ 34 -m 33554432 \ 35 -f $(word 1,$^) -a 1024 \ 36 -f $@ -a 0x10000 -A $(KDIR)/fs_mark 37 mv $@.new $@ 38endef 39 40define Build/trx-nand 41 # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even 42 # if it grows up between releases 43 # root: UBI with one extra block containing UBI mark to trigger erasing 44 # rest of partition 45 $(STAGING_DIR_HOST)/bin/trx \ 46 -o $@.new \ 47 -m 33554432 \ 48 -f $(word 1,$^) -a 0x20000 -b 0x400000 \ 49 -f $@ \ 50 -A $(KDIR)/ubi_mark -a 0x20000 51 mv $@.new $@ 52endef 53 54define Build/asus-trx 55 $(STAGING_DIR_HOST)/bin/asustrx \ 56 -p $(PRODUCTID) -i $@ -o $@.new 57 mv $@.new $@ 58endef 59 60define Build/seama-nand 61 # Seama entity 62 $(STAGING_DIR_HOST)/bin/oseama \ 63 entity $@.entity \ 64 -m "dev=/dev/mtdblock/7" \ 65 -m "type=firmware" \ 66 -f $(word 1,$^) \ 67 -b 0x400000 \ 68 -f $@ \ 69 -f $(KDIR)/ubi_mark 70 # Seama container 71 $(STAGING_DIR_HOST)/bin/seama \ 72 -s $@ \ 73 -m "signature=$(SIGNATURE)" \ 74 -i $@.entity 75endef 76 77DEVICE_VARS += DT PRODUCTID SIGNATURE NETGEAR_BOARD_ID NETGEAR_REGION 78 79define Device/Default 80 # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names 81 # extract the full dtb name based on the device info 82 DT := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb))) 83 KERNEL := kernel-bin | append-dtb | lzma-d16 84 KERNEL_DEPENDS = $$(wildcard $(KDIR)/$$(DT).dts) 85 FILESYSTEMS := squashfs 86 KERNEL_NAME := zImage 87 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2) 88 IMAGES := trx 89 BLOCKSIZE := 128KiB 90 PAGESIZE := 2048 91 UBINIZE_OPTS := 92 IMAGE/trx := append-ubi | trx-nand 93endef 94 95define Device/asus 96 IMAGES := trx 97 IMAGE/trx := append-ubi | trx-nand | asus-trx 98endef 99 100define AsusDevice 101 define Device/asus-$(1) 102 $$(Device/asus) 103 PRODUCTID := $(2) 104 endef 105 TARGET_DEVICES += asus-$(1) 106endef 107 108define LinksysDevice 109 TARGET_DEVICES += linksys-$(1) 110endef 111 112define Device/dlink 113 IMAGES := bin 114 IMAGE/bin := append-ubi | seama-nand 115endef 116 117define DLinkDevice 118 define Device/dlink-$(1) 119 $$(Device/dlink) 120 SIGNATURE := $(2) 121 endef 122 TARGET_DEVICES += dlink-$(1) 123endef 124 125define Device/netgear 126 IMAGES := chk 127 IMAGE/chk := append-ubi | trx-nand | netgear-chk 128 NETGEAR_REGION := 1 129endef 130 131define NetgearDevice 132 define Device/netgear-$(1) 133 $$(Device/netgear) 134 NETGEAR_BOARD_ID := $(2) 135 endef 136 TARGET_DEVICES += netgear-$(1) 137endef 138 139define Device/netgear-r6250 140 $(Device/netgear) 141 NETGEAR_BOARD_ID := U12H245T00_NETGEAR 142endef 143 144define Device/netgear-r6300-v2 145 $(Device/netgear) 146 NETGEAR_BOARD_ID := U12H240T00_NETGEAR 147endef 148 149define Device/netgear-r8000 150 $(Device/netgear) 151 NETGEAR_BOARD_ID := U12H315T00_NETGEAR 152endef 153 154define Device/smartrg-sr400ac 155 IMAGES := trx 156 IMAGE/trx := append-rootfs | trx-serial 157endef 158 159TARGET_DEVICES += \ 160 buffalo-wzr-1750dhp buffalo-wzr-600dhp2 buffalo-wzr-900dhp \ 161 buffalo-wxr-1900dhp \ 162 netgear-r6250 netgear-r6300-v2 netgear-r8000 \ 163 smartrg-sr400ac 164 165$(eval $(call AsusDevice,rt-ac56u,RT-AC56U)) 166$(eval $(call AsusDevice,rt-ac68u,RT-AC68U)) 167$(eval $(call AsusDevice,rt-ac87u,RT-AC87U)) 168$(eval $(call AsusDevice,rt-n18u,RT-N18U)) 169$(eval $(call DLinkDevice,dir-885l,wrgac42_dlink.2015_dir885l)) 170$(eval $(call LinksysDevice,ea6300-v1)) 171$(eval $(call NetgearDevice,r7000,U12H270T00_NETGEAR)) 172$(eval $(call NetgearDevice,r7900,U12H315T30_NETGEAR)) 173# $(eval $(call NetgearDevice,r8500,U12H334T00_NETGEAR)) 174 175$(eval $(call BuildImage)) 176