From: Linus Walleij <linus.walleij@linaro.org>
Date: Thu, 12 Oct 2023 08:42:16 +0000 (+0200)
Subject: boot/apex: Restore the APEX boot loader
X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=9340babdcbdc12c921cc9e30889a9a4189b435ef;p=openwrt%2Fstaging%2Fblocktrron.git

boot/apex: Restore the APEX boot loader

This is a partial revert of the deletion of the IXP4xx
target: we restore the APEX boot loader so we can use it
for the NSLU2 and related targets.

The APEX upstream is as dead as it gets so I have applied
OpenWrts old patches on top of the never released
v1.6.10 version and forked it into an OpenWrt variant
on GitHub. If the upstream comes back alive I will
happily switch over to it.

The file refers to the external GitHub, I suppose when
integrating this patch the file should be copied to OpenWrts
file repository and the file link changed.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---

diff --git a/package/boot/apex/Makefile b/package/boot/apex/Makefile
new file mode 100644
index 0000000000..66a1b7667e
--- /dev/null
+++ b/package/boot/apex/Makefile
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2006-2023 OpenWrt.org
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=apex
+# This version was created from the stalled and unreleased v1.6.10
+# with some patches on top.
+PKG_VERSION:=1.6.10-openwrt
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/linusw/apex.git
+PKG_SOURCE_VERSION:=483e18aa133d5e25866570c29b124530b2d1e0d3
+PKG_MIRROR_HASH:=42230bb436f5590447ca55e8befb8927e6ea74c1e6953c043bbbef986c411704
+
+PKG_TARGETS:=bin
+PKG_FLAGS:=nonshared
+PKG_LICENSE:=GPL-2.0
+PKG_LICENSE_FILES:=COPYING
+
+include $(INCLUDE_DIR)/package.mk
+
+export GCC_HONOUR_COPTS=s
+
+define Package/apex
+  SECTION:=boot
+  CATEGORY:=Boot Loaders
+  DEPENDS:=@TARGET_ixp4xx @!IN_SDK
+  DEFAULT:=y
+  TITLE:=Boot loader for NSLU2, FSG3, NAS100D and others
+endef
+
+define build_apex
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		ARCH=arm \
+		$(1)_config
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		$(TARGET_CONFIGURE_OPTS) \
+		KBUILD_HAVE_NLS=no \
+		ARCH=arm \
+		clean all
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/apex.bin $(PKG_BUILD_DIR)/out/apex-$(2).bin
+endef
+
+define Build/Compile
+	$(INSTALL_DIR) $(PKG_BUILD_DIR)/out
+	$(call build_apex,openwrt-nslu2-armeb,nslu2-armeb)
+	$(call build_apex,openwrt-nslu2-16mb-armeb,nslu2-16mb-armeb)
+	$(call build_apex,openwrt-fsg3-armeb,fsg3-armeb)
+	$(call build_apex,openwrt-nas100d-armeb,nas100d-armeb)
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(STAGING_DIR_IMAGE)/apex
+	$(CP) $(PKG_BUILD_DIR)/out/*.bin $(STAGING_DIR_IMAGE)/apex
+endef
+
+$(eval $(call BuildPackage,apex))