From ArmadeusWiki
Jump to: navigation, search

Page under construction... Construction.png Informations on this page are not guaranteed !!


The goal of this tutorial is to build from scratch a simple led driver wire on GPIO of the iMX. This document will describes step by step how to implement a such driver

Howto Load/unload modules : "hwmon" module

Loading a module is quite simple once it is compiled and is present in the rootfs of the apf board. All the compiled driver modules are in the "/lib/modules/<kernel version>/kernel" in the apf rootfs. To list all the loadable modules by the kernel in the board type :

 # find /lib/modules/`uname -r`/kernel -name "*.ko"

For example, I will load "/lib/modules/" module :

 # modprobe hwmon

To list all mod loaded :

 # lsmod
Module                  Size  Used by    Not tainted
hwmon                   2356  0 

To unload it just type :

 # rmmod hwmon


Howto Build a simple char module and load/unload it : the "Hello World" module

The "Hello World" module code is quite simple have only load and unload fonction.

Create required folder and files

Create a hello folder in <armadeus_directory>/target/linux/modules/. On the host computer type :

cd <armadeus_directory>/target/linux/modules/
mkdir hello

Hello.c source file

#include <linux/module.h> /* Default module librairies TBC */
#include <linux/kernel.h>

/* Print "Hello, world\n" with KERN_ALERT level (stdio TBC) */
static int hello_init(void){
      printk(KERN_ALERT "Hello, world\n");
      return 0;

/* Print "Goodbye, cruel world\n" with KERN_ALERT level (stdio TBC) */
static void hello_exit(void){
      printk(KERN_ALERT "Goodbye, cruel world\n");

module_init(hello_init); /* Set hello_init function as the module init one (called when module load) */
module_exit(hello_exit); /* Set hello_exit function as the module exit one (called when module unload) */

MODULE_LICENSE("GPL"); /* Set the license module */

Makefile file

# Part executed when called from kernel build system:


#hello-objs	:= hello.o

# Part executed when called from standard make in this directory:
# (preferably use Makefile in parent directory)


PWD	:= $(shell pwd)

# Armadeus custom drivers common targets:
include ../



Howto Provide read/write commands to the user though /dev/hello : "Hello World Read Write" module

Howto Build a register use module : "iMX LED" module