How to get the linux source for Xavier NX

Hello, I’m having an issue locating the linux source for the Xavier NX platform. Specifically, I’m following a tutorial (previously suggested by another user here and an Nvidia staff member) to modify the uvcvideo driver. However, one of the first lines in said tutorial is apt-get source linux-image-unsigned-$(uname -r) which returns Unable to find a source package for linux-image-unsigned-4.9.140-tegra. Is the source for the Tegra version of Linux available? If so, what argument should I use instead of uname -r to find it?
Thanks in advance.

check this link

Thanks for your reply. That looks promising, although I’m not sure yet how to get apt-get source to find a source file on my computer directly. Trying to work on that right now.

Which specific release of L4T are you working with? You can find this by one of these commands:
head -n 1 /etc/nv_tegra_release
`dpkg -l | grep ‘nvidia-l4t-core’

This is available (if apt does not supply what you need; possibly the instructions you saw were for a desktop PC and not a Jetson) in source form for each specific L4T release. You can find your L4T release here (you might have to go there, log in, and then click the link again):
(some content is available via apt-get in newer releases, but all releases are available as source from the particular L4T page)

Within this you will see something like this:
L4T Driver Package (BSP) Sources

This contains much more than just the kernel, but within this the “kernel_src.tbz2” has everything you need (including both in-tree and out-of-tree content of full kernel source). I typically copy the main source to a PC, extract just the kernel_src.tbz2, copy this to the Jetson at either “/usr/src” or “/usr/local/src”, and then unpack using “sudo tar xjf”. Note that you only need “sudo” if the unpack location is owned by root. I prefer this since I think do all compile steps as non-root. This guarantees my original source code won’t be polluted with configuration changes (having source owned by root, and building as non-root is a safety mechanism for future builds when you don’t remember what might have changed).

Result of unpack should show a “sources/kernel/kernel-4.9/” subdirectory. The out-of-tree content will be other subdirectories of “sources/”.

Many thanks, that definitely answers my original question.

The first command you posted returns:

# R32 (release), REVISION: 4.3, GCID: 21589-87, BOARD: t186ref, EABI: aarch64, DATE: Fro Jun 26 04:34:27 UTC 2020

I am now poised to patch that driver, if it becomes necessary. Curiously, the original question was due to the fact that the board I first tried my code with, a Jetson Nano, was running out of bandwidth when two USB 3.0 cameras were connected and activated. This was apparently due to the uvc video driver allocating more bandwidth to the first camera than it actually needed. I made the assumption that when running on the Xavier NX, I would see the same exact error again. I indeed got an error, but a different, so now I’m no longer sure whether the driver patch will solve it. I will start another thread regarding that so as not to go off-topic.