Making the Gertboard code examples work on a Raspberry Pi 2

If you have downloaded the gertboard software package gertboard_sw_20120725.zip from the farnell site at http://www.element14.com/community/docs … rd-techdoc on your Raspberry Pi 2, you’ll find it doesn’t work right away.

When you run “make all” to build the library and example code, you’ll find the gb_common.o file created for the Raspberry Pi (the single-core ARM1176JZF-SARM CPU bcm2835) will not work with the Raspberry Pi 2 (which is a quad-core ARM Cortex-A7 bcm2836).

The hardware connections on the boards are the same; the problem is due to memory map differences between the 256/512Mb on the Pi vs. 1Gb memory on the Pi 2. Basically, the peripheral address map has moved.
The Gertboard examples are all written using hard coded peripheral addresses. So all your reads and writes using the addresses assumed by the gertboard library end up in the wilderness.
All the peripheral addresses are defined as an offset from BCM2708_PERI_BASE which is set to 0x20000000 in gb_common.c
Change that to ‘0x3F000000’ and it should all work again on the Pi 2.

What to do

1. edit gb_common.c , changing the constant definition for the base peripheral address location in line 39 from

#define BCM2708_PERI_BASE 0x20000000

to

#define BCM2708_PERI_BASE 0x3F000000

2. then re-build the complete package

make all

3. And finally, run one of the test programs

sudo ./leds

And provided you’ve set the right jumpers on your gertboard and connected it up right, watch the LEDs blinking.

3 comments

  1. w5dbw

    Will this same fix work for a Pi3? When I wired it up to run the LED test, and installed all the output jumpers, the LEDs were all off, pulled the output jumpers off and the LEDs all came on.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s