2008-09-07 21:28:07 +08:00
|
|
|
#
|
2011-08-05 03:41:16 +08:00
|
|
|
# Copyright (C) 2008-2011 OpenWrt.org
|
2008-07-22 01:08:14 +08:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2015-08-05 21:55:52 +08:00
|
|
|
|
2008-07-22 01:08:14 +08:00
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
include $(INCLUDE_DIR)/image.mk
|
|
|
|
|
2015-01-10 23:27:00 +08:00
|
|
|
KERNEL_LOADADDR = 0x80060000
|
|
|
|
|
2016-03-23 20:52:44 +08:00
|
|
|
DEVICE_VARS += NETGEAR_KERNEL_MAGIC NETGEAR_BOARD_ID NETGEAR_HW_ID CMDLINE CONSOLE IMAGE_SIZE BOARDNAME LOADER_FLASH_OFFS LOADER_TYPE
|
2015-01-10 23:27:07 +08:00
|
|
|
|
2016-05-23 05:10:02 +08:00
|
|
|
ifeq ($(SUBTARGET),generic)
|
2016-05-23 04:57:32 +08:00
|
|
|
include ./tp-link.mk
|
2016-05-23 05:06:59 +08:00
|
|
|
include ./ubnt.mk
|
2016-05-23 05:10:02 +08:00
|
|
|
include ./generic.mk
|
2016-07-05 15:07:16 +08:00
|
|
|
include ./legacy-devices.mk
|
2016-05-23 05:10:02 +08:00
|
|
|
endif
|
2016-05-23 05:10:54 +08:00
|
|
|
ifeq ($(SUBTARGET),nand)
|
|
|
|
include ./nand.mk
|
|
|
|
endif
|
2017-01-08 21:27:38 +08:00
|
|
|
ifeq ($(SUBTARGET),mikrotik)
|
|
|
|
include ./mikrotik.mk
|
|
|
|
endif
|
2016-05-23 05:04:50 +08:00
|
|
|
include ./legacy.mk
|
2016-05-23 04:57:32 +08:00
|
|
|
|
2015-01-10 23:27:07 +08:00
|
|
|
define Build/netgear-squashfs
|
|
|
|
rm -rf $@.fs $@.squashfs
|
|
|
|
mkdir -p $@.fs/image
|
|
|
|
cp $@ $@.fs/image/uImage
|
|
|
|
$(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
|
|
|
|
$@.fs $@.squashfs \
|
2016-02-01 07:29:41 +08:00
|
|
|
-noappend -root-owned -be -b 65536 \
|
|
|
|
$(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
|
|
|
|
|
2015-01-10 23:27:07 +08:00
|
|
|
dd if=/dev/zero bs=1k count=1 >> $@.squashfs
|
|
|
|
mkimage \
|
|
|
|
-A mips -O linux -T filesystem -C none \
|
|
|
|
-M $(NETGEAR_KERNEL_MAGIC) \
|
|
|
|
-a 0xbf070000 -e 0xbf070000 \
|
|
|
|
-n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
|
|
|
|
-d $@.squashfs $@
|
|
|
|
rm -rf $@.squashfs $@.fs
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/netgear-uImage
|
|
|
|
$(call Build/uImage,$(1) -M $(NETGEAR_KERNEL_MAGIC))
|
|
|
|
endef
|
|
|
|
|
2015-05-11 17:08:33 +08:00
|
|
|
define Build/loader-common
|
|
|
|
rm -rf $@.src
|
|
|
|
$(MAKE) -C lzma-loader \
|
|
|
|
PKG_BUILD_DIR="$@.src" \
|
|
|
|
TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
|
2016-03-23 20:52:47 +08:00
|
|
|
BOARD="$(BOARDNAME)" \
|
2015-05-11 17:08:33 +08:00
|
|
|
LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
|
2016-03-23 20:52:44 +08:00
|
|
|
$(1) compile loader.$(LOADER_TYPE)
|
|
|
|
mv "$@.$(LOADER_TYPE)" "$@"
|
2015-05-11 17:08:33 +08:00
|
|
|
rm -rf $@.src
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/loader-okli-compile
|
2016-03-23 20:52:47 +08:00
|
|
|
$(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0 KERNEL_CMDLINE="$(CMDLINE)")
|
2015-05-11 17:08:33 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/loader-kernel
|
|
|
|
$(call Build/loader-common,LOADER_DATA="$@")
|
|
|
|
endef
|
|
|
|
|
2016-03-23 20:52:47 +08:00
|
|
|
define Build/loader-kernel-cmdline
|
|
|
|
$(call Build/loader-common,LOADER_DATA="$@" KERNEL_CMDLINE="$(CMDLINE)")
|
|
|
|
endef
|
|
|
|
|
2015-05-11 17:08:33 +08:00
|
|
|
define Build/loader-okli
|
|
|
|
dd if=$(KDIR)/loader-$(1).gz bs=7680 conv=sync of="$@.new"
|
|
|
|
cat "$@" >> "$@.new"
|
|
|
|
mv "$@.new" "$@"
|
|
|
|
endef
|
|
|
|
|
2016-10-12 02:32:25 +08:00
|
|
|
define Build/relocate-kernel
|
2016-11-08 18:50:50 +08:00
|
|
|
rm -rf $@.relocate
|
|
|
|
$(CP) ../../generic/image/relocate $@.relocate
|
|
|
|
$(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS)
|
2016-10-12 02:32:25 +08:00
|
|
|
( \
|
2016-11-08 18:50:50 +08:00
|
|
|
dd if=$@.relocate/loader.bin bs=32 conv=sync && \
|
2016-10-12 02:32:25 +08:00
|
|
|
perl -e '@s = stat("$@"); print pack("N", @s[7])' && \
|
|
|
|
cat "$@" \
|
|
|
|
) > "$@.new"
|
|
|
|
mv "$@.new" "$@"
|
2016-11-08 18:50:50 +08:00
|
|
|
rm -rf $@.relocate
|
2016-10-12 02:32:25 +08:00
|
|
|
endef
|
|
|
|
|
2015-05-11 17:08:33 +08:00
|
|
|
define Build/copy-file
|
|
|
|
cat "$(1)" > "$@"
|
|
|
|
endef
|
|
|
|
|
2015-01-10 23:27:00 +08:00
|
|
|
define Device/Default
|
|
|
|
BOARDNAME :=
|
|
|
|
DEVICE_PROFILE = $$(BOARDNAME)
|
|
|
|
PROFILES = Default Minimal $$(DEVICE_PROFILE)
|
|
|
|
MTDPARTS :=
|
|
|
|
BLOCKSIZE := 64k
|
2015-01-11 02:48:14 +08:00
|
|
|
CONSOLE = ttyS0,115200
|
|
|
|
CMDLINE = $$(if $$(BOARDNAME),board=$$(BOARDNAME)) $$(if $$(MTDPARTS),mtdparts=$$(MTDPARTS)) $$(if $$(CONSOLE),console=$$(CONSOLE))
|
2015-01-10 23:27:00 +08:00
|
|
|
KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
|
2015-05-11 17:08:33 +08:00
|
|
|
COMPILE :=
|
2015-01-10 23:27:00 +08:00
|
|
|
IMAGES := sysupgrade.bin
|
2016-09-12 01:05:20 +08:00
|
|
|
IMAGE/sysupgrade.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
|
2015-01-10 23:27:00 +08:00
|
|
|
endef
|
|
|
|
|
2008-07-22 01:08:14 +08:00
|
|
|
$(eval $(call BuildImage))
|