For the i.MX8MP-EVK Debian image built with Flexbuild, the practical answer is: do not rely on apt install linux-headers-$(uname -r) on the target . The retrieved NXP material shows Flexbuild builds the kernel, DTBs, modules, boot image, and rootfs, but I did not find an i.MX8MP-specific Flexbuild option that generates and preinstalls a matching linux-headers-* package into the Debian rootfs. The supported/clean workflow is to build your out-of-tree module against the same compiled kernel tree used by Flexbuild, then copy the .ko to the board.
Recommended workflow:
cd flexbuild
. setup.env
bld docker
. setup.env
bld host-dep
# Full image, or at least the kernel
LOG_LEVEL=0 bld -m imx8mpevk
# or:
LOG_LEVEL=0 bld linux -m imx8mpevk
The Debian SDK guide lists bld -m imx8mpevk as the full build command and bld linux -m imx8mpevk as the separate kernel build command; it also says the kernel-related source is under components_lsdk2512/linux/ , and the compiled output is under build_lsdk2512/linux/linux/arm64/IMX for the i.MX platform example.
Then build your external module on the host against that compiled/prepared kernel tree, for example:
obj-m += my_driver.o
KERNEL_SRC ?= /path/to/flexbuild/components_lsdk2512/linux
all:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
For external modules, NXP’s current i.MX Linux 6.12 guide says the requirements are a compiled kernel, a board running the same kernel version, and a toolchain; it also notes that a full kernel compilation is required to generate the headers and symbol files needed for external module compilation. The same guide uses the standard external-module form:
make -C $(KERNEL_SRC) M=$(PWD) modules
and then copies the resulting .ko to the board for insmod .
If you specifically want on-target builds, you can manually install a matching prepared kernel tree on the target, but treat it as a manual workaround rather than a documented i.MX8MP Flexbuild “install headers” feature:
# on target
sudo mkdir -p /usr/src/linux-headers-$(uname -r)
sudo ln -sfn /usr/src/linux-headers-$(uname -r) /lib/modules/$(uname -r)/build
Copy the matching Flexbuild kernel source/build artifacts from the host into that directory, including the generated files and Module.symvers . Then on the target:
cd /usr/src/linux-headers-$(uname -r)
make oldconfig
make prepare
# or, for module builds:
make modules_prepare
The important points are:
- The kernel source/build tree must match the exact kernel running on the board: check uname -r .
- Module.symvers should be present; otherwise module versioning/dependency information may be missing.
- make oldconfig && make prepare / make modules_prepare is the usual step to prepare the tree for external module builds.
- Native builds on the board are usually slower; NXP guidance generally recommends host-side cross-compilation for i.MX external modules.
So the short answer is: Flexbuild can build the matching kernel, but for i.MX8MP Debian I would build the module on the host against the Flexbuild kernel tree, not try to install distro-style linux-headers on the board. If you need on-target iteration, copy the matching prepared kernel tree to /usr/src/linux-headers-$(uname -r) and point /lib/modules/$(uname -r)/build at it.
Use the Flexbuild-compiled kernel tree as your “headers” source; a packaged, apt-installable linux-headers-$(uname -r) flow is not documented for i.MX8MP Flexbuild Debian in the material retrieved.