Detecting the Raspberry Pi

General programming chat and advice for beginners

4 posts
by Tripel Hop » Thu Jun 28, 2012 1:36 am
Hello

My Raspberry Pi is equipped with Debian 6 (dated 2012-04-19). I'm working on a program that controls an expansion board connected to the GPIO connector. The board is wired to the I2C bus. My program accesses /dev/mem to control to BCM2835 I2C part.

My concern now is that my program is built as an armv6l/armel executable and it runs on other computers as well (including the BeagleBoard) but it needs the BCM2835 specifically so this means trouble when not run on a Raspberry Pi. So I'm looking for a way to detect whether my program is running on a Raspberry or not. Any ideas?

Thanks
Posts: 10
Joined: Wed Jun 27, 2012 12:12 am
by aaa801 » Fri Jun 29, 2012 4:41 pm
Gimme just a min..
Posts: 427
Joined: Mon Jun 04, 2012 9:06 pm
Location: Berkshire
by aaa801 » Fri Jun 29, 2012 5:11 pm
grep -i "Hardware" /proc/cpuinfo | sort

or
cat /proc/fb

or cat /proc/iomem and crosscheck the gpio memory map?
please be advised that it shows as a BCM2708 on my pi :/
Posts: 427
Joined: Mon Jun 04, 2012 9:06 pm
Location: Berkshire
by Tripel Hop » Sat Jun 30, 2012 10:14 pm
Thanks.

I'm going to extract the "Hardware" line from /proc/cpuinfo in my program as it states the hardware family name "BCM2708". This line is also present on the BeagleBoard ("OMAP3 Beagle Board"). It's doesn't show up on my x86-based Linux systems though.

A related question: what's the character encoding of the text returned by /proc/cpuinfo and other procfs files? UTF-8?
Posts: 10
Joined: Wed Jun 27, 2012 12:12 am