Looking at a running Jetson’s kernel config I see that the driver is already part of the source tree, but needs activation:
# CONFIG_FB_SM750 is not set
The best native compile is to add source to the Jetson (make sure you have enough disk space for any temporary output since it is likely there is not enough output space on a TX2, e.g., a thumb drive could be used for output), set the configuration to match the existing Jetson (e.g., copy “/proc/config.gz” to the output location “O=/some/where”, gunzip it, and rename it “.config”), and note the output of “uname -r”. The suffix of “uname -r” is what the “CONFIG_LOCALVERSION” of the “.config” should be set to. If nothing has ever changed, then this would be “-tegra”. Example in “.config” at the “O=/some/where” compile option:
CONFIG_LOCALVERSION="-tegra"
This means at this point the kernel being built is an exact match to what is running. You can then use a config editor (many people use “menuconfig”, I use “nconfig” since it can search for symbols, e.g., you can search for “SM750”), and see if it is available as a module. If so, then use the “m” key to enable this. Then, from the source directory:
make O=/some/where modules_prepare
make O=/some/where modules
There are then options if you want to copy the module to a temp location (I recommend sending to a temp location, followed by manual copy of the single module to the right “/lib/modules/$(uname -r)/kernel” subdirectory.
Notes:
- If you have not installed the correct “
libncurses5-dev” package, then the config editors won’t be available. You would fix this via “sudo apt-get install libncurses5-dev”.
- I recommend building the full kernel “
make -j 6 O=/some/where Image” even if you won’t use it. This also performs the “modules_prepare” step, but more importantly, is something of an acid test for whether things are going to work correctly. This takes time, but if Image compiles correctly once, then you know everything else should already be set up properly. “modules_prepare” should also work without building “Image”, but is not necessarily a thorough QA test.
- If
CONFIG_FB_SM750 cannot be set as a module, meaning the “m” key won’t enable this, and only the “y” key can be used, then you must compile Image. You’d want to use a new file name to install this, and leave the original file name intact. Then add a new entry to “/boot/extlinux/extlinux.conf” to point at the new kernel (if it works, then you could remove the original entry and kernel, but it is very valuable to have a backup kernel). Note that if you must build Image for install, that you also need all modules built and installed. You’d want to alter the “CONFIG_LOCALVERSION” to something other than “-tegra” so that the module directory is new and not mixed with the original, e.g., something like:
CONFIG_LOCALVERSION="-sm750"
Hopefully this can be built only as a module. Here is something of a template/recipe for native build (the directories are only examples…you should point at some temporary storage mount point so you have enough space…though I suppose if you have very little on the Jetson that something like a thumb drive would not be needed):
# --- Setting Up: -------------------------------------------------------
# DO NOT BUILD AS ROOT/SUDO!!! You might need to install source code as root/sudo.
# --- Notes: ------------------------------------------------------------
# It is assumed kernel source is at "/usr/src/sources/kernel/kernel-4.9".
# Check if you have 6 CPU cores, e.g., via "htop".
# If you are missing cores, then experiment with "sudo nvpmodel -m 0, -m 1, and -m 2".
# Perhaps use "htop" to see core counts.
# Using "-j 6" in hints below because of assumption of 6 cores.
# -----------------------------------------------------------------------
mkdir -p "${HOME}/build/kernel"
mkdir -p "${HOME}/build/modules"
mkdir -p "${HOME}/build/firmware"
export TOP="/usr/src/sources/kernel/kernel-4.9"
export TEGRA_KERNEL_OUT="${HOME}/build/kernel"
export TEGRA_MODULES_OUT="${HOME}/build/modules"
export TEGRA_FIRMWARE_OUT="${HOME}/build/firmware"
export TEGRA_BUILD="${HOME}/build"
# Compile commands start in $TOP, thus:
cd $TOP
# Do not forget to provide a starting configuration. Probably copy of "/proc/config.gz",
# to $TEGRA_KERNEL_OUT, but also perhaps via the make target of "`tegra_defconfig`",
# plus your own edit after initial config:
make O=$TEGRA_KERNEL_OUT nconfig
# If building the kernel Image (not needed if only modules being built, but recommended
# for testing if all is well before building modules):
make -j 6 O=$TEGRA_KERNEL_OUT Image
# If you did not build Image, but are building modules (only needed if "Image" was not built):
make -j 6 O=$TEGRA_KERNEL_OUT modules_prepare
# To build modules:
make -j 6 O=$TEGRA_KERNEL_OUT modules
# To build device tree content (NOT NEEDED BUT SHOWN):
make -j 6 O=$TEGRA_KERNEL_OUT dtbs
# To put modules in "$TEGRA_MODULES_OUT" (then one would look at the path within this
# subdirectory to see where your kernel module was placed, and copy it manually to the
# similar path at "/lib/modules/$(uname -r)/kernel", noting that we are using the "uname -r"
# of the new kernel, not the old kernel...perhaps it is the same if using just a module, but if
# a new Image is being installed, then "uname -r" would have changed):
make -j 6 O=$TEGRA_KERNEL_OUT INSTALL_MOD_PATH=$TEGRA_MODULES_OUT
# To put firmware and device trees in "$TEGRA_FIRMWARE_OUT" (NOT NEEDED FOR YOU
# BUT SHOWN):
make -j 6 O=$TEGRA_KERNEL_OUT INSTALL_FW_PATH=$TEGRA_FIRMWARE_OUT