Linux drivers generalities

From ArmadeusWiki
Jump to: navigation, search

This page summarizes all the important things to know when talking about Linux drivers in general.

What are they ?

Linux drivers are the piece of code running inside the kernel itself that are assigned to a specific peripheral driving. They can exist in 2 forms:

  • they can be statically linked to the kernel image. In that case we refer to static drivers
  • or they can be compiled as loadable modules (the famous .ko files)

How to use them

When compiled as "static" (<*>, in Linux menuconfig) they are integrated in the Linux image (buildroot/binaries/apfxx/linux-kernel-2.6.xx-arm.bin), so when you reflash your kernel, the driver are immediately available. But if you don't use them, they consume some place in memory (RAM).

When compiled as "module" (<M>, in Linux menuconfig) they can be dynamically loaded at runtime, when necessary. For example if you need to load the FPGA at a particular time you can do a:

 # modprobe fpga_loader

or

 # insmod /lib/modules/2.6.xx/drivers/armadeus/fpga/fpga_loader.ko

Where should I copy modules ?

modprobe knows where to find the corresponding .ko file and find all its dependencies thanks to the /lib/modules/2.6.2x/modules.dep file. So If you compile new drivers as module and copy them on your board "manually" (ie TFTP or NFS), don't forget to update /lib/modules/2.6.2x/modules.dep too. On your Host this file can be found in buildroot/project_build_armvxx/apfxx/root/lib/modules/2.6.2x/modules.dep. All modules are located in /lib/modules/2.6.xx/drivers/ subdirectories on your target and buildroot/project_build_armvxx/apfxx/root/lib/modules/drivers on your Host.