-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
+# SPDX-License-Identifier: GPL-2.0-only
+
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
KERNEL_LOADADDR = 0x80000000
KERNEL_ENTRY = 0x80000400
-define Device/Default
- PROFILES = Default
- KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
- KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip
- DEVICE_DTS_DIR := ../dts
- DEVICE_DTS = $$(SOC)_$(1)
- SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
- IMAGES := sysupgrade.bin
- IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-rootfs | pad-rootfs | \
- append-metadata | check-size
+DEVICE_VARS += ZYXEL_VERS DLINK_KERNEL_PART_SIZE
+DEVICE_VARS += CAMEO_KERNEL_PART CAMEO_ROOTFS_PART CAMEO_CUSTOMER_SIGNATURE CAMEO_BOARD_VERSION
+DEVICE_VARS += H3C_PRODUCT_ID H3C_DEVICE_ID
+
+define Build/zyxel-vers
+ ( echo VERS;\
+ for hw in $(ZYXEL_VERS); do\
+ echo -n "V9.99($$hw.0) | ";\
+ date -d @$(SOURCE_DATE_EPOCH) +%m/%d/%Y;\
+ done ) >> $@
endef
-define Device/allnet_all-sg8208m
- SOC := rtl8382
- IMAGE_SIZE := 7168k
- DEVICE_VENDOR := ALLNET
- DEVICE_MODEL := ALL-SG8208M
- UIMAGE_MAGIC := 0x00000006
- UIMAGE_NAME := 2.2.2.0
+define Build/dlink-cameo
+ $(SCRIPT_DIR)/cameo-tag.py $@ $(DLINK_KERNEL_PART_SIZE)
endef
-TARGET_DEVICES += allnet_all-sg8208m
-define Device/d-link_dgs-1210
- SOC := rtl8382
- IMAGE_SIZE := 13824k
- DEVICE_VENDOR := D-Link
+define Build/dlink-version
+ echo -n "OpenWrt" >> $@
+ dd if=/dev/zero bs=25 count=1 >> $@
endef
-define Device/d-link_dgs-1210-10p
- $(Device/d-link_dgs-1210)
- DEVICE_MODEL := DGS-1210-10P
- DEVICE_PACKAGES += lua-rs232
+define Build/dlink-headers
+ dd if=$@ bs=$(DLINK_KERNEL_PART_SIZE) count=1 of=$@.kernel_part; \
+ dd if=$@ bs=$(DLINK_KERNEL_PART_SIZE) skip=1 of=$@.rootfs_part; \
+ $(SCRIPT_DIR)/cameo-imghdr.py $@.kernel_part $@.kernel_part.hex \
+ "$(DEVICE_MODEL)" os $(CAMEO_KERNEL_PART) \
+ $(CAMEO_CUSTOMER_SIGNATURE) \
+ $(CAMEO_BOARD_VERSION) \
+ $(KERNEL_LOADADDR); \
+ $(SCRIPT_DIR)/cameo-imghdr.py $@.rootfs_part $@.rootfs_part.hex \
+ "$(DEVICE_MODEL)" squashfs $(CAMEO_ROOTFS_PART) \
+ $(CAMEO_CUSTOMER_SIGNATURE) \
+ $(CAMEO_BOARD_VERSION); \
+ cat $@.kernel_part.hex $@.rootfs_part.hex > $@
endef
-TARGET_DEVICES += d-link_dgs-1210-10p
-define Device/d-link_dgs-1210-16
- $(Device/d-link_dgs-1210)
- DEVICE_MODEL := DGS-1210-16
+define Build/7z
+ $(STAGING_DIR_HOST)/bin/7zr a $(@).new -t7z -m0=lzma $(@)
+ mv $@.new $@
endef
-TARGET_DEVICES += d-link_dgs-1210-16
-define Device/d-link_dgs-1210-28
- $(Device/d-link_dgs-1210)
- DEVICE_MODEL := DGS-1210-28
+define Build/h3c-image
+ $(STAGING_DIR_HOST)/bin/mkh3cimg \
+ -i $(@) \
+ -o $(@).new \
+ -c 7z \
+ -p $(H3C_PRODUCT_ID) \
+ -d $(H3C_DEVICE_ID)
+ mv $@.new $@
endef
-TARGET_DEVICES += d-link_dgs-1210-28
-define Device/netgear_gs110tpp-v1
- $(Device/Default)
- SOC := rtl8380
- IMAGE_SIZE := 14848k
- UIMAGE_MAGIC := 0x4e474520
- DEVICE_VENDOR := NETGEAR
- DEVICE_MODEL := GS110TP
- DEVICE_VARIANT := v1
+define Build/h3c-vfs
+ $(STAGING_DIR_HOST)/bin/mkh3cvfs \
+ -i $(@) \
+ -o $(@).new \
+ -f openwrt-kernel.bin
+ mv $@.new $@
endef
-TARGET_DEVICES += netgear_gs110tpp-v1
-define Device/zyxel_gs1900-10hp
- SOC := rtl8380
- IMAGE_SIZE := 6976k
- DEVICE_VENDOR := ZyXEL
- DEVICE_MODEL := GS1900-10HP
+define Build/relocate-kernel
+ rm -rf $@.relocate
+ $(CP) ../../generic/image/relocate $@.relocate
+ $(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) LZMA_TEXT_START=0x82000000 \
+ CROSS_COMPILE=$(TARGET_CROSS)
+ ( \
+ dd if=$@.relocate/loader.bin bs=32 conv=sync && \
+ perl -e '@s = stat("$@"); print pack("N", @s[7])' && \
+ cat "$@" \
+ ) > "$@.new"
+ mv "$@.new" "$@"
+ rm -rf $@.relocate
endef
-TARGET_DEVICES += zyxel_gs1900-10hp
+
+define Device/Default
+ PROFILES = Default
+ KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
+ KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip
+ DEVICE_DTS_DIR := ../dts-$(KERNEL_PATCHVER)
+ DEVICE_DTS = $$(SOC)_$(1)
+ IMAGES := sysupgrade.bin
+ IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-rootfs | pad-rootfs | \
+ check-size | append-metadata
+endef
+
+include $(SUBTARGET).mk
$(eval $(call BuildImage))