This is an old revision of the document!


GPIO bit-bang driver for Raspbian

Kernel Config

Determine the running kernel and it's config on the Raspberry Pi target machine.

uname -a
Linux pi3 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l GNU/Linux
zgrep "* firmware as of" /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | head -1 | awk '{ print $5 }'
53d1ae311226b5c
zcat /proc/config.gz > 53d1ae311226b5c.config

Examples.

Linux pi3 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/Linux  d4f5315cfac4e
Linux pi3 3.10.23+ #608 PREEMPT Mon Dec 9 21:11:23 GMT 2013 armv6l GNU/Linux  9d34d0475f9
Linux pi3 3.10.24+ #614 PREEMPT Thu Dec 19 20:38:42 GMT 2013 armv6l GNU/Linux c32bc633039cd9
Linux pi3 3.10.25+ #622 PREEMPT Fri Jan 3 18:41:00 GMT 2014 armv6l GNU/Linux  030082b403b
Linux pi3 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l GNU/Linux  53d1ae311226b5c

Kernel Hash

Determine the kernel hash for the firmware.

wget -q https://raw.github.com/raspberrypi/firmware/53d1ae311226b5c/extra/git_hash -O /tmp/hash
cat /tmp/hash 
94a382fed1a5ec303eef9e1f3439df8f759ba60c

Examples.

3.6.11+  d4f5315cfac4e   1587f775d0a3c437485262ba951afc5e30be69fa
3.10.23+ 9d34d0475f9     c15430e6a01e1332032d83f6484a866504e8ee97
3.10.24+ c32bc633039cd9  4bbea92eae6c0792e85a4ba079d367ac6aa77fb5
3.10.25+ 030082b403b     16eb921a96db3dc3555a65b53b99c15753e6b770
3.12.28+ 53d1ae311226b5c 94a382fed1a5ec303eef9e1f3439df8f759ba60c

Build

On the build host fetch the raspberry pi build tools.

mkdir -p /embedded/rpi
cd /embedded/rpi
git clone git://github.com/raspberrypi/tools.git

Fetch the kernel source for the previously determined hash.

rm -Rf /embedded/rpi/linux
cd /embedded/rpi
git clone https://github.com/raspberrypi/linux.git
cd /embedded/rpi/linux/
git checkout 94a382fed1a5ec303eef9e1f3439df8f759ba60c
git reset --hard

Prepare to build kernel and copy over configuration.

make ARCH=arm mrproper
scp pi@pi:53d1ae311226b5c.config .config

Build the kernel using the raspberry pi build tools.

make ARCH=arm oldconfig
make ARCH=arm CROSS_COMPILE=/embedded/rpi/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- -j 8

Build the GPIO bit-bang module and copy to target machine.

hg clone http://hg.kewl.org/pub/gpio-bb
cd gpio-bb/rpi-raspbian
make 
scp ../module/src/gpio-bb.ko pi@pi:

Install

Install the module on the Raspberry Pi target machine (Eg. 3.12.28+).

mkdir -p /lib/modules/3.12.28+/kernel/local/
cp gpio-bb.ko /lib/modules/3.12.28+/kernel/local/
chown -R 0:0 /lib/modules/3.12.28+/kernel/local/
depmod -a

Modprobe

Load modules on target machine.

/etc/modprobe.d/modprobe.conf:
install gpio-bb modprobe --ignore-install gpio-bb && modprobe gpio-bb && mknod /dev/gpio-bb c 180 0
modprobe gpio-bb
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies