How to compile tc358748.c into tc358748.ko file?

Hello,

I want to insmod tc358748.ko after the start of board.
How to compile tc358748.c into tc358748.ko file?

Thank you very much!

You would need to understand compiling the kernel. The documentation which comes with L4T is one place to find this (but it concentrates on cross compiling from a PC so it is slightly more complicated than needs to be). Some issues change depending on release, but here is something basic for native compile directly on the Jetson (mostly you can just exchange “tx2” for “tx1” in this URL):
https://devtalk.nvidia.com/default/topic/1028931/jetson-tx2/aws-greengrass-core-on-nvidia-jetson-tx2-requirements/post/5233943/#5233943

Understand that a module is mostly the same as an integrated feature, except that an integrated feature is always present. No module loading is needed. If you are in one of the menu config editors the “y” key builds something integrated, the “m” key marks something to build as a module". Some features depend on other features so you can’t normally just edit a config file without one of the menu config editors (such as “make nconfig”, “make xconfig”, or “make menuconfig”).

If you create a module you can add it to the correct subdirectory of “/lib/modules/$(uname -r)/”. If you integrate directly into the kernel you’d build the new kernel and copy the Image file to “/boot/Image-some-custom-name-to-avoid-overwriting-original” and then an edit to “/boot/extlinux.conf” to point at the new kernel. If you build an integrated kernel be careful to pay attention to the original URL’s comment on CONFIG_LOCALVERSION…else your kernel might not find its modules.

To see what features your kernel is currently using:

zcat /proc/config.gz | less

To see currently installed features related to “TC358”:

zcat /proc/config.gz | grep 'TC358'

Keep in mind that a driver is typically for a chipset. Some different models might support multiple devices of the same family. If your driver is external to the kernel, then there are more questions and steps…but you’d still need to know all of the above steps since you want the integrated feature instead of a module.

If you have a reason to require this driver before some step during boot, then you could script insert of module. In this case you wouldn’t need an integrated driver, you’d just need to make sure the system has made the module available. Most mandatory integrated features are due to them being needed to mount the file system which has drivers on it. I suspect you don’t really need the driver to be integrated and that the module would suffice.

1 Like