Difference between revisions of "Linux drivers development"

From ArmadeusWiki
Jump to: navigation, search
m (i.MX register access from driver)
m
Line 9: Line 9:
 
Our custom drivers build is integrated to the Linux build system (kbuild).
 
Our custom drivers build is integrated to the Linux build system (kbuild).
 
You can select, in the linux "menuconfig / xconfig" tool, which Armadeus drivers you want to add on your target.
 
You can select, in the linux "menuconfig / xconfig" tool, which Armadeus drivers you want to add on your target.
 +
<pre class="host">
 
  $ make linux26-menuconfig
 
  $ make linux26-menuconfig
 +
</pre>
 +
 +
<pre class="config">
 +
Device Drivers  --->
 +
    Armadeus specific drivers  --->
 +
</pre>
  
 
Here is the way to add custom drivers:
 
Here is the way to add custom drivers:
* in ''armadeus/target/linux/modules/'', add a directory for you driver (ex ''toto/'')
+
* in ''armadeus/target/linux/modules/'', add a directory for your driver (ex ''toto/'')
 
* put reference to this directory in the ''armadeus/target/linux/modules/Makefile'' and ''armadeus/target/linux/modules/Kconfig'' files
 
* put reference to this directory in the ''armadeus/target/linux/modules/Makefile'' and ''armadeus/target/linux/modules/Kconfig'' files
 
* in ''toto/'' put your driver source code and create 2 files, ''Kconfig'' and ''Makefile''. (Use ''armadeus/target/linux/modules/gpio/Makefile'' & ''Kconfig'' as examples.)
 
* in ''toto/'' put your driver source code and create 2 files, ''Kconfig'' and ''Makefile''. (Use ''armadeus/target/linux/modules/gpio/Makefile'' & ''Kconfig'' as examples.)
  
 
To compile all the custom modules, either launch:
 
To compile all the custom modules, either launch:
 +
<pre class="host">
 
  $ make -C armadeus/target/linux/modules/
 
  $ make -C armadeus/target/linux/modules/
 +
</pre>
 
or
 
or
 +
<pre class="host">
 
  $ make linux26
 
  $ make linux26
 +
</pre>
  
only ''make linux26'' will install the modules in target rootfs image
+
only ''make linux26'' will install the modules in the target rootfs image
  
 
== i.MX register access from driver ==
 
== i.MX register access from driver ==
Line 30: Line 41:
 
</source>
 
</source>
  
For example (access to PWM control register):
+
<strike>For example (access to PWM control register):</strike>
 
<source lang="c">
 
<source lang="c">
 
/* enable the PWM */
 
/* enable the PWM */
Line 37: Line 48:
  
 
==Debug==
 
==Debug==
Activate debug messages (from pr_debug() function) on console:
+
* Activate debug messages (from pr_debug() function) on console:
 +
<pre class="apf">
 
  # echo 8 > /proc/sys/kernel/printk
 
  # echo 8 > /proc/sys/kernel/printk
 +
</pre>
  
 
== Useful Links ==
 
== Useful Links ==
Line 44: Line 57:
 
* http://lwn.net/Articles/driver-porting/
 
* http://lwn.net/Articles/driver-porting/
  
<br>[[Image:FrenchFlag.png]][[Fr:Développement de pilotes linux | Cette page en Français]]
+
{{LanguageBar|Linux_drivers_development|Développement de pilotes linux|Linux Treiber Entwicklung}}

Revision as of 22:23, 11 February 2009

This page summarizes all you need to know before starting to develop Linux drivers for your Armadeus board

Recommended reading before starting

We advise you to read (not necessarly understand ;-) ):

Adding your own drivers

Our custom drivers build is integrated to the Linux build system (kbuild). You can select, in the linux "menuconfig / xconfig" tool, which Armadeus drivers you want to add on your target.

 $ make linux26-menuconfig
Device Drivers  --->
    Armadeus specific drivers  --->

Here is the way to add custom drivers:

  • in armadeus/target/linux/modules/, add a directory for your driver (ex toto/)
  • put reference to this directory in the armadeus/target/linux/modules/Makefile and armadeus/target/linux/modules/Kconfig files
  • in toto/ put your driver source code and create 2 files, Kconfig and Makefile. (Use armadeus/target/linux/modules/gpio/Makefile & Kconfig as examples.)

To compile all the custom modules, either launch:

 $ make -C armadeus/target/linux/modules/

or

 $ make linux26

only make linux26 will install the modules in the target rootfs image

i.MX register access from driver

To access i.MX registers from your driver, please use the macros defined in:

#include <mach/imx-regs.h>

For example (access to PWM control register):

/* enable the PWM */
PWMC |= PWMC_EN;

Debug

  • Activate debug messages (from pr_debug() function) on console:
 # echo 8 > /proc/sys/kernel/printk

Useful Links

Other languages:

English Flag.svg English  •  French Flag.svg Français