Difference between revisions of "Linux drivers development"

From ArmadeusWiki
Jump to: navigation, search
m
m (Adding your own drivers)
 
(3 intermediate revisions by 2 users not shown)
Line 10: Line 10:
 
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">
 
<pre class="host">
  $ make linux26-menuconfig
+
  $ make linux-menuconfig
 
</pre>
 
</pre>
  
Line 19: Line 19:
  
 
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 your driver (ex ''toto/'')
+
* change current dir to your armadeus view
* put reference to this directory in the ''armadeus/target/linux/modules/Makefile'' and ''armadeus/target/linux/modules/Kconfig'' files
+
* in ''target/linux/modules/'', add a directory for your driver (ex ''toto/'')
* in ''toto/'' put your driver source code and create 2 files, ''Kconfig'' and ''Makefile''. (Use ''armadeus/target/linux/modules/gpio/Makefile'' & ''Kconfig'' as examples.)
+
* put reference to this directory in the ''target/linux/modules/Makefile'' and ''target/linux/modules/Kconfig'' files
 +
* in ''toto/'' put your driver source code and create 2 files, ''Kconfig'' and ''Makefile''. (Use ''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">
 
<pre class="host">
  $ make -C armadeus/target/linux/modules/
+
  $ make -C target/linux/modules/
 
</pre>
 
</pre>
 
or
 
or
 
<pre class="host">
 
<pre class="host">
  $ make linux26
+
  $ make linux
 
</pre>
 
</pre>
  
only ''make linux26'' will install the modules in the target rootfs image
+
Only ''make linux'' will install the modules in the target rootfs image
  
 
== i.MX register access from driver ==
 
== i.MX register access from driver ==
  
To access i.MX registers from your driver, please use the macros defined in:
+
To access i.MX registers from your driver, please use the ''readw/readl/writew/writel'' helper functions.
<source lang="c">
+
Take a look at at ''arch/arm/mach-mx2/apf27.c'' or ''arch/arm/mach-imx/apf9328.c'' to have examples.
#include <mach/imx-regs.h>
+
</source>
+
 
+
<strike>For example (access to PWM control register):</strike>
+
<source lang="c">
+
/* enable the PWM */
+
PWMC |= PWMC_EN;
+
</source>
+
  
 
==Debug==
 
==Debug==
Line 56: Line 49:
 
* http://old.kernelnewbies.org/documents/kdoc/kernel-api/linuxkernelapi.html
 
* http://old.kernelnewbies.org/documents/kdoc/kernel-api/linuxkernelapi.html
 
* http://lwn.net/Articles/driver-porting/
 
* http://lwn.net/Articles/driver-porting/
 
{{LanguageBar|Linux_drivers_development|Développement de pilotes linux|Linux Treiber Entwicklung}}
 

Latest revision as of 16:55, 4 September 2013

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 linux-menuconfig
Device Drivers  --->
    Armadeus specific drivers  --->

Here is the way to add custom drivers:

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

To compile all the custom modules, either launch:

 $ make -C target/linux/modules/

or

 $ make linux

Only make linux 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 readw/readl/writew/writel helper functions. Take a look at at arch/arm/mach-mx2/apf27.c or arch/arm/mach-imx/apf9328.c to have examples.

Debug

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

Useful Links