About Raspberry Pi

These are some notes I've made on the Raspberry Pi devices while investigating how to make use of them.

The default operating system is Raspbian, which is a port of Debian (Wheezy), it is 32-bit and little-endian. Other OSes are available, as per the download page at raspberrypi.org.

One interesting alternate OS is Devuan, which has a 64-bit version that runs on the PI3B and Pi3B+ models. I have done some further investigations into that.

I found out that time_t is 32 bits, so what happens in 2038 will be somewhat interesting... though there is still time to change the time_t size even in these 32-bit systems.

There are several models of these, of which the following ones I have made some use of, for various projects:

Name RAMGPIO PinsEthernetWLAN,BTUSB
Raspberry Pi Model B Rev 2512 MB26+810/100No2
Raspberry Pi Model A256 MB26+8NoneNo1
Raspberry Pi Model B+512 MB4010/100No4
Raspberry Pi Model A+256 MB40NoneNo1
Raspberry Pi 2B1024 MB4010/100No4
Raspberry Pi 3B1024 MB4010/100Yes4
Raspberry Pi 3B+1024 MB4010/100Yes4
Raspberry Pi Model Zero512 MB40NoneNo1
Raspberry Pi Model Zero W512 MB40NoneYes1
Raspberry Pi 3A+512 MB40NoneYes1
Raspberry Pi 4B4096 MB4010/100Yes4

There exist also the following variants which I have not had access to.

Raspberry Pi Model B Revision 1
Raspberry Pi Compute Module

Do not confuse the Raspberry Pi 2 with the old Raspberry Pi Model B Revision 2! Although they run the same programs and cost the same to buy, the Pi 2 has a 4-core cpu and 1 GB of memory, and runs a lot faster than the older single-core versions.

As of May 2015, it seems that the original models A with the 26+8 gpio pins are going out of production or at least becoming less available. For something like the A+ this is a good change, the A+ is physically smaller than the A, as well as using less power. The A+ has 4 mounting holes in the corners, an improvement on the two mounting holes on the A and B which were added at rev 2 in places where they happened to be possible to fit.

The original Model B also seems to be on its way out, replaced by the B+ which has more USB ports, better power management, better mechanical mounting with 4 holes, (in a 58 mm by 49 mm rectangle) as well as more GPIO lines. Although GPIOs 28-31 are no longer made available, and the I2C-0 buss has been made reserved for autoconfiguration of HAT (Hardware on Top) boards.

Even the B+ is fading from popularity now at the turn of 2015, having been superseded by the physically nearly identical, but much faster, Pi 2, which in turn has been superseded by the even more powerful Pi 3. Similarly, the A+ is mostly being replaced with the Zero and the Zero W, as these have the same GPIOs but a smaller footprint and more memory. The Zero W is in the sweet spot of having wireless networking built in, so it doesn't require any additional hardware beyond a power supply to go online.

Then the Raspberry Pi 3 model B came on the 4th anniversary of the first devices. 2016-02-29. While still physically similar to the B+ and B2, with the same 40-pin GPIO, and like the Pi 2, it has 4 cores, but now this is the BCM2837 with the BCM2709 processor. There is also a Bluetooth system and a wireless LAN on-board, in addition to the regular Ethernet.

More on various hardware and software aspects:
GPIO lines
I2C-bus programming
On making Kernel Modules
Using the GPU for such things as FFTs
SPI programming
Notes on DMA hacking
Sound cards
Serial port (and NTP)
1-wire
On-board PWM
On Using 64-bit Devuan on the Pi 3

The startup screens, when the booting activity is shown as scrolling text, in Debian style, has a logo at the top of the screen. Where Debian shows Tux, the Raspbian operating systems shows the Raspberry Pi logo. On the four-core Pi 2 and Pi 3 units the start-up shows four of these Raspberries.

Setup

Making SD cards

SD-cards: Sandisk from Clas Ohlson: SDHC Card Size, labeled. Types:

 8 GB: SDSDB-008G-B35 - Class 4, expected to be oke
32 GB: SDSDB-032G-B35 - Class 4, expected to be oke

as per http://elinux.org/RPi_SD_cards and http://elinux.org/RaspberryPiBoardVerifiedPeripherals#SD_cards

At first, downloaded and wrote the 2GB 2012-12-16-wheezy-raspbian.img file.

Now, the latest kernel is in the downloads area of the main Raspberry Pi website. http://www.raspberrypi.org/ The name of the file will thus be a little different than the one shown but it is used the same way as shown here.

dd bs=4M if=2012-12-16-wheezy-raspbian.img of=/dev/sdb

Using one of the 32GB cards now, seems to be working really well.

Tried a 16GB card from Kingston, also class 4, which also works oke.

Once booting with the card, I run through the standard setup-options in the raspi-config: set keyboard, make sure ssh runs at startup, and extend the file-system to the entire card. Depending on what I want to use the device for I may or may not elect to have it start with the GUI.

Also, if there are more of them running they cannot all be called "raspberrypi", so the hostname is changed in the two files /etc/hostname and /etc/hosts.

If I want to change from the DHCP to a fixed address, I will edit /etc/network/interfaces, and change the line:

iface eth0 inet dhcp

to something along the lines of:

iface eth0 inet static
address 10.0.1.201
netmask 255.255.255.0
gateway 10.0.1.98

The alternative is to assign a fixed dhcp address in the main router, based on the MAC address of the Raspberry Pi.

Then i2c and SPI have to be enabled by commenting their modules out from the blacklist, /etc/modprobe.d/raspi-blacklist.conf and adding them in the list of loaded modules, /etc/modules. More recent versions of Raspian has a configuration tool where this is handled. Makes it easy to get things going, but makes it less known what has to actually be changed.

