From a9d6851a382f51fd014bf6f25a6487cb0b44eb19 Mon Sep 17 00:00:00 2001 From: Tomaz Zaman Date: Mon, 10 Aug 2026 17:21:41 +0200 Subject: [PATCH 15/62] mono: multi-device readiness for the product lineup The lineup is gateway-dk (this DK), gateway, gateway-pro. Naming was already mechanical (mono_ profile -> mono-.dts -> mono, board) and every board case is an exact match, so new devices are additive. Two things needed real changes: - cdx_cfg.xml (the only device-specific ASK input) now ships all variants under /etc/cdx_cfg/ with a preinit hook linking the right one per board. Preinit, not uci-defaults: /etc/init.d/boot runs kmodloader before uci_apply_defaults, and cdx.ko's dpa_app helper needs the config on the very first boot. - latest.json gained a devices map keyed by board name; the on-device checker looks up its own board (minus the -sdboot suffix) and ignores releases carrying no image for it. sysupgrade's SUPPORTED_DEVICES metadata remains the on-device guardrail. Co-Authored-By: Claude Fable 5 --- package/ask/dpa-app/Makefile | 9 ++++- package/ask/dpa-app/files/81_cdx_cfg_select | 16 +++++++++ .../mono-update-check/files/mono-update-check | 11 +++++-- scripts/mono-update.sh | 33 ++++++++++++------- 4 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 package/ask/dpa-app/files/81_cdx_cfg_select diff --git a/package/ask/dpa-app/Makefile b/package/ask/dpa-app/Makefile index 388baf6108..36f8eeb5d9 100644 --- a/package/ask/dpa-app/Makefile +++ b/package/ask/dpa-app/Makefile @@ -58,13 +58,20 @@ define Build/Compile -L$(STAGING_DIR)/usr/lib -lfmc -lfm -lstdc++ -lxml2 -lm" endef +# cdx_cfg.xml is the only device-specific ASK input; all variants ship +# and a preinit hook links the right one for the booted board (preinit, +# not uci-defaults: cdx.ko autoloads before uci-defaults run). define Package/dpa-app/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/dpa_app/dpa_app $(1)/usr/bin/ $(INSTALL_DIR) $(1)/etc $(INSTALL_DATA) $(PKG_BUILD_DIR)/dpa_app/files/etc/cdx_pcd.xml $(1)/etc/ $(INSTALL_DATA) $(PKG_BUILD_DIR)/dpa_app/files/etc/cdx_sp.xml $(1)/etc/ - $(INSTALL_DATA) $(PKG_BUILD_DIR)/config/gateway-dk/cdx_cfg.xml $(1)/etc/ + $(INSTALL_DIR) $(1)/etc/cdx_cfg + $(foreach cfg,$(wildcard $(PKG_BUILD_DIR)/config/*/cdx_cfg.xml), \ + $(INSTALL_DATA) $(cfg) $(1)/etc/cdx_cfg/$(notdir $(patsubst %/cdx_cfg.xml,%,$(cfg))).xml; ) + $(INSTALL_DIR) $(1)/lib/preinit + $(INSTALL_DATA) ./files/81_cdx_cfg_select $(1)/lib/preinit/ endef $(eval $(call BuildPackage,dpa-app)) diff --git a/package/ask/dpa-app/files/81_cdx_cfg_select b/package/ask/dpa-app/files/81_cdx_cfg_select new file mode 100644 index 0000000000..bbcd84a1bf --- /dev/null +++ b/package/ask/dpa-app/files/81_cdx_cfg_select @@ -0,0 +1,16 @@ +# Select the FMan hardware config for this board before init runs: +# cdx.ko autoloads from kmodloader BEFORE uci-defaults execute, and its +# dpa_app helper reads the fixed path /etc/cdx_cfg.xml. Variants ship in +# /etc/cdx_cfg/.xml (device = board name minus the "mono," +# vendor prefix and the -sdboot boot-medium suffix). Idempotent, runs +# every boot after 02_sysinfo_fixup has finalized the board name. +do_cdx_cfg_select() { + [ -e /tmp/sysinfo/board_name ] || return + board="$(strings /tmp/sysinfo/board_name)" + board="${board#mono,}" + board="${board%-sdboot}" + [ -f "/etc/cdx_cfg/${board}.xml" ] && \ + ln -sf "/etc/cdx_cfg/${board}.xml" /etc/cdx_cfg.xml +} + +boot_hook_add preinit_main do_cdx_cfg_select diff --git a/package/mono/mono-update-check/files/mono-update-check b/package/mono/mono-update-check/files/mono-update-check index 798e9d084a..b2237ec16e 100644 --- a/package/mono/mono-update-check/files/mono-update-check +++ b/package/mono/mono-update-check/files/mono-update-check @@ -11,14 +11,21 @@ STATE=/tmp/mono-update-available [ -n "$URL" ] || exit 0 CURRENT=$(cat /etc/mono_release 2>/dev/null || echo dev) +BOARD=$(board_name) +BOARD=${BOARD%-sdboot} JSON=$(wget -q -T 30 -O - "$URL/latest.json") || { logger -t mono-update "cannot fetch $URL/latest.json" exit 0 } TAG=$(echo "$JSON" | jsonfilter -e '@.tag') -SYSUPGRADE_URL=$(echo "$JSON" | jsonfilter -e '@.sysupgrade') -SHA=$(echo "$JSON" | jsonfilter -e '@.sha256') +SYSUPGRADE_URL=$(echo "$JSON" | jsonfilter -e "@.devices['$BOARD'].sysupgrade") +SHA=$(echo "$JSON" | jsonfilter -e "@.devices['$BOARD'].sha256") + +[ -n "$SYSUPGRADE_URL" ] || { + logger -t mono-update "no image for board $BOARD in latest.json" + exit 0 +} [ -n "$TAG" ] || exit 0 if [ "$TAG" = "$CURRENT" ]; then diff --git a/scripts/mono-update.sh b/scripts/mono-update.sh index 076bc8859d..d686b0f8aa 100755 --- a/scripts/mono-update.sh +++ b/scripts/mono-update.sh @@ -62,23 +62,34 @@ make -j"$(nproc)" world || cleanup_fail OUT="releases/$RELTAG" BINDIR=bin/targets/layerscape/armv8_64b +URLBASE="${MONO_PUBLISH_URL:-https://openwrt.mono.si}" rm -rf "$OUT" mkdir -p "$OUT" -cp "$BINDIR"/openwrt-layerscape-armv8_64b-mono_gateway-dk-ext4-emmc.img.gz "$OUT/" -cp "$BINDIR"/openwrt-layerscape-armv8_64b-mono_gateway-dk-ext4-sysupgrade.bin "$OUT/" -cp "$BINDIR"/openwrt-layerscape-armv8_64b-mono_gateway-dk.manifest "$OUT/" +cp "$BINDIR"/openwrt-layerscape-armv8_64b-mono_*-emmc.img.gz \ + "$BINDIR"/openwrt-layerscape-armv8_64b-mono_*-sysupgrade.bin \ + "$BINDIR"/openwrt-layerscape-armv8_64b-mono_*.manifest "$OUT/" git format-patch --quiet -o "$OUT/patches" "$LATEST..$BRANCH" (cd "$OUT" && sha256sum *.img.gz *.bin > sha256sums) -SYSUPGRADE_SHA=$(sha256sum "$OUT"/*-sysupgrade.bin | cut -d' ' -f1) -cat > releases/latest.json < releases/latest.json if [ -n "${MONO_PUBLISH_DEST:-}" ]; then echo "mono-update: publishing to $MONO_PUBLISH_DEST" -- 2.47.3