Ethernet Custom Switch Driver files add in Yocto and build the kernel

Hi All,

I am using Verdin iMX8MP and IVY carrier board and successfully build the Toradex reference minimal image. From last couple of days i am trying to add custom ethernet switch driver DSA with their source and header files. But getting below error

image

The complete ERROR log is

meta-poky            = "HEAD:50e5c0d85d3775ac1294bdcd7f11deaa382c9d08"
meta                 = "HEAD:c374e6cfcdd2c8ba17d82ffcfdeb97d21144e2bf"
meta-customer        = "<unknown>:<unknown>"
workspace            = "master:a68a6f262b36d9a1b00ffb178b474ab3807af36f"
meta-switch-driver   = "<unknown>:<unknown>"

WARNING: /home/vishal/oe-core/build/../layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex_6.6-2.2.x.bb:do_populate_sysroot is tainted from a forced run          | ETA:  0:00:00
Sstate summary: Wanted 19 Local 6 Mirrors 0 Missed 13 Current 527 (31% match, 97% complete)###############################################################               | ETA:  0:00:00
Removing 1 stale sstate objects for arch verdin_imx8mp: 100% |###########################################################################################################| Time: 0:00:00
NOTE: Executing Tasks
ERROR: gsw145-0.1-r0 do_compile: oe_runmake failed
ERROR: gsw145-0.1-r0 do_compile: ExecutionError('/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/temp/run.do_compile.297028', 1, None, None)
ERROR: Logfile of failure stored in: /home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/temp/log.do_compile.297028
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: make -j 2 KERNEL_SRC=/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-source KERNEL_PATH=/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-source KERNEL_VERSION=6.6.94-7.4.0-devel CC=aarch64-tdx-linux-gcc    -fuse-ld=bfd -fcanon-prefix-map  -fmacro-prefix-map=/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver=/usr/src/debug/gsw145/0.1  -fdebug-prefix-map=/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver=/usr/src/debug/gsw145/0.1  -fmacro-prefix-map=/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver=/usr/src/debug/gsw145/0.1  -fdebug-prefix-map=/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver=/usr/src/debug/gsw145/0.1  -fdebug-prefix-map=/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/recipe-sysroot=  -fmacro-prefix-map=/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/recipe-sysroot=  -fdebug-prefix-map=/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/recipe-sysroot-native=   -fdebug-prefix-map=/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-source=/usr/src/kernel  -fmacro-prefix-map=/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-source=/usr/src/kernel  -fdebug-prefix-map=/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-build-artifacts=/usr/src/kernel  -fmacro-prefix-map=/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-build-artifacts=/usr/src/kernel  LD=aarch64-tdx-linux-ld.bfd   AR=aarch64-tdx-linux-ar  OBJCOPY=aarch64-tdx-linux-objcopy  STRIP=aarch64-tdx-linux-strip O=/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-build-artifacts KBUILD_EXTRA_SYMBOLS=
| make -C /home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-source M=/home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver modules
| make[1]: Entering directory '/home/vishal/oe-core/build/workspace/sources/linux-toradex'
| make[2]: Entering directory '/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-build-artifacts'
| make[4]: Circular /home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver/mxl-gsw145.o <- /home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver/mxl-gsw145.o dependency dropped.
|   CC [M]  /home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver/tag_mxl-gsw145.o
| /home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver/tag_mxl-gsw145.c:28:10: fatal error: dsa_priv.h: No such file or directory
|    28 | #include "dsa_priv.h"
|       |          ^~~~~~~~~~~~
| compilation terminated.
| make[4]: *** [/home/vishal/oe-core/build/workspace/sources/linux-toradex/scripts/Makefile.build:243: /home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver/tag_mxl-gsw145.o] Error 1
| make[3]: *** [/home/vishal/oe-core/build/workspace/sources/linux-toradex/Makefile:1924: /home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/switch-driver] Error 2
| ERROR: oe_runmake failed
| make[2]: Leaving directory '/home/vishal/oe-core/build/tmp/work-shared/verdin-imx8mp/kernel-build-artifacts'
| make[1]: Leaving directory '/home/vishal/oe-core/build/workspace/sources/linux-toradex'
| WARNING: exit code 1 from a shell command.
| make[2]: *** [/home/vishal/oe-core/build/workspace/sources/linux-toradex/Makefile:234: __sub-make] Error 2
| make[1]: *** [Makefile:234: __sub-make] Error 2
| make: *** [Makefile:8: all] Error 2
ERROR: Task (/home/vishal/oe-core/layers/meta-switch-driver/recipes-kernel/gsw145/gsw145_0.1.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 1270 tasks of which 1254 didn't need to be rerun and 1 failed.
NOTE: Writing buildhistory
NOTE: Writing buildhistory took: 4 seconds

Summary: 1 task failed:
  /home/vishal/oe-core/layers/meta-switch-driver/recipes-kernel/gsw145/gsw145_0.1.bb:do_compile
    log: /home/vishal/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/gsw145/0.1/temp/log.do_compile.297028
Summary: There was 1 WARNING message.
Summary: There were 2 ERROR messages, returning a non-zero exit code.

Please help me how to fix this? Creating custom meta layer for addition of switch is it correct method?

Thanks,

Vishal

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


Solving the DSA Driver Build Error

The error you’re encountering is a missing header file issue (dsa_priv.h: No such file or directory). This is a common problem when building custom kernel modules that depend on internal kernel headers not exposed in the standard build environment.

Root Cause Analysis

The dsa_priv.h header is an internal DSA (Distributed Switch Architecture) subsystem header that’s not typically available to external modules. Your custom ethernet switch driver is trying to include this private header, which causes the compilation to fail.

Solution Approach

Creating a custom meta layer is indeed the correct method for adding custom drivers to your Yocto build(1). However, you need to address the missing header dependency.

Recommended Solutions

Option 1: Modify Your Driver Code

If possible, modify your switch driver to use only public DSA APIs instead of relying on private headers. The Linux DSA subsystem provides public interfaces that should be sufficient for most switch implementations.

Option 2: Add the Missing Header via Kernel Customization

You can customize the kernel to make the required header available(1). Create a kernel patch that either:

  1. Makes dsa_priv.h available to external modules
  2. Copies the necessary definitions to a public header

Here’s how to add a kernel patch in your custom meta layer(1):

# Create the patch file structure
recipes-kernel/linux/linux-toradex/your-dsa-header.patch

Option 3: Build as In-Tree Module

Consider integrating your driver directly into the kernel source tree rather than as an external module. This approach gives you access to all internal headers.

Meta Layer Structure Verification

Your custom meta layer approach is correct(1). Ensure your layer structure follows this pattern:

meta-switch-driver/
├── conf/
│   └── layer.conf
└── recipes-kernel/
    └── gsw145/
        ├── gsw145_0.1.bb
        └── files/
            └── (your driver source files)

Additional Troubleshooting Steps

  1. Check Kernel Configuration: Ensure DSA support is enabled in your kernel configuration
  2. Verify Dependencies: Make sure all required kernel modules and dependencies are properly configured
  3. Review Driver Compatibility: Confirm your driver is compatible with the Linux kernel version (6.6.94) being used

Network Configuration Context

Since you’re working with ethernet switches, you may also want to review the network configuration documentation(2) to ensure proper integration once your driver builds successfully.

The custom meta layer approach you’re using is the standard and recommended method for adding custom drivers to Toradex Reference Images(1)(3).

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

I have check and below directories and looks correct to me:

But still same error.

Please guide me how to fix fatal error: dsa_priv.h: No such file or directory

Hey @vishalborle92,

Is it possible you are wanting to include ../net/dsa/dsa.h instead?

-Eric

Thanks @eric.tx for your response.

This already included

What is the recommend way to fix this error? Can download “dsa_priv.h“ file and include in kernel? but if did this another API errors getting?

Hey @vishalborle92,

Looking at the comments notes for upstream linux kernel (6.6) it looks like there was effort to remove or “kill off” dsa_priv.h. Stating the contents have been restructured.

See comment notes throughout here: such as netlink.h

Was this comment code supplied from a vendor? And if so did they say what linux kernel is supported? It may be that is it still supported, but via other headers.

-Eric