Create a SD card image :
– get the last Raspbian image ont the website : https://www.raspberrypi.org/downloads/raspbian/
– get the last applePi-Baker : http://www.tweaking4all.com/hardware/raspberry-pi/macosx-apple-pi-baker/
– unzip the image, connect the SD card and launch applePi-Baker
Connect the rpi using usb serial connexion :
– install the PL2303 driver
– install minicom
– connect the usb serial adapter to the rpi and ti the mac, check in dev (/dev/tty.usbserial)
– launch « minicom -s » in a terminal and enter the device address
minicom -s
– login : pi, password : raspberry
– activate root account :
sudo passwd root
– exit and log with root
Expand Filesystem:
– launch raspi-config
raspi-config
– choose « 1 Expand Filesystem »
– reboot
Get the module development environment :
apt-get install rpi-update rpi-update
– get the kernel version :
uname -r
– download corresponding package at https://www.niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi/
– install with dpkg :
dpkg -i linux-headers...
Try module compilation :
– create hello.c file containing :
/*
* hello.c - The simplest kernel module.
*/
#include "linux/module.h" // included for all kernel modules
#include "linux/kernel.h" // included for KERN_INFO
#include "linux/init." // included for __init and __exit macros
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Martin");
MODULE_DESCRIPTION("A Simple Hello World module");
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world!\n");
return 0; // Non-zero return means that the module couldn't be loaded.
}
static void __exit hello_cleanup(void)
{
printk(KERN_INFO "Cleaning up module.\n");
}
module_init(hello_init);
module_exit(hello_cleanup);
– create Makefile file containing :
obj-m += hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean
– try to load and unload the module :
insmod hello.ko rmmod hello.ko
– check the results through the kernel messages :
>dmesg | tail -20
– it should be written something like :
[ 2831.586831] Hello world. [ 2846.286438] Goodbye world.
– And it’s good !
Install the new driver so it will be loaded at start up :
– copy the .ko file to the appropropriate directory : /lib/modules/`uname -r`/kernel/drivers/gpio
– run depmod
>depmod
– and reboot
>shutdown -r now
For the raspberry, the serial connexion is limited and graphical interface is not supplied. So create a ssh server is a good way to use geany for example. As I use a wifi connexion, the ssh server will hang up soon as you are connected so. To get rid of this, add the following lines at the end of /etc/ssh/sshd_config :
KeepAlive yes ClientAliveInterval 60
Ok ?