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.

How do the CAN drivers get loaded?

I'm trying to understand how CAN drivers get loaded into the TI AM335x based Linux system. When I check the output of lsmod:

[root /usr]# lsmod
Module                  Size  Used by
c_can_platform          4172  0
c_can                   8180  1 c_can_platform
can_dev                 6951  1 c_can

I can see the CAN drivers in the system and when I run a dmesg I can see them being loaded:

[    3.745933] CAN device driver interface
[    3.891592] c_can_platform 481cc000.d_can: c_can_platform device registered (regs=fa1cc000, irq=68)

but I don't know what loads them. I've noticed there's no /etc/modules or /etc/modules.conf file and I can't seem to find any "modprobe" or "insmod" calls in the /etc/init.d scripts which load the CAN drivers.

So where are these loaded? And as a general side note, is there anyway to determine what mechinsm/scripts was used to load a driver to begin with?

  • Hi Mike,

    Can you share which TI SDK version are you using?

    Check the defconfig file in your sources. It is possible that CAN drivers are NOT built as loadable modules (m), but built in the kernel image (y).

    Best Regards,
    Yordan
  • Hi Yordan,

    Yordan Kovachev said:


    Can you share which TI SDK version are you using?

    It is version 07.00.00.00

    Yordan Kovachev said:


    It is possible that CAN drivers are NOT built as loadable modules (m), but built in the kernel image (y).

    Nope, I can see the modules loaded:

    [root /etc]# lsmod
    Module Size Used by
    c_can_platform 4172 0
    c_can 8180 1 c_can_platform
    can_dev 6951 1 c_can
    

    They exist as .ko's on the system:

    [root /etc]# ls /lib/modules/`uname -r`/kernel/drivers/net/can
    c_can can-dev.ko
    [root /etc]# ls /lib/modules/`uname -r`/kernel/drivers/net/can/c_can
    c_can.ko c_can_platform.ko

    And in the defconfig file they are clearly set as modules:

    #
    # CAN Device Drivers
    #
    # CONFIG_CAN_VCAN is not set
    # CONFIG_CAN_SLCAN is not set
    CONFIG_CAN_DEV=m
    CONFIG_CAN_CALC_BITTIMING=y
    # CONFIG_CAN_LEDS is not set
    # CONFIG_CAN_AT91 is not set
    # CONFIG_CAN_TI_HECC is not set
    # CONFIG_CAN_MCP251X is not set
    # CONFIG_CAN_FLEXCAN is not set
    # CONFIG_PCH_CAN is not set
    # CONFIG_CAN_GRCAN is not set
    # CONFIG_CAN_SJA1000 is not set
    CONFIG_CAN_C_CAN=m
    CONFIG_CAN_C_CAN_PLATFORM=m

    So I am quite confident they are not built into the kernel.

  • Hi Mike,

    Have you done any modifications to your kernel? 

    I just tested prebuilt images from SDK7.0 on my beaglebone black and I didn't see the behavior you describe.

    Here is the result from my test:

    1. boot up BBB with SDK7.0:

    am335x-evm login: root                                                                                                                                                    

    root@am335x-evm:~# ls                                                                                                                                                    

    root@am335x-evm:~#                                                                                                                                                        

    root@am335x-evm:~#                                                                                                                                                        

    root@am335x-evm:~# lsmod                                                                                                                                                  

    Module                  Size  Used by                                                                                                                                    

    g_mass_storage          1787  0                                                                                                                                          

    usb_f_mass_storage     32479  2 g_mass_storage                                                                                                                            

    libcomposite           30114  2 usb_f_mass_storage,g_mass_storage                                                                                                        

    configfs               19119  3 libcomposite,usb_f_mass_storage                                                                                                          

    bufferclass_ti          5405  0                                                                                                                                          

    omaplfb                11426  0                                                                                                                                          

    cryptodev              31027  1                                                                                                                                          

    musb_dsps               6511  0                                                                                                                                          

    musb_hdrc              52593  1 musb_dsps                                                                                                                                

    snd_soc_omap            2494  0                                                                                                                                          

    snd_pcm_dmaengine       2997  1 snd_soc_omap                                                                                                                              

    snd_soc_core           99221  1 snd_soc_omap                                                                                                                              

    snd_compress            7419  1 snd_soc_core                                                                                                                              

    regmap_spi              1469  1 snd_soc_core                                                                                                                              

    snd_pcm                66734  3 snd_soc_core,snd_soc_omap,snd_pcm_dmaengine                                                                                              

    snd_page_alloc          4843  1 snd_pcm                                                                                                                                  

    snd_timer              16028  1 snd_pcm                                                                                                                                  

    snd                    45368  4 snd_soc_core,snd_timer,snd_pcm,snd_compress                                                                                              

    soundcore               4767  1 snd                                                                                                                                      

    pvrsrvkm              175491  2 bufferclass_ti,omaplfb                                                                                                                    

    musb_am335x             1199  0

    2.  Insert can modules:

      root@am335x-evm:~# cd /lib/modules/3.12.10-ti2013.12.01/kernel/drivers/net/can

      root@am335x-evm:/lib/modules/3.12.10-ti2013.12.01/kernel/drivers/net/can# insmod can-dev.ko

      [  176.598823] CAN device driver interface  

     root@am335x-evm:/lib/modules/3.12.10-ti2013.12.01/kernel/drivers/net/can# cd c_can

     root@am335x-evm:/lib/modules/3.12.10-ti2013.12.01/kernel/drivers/net/can/c_can# insmod c_can.ko

     root@am335x-evm:/lib/modules/3.12.10-ti2013.12.01/kernel/drivers/net/can/c_can# insmod  c_can_platform.ko

    And only after this I have the can drivers loaded in the kernel:

    root@am335x-evm:/lib/modules/3.12.10-ti2013.12.01/kernel/drivers/net/can/c_can# cd ~

    root@am335x-evm:~# lsmod                                                                                                                                                  

    Module                  Size  Used by                                                                                                                                    

    c_can_platform          4176  0                                                                                                                                          

    c_can                   8182  1 c_can_platform                                                                                                                            

    can_dev                 6951  1 c_can                                                                                                                                    

    g_mass_storage          1787  0                                                                                                                                          

    usb_f_mass_storage     32479  2 g_mass_storage                                                                                                                            

    libcomposite           30114  2 usb_f_mass_storage,g_mass_storage                                                                                                        

    configfs               19119  3 libcomposite,usb_f_mass_storage                                                                                                          

    bufferclass_ti          5405  0                                                                                                                                          

    omaplfb                11426  0                                                                                                                                          

    cryptodev              31027  1                                                                                                                                          

    musb_dsps               6511  0                                                                                                                                          

    musb_hdrc              52593  1 musb_dsps                                                                                                                                

    snd_soc_omap            2494  0                                                                                                                                          

    snd_pcm_dmaengine       2997  1 snd_soc_omap                                                                                                                              

    snd_soc_core           99221  1 snd_soc_omap                                                                                                                              

    snd_compress            7419  1 snd_soc_core                                                                                                                              

    regmap_spi              1469  1 snd_soc_core                                                                                                                              

    snd_pcm                66734  3 snd_soc_core,snd_soc_omap,snd_pcm_dmaengine                                                                                              

    snd_page_alloc          4843  1 snd_pcm                                                                                                                                  

    snd_timer              16028  1 snd_pcm                                                                                                                                  

    snd                    45368  4 snd_soc_core,snd_timer,snd_pcm,snd_compress                                                                                              

    soundcore               4767  1 snd                                                                                                                                      

    pvrsrvkm              175491  2 bufferclass_ti,omaplfb                                                                                                                    

    musb_am335x             1199  0                                                                                                                                          

    Best Regards,

    Yordan