diff --git a/config/boards/gateway-dk.conf b/config/boards/gateway-dk.conf index c12879510e11..e5373c0cb0b7 100644 --- a/config/boards/gateway-dk.conf +++ b/config/boards/gateway-dk.conf @@ -9,6 +9,9 @@ KERNEL_TEST_TARGET="current" HAS_VIDEO_OUTPUT="no" BOOT_FDT_FILE="freescale/mono-gateway-dk.dtb" BOOTENV_FILE="gateway-dk.txt" +# Remove fake-hwclock: we have a real pcf2131 RTC, util-linux-extra handles sync via udev +PACKAGE_LIST_BOARD_REMOVE="fake-hwclock" +INTRODUCED="2026" # U-Boot, ATF, and RCW — Mono forks with custom DDR4 config and SERDES declare -g BOOTSOURCE="https://github.com/we-are-mono/u-boot" @@ -55,6 +58,9 @@ function post_family_tweaks__gateway_dk_services() { display_alert "Installing fancontrol" "emc2305 + cluster_thermal" "info" chroot_sdcard_apt_get_install fancontrol lm-sensors + # hwclock for RTC management (pcf2131 on I2C) + chroot_sdcard_apt_get_install util-linux-extra + chroot_sdcard systemctl enable gateway-dk-leds.service chroot_sdcard systemctl enable generate-fancontrol-conf.service chroot_sdcard systemctl enable fancontrol.service diff --git a/config/kernel/linux-ls1046a-current.config b/config/kernel/linux-ls1046a-current.config index d6394bfec84b..eef02a6ddf2d 100644 --- a/config/kernel/linux-ls1046a-current.config +++ b/config/kernel/linux-ls1046a-current.config @@ -443,6 +443,7 @@ CONFIG_GPIO_SYSFS=y CONFIG_GPIO_MPC8XXX=y CONFIG_GPIO_SYSCON=y CONFIG_GPIO_PCA953X=y +CONFIG_POWER_RESET_GPIO=y CONFIG_SENSORS_LM75=y CONFIG_SENSORS_EMC2103=y CONFIG_SENSORS_EMC2305=y diff --git a/extensions/gateway-dk-ask.sh b/extensions/gateway-dk-ask.sh index 7a0b9b9e2d71..64109578875e 100644 --- a/extensions/gateway-dk-ask.sh +++ b/extensions/gateway-dk-ask.sh @@ -15,7 +15,7 @@ # Source repos and refs (pinned to match Yocto) # For local testing: set ASK_REPO="file:///path/to/ASK" — the Docker mount hook below handles it declare -g ASK_REPO="https://github.com/we-are-mono/ASK.git" -declare -g ASK_BRANCH="commit:44883f88b26478fa2c9beea81702023cbc057f94" +declare -g ASK_BRANCH="commit:252b6db5a274383917c7a7688c931d61409978c2" declare -g FMLIB_REPO="https://github.com/nxp-qoriq/fmlib.git" declare -g FMLIB_COMMIT="7a58ecaf0d90d71d6b78d3ac7998282a472c4394" declare -g FMC_REPO="https://github.com/nxp-qoriq/fmc.git" @@ -162,18 +162,22 @@ function post_install_kernel_debs__ask_module_autoload() { # Copy patches into chroot before patched library builds (runs before build_ask_userspace) function pre_customize_image__000_prepare_ask_patches() { mkdir -p "${SDCARD}/tmp/ask-patches" - local patch_dirs=("libnetfilter-conntrack" "libnfnetlink" "iptables") + local patch_dirs=("libnetfilter-conntrack" "libnfnetlink") for pdir in "${patch_dirs[@]}"; do [[ -d "${ASK_CACHE_DIR}/patches/${pdir}" ]] || exit_with_error "ASK patch directory missing" "${ASK_CACHE_DIR}/patches/${pdir}" cp "${ASK_CACHE_DIR}/patches/${pdir}/"*.patch "${SDCARD}/tmp/ask-patches/" done - # Enable deb-src for apt-get source - chroot_sdcard "if [ -f /etc/apt/sources.list.d/debian.sources ]; then \ - sed -i 's/^Types: deb\$/Types: deb deb-src/' /etc/apt/sources.list.d/debian.sources; \ - elif [ -f /etc/apt/sources.list ]; then \ - sed -i 's/^#\\s*deb-src/deb-src/' /etc/apt/sources.list; \ - fi && apt-get update -qq" + # Enable deb-src for apt-get source (handles both Debian and Ubuntu) + # deb822 format: *.sources files (Debian bookworm+, Ubuntu noble+) + # Legacy format: sources.list (older Debian/Ubuntu) + chroot_sdcard "shopt -s nullglob; \ + for f in /etc/apt/sources.list.d/*.sources; do \ + sed -i 's/^Types: deb\$/Types: deb deb-src/' \"\$f\"; \ + done; \ + if [ -f /etc/apt/sources.list ]; then \ + sed -i 's/^#\\s*deb-src/deb-src/' /etc/apt/sources.list; \ + fi && apt-get update -qq" chroot_sdcard_apt_get_install dpkg-dev devscripts } @@ -186,10 +190,12 @@ function pre_customize_image__001_build_ask_userspace() { [[ -z "${kernel_ver}" ]] && exit_with_error "No kernel version found in ${SDCARD}/lib/modules/" local kdir="/usr/src/linux-headers-${kernel_ver}" - # Install build dependencies in chroot + # Install build dependencies and runtime packages in chroot + # iptables is a runtime dep — CMM uses QOSMARK rules via our xtables extensions display_alert "ASK extension" "installing build dependencies" "info" chroot_sdcard_apt_get_install build-essential \ - pkg-config libxml2-dev libpcap-dev libcrypt-dev libtclap-dev + pkg-config libxml2-dev libpcap-dev libcrypt-dev libtclap-dev libxtables-dev \ + iptables # Copy sources into chroot mkdir -p "${SDCARD}/tmp/ask-userspace" @@ -269,6 +275,27 @@ function pre_customize_image__001_build_ask_userspace() { cp "${ASK_CACHE_DIR}/${ASK_DPA_APP_DIR}/files/etc/cdx_pcd.xml" "${SDCARD}/etc/" cp "${ASK_CACHE_DIR}/${ASK_DPA_APP_DIR}/files/etc/cdx_sp.xml" "${SDCARD}/etc/" + # --- xtables extensions (standalone .so files, not patching iptables) --- + # Note: we don't use pkg-config for libxtables here. These are dlopen()-loaded + # extensions — they don't link against libxtables.so, they use symbols resolved + # from the iptables process that loads them. The -I./include picks up our local + # xt_QOSMARK.h etc. UAPI headers which aren't in libxtables-dev (they're our + # additions). Adding -lxtables would cause duplicate symbol issues at load time. + local ask_xtables_modules=(libxt_qosmark libxt_QOSMARK libxt_qosconnmark libxt_QOSCONNMARK) + display_alert "ASK extension" "building xtables extensions" "info" + cp -a "${ASK_CACHE_DIR}/iptables-extensions" "${SDCARD}/tmp/ask-userspace/iptables-extensions" + chroot_sdcard "cd /tmp/ask-userspace/iptables-extensions && \ + for name in ${ask_xtables_modules[*]}; do \ + gcc -shared -fPIC -O2 \ + -I./include \ + -o \"\${name}.so\" \"\${name}.c\" || exit 1; \ + done && \ + install -d /usr/lib/${ASK_HOST_TRIPLET}/xtables && \ + for name in ${ask_xtables_modules[*]}; do \ + install -m 644 \"\${name}.so\" /usr/lib/${ASK_HOST_TRIPLET}/xtables/ || exit 1; \ + done" \ + || exit_with_error "xtables extensions build failed" + # --- Patched system libraries (must be before CMM which depends on patched libnetfilter-conntrack) --- build_ask_patched_libraries @@ -307,7 +334,7 @@ function pre_customize_image__001_build_ask_userspace() { # The postinst re-applies holds on every upgrade. Security updates must be # tracked and re-patched manually. display_alert "ASK extension" "pinning patched packages" "info" - chroot_sdcard "apt-mark hold libnetfilter-conntrack3 libnfnetlink0 iptables" + chroot_sdcard "apt-mark hold libnetfilter-conntrack3 libnfnetlink0" # Install sysctl tuning for conntrack install -Dm 644 "${SRC}/packages/bsp/gateway-dk/99-ls1046a-conntrack.conf" \ @@ -359,6 +386,15 @@ function pre_customize_image__001_build_ask_userspace() { done done + # xtables extensions — use the same explicit list as the build step + local ask_xtables_modules=(libxt_qosmark libxt_QOSMARK libxt_qosconnmark libxt_QOSCONNMARK) + mkdir -p "${pkgdir}/usr/lib/${ASK_HOST_TRIPLET}/xtables" + for name in "${ask_xtables_modules[@]}"; do + local src="${SDCARD}/usr/lib/${ASK_HOST_TRIPLET}/xtables/${name}.so" + [[ -f "${src}" ]] || exit_with_error "xtables extension missing" "${name}.so" + cp -a "${src}" "${pkgdir}/usr/lib/${ASK_HOST_TRIPLET}/xtables/" + done + # Version: kernel version + build date — allows bugfix rebuilds without kernel change local ask_version="${kernel_ver}+$(date +%Y%m%d)" @@ -374,7 +410,7 @@ Architecture: arm64 Section: net Priority: optional Maintainer: Mono Technologies -Depends: linux-image-${BRANCH}-${LINUXFAMILY} (>= ${kernel_ver}), libxml2, libpcap0.8 +Depends: linux-image-${BRANCH}-${LINUXFAMILY} (>= ${kernel_ver}), libxml2, libpcap0.8, iptables Description: NXP ASK hardware offloading userspace for Mono Gateway DK Userspace tools (fmlib, fmc, libfci, libcli, dpa-app, cmm) and configuration for NXP ASK data-plane acceleration on the LS1046A Gateway DK. @@ -391,7 +427,7 @@ if command -v systemctl >/dev/null 2>&1; then systemctl enable cmm.service 2>/dev/null || true fi # Re-pin patched ASK libraries — vanilla Debian versions break CMM/CDX offloading -apt-mark hold libnetfilter-conntrack3 libnfnetlink0 iptables 2>/dev/null || true +apt-mark hold libnetfilter-conntrack3 libnfnetlink0 2>/dev/null || true EOF chmod 755 "${pkgdir}/DEBIAN/postinst" @@ -406,7 +442,7 @@ EOF ldconfig || true systemctl daemon-reload || true if [ "\$1" = "remove" ] || [ "\$1" = "purge" ]; then - apt-mark unhold libnetfilter-conntrack3 libnfnetlink0 iptables 2>/dev/null || true + apt-mark unhold libnetfilter-conntrack3 libnfnetlink0 2>/dev/null || true fi EOF chmod 755 "${pkgdir}/DEBIAN/postrm" @@ -438,7 +474,7 @@ function build_ask_patched_libraries() { # Install all build dependencies upfront display_alert "ASK extension" "installing build deps for patched libraries" "info" chroot_sdcard "DEBIAN_FRONTEND=noninteractive apt-get -y build-dep \ - libnetfilter-conntrack libnfnetlink iptables" + libnetfilter-conntrack libnfnetlink" # Staging dir for patched .debs (saved to output later) mkdir -p "${SDCARD}/tmp/ask-patched-debs" @@ -452,9 +488,6 @@ function build_ask_patched_libraries() { "01-nxp-ask-nonblocking-heap-buffer.patch" \ "libnfnetlink0_*.deb libnfnetlink-dev_*.deb" - rebuild_patched_deb "iptables" \ - "001-qosmark-extensions.patch" \ - "libip4tc2_*.deb libip6tc2_*.deb libxtables12_*.deb iptables_*.deb" # Copy patched .debs to output for distribution mkdir -p "${SRC}/output/debs" diff --git a/packages/bsp/gateway-dk/sfp-led.c b/packages/bsp/gateway-dk/sfp-led.c index 8dde4456f284..97f092067c05 100644 --- a/packages/bsp/gateway-dk/sfp-led.c +++ b/packages/bsp/gateway-dk/sfp-led.c @@ -34,12 +34,19 @@ * sfp0: sfp-0 { * compatible = "sff,sfp"; * i2c-bus = <&sfp0_i2c>; - * leds = <&led_sfp0_link>, <&led_sfp0_activity>; * }; * * sfp-led-controller { * compatible = "mono,sfp-led"; - * sfp-ports = <&sfp0>, <&sfp1>; + * + * port@0 { + * sfp = <&sfp0>; + * leds = <&led_sfp0_link>, <&led_sfp0_activity>; + * }; + * port@1 { + * sfp = <&sfp1>; + * leds = <&led_sfp1_link>, <&led_sfp1_activity>; + * }; * }; * * // MAC node must reference SFP for netdev association @@ -483,14 +490,21 @@ static void sfp_led_poll_work_handler(struct work_struct *work) } static int sfp_led_register_port(struct sfp_led_priv *priv, - struct device_node *sfp_np, int index) + struct device_node *port_np, int index) { struct sfp_led_port *port = &priv->ports[index]; - struct device_node *i2c_np; + struct device_node *sfp_np, *i2c_np; + + /* Parse SFP node from port child node */ + sfp_np = of_parse_phandle(port_np, "sfp", 0); + if (!sfp_np) { + dev_err(priv->dev, "port %d: missing sfp phandle\n", index); + return -ENODEV; + } port->priv = priv; port->sfp_np = sfp_np; - of_node_get(sfp_np); + /* sfp_np has ref from of_parse_phandle — don't add of_node_get */ /* Get I2C adapter for module detection */ i2c_np = of_parse_phandle(sfp_np, "i2c-bus", 0); @@ -510,15 +524,15 @@ static int sfp_led_register_port(struct sfp_led_priv *priv, return ret ? ret : -ENODEV; } - /* Get LEDs */ - port->link_led = of_led_get(sfp_np, 0); + /* Get LEDs from port child node */ + port->link_led = of_led_get(port_np, 0); if (IS_ERR(port->link_led)) { dev_dbg(priv->dev, "port %d: link LED not in DT: %ld\n", index, PTR_ERR(port->link_led)); port->link_led = NULL; } - port->activity_led = of_led_get(sfp_np, 1); + port->activity_led = of_led_get(port_np, 1); if (IS_ERR(port->activity_led)) { dev_dbg(priv->dev, "port %d: activity LED not in DT: %ld\n", index, PTR_ERR(port->activity_led)); @@ -589,7 +603,7 @@ static void sfp_led_cleanup_port(struct sfp_led_port *port) static int sfp_led_probe(struct platform_device *pdev) { struct sfp_led_priv *priv; - struct device_node *np; + struct device_node *child; int count, i, registered = 0; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); @@ -599,9 +613,9 @@ static int sfp_led_probe(struct platform_device *pdev) priv->dev = &pdev->dev; platform_set_drvdata(pdev, priv); - count = of_count_phandle_with_args(pdev->dev.of_node, "sfp-ports", NULL); - if (count <= 0) { - dev_err(&pdev->dev, "no sfp-ports specified\n"); + count = of_get_child_count(pdev->dev.of_node); + if (count == 0) { + dev_err(&pdev->dev, "no port child nodes specified\n"); return -ENODEV; } @@ -612,17 +626,11 @@ static int sfp_led_probe(struct platform_device *pdev) priv->num_ports = count; - for (i = 0; i < count; i++) { - np = of_parse_phandle(pdev->dev.of_node, "sfp-ports", i); - if (!np) { - dev_warn(&pdev->dev, "failed to parse sfp-ports[%d]\n", i); - continue; - } - - if (sfp_led_register_port(priv, np, i) == 0) + i = 0; + for_each_child_of_node(pdev->dev.of_node, child) { + if (sfp_led_register_port(priv, child, i) == 0) registered++; - - of_node_put(np); + i++; } if (registered == 0) { diff --git a/patch/kernel/archive/ls1046a-6.12/002-arm64-dts-Add-Mono-Gateway-DK-device-tree.patch b/patch/kernel/archive/ls1046a-6.12/002-arm64-dts-Add-Mono-Gateway-DK-device-tree.patch index 0a9daed67903..dd6e3c70b91a 100644 --- a/patch/kernel/archive/ls1046a-6.12/002-arm64-dts-Add-Mono-Gateway-DK-device-tree.patch +++ b/patch/kernel/archive/ls1046a-6.12/002-arm64-dts-Add-Mono-Gateway-DK-device-tree.patch @@ -29,7 +29,7 @@ diff --git a/arch/arm64/boot/dts/freescale/mono-gateway-dk.dts b/arch/arm64/boot new file mode 100644 --- /dev/null +++ b/arch/arm64/boot/dts/freescale/mono-gateway-dk.dts -@@ -0,0 +1,1021 @@ +@@ -0,0 +1,1030 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Device Tree file for Mono Gateway DK (NXP LS1046A). @@ -60,6 +60,12 @@ new file mode 100644 + stdout-path = "serial0:115200n8"; + }; + ++ gpio-poweroff { ++ compatible = "gpio-poweroff"; ++ gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>; ++ timeout-ms = <1000>; ++ }; ++ + leds { + compatible = "gpio-leds"; + @@ -98,7 +104,6 @@ new file mode 100644 + mod-def0-gpios = <&gpio2 12 GPIO_ACTIVE_LOW>; + los-gpios = <&gpio2 11 GPIO_ACTIVE_HIGH>; + maximum-power-milliwatt = <3000>; -+ leds = <&led_sfp0_link>, <&led_sfp0_activity>; + }; + + /* SFP 2 */ @@ -109,13 +114,22 @@ new file mode 100644 + mod-def0-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>; + los-gpios = <&gpio2 9 GPIO_ACTIVE_HIGH>; + maximum-power-milliwatt = <3000>; -+ leds = <&led_sfp1_link>, <&led_sfp1_activity>; + }; + -+ /* SFP LED Controller */ ++ /* SFP LED Controller — LEDs are on the controller node, not SFP nodes ++ * (sff,sfp binding has additionalProperties: false) */ + sfp_led_controller: sfp-led-controller { + compatible = "mono,sfp-led"; -+ sfp-ports = <&sfp_xfi0>, <&sfp_xfi1>; ++ ++ port@0 { ++ sfp = <&sfp_xfi0>; ++ leds = <&led_sfp0_link>, <&led_sfp0_activity>; ++ }; ++ ++ port@1 { ++ sfp = <&sfp_xfi1>; ++ leds = <&led_sfp1_link>, <&led_sfp1_activity>; ++ }; + }; + + /* Boot memory regions for SDK DPAA driver */ @@ -599,11 +613,6 @@ new file mode 100644 + #address-cells = <1>; + #size-cells = <1>; + -+ partition@flash { -+ label = "flash"; -+ reg = <0x0 0x4000000>; -+ }; -+ + partition@0 { + label = "rcw-bl2"; + reg = <0x0 0x100000>;