2009-08-30 19:15:51 +00:00
|
|
|
#
|
2011-10-31 09:23:44 +00:00
|
|
|
# Copyright (C) 2008-2011 OpenWrt.org
|
2009-08-30 19:15:51 +00:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
include $(INCLUDE_DIR)/image.mk
|
|
|
|
|
2020-04-14 03:00:03 +00:00
|
|
|
DEVICE_VARS += LOADER_TYPE
|
2020-03-09 12:14:06 +00:00
|
|
|
DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID
|
2017-01-28 16:05:56 +00:00
|
|
|
DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR
|
2018-12-29 18:25:00 +00:00
|
|
|
DEVICE_VARS += SEAMA_SIGNATURE SEAMA_MTDBLOCK
|
2020-07-10 10:00:08 +00:00
|
|
|
DEVICE_VARS += SERCOMM_HWNAME SERCOMM_HWID SERCOMM_HWVER SERCOMM_SWVER
|
2020-08-03 17:23:50 +00:00
|
|
|
DEVICE_VARS += SERCOMM_PAD JCG_MAXSIZE
|
2015-01-10 15:26:53 +00:00
|
|
|
|
2015-01-10 15:26:38 +00:00
|
|
|
loadaddr-y := 0x80000000
|
|
|
|
loadaddr-$(CONFIG_TARGET_ramips_rt288x) := 0x88000000
|
|
|
|
loadaddr-$(CONFIG_TARGET_ramips_mt7621) := 0x80001000
|
2009-08-30 19:15:51 +00:00
|
|
|
|
2020-04-14 03:17:47 +00:00
|
|
|
ldrplatform-y := ralink
|
|
|
|
ldrplatform-$(CONFIG_TARGET_ramips_mt7621) := mt7621
|
|
|
|
|
2015-01-10 15:26:53 +00:00
|
|
|
KERNEL_LOADADDR := $(loadaddr-y)
|
2020-04-14 03:17:47 +00:00
|
|
|
LOADER_PLATFORM := $(ldrplatform-y)
|
2015-01-10 15:26:53 +00:00
|
|
|
|
2019-06-27 12:44:27 +00:00
|
|
|
KERNEL_DTB = kernel-bin | append-dtb | lzma
|
2015-01-10 15:26:53 +00:00
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/edimax-header
|
|
|
|
$(STAGING_DIR_HOST)/bin/mkedimaximg -i $@ -o $@.new $(1)
|
|
|
|
@mv $@.new $@
|
2015-01-17 21:20:05 +00:00
|
|
|
endef
|
|
|
|
|
2019-08-19 12:38:24 +00:00
|
|
|
define Build/elx-header
|
|
|
|
$(eval hw_id=$(word 1,$(1)))
|
|
|
|
$(eval xor_pattern=$(word 2,$(1)))
|
|
|
|
( \
|
|
|
|
echo -ne "\x00\x00\x00\x00\x00\x00\x00\x03" | \
|
|
|
|
dd bs=42 count=1 conv=sync; \
|
|
|
|
hw_id="$(hw_id)"; \
|
|
|
|
echo -ne "\x$${hw_id:0:2}\x$${hw_id:2:2}\x$${hw_id:4:2}\x$${hw_id:6:2}" | \
|
|
|
|
dd bs=20 count=1 conv=sync; \
|
|
|
|
echo -ne "$$(printf '%08x' $$(stat -c%s $@) | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \
|
|
|
|
dd bs=8 count=1 conv=sync; \
|
|
|
|
echo -ne "$$($(STAGING_DIR_HOST)/bin/mkhash md5 $@ | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \
|
|
|
|
dd bs=58 count=1 conv=sync; \
|
|
|
|
) > $(KDIR)/tmp/$(DEVICE_NAME).header
|
|
|
|
$(call Build/xor-image,-p $(xor_pattern) -x)
|
|
|
|
cat $(KDIR)/tmp/$(DEVICE_NAME).header $@ > $@.new
|
|
|
|
mv $@.new $@
|
|
|
|
rm -rf $(KDIR)/tmp/$(DEVICE_NAME).header
|
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/jcg-header
|
|
|
|
$(STAGING_DIR_HOST)/bin/jcgimage -v $(1) \
|
|
|
|
$(if $(JCG_MAXSIZE), -m $$(($(subst k, * 1024,$(JCG_MAXSIZE)))),) \
|
|
|
|
-u $@ -o $@.new
|
|
|
|
mv $@.new $@
|
2016-09-27 05:38:08 +00:00
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/loader-common
|
|
|
|
rm -rf $@.src
|
|
|
|
$(MAKE) -C lzma-loader \
|
|
|
|
PKG_BUILD_DIR="$@.src" \
|
|
|
|
TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
|
|
|
|
BOARD="$(BOARDNAME)" PLATFORM="$(LOADER_PLATFORM)" \
|
2020-08-04 16:03:42 +00:00
|
|
|
LZMA_TEXT_START=0x81800000 LOADADDR=$(KERNEL_LOADADDR) \
|
2020-05-08 16:20:53 +00:00
|
|
|
$(1) compile loader.$(LOADER_TYPE)
|
|
|
|
mv "$@.$(LOADER_TYPE)" "$@"
|
|
|
|
rm -rf $@.src
|
2016-11-21 07:46:48 +00:00
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/loader-kernel
|
|
|
|
$(call Build/loader-common,LOADER_DATA="$@")
|
2016-11-25 12:03:01 +00:00
|
|
|
endef
|
|
|
|
|
2018-01-20 08:27:03 +00:00
|
|
|
# combine kernel and rootfs into one image
|
|
|
|
# mkdlinkfw <type> <optional extra arguments to mkdlinkfw binary>
|
|
|
|
define Build/mkdlinkfw
|
|
|
|
-$(STAGING_DIR_HOST)/bin/mkdlinkfw \
|
|
|
|
-k $(IMAGE_KERNEL) \
|
|
|
|
-r $(IMAGE_ROOTFS) \
|
|
|
|
-o $@ \
|
2018-04-19 17:36:55 +00:00
|
|
|
$(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \
|
2018-01-20 08:27:03 +00:00
|
|
|
-s $(DLINK_FIRMWARE_SIZE)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/mkdlinkfw-factory
|
|
|
|
-$(STAGING_DIR_HOST)/bin/mkdlinkfw \
|
|
|
|
-m $(DLINK_ROM_ID) -f $(DLINK_FAMILY_MEMBER) \
|
|
|
|
-F $@ \
|
|
|
|
-o $@.new \
|
2018-04-19 17:36:55 +00:00
|
|
|
$(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \
|
2018-01-20 08:27:03 +00:00
|
|
|
-s $(DLINK_FIRMWARE_SIZE)
|
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2019-11-11 16:23:07 +00:00
|
|
|
define Build/netis-tail
|
|
|
|
echo -n $(1) >> $@
|
|
|
|
echo -n $(UIMAGE_NAME)-yun | $(STAGING_DIR_HOST)/bin/mkhash md5 | \
|
|
|
|
sed 's/../\\\\x&/g' | xargs echo -ne >> $@
|
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/poray-header
|
|
|
|
$(STAGING_DIR_HOST)/bin/mkporayfw $(1) -f $@ -o $@.new
|
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2020-06-29 10:24:01 +00:00
|
|
|
define Build/ravpower-wd009-factory
|
|
|
|
mkimage -A mips -T standalone -C none -a 0x80010000 -e 0x80010000 -n "OpenWrt Bootloader" -d $(UBOOT_PATH) $@.new
|
|
|
|
cat $@ >> $@.new
|
|
|
|
@mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/relocate-kernel
|
|
|
|
rm -rf $@.relocate
|
|
|
|
$(CP) ../../generic/image/relocate $@.relocate
|
|
|
|
$(MAKE) -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS)
|
|
|
|
( \
|
|
|
|
dd if=$@.relocate/loader.bin bs=32 conv=sync && \
|
|
|
|
perl -e '@s = stat("$@"); print pack("V", @s[7])' && \
|
|
|
|
cat $@ \
|
|
|
|
) > $@.new
|
|
|
|
mv $@.new $@
|
|
|
|
rm -rf $@.relocate
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/sercom-footer
|
|
|
|
$(call Build/sercom-seal,-f)
|
2018-06-28 05:26:39 +00:00
|
|
|
endef
|
|
|
|
|
2019-05-15 19:11:01 +00:00
|
|
|
define Build/sercom-seal
|
|
|
|
$(STAGING_DIR_HOST)/bin/mksercommfw \
|
|
|
|
-i $@ \
|
|
|
|
-b $(SERCOMM_HWID) \
|
|
|
|
-r $(SERCOMM_HWVER) \
|
|
|
|
-v $(SERCOMM_SWVER) \
|
|
|
|
$(1)
|
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/trx
|
|
|
|
$(STAGING_DIR_HOST)/bin/trx $(1) \
|
|
|
|
-o $@ \
|
|
|
|
-m $$(($(subst k, * 1024,$(IMAGE_SIZE)))) \
|
|
|
|
-f $(IMAGE_KERNEL) \
|
|
|
|
-a 4 -f $(IMAGE_ROOTFS)
|
2019-05-15 19:11:01 +00:00
|
|
|
endef
|
|
|
|
|
2020-07-10 12:16:23 +00:00
|
|
|
define Build/uimage-padhdr
|
|
|
|
uimage_padhdr $(if $(1),-l $(1)) -i $@ -o $@.new
|
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/umedia-header
|
|
|
|
fix-u-media-header -T 0x46 -B $(1) -i $@ -o $@.new && mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/wrg-header
|
|
|
|
mkwrgimg -i $@ -d "/dev/mtdblock/2" -s $(1) -o $@.new
|
2019-07-25 23:11:48 +00:00
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Build/zyimage
|
|
|
|
$(STAGING_DIR_HOST)/bin/zyimage $(1) $@
|
|
|
|
endef
|
2011-07-28 10:56:32 +00:00
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Device/Default
|
|
|
|
PROFILES = Default
|
|
|
|
KERNEL := $(KERNEL_DTB) | uImage lzma
|
|
|
|
SOC := $(DEFAULT_SOC)
|
|
|
|
DEVICE_DTS_DIR := ../dts
|
|
|
|
DEVICE_DTS = $$(SOC)_$(1)
|
|
|
|
IMAGES := sysupgrade.bin
|
|
|
|
SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
|
|
|
|
sysupgrade_bin := append-kernel | append-rootfs | pad-rootfs
|
|
|
|
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size
|
|
|
|
endef
|
2010-04-11 17:47:28 +00:00
|
|
|
|
2020-08-03 17:23:50 +00:00
|
|
|
define Device/netgear_sercomm_nor
|
|
|
|
BLOCKSIZE := 64k
|
|
|
|
DEVICE_VENDOR := NETGEAR
|
|
|
|
IMAGES += factory.img
|
|
|
|
IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | \
|
|
|
|
pad-rootfs
|
|
|
|
IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | check-size
|
|
|
|
IMAGE/factory.img := pad-extra $$$$(SERCOMM_PAD) | $$(IMAGE/default) | \
|
|
|
|
pad-to $$$$(BLOCKSIZE) | sercom-footer | pad-to 128 | \
|
|
|
|
zip $$$$(SERCOMM_HWNAME).bin | sercom-seal
|
|
|
|
endef
|
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Device/seama
|
|
|
|
SEAMA_MTDBLOCK := 2
|
|
|
|
IMAGES += factory.bin
|
2012-04-21 12:30:44 +00:00
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
# 64 bytes offset:
|
|
|
|
# - 28 bytes seama_header
|
|
|
|
# - 36 bytes of META data (4-bytes aligned)
|
|
|
|
IMAGE/default := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs
|
|
|
|
IMAGE/sysupgrade.bin := \
|
|
|
|
$$(IMAGE/default) | seama | pad-rootfs | append-metadata | check-size
|
|
|
|
IMAGE/factory.bin := \
|
|
|
|
$$(IMAGE/default) | pad-rootfs -x 64 | seama | seama-seal | check-size
|
|
|
|
SEAMA_SIGNATURE :=
|
|
|
|
endef
|
2013-11-16 20:28:52 +00:00
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
define Device/uimage-lzma-loader
|
|
|
|
LOADER_TYPE := bin
|
|
|
|
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
|
|
|
|
endef
|
2013-12-13 10:53:34 +00:00
|
|
|
|
2020-05-08 16:20:53 +00:00
|
|
|
include $(SUBTARGET).mk
|
2015-07-24 09:11:56 +00:00
|
|
|
|
2009-08-30 19:15:51 +00:00
|
|
|
$(eval $(call BuildImage))
|