I just did a fresh install of L4T 31.0.2 and tried building an external kernel module. It fails because kernel headers installed to /usr/src/linux-headers-4.9.108-tegra are broken - several files are missing and there are binaries built for x86_64 architecture present. I’ve managed to work around this issue by doing the following:
cd /usr/src/
sudo wget -O public_sources_31.0.2.tbz2 'https://developer.nvidia.com/embedded/dlc/l4t-sources-31-0-2'
sudo tar --no-same-owner -xf public_sources_31.0.2.tbz2 public_sources/kernel_src.tbz2
sudo tar --no-same-owner -xf public_sources/kernel_src.tbz2
zcat /proc/config.gz | sudo tee kernel/kernel-4.9/.config >/dev/null
sudo sed -i '/^EXTRAVERSION/ c EXTRAVERSION = -tegra' kernel/kernel-4.9/Makefile
sudo cp linux-headers-4.9.108-tegra/{modules.builtin,modules.order,Module.symvers,System.map} kernel/kernel-4.9/
sudo ln -snf /usr/src/kernel/kernel-4.9 /lib/modules/4.9.108-tegra/build
Then I prepared the sources the usual way:
sudo make -C /lib/modules/"$(uname -r)"/build modules_prepare
After that a kernel module can be built as normal.
It would be nice if linux-headers were fixed in next release. For example everything works fine with TX1 and TX2 in L4T R28.*.
You saved me a ton of time figuring this out so big thanks for sharing. Managed to build video capture driver module on Xavier (for Sensoray mPCIe card) and it works great.
I will probably need to re-flash but you are right the L4T documentation implies this should work without tinkering on the target. Just need to do module_prepare. I will give this a go when I next re-flash and confirm.
I was having issues but have been hacking away so really need to re-flash before I can confirm all is good.
FYI, you should be able to build the kernel and modules natively on the Xavier. However, you’d want to install the compatibility “gcc-6” package (this is the version 6.4 compiler mentioned in docs for kernel build):
TX2/TX1 had similar issues with some versions of L4T, but they were fixed in R28.x - make modules_prepare works there as expected. On L4T R31.0.2 make modules_prepare fails. I don’t want to cross-compile external module from host PC, I need to do it on Tegra itself. So which steps are we talking about exactly?
Basically the issue here is that kernel headers that get installed in L4T R31.0.2 are useless. Something got broken in headers package generation when you moved from R28 to R31.
root@jetson-123:/usr/src/linux-headers-4.9.108-tegra/kernel-4.9# make modules_prepare
seems to work, finally,
Now I can continue with my investigation of the issue of use of onboard CSI camera for video-chat purpose.
However, now I am stuck at the point where I need to rewrite the sequence:
gst-launch-1.0 -ev nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=640, height=480, framerate=30/1, format=NV12' ! nvvidconv flip-method=0 ! videoconvert ! v4l2sink device=/dev/video2
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstNvArgusCameraSrc:nvarguscamerasrc0.GstPad:src: caps = video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)NV12, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)NV12, framerate=(fraction)30/1
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)NV12, framerate=(fraction)30/1
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 2592 x 1944 FR = 29.999999 fps; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 34000, max 550385000;
GST_ARGUS: 2592 x 1458 FR = 29.999999 fps; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 34000, max 550385000;
GST_ARGUS: 1280 x 720 FR = 120.000005 fps; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 22000, max 358733000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 2
Output Stream W = 1280 H = 720
seconds to Run = 0
Frame Rate = 120.000005
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
ERROR: from element /GstPipeline:pipeline0/GstNvArgusCameraSrc:nvarguscamerasrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstNvArgusCameraSrc:nvarguscamerasrc0:
streaming stopped, reason not-negotiated (-4)
EOS on shutdown enabled -- waiting for EOS after Error
Waiting for EOS...