UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
10,306 Views
Registered: ‎11-13-2014

Autoload linux driver at startup

Hello,

 

I'm using petalinux 2015.4 and followed the turorial UG1165 for creating an IP and a custom linux driver. Everythink from the tutorial works well. I can load the module with modprobe and use the driver with the applikation provided.

 

As a next step I wanted that this driver is loaded at boottime without using /etc/modules. I have the device tree entry like this:

 

amba_pl: amba_pl {
   #address-cells = <1>;
   #size-cells = <1>;
    compatible = "simple-bus";
    ranges ;
    Blink_0: Blink@43c00000 {
       compatible = "xlnx,Blink-1.0";
        reg = <0x43c00000 0x10000>;
        xlnx,s00-axi-addr-width = <0x4>;
        xlnx,s00-axi-data-width = <0x20>;
};

 

and used the same name of "compatible" in my device driver:

 

#ifdef CONFIG_OF
static struct of_device_id blink_of_match[] = {
    { .compatible = "xlnx,Blink-1.0", },
    { /* end of list */ },
};

My problem is that it is not loaded at boot time.

 

Any suggestions?

 

PS: I'm booting over nfs.

0 Kudos
8 Replies
Adventurer
Adventurer
10,297 Views
Registered: ‎05-29-2015

Re: Autoload linux driver at startup

Easiest thing would be to add insmod kernel-module.ko command to a script in /etc/rc5.d. Would that meet your requirements? We do that for a lot of configuration type stuff.

10,263 Views
Registered: ‎11-13-2014

Re: Autoload linux driver at startup

Thanks for your suggestion. It also works when I add the module name to /etc/modules file. 

 

The advantage of the kernel loading the driver because of the device tree binding would be that I could check if the device, in my case a fpga device, is availible througt the probe function.

 

I think the problem is that I have to enable open firmware support in my kernel. As I understood when this is not the case only known bindings are accepted (compatible property in the device tree). 

 

I could not find this setting in the kernel configuration.

0 Kudos
Scholar norman_wong
Scholar
10,251 Views
Registered: ‎05-28-2012

Re: Autoload linux driver at startup

I would guess that your custom driver would have to be built-in as opposed to built "out of tree". As far as I know, you would have to modify the linux kernel build/config/make files to add a built-in driver. I don't know of anyway to include an "out of tree" driver into a kernel built.

0 Kudos
Highlighted
10,161 Views
Registered: ‎11-13-2014

Re: Autoload linux driver at startup

I understand but have a look here: http://xillybus.com/tutorials/device-tree-zynq-3

...

When the kernel scans the entries in the bus for devices (i.e. nodes in the device tree under a bus node) it retrieves the “compatible” properties and compares those strings with a list of strings it “knows about”. This happens automatically on two occasions during the boot process:

  • When the kernel starts up, it kicks off compiled-in drivers that match “compatible” entries it finds in the device tree.
  • At a later stage (when /lib/modules is available), all kernel modules that match “compatible” entries in the device tree are loaded.

....

It seems that there is a way to autoload drivers that are out-of-tree (.ko modules).

 

What makes me wondering is that when you create a module with petalinux-create the boilerplate code includes all that stuff that is needed to get data from device tree. In the README file provided:

....

If OF(OpenFirmware) is configured, you need to add the device node to the
DTS(Device Tree Source) file so that the device can be probed when the mdoule is
loaded. Here is an example of the device node in the device tree:

    blink_instance: blink@XXXXXXXX {
        compatible = "vendor,blink";
        reg = <PHYSICAL_START_ADDRESS ADDRESS_RANGE>;
        interrupt-parent = <&INTR_CONTROLLER_INSTANCE>;
        interrupts = < INTR_NUM INTR_SENSITIVITY >;
    };

...

What do you think?

 

0 Kudos
Scholar norman_wong
Scholar
10,142 Views
Registered: ‎05-28-2012

Re: Autoload linux driver at startup

I see where you going on this. I think that in your case, you are missing the update to the modules map file.

My guess is that you need do this on your target
  depmod -a
to update
  /lib/modules/{kernel version}/modules.ofmap
A power cycle would lose your change because the original ramdisk image is unchanged. You then have to transfer that file back to your host, write it into your ramdisk image and update the ramdisk image on the target.

The in-tree loadable modules are put into the modules map file on the root file system image as part of the big build. I don't think an out-of-tree build updates the map file. Or maybe the petalinux build system does. I've no experience with the petalinux build system.

 

0 Kudos
10,126 Views
Registered: ‎11-13-2014

Re: Autoload linux driver at startup

Thanks for you suggestion!

 

I'm running nfsboot, so ramdiskimage is not an issue.

What I can see is that my module is in the right place @ /lib/modules/4.0.0-xilinx/kernel/drivers/blink.ko.

I have also maked depmod -a and the timestamps of the files have changed but I'm missing the file modules.ofmap at all.I just have this files:

 

modules.alias, modules.alias.bin, modules.builtin, modules.builtin.bin, modules.dep, modules.dep.bin, modules.devname, modules.order, modules.softdep, modules.symbols, modules.symbols.bin

 

I think it has something to do with the open firmware support?

0 Kudos
Scholar norman_wong
Scholar
10,117 Views
Registered: ‎05-28-2012

Re: Autoload linux driver at startup

You are way ahead of me on this one. I thought device tree support was the same as open firmware support. If other loadable modules are being loaded by the device tree, I don't see why yours would not. Sorry, thats all I got.

0 Kudos
10,104 Views
Registered: ‎11-13-2014

Re: Autoload linux driver at startup

Anyway, thanks for your help!

0 Kudos