334 lines
12 KiB
Docker
334 lines
12 KiB
Docker
ARG BUILD_BASE_TAG=dev
|
|
ARG DOCKER_IMAGE_ROOT=monok8s
|
|
|
|
FROM --platform=$BUILDPLATFORM ${DOCKER_IMAGE_ROOT}/build-base:${BUILD_BASE_TAG} AS build
|
|
|
|
RUN mkdir /src
|
|
WORKDIR /src
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
devscripts debootstrap qemu-user-static qemu-utils parted kpartx build-essential make cmake ncurses-dev flex bison meson bc vim curl git pkg-config rsync nfs-kernel-server debootstrap debhelper dh-python python3-pyelftools python3-ply chrpath tftpd-hpa htop \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN debootstrap \
|
|
--arch=arm64 \
|
|
--foreign \
|
|
trixie \
|
|
/mnt/rootfs \
|
|
http://deb.debian.org/debian
|
|
|
|
ARG APT_PROXY
|
|
|
|
RUN if [ -n "${APT_PROXY}" ]; then \
|
|
echo "Acquire::http::Proxy \"http://${APT_PROXY}\";" > /mnt/rootfs/etc/apt/apt.conf.d/01proxy; \
|
|
fi
|
|
|
|
RUN chroot /mnt/rootfs apt-get update && \
|
|
chroot /mnt/rootfs apt-get install -y --no-install-recommends \
|
|
libelf-dev \
|
|
libssl-dev \
|
|
pkg-config \
|
|
zlib1g-dev \
|
|
libpcap-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
RUN tee -a /usr/bin/aarch64-linux-gnu-pkg-config << 'EOF'
|
|
#!/bin/sh -e
|
|
SYSROOT=/mnt/rootfs
|
|
export PKG_CONFIG_PATH=${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/local/lib/pkgconfig:${SYSROOT}/usr/lib/aarch64-linux-gnu/pkgconfig
|
|
export PKG_CONFIG_SYSROOT_DIR=${SYSROOT}
|
|
exec pkg-config "$@"
|
|
EOF
|
|
RUN chmod +x /usr/bin/aarch64-linux-gnu-pkg-config
|
|
|
|
ARG DPDK_TAR
|
|
ARG DPDK_VERSION
|
|
|
|
COPY ${DPDK_TAR} /tmp/
|
|
|
|
RUN set -eux; \
|
|
mkdir -p /src/dpdk; \
|
|
tar -xf "/tmp/$(basename "${DPDK_TAR}")" -C /src/dpdk --strip-components=1
|
|
|
|
WORKDIR /src/dpdk
|
|
|
|
|
|
RUN tee -a dpdk.config << 'END'
|
|
[binaries]
|
|
c = ['aarch64-linux-gnu-gcc', '--sysroot=/mnt/rootfs']
|
|
cpp = ['aarch64-linux-gnu-g++', '--sysroot=/mnt/rootfs']
|
|
ar = 'aarch64-linux-gnu-ar'
|
|
as = 'aarch64-linux-gnu-as'
|
|
ld = ['aarch64-linux-gnu-ld', '--sysroot=/mnt/rootfs']
|
|
strip = 'aarch64-linux-gnu-strip'
|
|
pkgconfig = '/usr/bin/aarch64-linux-gnu-pkg-config'
|
|
pcap-config = ''
|
|
|
|
[host_machine]
|
|
system = 'linux'
|
|
cpu_family = 'aarch64'
|
|
cpu = 'armv8-a'
|
|
endian = 'little'
|
|
|
|
[properties]
|
|
platform = 'dpaa'
|
|
END
|
|
|
|
RUN rm -rf build-aarch64 && \
|
|
meson setup build-aarch64 \
|
|
--prefix=/usr \
|
|
--buildtype=release \
|
|
--default-library=shared \
|
|
--cross-file=dpdk.config \
|
|
-Dkernel_dir=/usr/src/linux \
|
|
-Dexamples=l2fwd,l3fwd,helloworld \
|
|
-Dmax_lcores=4 \
|
|
-Dc_args="-g -Ofast -fPIC -ftls-model=local-dynamic -Wno-error=implicit-function-declaration -Wno-error=maybe-uninitialized \
|
|
-I/mnt/rootfs/usr/include \
|
|
-I/mnt/rootfs/usr/include/aarch64-linux-gnu" \
|
|
-Dc_link_args="-Wl,-rpath-link=/mnt/rootfs/usr/lib/aarch64-linux-gnu \
|
|
-L/mnt/rootfs/usr/lib/aarch64-linux-gnu \
|
|
-L/mnt/rootfs/usr/lib \
|
|
-L/mnt/rootfs/usr/local/lib \
|
|
-L/src/dpdk/build-aarch64/drivers \
|
|
-Wl,--no-as-needed"
|
|
|
|
RUN DESTDIR=/mnt/rootfs ninja -C build-aarch64 install
|
|
RUN install -m 644 ./drivers/bus/pci/bus_pci_driver.h /mnt/rootfs/usr/include
|
|
RUN find ./build-aarch64/examples/ -type f -name "dpdk-*" -type f -exec sh -c "install -m 755 {} /mnt/rootfs/usr/local/bin/" \;
|
|
|
|
# Copy the internal bus/driver headers that NXP's DPAA/VPP plugin needs
|
|
RUN install -m 644 /src/dpdk/lib/eal/include/dev_driver.h /mnt/rootfs/usr/include/
|
|
RUN install -m 644 /src/dpdk/lib/eal/arm/include/rte_cpuflags.h /mnt/rootfs/usr/include/ || true
|
|
RUN install -m 644 /src/dpdk/drivers/bus/pci/bus_pci_driver.h /mnt/rootfs/usr/include/
|
|
|
|
# Copy the internal bus headers required by NXP VPP DPDK plugin
|
|
RUN install -m 644 /src/dpdk/drivers/bus/pci/bus_pci_driver.h /mnt/rootfs/usr/include/
|
|
RUN install -m 644 /src/dpdk/drivers/bus/vmbus/bus_vmbus_driver.h /mnt/rootfs/usr/include/
|
|
RUN install -m 644 /src/dpdk/lib/eal/include/dev_driver.h /mnt/rootfs/usr/include/
|
|
|
|
# Sometimes it also looks for the vdev bus header
|
|
RUN install -m 644 /src/dpdk/drivers/bus/vdev/bus_vdev_driver.h /mnt/rootfs/usr/include/ || true
|
|
|
|
# Cryptodev internal headers (needed for VPP IPsec plugin)
|
|
RUN install -m 644 /src/dpdk/lib/cryptodev/cryptodev_pmd.h /mnt/rootfs/usr/include/
|
|
|
|
# Eventdev internal headers (often needed for NXP DPAA2 scheduler)
|
|
RUN install -m 644 /src/dpdk/lib/eventdev/eventdev_pmd.h /mnt/rootfs/usr/include/ || true
|
|
RUN install -m 644 /src/dpdk/lib/eventdev/event_timer_adapter_pmd.h /mnt/rootfs/usr/include/ || true
|
|
|
|
RUN ln -s /mnt/rootfs/usr/include /mnt/rootfs/usr/include/dpdk || true
|
|
|
|
ARG VPP_TAR
|
|
ARG VPP_VERSION
|
|
ARG VPP_UPSTREAM_VERSION
|
|
|
|
COPY ${VPP_TAR} /tmp/
|
|
|
|
RUN set -eux; \
|
|
mkdir -p /src/vpp; \
|
|
tar -xf "/tmp/$(basename "${VPP_TAR}")" -C /src/vpp --strip-components=1; \
|
|
cd /src/vpp; \
|
|
# Strings of surreal hacks from Gemini that make vpp builds
|
|
git init && git add . && git config user.email "you@example.com" && \
|
|
git config user.name "Your Name" && git commit -m "init" && \
|
|
git tag -a v${VPP_UPSTREAM_VERSION} -m "v${VPP_UPSTREAM_VERSION}"
|
|
|
|
WORKDIR /src/vpp
|
|
|
|
# Sync libs for the linker
|
|
RUN ln -s /mnt/rootfs/usr/lib/aarch64-linux-gnu /mnt/rootfs/usr/lib/lib64 || true
|
|
|
|
RUN cd build-root && \
|
|
export DEB_BUILD_OPTIONS="nocheck nodoc noautodbgsym" && \
|
|
make V=1 \
|
|
PLATFORM=dpaa \
|
|
TAG=dpaa \
|
|
CROSS_SYSROOT=/mnt/rootfs \
|
|
CROSS_PREFIX=aarch64-linux-gnu \
|
|
DPDK_PATH=/mnt/rootfs/usr \
|
|
VPP_VERSION=${VPP_VERSION} \
|
|
vpp-install
|
|
|
|
ARG FMLIB_TAR
|
|
ARG FMC_TAR
|
|
ARG FMLIB_VERSION
|
|
ARG FMC_VERSION
|
|
ARG NXP_VERSION
|
|
|
|
COPY packages/${NXP_VERSION}.tar.gz /tmp/
|
|
RUN set -eux; \
|
|
mkdir -p /src/nxplinux; \
|
|
tar -xf "/tmp/${NXP_VERSION}.tar.gz" -C /src/nxplinux --strip-components=1 \
|
|
&& rm -f /tmp/${NXP_VERSION}.tar.gz
|
|
|
|
COPY ${FMLIB_TAR} /tmp/
|
|
RUN set -eux; \
|
|
mkdir -p /src/fmlib; \
|
|
tar -xf "/tmp/$(basename "${FMLIB_TAR}")" -C /src/fmlib --strip-components=1;
|
|
|
|
COPY ${FMC_TAR} /tmp/
|
|
RUN set -eux; \
|
|
mkdir -p /src/fmc; \
|
|
tar -xf "/tmp/$(basename "${FMC_TAR}")" -C /src/fmc --strip-components=1;
|
|
|
|
WORKDIR /src/fmlib
|
|
|
|
RUN set -eux; KERNEL_SRC="/src/nxplinux" \
|
|
# We add CFLAGS to point to the specific UAPI headers for DPAA/FMan
|
|
EXTRA_CFLAGS="-I${KERNEL_SRC}/include/uapi -I${KERNEL_SRC}/drivers/net/ethernet/freescale/fman" \
|
|
make all -j8 && \
|
|
make install-libfm-arm DESTDIR=/mnt/rootfs PREFIX=/usr
|
|
|
|
WORKDIR /src/fmc
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
g++-aarch64-linux-gnu \
|
|
gcc-aarch64-linux-gnu \
|
|
binutils-aarch64-linux-gnu
|
|
|
|
RUN chroot /mnt/rootfs apt-get install -y --no-install-recommends \
|
|
libxml2-dev libtclap-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Patch the callback signature in FMC source to match libxml2
|
|
RUN set -eux; \
|
|
sed -i 's/const xmlError \*/xmlError */g' /src/fmc/source/FMCGenericError.h; \
|
|
sed -i 's/const xmlError \*/xmlError */g' /src/fmc/source/FMCGenericError.cpp;
|
|
|
|
RUN set -eux; make -C source clean && \
|
|
make -C source -j8 \
|
|
MACHINE=ls1046 \
|
|
CC="aarch64-linux-gnu-gcc --sysroot=/mnt/rootfs" \
|
|
CXX="aarch64-linux-gnu-g++ --sysroot=/mnt/rootfs" \
|
|
FMD_USPACE_HEADER_PATH=/mnt/rootfs/usr/include/fmd \
|
|
FMD_USPACE_LIB_PATH=/mnt/rootfs/usr/lib/aarch64-linux-gnu \
|
|
LIBXML2_HEADER_PATH=/mnt/rootfs/usr/include/libxml2 \
|
|
TCLAP_HEADER_PATH=/mnt/rootfs/usr/include
|
|
|
|
# Locate and Fix the XML + Schemas + Sub-configs
|
|
RUN set -eux; \
|
|
XML_SRC=$(find /src -name "usdpaa_config_ls1046.xml" | head -n 1); \
|
|
SCHEMA_DIR=$(dirname $(find /src -name "cfgdata.xsd" | head -n 1)); \
|
|
HXS_FILE=$(find /src -name "hxs_pdl_v3.xml" | head -n 1); \
|
|
\
|
|
# Create a structured staging area
|
|
mkdir -p /tmp/fmc_staging/config; \
|
|
\
|
|
# Copy main files
|
|
cp "$XML_SRC" /tmp/fmc_staging/config.xml; \
|
|
cp "$HXS_FILE" /tmp/fmc_staging/config/; \
|
|
cp "$SCHEMA_DIR"/*.xsd /tmp/fmc_staging/config/; \
|
|
\
|
|
# Production Cleanup: Remove RJ45 ports (MAC 3, 4, 5, 6) from the FMC config
|
|
# This ensures FMC only touches the SFP ports (MAC 9, 10)
|
|
sed -i '/<macport name="fm0-gb3"/{N;N;N;N;d;}' /tmp/fmc_staging/config.xml; \
|
|
sed -i '/<macport name="fm0-gb4"/{N;N;N;N;d;}' /tmp/fmc_staging/config.xml; \
|
|
sed -i '/<macport name="fm0-gb5"/{N;N;N;N;d;}' /tmp/fmc_staging/config.xml; \
|
|
sed -i '/<macport name="fm0-gb6"/{N;N;N;N;d;}' /tmp/fmc_staging/config.xml; \
|
|
\
|
|
# Also remove the port bindings for those MACs
|
|
sed -i '/<port type="MAC" number="3"/d' /tmp/fmc_staging/config.xml; \
|
|
sed -i '/<port type="MAC" number="4"/d' /tmp/fmc_staging/config.xml; \
|
|
sed -i '/<port type="MAC" number="5"/d' /tmp/fmc_staging/config.xml; \
|
|
sed -i '/<port type="MAC" number="6"/d' /tmp/fmc_staging/config.xml; \
|
|
\
|
|
# 1. Initialize policy.xml with the correct <netpcd> root tag
|
|
echo '<?xml version="1.0" encoding="UTF-8"?>' > /tmp/fmc_staging/policy.xml; \
|
|
echo '<netpcd>' >> /tmp/fmc_staging/policy.xml; \
|
|
\
|
|
# 2. Extract policy names and generate dummy blocks
|
|
# We use a subshell and tr to handle potential weird spacing
|
|
POLICY_NAMES=$(grep -o 'policy="[^"]*"' /tmp/fmc_staging/config.xml | cut -d'"' -f2 | sort -u); \
|
|
\
|
|
for NAME in $POLICY_NAMES; do \
|
|
echo " <policy name=\"$NAME\">" >> /tmp/fmc_staging/policy.xml; \
|
|
echo " <dist_order><distributionref name=\"dist_dummy\"/></dist_order>" >> /tmp/fmc_staging/policy.xml; \
|
|
echo " </policy>" >> /tmp/fmc_staging/policy.xml; \
|
|
done; \
|
|
\
|
|
# 3. Append the distribution and close the root tag
|
|
# Updated Distribution block for the Dockerfile RUN command
|
|
cat << 'EOF' >> /tmp/fmc_staging/policy.xml
|
|
<distribution name="dist_dummy">
|
|
<protocols><protocolref name="ethernet"/></protocols>
|
|
</distribution>
|
|
</netpcd>
|
|
EOF
|
|
|
|
RUN set -eux; \
|
|
cd /src/vpp; \
|
|
mkdir -p debian; \
|
|
echo "10" > debian/compat; \
|
|
\
|
|
# 1. Start the Rules file
|
|
echo '#!/usr/bin/make -f' > debian/rules; \
|
|
echo '%:' >> debian/rules; \
|
|
printf '\tdh $@\n' >> debian/rules; \
|
|
\
|
|
echo 'override_dh_auto_configure:' >> debian/rules; \
|
|
printf '\t@echo "Skipping configure"\n' >> debian/rules; \
|
|
\
|
|
echo 'override_dh_auto_clean:' >> debian/rules; \
|
|
printf '\t@echo "Skipping clean"\n' >> debian/rules; \
|
|
\
|
|
echo 'override_dh_auto_build:' >> debian/rules; \
|
|
printf '\t@echo "Skipping build"\n' >> debian/rules; \
|
|
\
|
|
# 2. THE INSTALL STEP (Crucial: everything here must have a Tab)
|
|
echo 'override_dh_auto_install:' >> debian/rules; \
|
|
printf '\tmkdir -p debian/vpp/usr/bin\n' >> debian/rules; \
|
|
printf '\tmkdir -p debian/vpp/usr/lib\n' >> debian/rules; \
|
|
printf '\tmkdir -p debian/vpp/etc/fmc/config\n' >> debian/rules; \
|
|
\
|
|
# Copy VPP binaries from build-root
|
|
printf '\tcp -a build-root/install-dpaa-aarch64/vpp/. debian/vpp/usr/\n' >> debian/rules; \
|
|
\
|
|
# Copy FMC binary
|
|
printf '\tcp /src/fmc/source/fmc debian/vpp/usr/bin/\n' >> debian/rules; \
|
|
\
|
|
# PULL FROM THE STAGING AREA
|
|
printf '\tcp /tmp/fmc_staging/config.xml debian/vpp/etc/fmc/\n' >> debian/rules; \
|
|
printf '\tcp /tmp/fmc_staging/policy.xml debian/vpp/etc/fmc/\n' >> debian/rules; \
|
|
printf '\tcp /tmp/fmc_staging/config/* debian/vpp/etc/fmc/config/\n' >> debian/rules; \
|
|
\
|
|
# Copy system libs
|
|
printf '\tcp /mnt/rootfs/usr/lib/libfm-arm.so* debian/vpp/usr/lib/ 2>/dev/null || true\n' >> debian/rules; \
|
|
printf '\tcp /mnt/rootfs/usr/lib/libusdpaa.so* debian/vpp/usr/lib/ 2>/dev/null || true\n' >> debian/rules; \
|
|
\
|
|
echo 'override_dh_usrlocal:' >> debian/rules; \
|
|
printf '\t@echo "Skipping usrlocal fixup"\n' >> debian/rules; \
|
|
\
|
|
echo 'override_dh_shlibdeps:' >> debian/rules; \
|
|
printf '\t@echo "Skipping shlibdeps (cross-compile)"\n' >> debian/rules; \
|
|
\
|
|
chmod +x debian/rules; \
|
|
\
|
|
# 3. Control and Changelog (echo is fine here because these aren't Makefiles)
|
|
echo "Source: vpp" > debian/control; \
|
|
echo "Maintainer: NXP Builder <builder@nxp.com>" >> debian/control; \
|
|
echo "Section: net" >> debian/control; \
|
|
echo "Priority: optional" >> debian/control; \
|
|
echo "Build-Depends: debhelper (>= 10)" >> debian/control; \
|
|
echo "" >> debian/control; \
|
|
echo "Package: vpp" >> debian/control; \
|
|
echo "Architecture: arm64" >> debian/control; \
|
|
echo "Depends: \${shlibs:Depends}, \${misc:Depends}, libxml2, libtclap-dev" >> debian/control; \
|
|
echo "Description: VPP for NXP DPAA" >> debian/control; \
|
|
\
|
|
echo "vpp (${VPP_VERSION#lf-}-1) stable; urgency=low" > debian/changelog; \
|
|
echo " * Custom NXP Build" >> debian/changelog; \
|
|
echo " -- NXP Builder <builder@nxp.com> $(date -R)" >> debian/changelog
|
|
|
|
# 5. Final Packaging
|
|
RUN cd /src/vpp && \
|
|
export DEB_BUILD_OPTIONS="nocheck nodoc noautodbgsym" && \
|
|
export CC=aarch64-linux-gnu-gcc && \
|
|
export CXX=aarch64-linux-gnu-g++ && \
|
|
dpkg-buildpackage -us -uc -b -aarm64 -d
|
|
|
|
FROM scratch
|
|
ARG VPP_VERSION
|
|
COPY --from=build /src/vpp_${VPP_VERSION#lf-}-1_arm64.deb /
|