gateway-dk-ask: build kernel modules in-tree for CI compatibility
Some checks failed
Infrastructure: Dispatch to fork / 📢 Run repository dispatch on fork (push) Has been cancelled
Infrastructure: Mirror to Codeberg / codeberg (push) Has been cancelled
Maintenance: Announce merge / announcepush (push) Has been cancelled
Maintenance: Security scan / Scorecards analysis (push) Has been cancelled

On Armbian CI, kernel builds and image assembly run on different runners.
The ASK extension's post_install_kernel_debs module build assumed the
kernel source worktree was available, which fails on the image runner.

Fix: build all ASK kernel modules (CDX, FCI, auto-bridge, sfp-led,
lp5812) in-tree during kernel compilation. Module sources are copied into
the kernel tree during custom_kernel_config (after patching, before
olddefconfig), following the pattern used by existing Armbian drivers.
Modules ship inside linux-image .deb automatically.

Changes:
- Add custom_kernel_config hook to copy module sources and enable configs
- Kbuild files for CDX/FCI/auto-bridge come from the ASK repo
- Board-specific modules (sfp-led, lp5812) use Kbuild files from BSP dir
- Remove post_install_kernel_debs module build (no longer needed)
- gateway-dk-ask .deb becomes userspace-only (tools, configs, services)
- Pin ASK repo to commit with Kbuild files
This commit is contained in:
Tomaz Zaman 2026-04-10 14:05:21 +02:00 committed by Ricardo Pardini
parent 4cd04e6660
commit fdef4074a4
6 changed files with 103 additions and 143 deletions

View File

