2021-02-10 13:52:34 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2012-10-27 09:42:58 +00:00
|
|
|
#
|
2016-03-08 18:33:16 +00:00
|
|
|
# Copyright (C) 2006-2016 OpenWrt.org
|
2021-02-10 13:52:34 +00:00
|
|
|
|
2010-06-26 20:41:49 +00:00
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
include $(INCLUDE_DIR)/image.mk
|
|
|
|
|
2016-12-29 07:06:16 +00:00
|
|
|
USB1_PACKAGES := kmod-usb-ohci
|
|
|
|
USB2_PACKAGES := $(USB1_PACKAGES) kmod-usb2
|
2016-12-28 22:10:14 +00:00
|
|
|
|
2010-06-26 20:41:49 +00:00
|
|
|
define Build/Clean
|
|
|
|
$(MAKE) -C lzma-loader clean
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Image/Prepare
|
2014-08-18 21:00:55 +00:00
|
|
|
# Optimized LZMA compression (with dictionary), handled by lzma-loader.
|
2010-06-26 20:41:49 +00:00
|
|
|
cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
|
2014-08-18 21:00:55 +00:00
|
|
|
|
|
|
|
# Less optimal LZMA compression (no dictionary), handled by CFE.
|
|
|
|
$(STAGING_DIR_HOST)/bin/lzma e -so -d16 $(KDIR)/vmlinux > $(KDIR)/vmlinux-nodictionary.lzma
|
|
|
|
|
2013-09-16 21:09:10 +00:00
|
|
|
gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
|
2013-06-27 19:58:31 +00:00
|
|
|
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
|
|
|
|
cat $(KDIR)/vmlinux-initramfs | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux-initramfs.lzma
|
2014-10-13 05:53:33 +00:00
|
|
|
$(STAGING_DIR_HOST)/bin/lzma e -so -d16 $(KDIR)/vmlinux-initramfs > $(KDIR)/vmlinux-initramfs-nodictionary.lzma
|
2013-06-27 19:58:31 +00:00
|
|
|
endif
|
2010-06-26 20:41:49 +00:00
|
|
|
rm -f $(KDIR)/loader.gz
|
|
|
|
$(MAKE) -C lzma-loader \
|
|
|
|
BUILD_DIR="$(KDIR)" \
|
|
|
|
TARGET="$(KDIR)" \
|
|
|
|
clean install
|
|
|
|
echo -ne "\\x00" >> $(KDIR)/loader.gz
|
|
|
|
rm -f $(KDIR)/fs_mark
|
2011-08-29 21:23:51 +00:00
|
|
|
echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
|
2010-06-26 20:41:49 +00:00
|
|
|
$(call prepare_generic_squashfs,$(KDIR)/fs_mark)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define trxalign/jffs2-128k
|
|
|
|
-a 0x20000 -f $(KDIR)/root.$(1)
|
|
|
|
endef
|
|
|
|
define trxalign/jffs2-64k
|
|
|
|
-a 0x10000 -f $(KDIR)/root.$(1)
|
|
|
|
endef
|
|
|
|
define trxalign/squashfs
|
2016-10-28 15:03:55 +00:00
|
|
|
-a 1024 -f $(1) $(if $(2),-f $(2)) -a 0x10000 -A $(KDIR)/fs_mark
|
2010-06-26 20:41:49 +00:00
|
|
|
endef
|
|
|
|
|
2015-03-29 18:15:38 +00:00
|
|
|
#################################################
|
|
|
|
# Images
|
|
|
|
#################################################
|
|
|
|
|
|
|
|
define Build/trx-with-loader
|
|
|
|
$(STAGING_DIR_HOST)/bin/trx \
|
2015-09-11 17:55:28 +00:00
|
|
|
-m 33554432 \
|
2016-10-28 14:43:19 +00:00
|
|
|
-o $@.new \
|
2015-03-29 18:15:38 +00:00
|
|
|
-f $(KDIR)/loader.gz \
|
2016-07-30 12:19:11 +00:00
|
|
|
-f $(IMAGE_KERNEL) \
|
2016-10-28 15:03:55 +00:00
|
|
|
$(call trxalign/$(FILESYSTEM),$@)
|
2016-10-28 14:43:19 +00:00
|
|
|
mv $@.new $@
|
2015-03-29 18:15:38 +00:00
|
|
|
endef
|
|
|
|
|
2016-03-09 06:34:25 +00:00
|
|
|
define Build/trx-v2-with-loader
|
|
|
|
$(STAGING_DIR_HOST)/bin/trx \
|
|
|
|
-2 \
|
|
|
|
-m 33554432 \
|
|
|
|
-o $@.new \
|
|
|
|
-f $(KDIR)/loader.gz \
|
|
|
|
-f $(KDIR)/vmlinux.lzma \
|
2016-10-28 15:03:55 +00:00
|
|
|
$(call trxalign/$(FILESYSTEM),$@,$@.pattern)
|
2016-03-09 06:34:25 +00:00
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2016-03-08 18:33:22 +00:00
|
|
|
define Build/trx-without-loader
|
|
|
|
$(STAGING_DIR_HOST)/bin/trx \
|
|
|
|
-m 33554432 \
|
2016-10-28 14:43:19 +00:00
|
|
|
-o $@.new \
|
2016-07-30 12:19:11 +00:00
|
|
|
-f $(IMAGE_KERNEL) \
|
2016-10-28 15:03:55 +00:00
|
|
|
$(call trxalign/$(FILESYSTEM),$@)
|
2016-10-28 14:43:19 +00:00
|
|
|
mv $@.new $@
|
2016-03-08 18:33:22 +00:00
|
|
|
endef
|
|
|
|
|
2015-05-27 13:54:19 +00:00
|
|
|
define Build/asus-trx
|
2016-10-20 05:59:03 +00:00
|
|
|
$(STAGING_DIR_HOST)/bin/asustrx -p $(PRODUCTID) -i $@ -o $@.new
|
2015-05-27 13:54:19 +00:00
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2016-03-08 18:33:22 +00:00
|
|
|
define Build/edimax-bin
|
|
|
|
$(STAGING_DIR_HOST)/bin/trx2edips $@ $@.new
|
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/huawei-bin
|
|
|
|
dd if=/dev/zero of=$@.new bs=92 count=1
|
|
|
|
echo -ne 'HDR0\x08\x00\x00\x00' >> $@.new
|
|
|
|
cat $@ >> $@.new
|
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2015-03-29 18:15:38 +00:00
|
|
|
define Build/linksys-bin
|
2016-03-09 06:34:25 +00:00
|
|
|
$(STAGING_DIR_HOST)/bin/addpattern -4 -p $(DEVICE_ID) -v v$(VERSION) $(if $(SERIAL),-s $(SERIAL)) -i $@ -o $@.new
|
2015-03-29 18:15:38 +00:00
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2016-03-09 06:34:25 +00:00
|
|
|
define Build/linksys-pattern-partition
|
2016-10-28 14:39:08 +00:00
|
|
|
$(STAGING_DIR_HOST)/bin/addpattern -5 -p $(DEVICE_ID) -v v$(VERSION) $(if $(SERIAL),-s $(SERIAL)) -i /dev/null -o $@.pattern
|
2016-03-09 06:34:25 +00:00
|
|
|
endef
|
|
|
|
|
2016-03-08 18:33:19 +00:00
|
|
|
define Build/motorola-bin
|
|
|
|
$(STAGING_DIR_HOST)/bin/motorola-bin -$(MOTOROLA_DEVICE) $@ $@.new
|
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2016-03-08 18:33:25 +00:00
|
|
|
define Build/prepend-with-elf
|
|
|
|
mv $@ $@.old
|
|
|
|
dd if=$(KDIR)/loader.elf of=$@ bs=131072 conv=sync
|
|
|
|
cat $@.old >> $@
|
|
|
|
endef
|
|
|
|
|
2016-03-08 18:33:16 +00:00
|
|
|
define Build/tailed-bin
|
|
|
|
echo $(BIN_TAIL) >> $@
|
|
|
|
endef
|
|
|
|
|
2016-03-08 18:33:22 +00:00
|
|
|
define Build/usrobotics-bin
|
|
|
|
$(STAGING_DIR_HOST)/bin/trx2usr $@ $@.new
|
|
|
|
mv $@.new $@
|
|
|
|
endef
|
|
|
|
|
2015-03-29 18:15:38 +00:00
|
|
|
#################################################
|
|
|
|
# Devices
|
|
|
|
#################################################
|
|
|
|
|
2015-05-27 13:54:19 +00:00
|
|
|
DEVICE_VARS += PRODUCTID
|
2016-03-09 06:34:25 +00:00
|
|
|
DEVICE_VARS += DEVICE_ID VERSION SERIAL
|
2015-08-14 13:04:22 +00:00
|
|
|
DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_REGION
|
2016-03-08 18:33:19 +00:00
|
|
|
DEVICE_VARS += MOTOROLA_DEVICE
|
2016-03-08 18:33:16 +00:00
|
|
|
DEVICE_VARS += BIN_TAIL
|
2015-03-29 18:15:38 +00:00
|
|
|
|
|
|
|
define Device/Default
|
2015-03-31 08:56:08 +00:00
|
|
|
KERNEL := kernel-bin
|
2021-02-22 14:55:43 +00:00
|
|
|
DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(1).$$(2)
|
2015-03-31 08:56:08 +00:00
|
|
|
KERNEL_NAME = vmlinux.lzma
|
2016-11-25 12:10:38 +00:00
|
|
|
KERNEL_INITRAMFS_NAME = vmlinux-initramfs.lzma
|
2015-03-29 18:15:38 +00:00
|
|
|
FILESYSTEMS := $(FS_64K)
|
|
|
|
IMAGES := trx
|
2016-10-28 15:03:55 +00:00
|
|
|
IMAGE/trx := append-rootfs | trx-with-loader
|
2015-03-29 18:15:38 +00:00
|
|
|
endef
|
|
|
|
|
2016-03-11 21:31:34 +00:00
|
|
|
define Device/standard
|
2016-10-24 19:33:21 +00:00
|
|
|
DEVICE_TITLE := Image with LZMA loader and LZMA compressed kernel
|
2016-03-11 21:31:34 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Device/standard-noloader-gz
|
2016-10-24 19:33:21 +00:00
|
|
|
DEVICE_TITLE := Image with gzipped kernel
|
|
|
|
KERNEL_NAME = vmlinux.gz
|
2016-10-28 15:03:55 +00:00
|
|
|
IMAGE/trx := append-rootfs | trx-without-loader
|
2016-03-11 21:31:34 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Device/standard-noloader-nodictionarylzma
|
2016-10-24 19:33:21 +00:00
|
|
|
DEVICE_TITLE := Image with LZMA compressed kernel matching CFE decompressor
|
|
|
|
KERNEL_NAME = vmlinux-nodictionary.lzma
|
2016-10-28 15:03:55 +00:00
|
|
|
IMAGE/trx := append-rootfs | trx-without-loader
|
2016-03-11 21:31:34 +00:00
|
|
|
endef
|
|
|
|
|
2015-05-27 13:54:19 +00:00
|
|
|
define Device/asus
|
2019-07-11 10:21:01 +00:00
|
|
|
DEVICE_VENDOR := ASUS
|
2015-05-27 13:54:19 +00:00
|
|
|
IMAGES := trx
|
2016-10-28 15:03:55 +00:00
|
|
|
IMAGE/trx := append-rootfs | trx-with-loader | asus-trx
|
2015-05-27 13:54:19 +00:00
|
|
|
endef
|
|
|
|
|
2015-03-29 18:15:38 +00:00
|
|
|
define Device/linksys
|
2019-07-11 10:21:01 +00:00
|
|
|
DEVICE_VENDOR := Linksys
|
2015-03-29 18:15:38 +00:00
|
|
|
IMAGES := bin
|
2016-10-28 15:03:55 +00:00
|
|
|
IMAGE/bin := append-rootfs | trx-with-loader | linksys-bin
|
2015-03-29 18:15:38 +00:00
|
|
|
endef
|
|
|
|
|
2016-03-08 18:33:19 +00:00
|
|
|
define Device/motorola
|
2019-07-11 10:21:01 +00:00
|
|
|
DEVICE_VENDOR := Motorola
|
2016-03-08 18:33:19 +00:00
|
|
|
IMAGES := bin
|
2016-10-28 15:03:55 +00:00
|
|
|
IMAGE/bin := append-rootfs | trx-with-loader | motorola-bin
|
2016-03-08 18:33:19 +00:00
|
|
|
endef
|
|
|
|
|
2015-03-29 19:53:11 +00:00
|
|
|
define Device/netgear
|
2019-07-11 10:21:01 +00:00
|
|
|
DEVICE_VENDOR := NETGEAR
|
2015-03-29 19:53:11 +00:00
|
|
|
IMAGES := chk
|
2016-10-28 15:03:55 +00:00
|
|
|
IMAGE/chk := append-rootfs | trx-with-loader | netgear-chk
|
2015-03-29 19:53:11 +00:00
|
|
|
endef
|
|
|
|
|
2014-06-05 21:23:58 +00:00
|
|
|
#################################################
|
2020-06-07 11:12:43 +00:00
|
|
|
# Subtarget devices
|
2014-06-05 21:23:58 +00:00
|
|
|
#################################################
|
|
|
|
|
2020-06-07 11:12:43 +00:00
|
|
|
include $(SUBTARGET).mk
|
2015-03-29 18:15:38 +00:00
|
|
|
|
2014-06-05 21:23:58 +00:00
|
|
|
#################################################
|
|
|
|
# Shared BuildImage defines
|
|
|
|
#################################################
|
|
|
|
|
2010-06-26 20:41:49 +00:00
|
|
|
define Image/Build/Initramfs
|
2015-09-11 17:54:55 +00:00
|
|
|
$(STAGING_DIR_HOST)/bin/trx \
|
2015-09-11 17:55:28 +00:00
|
|
|
-m 33554432 \
|
2015-09-11 17:54:55 +00:00
|
|
|
-o $(BIN_DIR)/$(IMG_PREFIX)-initramfs.trx \
|
|
|
|
-f $(KDIR)/loader.gz \
|
|
|
|
-f $(KDIR)/vmlinux-initramfs.lzma
|
|
|
|
$(STAGING_DIR_HOST)/bin/trx \
|
2015-09-11 17:55:28 +00:00
|
|
|
-m 33554432 \
|
2015-09-11 17:54:55 +00:00
|
|
|
-o $(BIN_DIR)/$(IMG_PREFIX)-initramfs-noloader-nodictionary.trx \
|
|
|
|
-f $(KDIR)/vmlinux-initramfs-nodictionary.lzma
|
2010-06-26 20:41:49 +00:00
|
|
|
endef
|
|
|
|
|
2014-05-14 10:08:22 +00:00
|
|
|
# $(1): filesystem type.
|
2010-06-26 20:41:49 +00:00
|
|
|
define Image/Build
|
2016-03-11 21:31:34 +00:00
|
|
|
# TODO: Move it to Device/*
|
2013-06-27 19:58:31 +00:00
|
|
|
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
|
|
|
|
$(call Image/Build/Initramfs)
|
|
|
|
endif
|
2010-06-26 20:41:49 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(call BuildImage))
|