There is more information on compiling kernels in the Documentation with the particular release (R28.1 is what JetPack 3.1 installs), plus eLinux.org. Beware that there may be differences in instructions for older releases versus the R28.1 or newer release (this is when TX1 and TX2 merged rootfs):
https://developer.nvidia.com/embedded/linux-tegra (see Documentation and Kernel Customization within this)
The following is not an inclusive list…use the docs above, use the following for a quick start…
The Linux kernel has many drivers and features you will never use. Building a module implies building a driver based on a kernel configured to match your existing and running system…inserting the module against a kernel not configured as matching could fail since there may be mismatched features. So adding a kernel module for addition of a feature is simple, but you must start with a configuration compatible with your running system. The file “/proc/config.gz” contains that configuration after it is copied to your build location, run through gunzip, and renamed as “.config”.
Assuming you have the kernel source on your Jetson, add package “libncurses5-dev” to make convenience config tools available from console:
sudo apt-get install libncurses5-dev
Now when you are at the top of your kernel source you can use “make nconfig”, or “make menuconfig”, or a number of other config targets to bring up a config utility. I prefer nconfig. Don’t actually save or use something from this utility unless you already have your “.config” in that directory.
Having .config in the build location (which will be the same as where you run “make” from if you don’t use the “O=/wherever” option to produce temp output somewhere outside of your clean source tree) implies this config will be read at the start of “make nconfig”, or when actually building something. You will be prompted to save changes to “.config” when you exit.
Understand that the output from the command “uname -r” is the kernel source version as prefix, and something from the config (“CONFIG_LOCALVERSION”) which produces the suffix. My R28.1 TX2 has “4.4.38-tegra”. This means the kernel source is “4.4.38”, and CONFIG_LOCALVERSION is “-tegra”. Modules are searched for at “/lib/modules/$(uname -r)/”. If base kernel version is different, or if CONFIG_LOCALVERSION is changed, then your existing modules won’t be found. Match CONFIG_LOCALVERSION as “-tegra” so module search location is matched.
General setup ->
() Local version - append to kernel release
# Hit enter while highlighting the above and type "-tegra" without quotes.
# Hit escape key to go back up one directory.
File systems ->
CD-ROM/DVD Filesystems ->
ISO 9660 CDROM file system support
# Hit the "m" key to set the feature as a module ("*" from "y" implies integrated,
# you need a module). You might also want to add UDF file system.
# Hit escape as many times as needed, and save on exit.
With the above you are set to build. Some instructions are for cross-compiling on a host PC, but you may be able to build just a module on the Jetson itself (I haven’t tried the ISO9660 module). You will see examples with “make O=something”…the O= keeps the original source clean and puts the output in some alternate location…if you do this, then the .config file must also be there and you must use the O= in every build command. The “O=” is optional…most documents which don’t use this work with the “O=” and it is recommended to keep your kernel source tree unmodified and clean even if you are not cross compiling from a desktop PC.
Putting the module in place is just a file copy to somewhere in “/lib/modules/$(uname -r)/”. Once there typing “sudo depmod -a” should tell the system about the module, and either rebooting or using modprobe on the module will put it in place. Then the CD reads should just work.
A typical sequence might be:
cp /proc/config.gz .
cp config .config
make O=~/some/where/temporary nconfig
# ...do stuff like set LOCALVERSION and add ISO9660 as a module...
make O=~/some/where/temporary modules_prepare
make -j4 O=~/some/where/temporary modules
# ...find your module.ko somewhere in a "driver" subdirectory...
# ...copy it to the mirror of that subdirectory in "/lib/modules/$(uname -r)/kernel drivers/..."
sudo depmod -a
Incidentally, “make mrproper” will make your kernel source tree pristine, and “make O=~/some/where/temporary mrproper” will clean your alternate destination out…including the “.config” file. Feel free to experiment, then run make mrproper to start over.