Compile/Build and INSERT the module FOR Target machine FROM MY local/host machine

Hello ,

MY TARGET MACHINE: I have flashed linux kernel version 4.9 (L4T 32.4.4) Ubuntu 18.04 , in my Jetson NX SOM module carrier board.

IN MY HOST (linux) MACHINE

  1. I have created a driver file “gpio-ls1-led.c”
  2. And made changes in all the required file like MAKEFILE , Kconfig,tegra_defconfig,created a dtsi file and included it in main (tegra194-p3668-all-p3509-0000.dts) file. Even my compilation and build is successful.

My question is , How can i compile + build and Insert the module for my target machine from my local machine.
Because usually if we try to insert the module (sudo insmod gpio-ls1-led.ko ) from our local machine , then it shows the error of insmod: ERROR: could not insert module gpio-ls1-led.ko: Invalid module format

What changes we can do in Makefile or other files.

This sounds like you compiled the module for the wrong architecture. If you build on a PC, then you must use the appropriate cross tools. If using the wrong architecture, then there is no possibility of the module ever working. Did you build natively on the Jetson, or did you build from a PC? If from a PC, did you use cross compile tools?