openwrt/target/linux/ramips/image/Makefile

224 lines
5.6 KiB
Makefile
Raw Normal View History

# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2008-2011 OpenWrt.org
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
DEVICE_VARS += LOADER_TYPE LOADER_FLASH_OFFS
DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID
DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR
DEVICE_VARS += SEAMA_SIGNATURE SEAMA_MTDBLOCK
DEVICE_VARS += SERCOMM_HWNAME SERCOMM_HWID SERCOMM_HWVER SERCOMM_SWVER
DEVICE_VARS += SERCOMM_PAD JCG_MAXSIZE
loadaddr-y := 0x80000000
loadaddr-$(CONFIG_TARGET_ramips_rt288x) := 0x88000000
loadaddr-$(CONFIG_TARGET_ramips_mt7621) := 0x80001000
ldrplatform-y := ralink
ldrplatform-$(CONFIG_TARGET_ramips_mt7621) := mt7621
ldrflashstart-y := 0x1c000000
ldrflashstart-$(CONFIG_TARGET_ramips_mt7621) := 0x1fc00000
KERNEL_LOADADDR := $(loadaddr-y)
LOADER_PLATFORM := $(ldrplatform-y)
LOADER_FLASH_START := $(ldrflashstart-y)
KERNEL_DTB = kernel-bin | append-dtb | lzma
define Build/edimax-header
$(STAGING_DIR_HOST)/bin/mkedimaximg -i $@ -o $@.new $(1)
@mv $@.new $@
endef
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 $@
endef
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)" \
LZMA_TEXT_START=0x81800000 LOADADDR=$(KERNEL_LOADADDR) \
$(1) compile loader.$(LOADER_TYPE)
mv "$@.$(LOADER_TYPE)" "$@"
rm -rf $@.src
endef
define Build/loader-kernel
$(call Build/loader-common,LOADER_DATA="$@")
endef
define Build/loader-okli-compile
$(call Build/loader-common, \
FLASH_START=$(LOADER_FLASH_START) \
FLASH_OFFS=$(LOADER_FLASH_OFFS) \
FLASH_MAX=0 \
)
endef
define Build/append-loader-okli
cat "$(KDIR)/loader-$(word 1,$(1)).$(LOADER_TYPE)" >> "$@"
endef
# 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 $@ \
$(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \
-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 \
$(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \
-s $(DLINK_FIRMWARE_SIZE)
mv $@.new $@
endef
define Build/mkdlinkfw-loader
-$(STAGING_DIR_HOST)/bin/mkdlinkfw \
-k $(KDIR)/loader-$(DEVICE_NAME).bin \
-r $@ \
-o $@.new \
$(if $(DLINK_IMAGE_OFFSET), -O $(DLINK_IMAGE_OFFSET)) \
-s $(DLINK_FIRMWARE_SIZE)
mv $@.new $@
endef
define Build/netis-tail
echo -n $(1) >> $@
echo -n $(UIMAGE_NAME)-yun | $(MKHASH) md5 | \
sed 's/../\\\\x&/g' | xargs echo -ne >> $@
endef
define Build/poray-header
$(STAGING_DIR_HOST)/bin/mkporayfw $(1) -f $@ -o $@.new
mv $@.new $@
endef
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)
endef
define Build/sercom-seal
$(STAGING_DIR_HOST)/bin/mksercommfw \
-i $@ \
-b $(SERCOMM_HWID) \
-r $(SERCOMM_HWVER) \
-v $(SERCOMM_SWVER) \
$(1)
endef
define Build/sign-dlink-ru
sign_dlink_ru $@ $1 $2
mv $@.new $@
endef
define Build/trx
$(STAGING_DIR_HOST)/bin/trx $(1) \
-o $@ \
-m $$(($(subst k, * 1024,$(IMAGE_SIZE)))) \
-f $(IMAGE_KERNEL) \
-a 4 -f $(IMAGE_ROOTFS)
endef
define Build/uimage-padhdr
uimage_padhdr $(if $(1),-l $(1)) -i $@ -o $@.new
mv $@.new $@
endef
define Build/uimage-sgehdr
uimage_sgehdr -i $@ -o $@.new -m $(DEVICE_MODEL) \
-h $(DEVICE_VARIANT) -s V1.00000
mv $@.new $@
endef
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
mv $@.new $@
endef
define Build/zyimage
$(STAGING_DIR_HOST)/bin/zyimage $(1) $@
endef
define Device/Default
PROFILES = Default
KERNEL := $(KERNEL_DTB) | uImage lzma
SOC := $(DEFAULT_SOC)
DEVICE_DTS_DIR := ../dts
DEVICE_DTS = $$(SOC)_$(1)
IMAGES := sysupgrade.bin
ramips: add support for HooToo HT-TM05 The HooToo HT-TM05 is a battery powered router, with an Ethernet and USB port. Vendor U-Boot limited to 1.5 MB kernel size, so use lzma loader (loader-okli). Specifications: SOC: MediaTek MT7620N BATTERY: 10400mAh WLAN: 802.11bgn LAN: 1x 10/100 Mbps Ethernet USB: 1x USB 2.0 (Type-A) RAM: 64 MB FLASH: GigaDevice GD25Q64, Serial 8 MB Flash, clocked at 50 MHz Flash itself specified to 80 MHz, but speed limited by mt7620 SPI fast-read enabled (m25p) LED: Status LED (blue after boot, green with WiFi traffic 4 leds to indicate power level of the battery (unable to control) INPUT: Power, reset button MAC assignment based on vendor firmware: 2.4 GHz *:b4 (factory 0x04) LAN/label *:b4 (factory 0x28) WAN *:b5 (factory 0x2e) Tested and working: - Ethernet - 2.4 GHz WiFi (Correct MAC-address) - Installation from TFTP (recovery) - OpenWRT sysupgrade (Preserving and non-preserving), through the usual ways: command line and LuCI - LEDs (except as noted above) - Button (reset) - I2C, which is needed for reading battery charge status and level - U-Boot environment / variables (from U-Boot, and OpenWrt) Installation: - Download the needed OpenWrt install files, place them in the root of a clean TFTP server running on your computer. Rename the files as, - ramips-mt7620-hootoo_tm05-squashfs-kernel.bin => kernel - ramips-mt7620-hootoo_tm05-squashfs-rootfs.bin => rootfs - Plug the router into your computer via Ethernet - Set your computer to use 10.10.10.254 as its IP address - With your router shut down, hold down the power button until the first white LED lights up. - Push and hold the reset button and release the power button. Continue holding the reset button for 30 seconds or until it begins searching for files on your TFTP server, whichever comes first. - The router (10.10.10.128) will look for your computer at 10.10.10.254 and install the two files. Once it has finished installation, it will automatically reboot and start up OpenWrt. - Set your computer to use DHCP for its IP address Notes: - U-Boot environment can be modified, u-boot-env is preserved on initial install or sysupgrade - mtd-concat functionality is included, to leave a "hole" for u-boot-env, combining the OEM kernel and rootfs partitions I would like to thank @mpratt14 and @xabolcs for their help getting the lzma loader to work! Signed-off-by: Russell Morris <rmorris@rkmorris.us> [drop changes in image/Makefile, fix indent and PKG_RELEASE in uboot-envtools, fix LOADER_FLASH_OFFS, minor commit message facelift, add COMPILE to Device/Default] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-12-25 00:38:36 +00:00
COMPILE :=
sysupgrade_bin := append-kernel | append-rootfs | pad-rootfs
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size | append-metadata
endef
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) | check-size | append-metadata
IMAGE/factory.img := pad-extra $$$$(SERCOMM_PAD) | $$(IMAGE/default) | \
pad-to $$$$(BLOCKSIZE) | sercom-footer | pad-to 128 | \
zip $$$$(SERCOMM_HWNAME).bin | sercom-seal
endef
define Device/seama
BLOCKSIZE := 64k
SEAMA_MTDBLOCK := 2
IMAGES += factory.bin
# 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 | check-size | append-metadata
IMAGE/factory.bin := \
$$(IMAGE/default) | pad-rootfs -x 64 | seama | seama-seal | check-size
SEAMA_SIGNATURE :=
endef
define Device/uimage-lzma-loader
LOADER_TYPE := bin
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
endef
include $(SUBTARGET).mk
$(eval $(call BuildImage))