@ -5,8 +5,8 @@
# Copyright (c) 2026 Mono Technologies Inc.
#
# NXP ASK (Application Solutions Kit) extension for LS1046A
# Builds and installs: kernel modules (CDX, FCI, auto-bridge),
# userspace tools (fmlib, fmc, libfci, libcli, dpa-app, cmm),
# Integrates kernel modules (CDX, FCI, auto-bridge, sfp-led, lp5812) in-tree
# and builds userspace tools (fmlib, fmc, libfci, libcli, dpa-app, cmm),
# patched system libraries, and configuration files.
#
# All ASK sources, patches, and configs come from the ASK repo.
@ -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="tag:mt-6.12.49-2.2.0"
declare -g ASK_BRANCH="commit:44883f88b26478fa2c9beea81702023cbc057f94"
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"
@ -66,17 +66,77 @@ function post_family_config__ask_fetch_repo() {
declare -g ASK_CACHE_DIR="${SRC}/cache/sources/ask-repo"
}
# Ensure kernel headers are available for module builds
function extension_finish_config__ask_enable_headers() {
# Post-config setup: enable kernel headers (userspace builds need FMAN UAPI headers)
# and derive multiarch triplet from KERNEL_COMPILER (set by arch config)
function extension_finish_config__ask_setup() {
declare -g INSTALL_HEADERS="yes"
# Derive multiarch triplet here (not at source time) — KERNEL_COMPILER is set by arch config
[[ -z "${KERNEL_COMPILER}" ]] && exit_with_error "ASK extension: KERNEL_COMPILER is not set, cannot derive host triplet"
declare -g ASK_HOST_TRIPLET="${KERNEL_COMPILER%-}"
display_alert "ASK extension" "enabling kernel headers for module builds" "info"
}
# Host build dependencies — kernel module cross-compilation only needs the kernel source tree
# (libxml2-dev, libtclap-dev, libpcap-dev, pkg-config are installed in-chroot for userspace builds)
# Copy ASK kernel module sources into the kernel tree and enable them in Kconfig.
# Runs during custom_kernel_config — AFTER patching (which does git reset + git clean),
# but BEFORE olddefconfig parses Kconfig. kernel_copy_extra_sources runs too early
# (files get wiped by git clean from CLEAN_LEVEL=make-kernel).
function custom_kernel_config__ask_modules() {
# Invalidate kernel cache when ASK source changes (same pattern as Khadas meson-s4t7)
kernel_config_modifying_hashes+=("ask_modules=${ASK_BRANCH}")
# Skip file operations during config-dump-json and version calculation
[[ ! -f .config ]] && return 0
display_alert "ASK extension" "copying ASK module sources into kernel tree" "info"
local ask_drv="${kernel_work_dir}/drivers/net/ethernet/freescale/ask"
local bsp_dir="${SRC}/packages/bsp/gateway-dk"
# Copy module sources and Kbuild files from ASK cache
# (Kbuild files coexist with old Makefiles — kbuild prefers Kbuild when both exist)
mkdir -p "${ask_drv}"
cp -a "${ASK_CACHE_DIR}/${ASK_CDX_DIR}" "${ask_drv}/cdx"
cp -a "${ASK_CACHE_DIR}/${ASK_FCI_DIR}" "${ask_drv}/fci"
cp -a "${ASK_CACHE_DIR}/${ASK_AUTOBRIDGE_DIR}" "${ask_drv}/auto_bridge"
# Parent Kconfig and Makefile from ASK repo
cp "${ASK_CACHE_DIR}/Kconfig" "${ask_drv}/Kconfig"
cp "${ASK_CACHE_DIR}/Kbuild.mk" "${ask_drv}/Makefile"
# Board-specific modules (not part of ASK repo — from Armbian BSP)
if [[ "${BOARD}" == "gateway-dk" ]]; then
mkdir -p "${ask_drv}/sfp_led" "${ask_drv}/leds_lp5812"
cp "${bsp_dir}/sfp-led.c" "${ask_drv}/sfp_led/"
cp "${bsp_dir}/sfp-led.Kbuild" "${ask_drv}/sfp_led/Kbuild"
cp "${bsp_dir}/leds-lp5812.c" "${ask_drv}/leds_lp5812/"
cp "${bsp_dir}/leds-lp5812.h" "${ask_drv}/leds_lp5812/"
cp "${bsp_dir}/leds-lp5812.Kbuild" "${ask_drv}/leds_lp5812/Kbuild"
# Add board-specific entries to ASK Kconfig and Makefile
patch -p1 -d "${ask_drv}" < "${bsp_dir}/ask-kconfig-board-modules.patch"
echo 'obj-$(CONFIG_ASK_SFP_LED) += sfp_led/' >> "${ask_drv}/Makefile"
echo 'obj-$(CONFIG_ASK_LEDS_LP5812) += leds_lp5812/' >> "${ask_drv}/Makefile"
fi
# Wire into parent freescale Kconfig and Makefile
local fsl_dir="${kernel_work_dir}/drivers/net/ethernet/freescale"
if ! grep -q 'source.*ask/Kconfig' "${fsl_dir}/Kconfig" 2>/dev/null; then
sed -i '/endif.*NET_VENDOR_FREESCALE/i source "drivers/net/ethernet/freescale/ask/Kconfig"' "${fsl_dir}/Kconfig"
fi
if ! grep -q 'ask/' "${fsl_dir}/Makefile" 2>/dev/null; then
echo 'obj-y += ask/' >> "${fsl_dir}/Makefile"
fi
display_alert "ASK extension" "ASK module sources and Kbuild files placed in kernel tree" "info"
# Enable ASK modules in kernel config (opts_m array, same pattern as meson64_common.inc)
opts_y+=("CONFIG_NXP_ASK")
opts_m+=("CONFIG_ASK_CDX")
opts_m+=("CONFIG_ASK_FCI")
opts_m+=("CONFIG_ASK_AUTO_BRIDGE")
if [[ "${BOARD}" == "gateway-dk" ]]; then
opts_m+=("CONFIG_ASK_SFP_LED")
opts_m+=("CONFIG_ASK_LEDS_LP5812")
fi
}
# Copy ASK kernel patch to userpatches (gitignored) so it's applied during kernel build.
# userpatches/ is the Armbian-standard location for extension-provided patches — the build
@ -93,104 +153,10 @@ function post_family_config__ask_kernel_patch() {
display_alert "ASK extension" "ASK kernel patch staged in userpatches" "info"
}
function cleanup_ask_module_builddir() {
[[ -n "${ASK_MODULE_BUILDDIR}" && -d "${ASK_MODULE_BUILDDIR}" ]] && rm -rf "${ASK_MODULE_BUILDDIR}" || true
}
# Build kernel modules after kernel debs are installed in chroot
function post_install_kernel_debs__build_ask_modules() {
[[ "${INSTALL_HEADERS}" != "yes" ]] && return 0
display_alert "ASK extension" "building kernel modules (host cross-compile)" "info"
declare -g ASK_KERNEL_VER
ASK_KERNEL_VER=$(ls -1v "${SDCARD}/lib/modules/" | tail -1)
[[ -z "${ASK_KERNEL_VER}" ]] && exit_with_error "No kernel version found in ${SDCARD}/lib/modules/"
local kernel_ver="${ASK_KERNEL_VER}"
# Full kernel source tree (needed for CDX — it includes ncsw_config.mk from the FMAN driver)
local ksrc="${SRC}/cache/sources/linux-kernel-worktree/${KERNEL_MAJOR_MINOR}__${LINUXFAMILY}__${ARCH}"
[[ -d "${ksrc}" ]] || exit_with_error "Kernel source tree not found at ${ksrc}"
local cross="${KERNEL_COMPILER}"
local bsp_dir="${SRC}/packages/bsp/gateway-dk"
local builddir
builddir=$(mktemp -d)
declare -g ASK_MODULE_BUILDDIR="${builddir}"
add_cleanup_handler cleanup_ask_module_builddir
# Copy ASK module sources to build dir
cp -a "${ASK_CACHE_DIR}/${ASK_CDX_DIR}" "${builddir}/cdx"
cp -a "${ASK_CACHE_DIR}/${ASK_FCI_DIR}" "${builddir}/fci"
cp -a "${ASK_CACHE_DIR}/${ASK_AUTOBRIDGE_DIR}" "${builddir}/auto-bridge"
# Build CDX module (cross-compile on host against full kernel source)
# NXP ASK uses LS1043A as the DPAA1 platform ID for all DPAA1 SoCs (LS1043A/LS1046A)
display_alert "ASK extension" "building CDX kernel module" "info"
make -C "${builddir}/cdx" \
KERNELDIR="${ksrc}" ARCH=arm64 CROSS_COMPILE="${cross}" PLATFORM=LS1043A \
CFG_FLAGS="-DSEC_PROFILE_SUPPORT -DVLAN_FILTER -DWIFI_ENABLE -DENABLE_EGRESS_QOS" \
|| exit_with_error "CDX module build failed"
# Build FCI module (depends on CDX Module.symvers)
display_alert "ASK extension" "building FCI kernel module" "info"
make -C "${builddir}/fci" \
KERNEL_SOURCE="${ksrc}" ARCH=arm64 CROSS_COMPILE="${cross}" BOARD_ARCH=arm64 \
KBUILD_EXTRA_SYMBOLS="${builddir}/cdx/Module.symvers" \
|| exit_with_error "FCI module build failed"
# Build auto-bridge module (uses its own Makefile which adds -I for br_private.h)
display_alert "ASK extension" "building auto-bridge kernel module" "info"
make -C "${builddir}/auto-bridge" \
KERNEL_SOURCE="${ksrc}" CROSS_COMPILE="${cross}" PLATFORM=LS1043A ENABLE_VLAN_FILTER=y \
|| exit_with_error "auto-bridge module build failed"
# Board-specific modules (gateway-dk only)
if [[ "${BOARD}" == "gateway-dk" ]]; then
# SFP-LED: GPIO-based SFP port LED control
display_alert "ASK extension" "building SFP-LED kernel module" "info"
mkdir -p "${builddir}/sfp-led"
cp "${bsp_dir}/sfp-led.c" "${builddir}/sfp-led/"
cp "${bsp_dir}/sfp-led.mk" "${builddir}/sfp-led/Makefile"
pushd "${builddir}/sfp-led"
make KERNEL_SRC="${ksrc}" ARCH=arm64 CROSS_COMPILE="${cross}" \
|| exit_with_error "SFP-LED module build failed"
popd
# LP5812: TI 4x3 LED matrix controller (not yet in mainline, targeting 6.19+)
display_alert "ASK extension" "building LP5812 LED driver" "info"
mkdir -p "${builddir}/lp5812"
cp "${bsp_dir}/leds-lp5812.c" "${builddir}/lp5812/"
cp "${bsp_dir}/leds-lp5812.h" "${builddir}/lp5812/"
cp "${bsp_dir}/leds-lp5812.mk" "${builddir}/lp5812/Makefile"
pushd "${builddir}/lp5812"
make KERNEL_SRC="${ksrc}" ARCH=arm64 CROSS_COMPILE="${cross}" \
|| exit_with_error "LP5812 module build failed"
popd
fi
# Stage built modules for the combined .deb (packaged later in userspace phase)
display_alert "ASK extension" "staging kernel modules for packaging" "info"
declare -g ASK_MODULE_STAGING="${SRC}/cache/sources/ask-module-staging"
rm -rf "${ASK_MODULE_STAGING}"
mkdir -p "${ASK_MODULE_STAGING}"
cp "${builddir}/cdx/cdx.ko" "${ASK_MODULE_STAGING}/"
cp "${builddir}/fci/fci.ko" "${ASK_MODULE_STAGING}/"
cp "${builddir}/auto-bridge/auto_bridge.ko" "${ASK_MODULE_STAGING}/"
[[ -f "${builddir}/sfp-led/sfp-led.ko" ]] && cp "${builddir}/sfp-led/sfp-led.ko" "${ASK_MODULE_STAGING}/"
[[ -f "${builddir}/lp5812/leds-lp5812.ko" ]] && cp "${builddir}/lp5812/leds-lp5812.ko" "${ASK_MODULE_STAGING}/"
# Also install directly into rootfs so they're available during the rest of the build
mkdir -p "${SDCARD}/lib/modules/${kernel_ver}/extra"
cp "${ASK_MODULE_STAGING}"/*.ko "${SDCARD}/lib/modules/${kernel_ver}/extra/"
chroot_sdcard "depmod -a ${kernel_ver}" || exit_with_error "depmod failed"
# Install module autoload config (modules are in the kernel .deb, just need the load list)
function post_install_kernel_debs__ask_module_autoload() {
cp "${ASK_CACHE_DIR}/config/ask-modules.conf" "${SDCARD}/etc/modules-load.d/"
# Clean up build dir
rm -rf "${builddir}"
display_alert "ASK extension" "kernel modules built and staged" "info"
}
# Copy patches into chroot before patched library builds (runs before build_ask_userspace)
@ -215,7 +181,9 @@ function pre_customize_image__000_prepare_ask_patches() {
function pre_customize_image__001_build_ask_userspace() {
display_alert "ASK extension" "building userspace components" "info"
local kernel_ver="${ASK_KERNEL_VER}"
local kernel_ver
kernel_ver=$(ls -1v "${SDCARD}/lib/modules/" | tail -1)
[[ -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
@ -348,20 +316,13 @@ function pre_customize_image__001_build_ask_userspace() {
# Cleanup build sources
rm -rf "${SDCARD}/tmp/ask-userspace" "${SDCARD}/tmp/ask-patches"
# --- Package everything as a single gateway-dk-ask .deb ---
display_alert "ASK extension" "packaging combined ASK .deb" "info"
# --- Package ASK userspace as a .deb (kernel modules are in linux-image .deb) ---
display_alert "ASK extension" "packaging ASK userspace .deb" "info"
local pkgname="gateway-dk-ask"
local pkgdir
pkgdir=$(mktemp -d)
mkdir -p "${pkgdir}/DEBIAN"
# Kernel modules (staged during post_install_kernel_debs phase)
local moddir="${pkgdir}/lib/modules/${kernel_ver}/extra"
mkdir -p "${moddir}" "${pkgdir}/etc/modules-load.d"
cp "${ASK_MODULE_STAGING}"/*.ko "${moddir}/"
cp "${ASK_CACHE_DIR}/config/ask-modules.conf" "${pkgdir}/etc/modules-load.d/"
rm -rf "${ASK_MODULE_STAGING}"
# Snapshot userspace files into package tree
local -a ask_files=(
usr/bin/fmc
@ -414,15 +375,15 @@ Section: net
Priority: optional
Maintainer: Mono Technologies <support@mono.si>
Depends: linux-image-${BRANCH}-${LINUXFAMILY} (>= ${kernel_ver}), libxml2, libpcap0.8
Description: NXP ASK hardware offloading for Mono Gateway DK
Kernel modules (CDX, FCI, auto-bridge, sfp-led, leds-lp5812) and
userspace tools (fmlib, fmc, libfci, libcli, dpa-app, cmm) for
NXP ASK data-plane acceleration on the LS1046A Gateway DK.
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.
Kernel modules (CDX, FCI, auto-bridge, sfp-led, leds-lp5812) are in the
linux-image package.
EOF
cat > "${pkgdir}/DEBIAN/postinst" << EOF
#!/bin/bash
depmod -a ${kernel_ver}
systemctl daemon-reload || true
ldconfig || true
# Enable CMM service on OTA install (guarded by ConditionPathExists=/dev/cdx_ctrl at runtime)
@ -442,7 +403,6 @@ EOF
cat > "${pkgdir}/DEBIAN/postrm" << EOF
#!/bin/bash
depmod -a ${kernel_ver} || true
ldconfig || true
systemctl daemon-reload || true
if [ "\$1" = "remove" ] || [ "\$1" = "purge" ]; then

View File

@ -0,0 +1,19 @@
--- a/Kconfig
+++ b/Kconfig
@@ -27,4 +27,16 @@ config ASK_AUTO_BRIDGE
help
Automatic bridge offloading with VLAN filter support.
+config ASK_SFP_LED
+ tristate "SFP port LED driver (Mono Gateway DK)"
+ depends on LEDS_CLASS && I2C
+ help
+ GPIO-based SFP port link/activity LED control for Mono Gateway DK.
+
+config ASK_LEDS_LP5812
+ tristate "TI LP5812 LED matrix driver (Mono Gateway DK)"
+ depends on LEDS_CLASS && I2C
+ help
+ TI LP5812 4x3 LED matrix controller driver.
+
endif # NXP_ASK

View File

@ -0,0 +1,2 @@
ccflags-y += -I$(src)
obj-$(CONFIG_ASK_LEDS_LP5812) += leds-lp5812.o

View File

@ -1,12 +0,0 @@
obj-m := leds-lp5812.o
ccflags-y := -I$(src)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean

View File

@ -0,0 +1 @@
obj-$(CONFIG_ASK_SFP_LED) += sfp-led.o

View File

@ -1,10 +0,0 @@
obj-m := sfp-led.o
all:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean