Can't compile LKM for custom sensor driver

Hello,

I am trying to compile my imaging sensor driver as a module with the command:

make ARCH="arm64" O=$TEGRA_KERNEL_OUT -j$(nproc)

Yet, the compiler throws out this error:

rm drivers/misc/mods/mods.dtb drivers/misc/mods/mods.dtb.S
  Building modules, stage 2.
  MODPOST 656 modules
WARNING: could not open drivers/misc/mods/mods.dtb.S: No such file or directory
FATAL: modpost: GPL-incompatible module imx392.ko uses GPL-only symbol 'tegracam_v4l2subdev_register'
/home/ubuntu/repositories/Stereo-Vision_TX2/build/Linux_for_Tegra/sources/kernel/kernel-4.9/scripts/Makefile.modpost:107: recipe for target '__modpost' failed
make[2]: *** [__modpost] Error 1
/home/ubuntu/repositories/Stereo-Vision_TX2/build/Linux_for_Tegra/sources/kernel/kernel-4.9/Makefile:1333: recipe for target 'modules' failed
make[1]: *** [modules] Error 2
make[1]: Leaving directory '/home/ubuntu/repositories/Stereo-Vision_TX2/build/Linux_for_Tegra/images'
Makefile:171: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2

I wrote my driver almost like the IMX185 (v2) driver. It compiles correctly if the driver is set to “y” in tegra_defconfig.
Any idea how I can solve this issue?

I tried following the building of EKM and got as far as just the preparation of the sources. The docs specify to change the directory to <path_to_module_source>. I looked around, tried different paths but I can’t find which path is meant by “module_source”.

Furthermore, since I updated the sources to 32.4.2, I get these errors while compiling:

dpkg: error processing package ... (--install):
   dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ...:
Package ... is not configured yet

Errors were encountered while processing:
 nvidia-l4t-init
 nvidia-l4t-x11
 nvidia-l4t-3d-core
 nvidia-l4t-camera
 nvidia-l4t-cuda
 nvidia-l4t-graphics-demos
 nvidia-l4t-gstreamer
 nvidia-l4t-multimedia

Did you build the r32.3.1 or r32.4.x ?
These version are build imx185 as LKM without problem.