You can get pcDuino kernel source code from https://github.com/pcduino/kernel, and follow the guide http://www.pcduino.com/?p=957 to build your own kernel.
However, sometimes people do not want to build the whole kernel, but only some drivers, and they do not want to use another machine to build a simple driver.
This guide will show you how to build your drivers on pcDuino.
1) install pcduino-linux-headers-3.4.29+
$ sudo apt-get update && sudo apt-get install pcduino-linux-headers-3.4.29+
Note:
You need to update your system to 2013-05-31 version to do this.
2) make a new directory and write a test driver
$ mkdir hello && cd hello && cat > hello.c << EOF
#include <linux/init.h>
#include <linux/module.h>
static int pcduino_hello_init(void)
{
printk(“Hello, pcDuinon”);
return 0;
}
static void pcduino_hello_exit(void)
{
printk(“Bye, pcDuinon”);
}
MODULE_LICENSE("GPL");
MODULE_AUTHOR("pcDuino Team");
module_init(pcduino_hello_init);
module_exit(pcduino_hello_exit);
EOF
b) Create a Makefile
$ cat > Makefile << EOF
obj-m = hello.o
EOF
3) Compile and run test driver
a) compile
$ make M=`pwd` -C /usr/src/linux-headers-3.4.29+
b) load driver
$ sudo insmod hello.ko
you can see the debug message by:
$ sudo dmesg | tail -n 1
[ 1414.020000] Hello, pcDuino
c) Unload driver
$ sudo rmmod hello.ko
you can see the debug message by:
$ sudo dmesg | tail -n 1
[ 1486.290000] Bye, pcDuino
Leave a Reply
You must be logged in to post a comment.