Setup Summary

Once the inital raspi-config is run, and the sd-card has had the file system extended from the initial small size, I run some of these various apt-get calls:

apt-get update
apt-get upgrade

apt-get install i2c-tools
apt-get install libi2c-dev 
apt-get install libasound2-dev
apt-get install libasound2-doc
apt-get install sqlite3
apt-get install libsqlite3-dev
apt-get install sqlite3-doc
apt-get install zlib1g-dev
apt-get install libx11-dev
apt-get install libxcb-doc
apt-get install ntpsec
apt-get install wavemon
apt-get install bc

Wavemon is only useful when WiFi is enabled. Older alternate to ntpsec is ntp, but ntpsec is newer and more accurate.

The above adds i2c, sound, sqlite, X11 development files.

In order to see what has been installed, I use

dpkg -l

or as the list is rather long, I feed the output of that through grep to have it show if something is there or not.

For touch-screens: this may be useful.

apt-get install matchbox

For NFS, server:

The rpcbind and the nfs-kernel-server should be started and running. These are not necessarily present or active by default. First, make sure the binaries are installed:

apt-get install nfs-kernel-server
apt-get install nfs-common
apt-get install rpcbind

nfs-common and rpcbind might be pre-installed in recent systems.

Then set the exports in /etc/exports, something along the lines of:

/home/pi 10.0.1.0/255.255.255.0(rw,sync,no_subtree_check)

Then run exportfs -a

In /etc/rc2.d, there is a number of symlinks that have to be changed:

K05rpcbind -> ../init.d/rpcbind change to S05rpcbind
K05nfs-common -> ../init.d/nfs-common change to S05nfs-common
S01nfs-kernel-server -> ../init.d/nfs-kernel-server make sure this is here

Then run the command update-rc.d networking defaults which puts the various scripts into the correct order, and reboot.

This makes sure the rpcbind and the nfs server start initially in the correct order, so as to make it able to serve files, and the other startup scripts such as rc.local are run at the end as they are supposed to be. To start or restart the nfs server manually:

exportfs -a
/etc/init.d/nfs-kernel-server restart

For NFS, client:

apt-get install nfs-common

Chances are, the nfs-common is already in place.

For Samba:

apt-get install samba samba-common-bin

Then chmod 1777 the shared directory, add the reference to it in at the end of /etc/samba/smb.conf, along the lines of:

[pi]
   comment = R Pi std
   read only = no
   locking = no
   path = /home/pi
   guest ok = yes

Use testparm to see that things are oke, then smbpasswd -a username to add the users.

To re-start samba, use /etc/init.d/samba restart

I also like to add the /bin/ll file implementing the ls -l command, and some of the utilities that I use on all systems.

Serial Port Connector

The /dev/ttyAMA0 serial port is on pins 8 and 10. This is pin-out for connecting the Adafruit USB cable. On Models A, A+, and Zero, the power into pins P4 and P6 is enough to run the device.

TTY +5V GND Tx Rx
AMA0 P4 P6 P8 P10
Adafruit
USB cable
Red Black White Green
DE9M pin # NA 5 3 2

The R.pi 3 and 4 has the ttyAMA0 assigned to the bluetooth channel, but there is another serial port called the miniuart, that shows up as /dev/ttyS0. The following added at the end of /boot/config.txt will reassign these:

enable_uart=1
dtoverlay=pi3-miniuart-bt

The bluetooth thing can be disabled altogether, as when running a server in a box somewhere, with:

dtoverlay=pi3-disable-bt

HDMI settings

As it turns out, it may be possible to turn off the HDMI output and save the power that this is using, with the command

/opt/vc/bin/tvservice --off

Other HDMI settings can be made with tvservice Mode 18 seems to work well with a HDMI-VGA converter.

Some newer versions, Debian 10 and equivalents, might be hanging forever when looking for a hdmi monitor (or at least a converter to vga) if there is no monitor connected. To get past this, have the following entry active in /boot/config.txt:

hdmi_force_hotplug=1

This makes it not bother to check for any hdmi, but just expect it to be there whether there actually is anything there or not.

CPU Temperature sensor

There is an on-board temperature sensor, that indicates how hot the CPU runs.

The value can be accessed by reading the pseudo-file at /sys/class/thermal/thermal_zone0/temp, where a number corresponding to 1/100 degrees C is found.

Thus,

cat /sys/class/thermal/thermal_zone0/temp

returns

49230

on one of the units here, which means it is running at 49.23 degrees C.

I'm not sure of the accuracy vs. resolution -- the thermometer is probably not accurate to 0.01 degrees, so rounding off to 0.1 or 0.5 degrees is probably advisable.

Reliability

I have had some varying experience with how reliable the hardware has been. I have had two SD cards go bad, but these are likely caused by wear or damage from less than good power supplies. Same system (same Raspberry Pi unit and associated sensors) run on a better, that is, more stable, power supply has shown that the problem was likely to do with the power supply and not the way the Raspberry Pi operates.

As for hardware failures the only thing that has happened to any of the devices, was that the USB-connector broke on one of the early Model B units, but the computer still works, and is used in a project where the USB connections were not needed.

Another unit, a Pi1B+, has been subject to moisture, as well as having problems with the holder for the SD card. Its wired networking isn't working anymore. This was not really the fault of the device itself however. And it can still be accessed via the serial port.

Several of the Raspberry Pi units have been outside for several years now, while connected to the weather station hardware, and sensing temperature and precipitation all winter and remain operating just fine. These have been inside cases in a shed and that has provided sufficient protection.


Powered by Apache

Valid XHTML 1.0!