This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Diff between kernel modules and default initialization



Hi Experts,

I had worked with kernel modules, separately compiled and used for loading/unloading. How to make it available in default kernel and initialized during startup ?

I had opted it as default in menu conifg and generated the image. But still it is not initialized during startup. Whether I need to initialize it in any startup scripts ?

  • Hi Lyf,

    I had worked with kernel modules, separately compiled and used for loading/unloading. How to make it available in default kernel and initialized during startup ?

    Please check "modutils.sh" file from your filesystem "etc/init.d/modutils.sh"

    If that file present then you have to create soft link with name staring "S" for loading and "K' for unloading.

    Ex:

    S20modutils.sh

    Else,

    For more easier,

    You need to create 2 script file for loading module (inserting) while startup (switch ON) and removing the module while shutdown (reboot/switch OFF) and should place that file under your init runlevel.

    Say e.g:

    If you use init 5 runlevel then you have to create 2 script named "module_load.sh" and "module_unload.sh"

    You have to places those file at "etc/init.d/" of your filesystem.

    then you have to create link file for "module_load.sh"

    ex:

    link -s /etc/init.d/module_load.sh /etc/rc5.d/SXXmodule_load.sh

    where 'XX' priority (minimum no will have get highest priority and will load soon)

    Also, for "unloading", you have to create link file for "module_unload.sh"

    ex:

    link -s /etc/init.d/module_unload.sh /etc/rc5.d/KXXmodule_unload.sh

    Note:

    "module_load.sh" should have "insmod /opt/test.k"

    module_unload.sh should have "rmmod test.ko"

  • Hi Titus,

    Thanks for the reply.

    The one you mentioned above is for automatically loading marked - kernel modules or marked - default kernel code during menuconfig ?

    I could find some of the drivers are initialized during kernel initialization in the dmesg logs as "new <driver> registered". Those drivers are not loadable modules instead the default kernel code. So even that code needs to be initialized like this or if I mark as part of kernel code  it will automatically load itself ?

    Regards,

    Lyf

  • Hi Lyf,

    In "make menuconfig",

    If you want to build SPI driver as inbuilt with kernel, it must be like below,

    [*] SPI support  --->

    If you want to build SPI driver as loadable module ie insert "insmod spi.ko" when you need SPI support, it must be like below,

    [M] SPI support  --->

    Uuse "space" button to select kernel options.

  • Hi Titus,

    Consider I am choosing the below option ,

    In "make menuconfig",

    If you want to build SPI driver as inbuilt with kernel, it must be like below,

    [*] SPI support  --->



    In this case, whether the SPI driver will be initialized by default or any special initialization is required during startup ?

  • Hi Lyf,

    Yes. You are right. "*" means the driver compiled in built with kernel image (uImage or zImage)

    "M" means module; the driver compiled ".ko" when you do "make modules"