Problem in First-Patch-Tutorial

SIMRAN SINGHAL singhalsimran0 at gmail.com
Mon Mar 13 06:08:07 EDT 2017


On Mon, Mar 13, 2017 at 1:05 PM, Greg KH <greg at kroah.com> wrote:
> On Mon, Mar 13, 2017 at 11:39:36AM +0530, SIMRAN SINGHAL wrote:
>> On Mon, Mar 13, 2017 at 10:42 AM, Alexander Kapshuk
>> <alexander.kapshuk at gmail.com> wrote:
>> > On Mon, Mar 13, 2017 at 6:18 AM, SIMRAN SINGHAL
>> > <singhalsimran0 at gmail.com> wrote:
>> >> On Mon, Mar 13, 2017 at 12:05 AM, Alexander Kapshuk
>> >> <alexander.kapshuk at gmail.com> wrote:
>> >>> On Sun, Mar 12, 2017 at 8:20 PM, SIMRAN SINGHAL
>> >>> <singhalsimran0 at gmail.com> wrote:
>> >>>> On Sun, Mar 12, 2017 at 10:15 PM, Alexander Kapshuk
>> >>>> <alexander.kapshuk at gmail.com> wrote:
>> >>>>> On Sun, Mar 12, 2017 at 5:34 PM,  <valdis.kletnieks at vt.edu> wrote:
>> >>>>>> On Sun, 12 Mar 2017 15:49:31 +0200, Alexander Kapshuk said:
>> >>>>>>
>> >>>>>>> Are these drivers, drivers/iio/dummy/{iio_dummy_evgen,iio_dummy}.ko,
>> >>>>>>> something of your own making, as I'm not seeing them in the kernel
>> >>>>>>> source tree?
>> >>>>>>>
>> >>>>>>> The 'modules_install' make target installs drivers that have been
>> >>>>>>> compiled as modules as opposed to those compiled into the kernel, into
>> >>>>>>> /lib/modules/`uname -r`. For your own modules added to the kernel
>> >>>>>>> source tree, or built out-of-tree, that would involve putting
>> >>>>>>> appropriate entries into  Kconfig and/or Makefiles.
>> >>>>>>>
>> >>>>>>> Modeprobe expects your module to be found in /lib/modules/`uname -r`.
>> >>>>>>> Otherwise, your module won't get loaded.
>> >>>>>>
>> >>>>>> One other thing to remember is that although 'make modules_install' will
>> >>>>>> take all the .ko files from in-tree modules and put them in their proper
>> >>>>>> place in /lib/modules/`uname-r`  and then run 'depmod', many out-of-tree
>> >>>>>> Makefiles manage to forget to do that last step.
>> >>>>>>
>> >>>>>> modprobe is a wrapper around insmod - and the file produced by 'depmod'
>> >>>>>> are what the wrapper uses to find the module.
>> >>>>>
>> >>>>> Thanks for elaborating on that.
>> >>>>
>> >>>> Still not working
>> >>>>
>> >>>> First I executed following commands:-
>> >>>>
>> >>>> $ make drivers/iio/dummy/iio_dummy_evgen.ko
>> >>>> $ make drivers/iio/dummy/iio_dummy.ko
>> >>>>
>> >>>> Above commands executed successfully
>> >>>>
>> >>>> Then I run following command:
>> >>>> $ insmod iio_dummy_evgen.ko
>> >>>>
>> >>>> Getting following error:
>> >>>> insmod: ERROR: could not load module iio_dummy_evgen.ko: No such file
>> >>>> or directory
>> >>>>
>> >>>> And, then I try executing them from driver/staging/dummy and then I
>> >>>> got this error:
>> >>>> insmod: ERROR: could not insert module iio_dummy_evgen.ko: Operation
>> >>>> not permitted
>> >>>
>> >>> You have to run insmod as user root. Either specify the full path to
>> >>> your module, or cd into the directory where the module is and run
>> >>> insmod from there.
>> >>
>> >> I tried this before also but as you said I tried it again:
>> >> # insmod iio_dummy_evgen.ko
>> >> insmod: ERROR: could not insert module iio_dummy_evgen.ko: Invalid module format
>> >>
>> >> Now, I am getting this error.
>> >
>> > Sounds like your kernel module has been compiled for kernel sources
>> > whose version is different to the version of the kernel you are trying
>> > to load your module into.
>> >
>> > See http://www.tldp.org/LDP/lkmpg/2.6/html/x380.html for details.
>> >
>> > In other words, the version output by 'uname -r' must match the
>> > version output by 'modinfo iio_dummy_evgen.ko | grep vermagic'.
>>
>> Hi,
>>
>> The problem is same you got, I have different versions of uname-r and the
>> version output I got through vermagic.
>>
>> # modinfo iio_dummy_evgen.ko
>> filename:
>> /home/simran/git/kernels/staging/drivers/iio/dummy/iio_dummy_evgen.ko
>> license:        GPL v2
>> description:    IIO dummy driver
>> author:         Jonathan Cameron <jic23 at kernel.org>
>> srcversion:     A8AC238EC07833E018CAF7B
>> depends:        industrialio
>> intree:         Y
>> vermagic:       4.11.0-rc1+ SMP mod_unload modversions
>>
>>
>> $ uname -r
>> 4.10.0-rc3+
>>
>> How to deal with this?
>
> You did look in the kernel log when modprobe or insmod failed, right?
> It should tell you what went wrong.
>
> As others pointed out, you need to build your module against the kernel
> you are running.
>
Greg, I got that I have to build the module against the kernel I am using.
But, How can I do this?

> good luck!
>
> greg k-h



More information about the Kernelnewbies mailing list