Raspberry Pi

From BC Wiki
Jump to: navigation, search

Models and Performance[edit]

Understanding the system/gpu RAM split

Raspberry Pi Setup[edit]

Flash-Friendly File System (f2fs)[edit]

"Added f2fs support to the build script. Pre-built images available for download use ext4 because f2fs file systems can not be resized at present."

Memory Card Selection[edit]

"We have done what we can to optimise the build for the Raspberry Pi 2 and one can comfortably use applications such as LibreOffice, which in fact is a joy to use :-) But the microSDHC I/O throughput is a bottleneck so we recommend that you use a Class 6 or Class 10 microSDHC card. If you build the image yourself we recommend you use the f2fs filesystem."

Creating Swap with dphys-swapfile[edit]

On Ubuntu, install with `sudo apt install dphys-swapfile`.

The configuration file is in `/etc/dphys-swapfile`. Set swap location with `CONF_SWAPFILE=/your/location` and set size in megabytes with `CONF_SWAPSIZE=100`.

Use `systemd` to control it:

  • `sudo systemctl status dphys-swapfile`
  • `sudo systemctl enable dphys-swapfile`
  • `sudo systemctl start dphys-swapfile`
  • `sudo systemctl stop dphys-swapfile`
  • `sudo dphys-swapfile uninstall`


Some people will tell you that making a swapfile on an SD card is a recipe for disaster; others will tell you that swap thrashing is not a realistic concern. I keep my swapfile on a spinning disk connected to the Raspberry Pi.


Non-Contact Temperature Measurement



Serial Interfaces (SPI and I2C)[edit]


You need to load the 'spidev' module to get userspace spi device access, in the same way the i2c-dev module provides userspace i2c access.
Try "modprobe spidev".

how to detect spi devices?

Scientific Computing[edit]

pip install matplotlib memory error
pip install --no-cache-dir matplotlib

apt-get install libfreetype6-dev libpng12-dev
pip install matplotlib


Wireless Sequencing Error[edit]

RPi3 wifi sequence error

problem: `brcmfmac: brcmf_sdio_hdparse: seq 194: sequence number error` in console when receiving wifi packets

Missing Console Cursor[edit]

Ubuntu Mate for Raspberry Pi

"We created a simple utility called graphical to disable/enable the MATE desktop environment for easily creating a headless “server”. Executing graphical disable will present a console login on the next boot, with no X11 or associated services running. If you want to get the full Ubuntu MATE desktop back, run graphical enable and reboot."

Problem: can't see cursor position in terminal when rebooting after `graphical disable`


Controlling General-Purpose I/O with Python[edit]

Raspberry gPIo

"Driving the Raspberry Pi’s I/O lines requires a bit of programming. Programming in what language? Take your pick! A quick glance at the Raspberry Pi GPIO examples shows that there are dozens of programming-language-choices. We’ve pared that list down, and ended up with two really solid, easy tools for driving I/O: Python and C (using the WiringPi library)."

Pins 2,4 - 5VDC
Pins 6,9,14,20,25,30,34,39 - Ground

Python module: RPi.GPIO

"Note that this module is unsuitable for real-time or timing critical applications. This is because you can not predict when Python will be busy garbage collecting. It also runs under the Linux kernel which is not suitable for real time applications - it is multitasking O/S and another process may be given priority over the CPU, causing jitter in your program. If you are after true real-time performance and predictability, buy yourself an Arduino! (see http://www.arduino.cc  )

Note that the current release does not support SPI, I2C, 1-wire or serial functionality on the RPi yet. This is planned for the near future - watch this space!"

RPi.GPIO 0.6.2

pip install rpi.gpio
Collecting rpi.gpio
  Downloading RPi.GPIO-0.6.2.tar.gz

import RPi.GPIO as GPIO
GPIO.setup(18, GPIO.OUT)
GPIO.output(18, GPIO.HIGH)
pwm = GPIO.PWM(18, 1000)
if GPIO.input(17):
    print("Pin 11 is HIGH")
    print("Pin 11 is LOW")
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)