The hardware in the Raspberry Pi
- Pinout
- Raspberry Pi GPIO BCM numbering
- Schematics for the Raspberry Pi
- BCM2835
- The Broadcom processor used in Raspberry Pi 1 and Zero
- BCM2836
- The Broadcom processor used in Raspberry Pi 2
- BCM2837
- The Broadcom processor used in Raspberry Pi 3 (and later Raspberry Pi 2)
- A description of the BCM2835/6/7 bootmodes available
- Mechanical drawings of the Raspberry Pi
- Power
- Powering the Raspberry Pi
- USB
- USB on the Raspberry Pi
- GPIO
- General Purpose Input/Output pins on the Raspberry Pi
- SPI
- SPI on the Raspberry Pi
- DPI on the Raspberry Pi
- How to access peripheral addresses using the bcm_host helpers
- Standard conformity documentation
- Conformance documentation for the various standards bodies
- Raspberry Pi revision code reference
- Register and bit definitons for the One-Time Programmable (OTP) memory on the Raspberry Pi
- Processor frequency and thermal management
- Information on how the Raspberry Pi manages CPU frequencies and heat dissipation
Schematics for the various Raspberry Pi board versions:
Raspberry Pi 3 Model B+
Raspberry Pi 3 Model B
Raspberry Pi 2 Model B
Raspberry Pi Model B+
Raspberry Pi Model A+
Raspberry Pi Zero
Raspberry Pi Zero W
This is the Broadcom chip used in the Raspberry Pi Model A, B, B+, the Compute Module, and the Raspberry Pi Zero.
Please refer to:
- GPU documentation and open-source driver
Also see the Raspberry Pi 2 Model B's chip, BCM2836.
The Broadcom chip used in the Raspberry Pi 2 Model B
The underlying architecture in BCM2836 is identical to BCM2835. The only significant difference is the removal of the ARM1176JZF-S processor and replacement with a quad-core Cortex-A7 cluster.
Please refer to:
- BCM2836 ARM-local peripherals
- Cortex-A7 MPcore Processor Reference Manual
Also see the chip used in the Raspberry Pi Model A, B, B+, the Compute Module, and the Raspberry Pi Zero, BCM2835
This is the Broadcom chip used in the Raspberry Pi 3, and in later models of the Raspberry Pi 2. The underlying architecture of the BCM2837 is identical to the BCM2836. The only significant difference is the replacement of the ARMv7 quad core cluster with a quad-core ARM Cortex A53 (ARMv8) cluster.
The ARM cores run at 1.2GHz, making the device about 50% faster than the Raspberry Pi 2. The VideoCore IV runs at 400MHz.
Also see the Raspberry Pi 2's chip BCM2836 and the Raspberry Pi 1's chip BCM2835.
Introduction
The Raspberry Pi has a number of different stages of booting. This document is meant to help explain how the boot modes work, and which ones are supported for Linux booting.
- Bootflow: Boot sequence description
- SD card: SD card boot description
- USB: USB boot description
- Device boot: Booting as a mass storage device
- Host boot: Booting as a USB host
- Mass storage boot: Boot from Mass Storage Device (MSD)
- Network boot: Boot from ethernet
Special bootcode.bin-only boot mode
For the original Raspberry Pi and the Raspberry Pi 2 (based on the BCM2835 and BCM2836 devices), and in situations where the Pi 3 fails to boot, there is a new method of booting from one of the new boot modes (MSD or ethernet).
Just format an SD card as FAT32 and copy on the latest bootcode.bin.
This will then enable the new bootmodes with some bug fixes for the failing Pi 3 cases.
If you have a problem with a mass storage device still not working even with this bootcode.bin, then please add a new file 'timeout' to the SD card. This should extend the time it waits for the mass storage device to initialise to six seconds.
bootcode.bin UART enable
It is possible to enable an early stage UART to debug booting issues (useful with the above bootcode.bin only boot mode). To do this, make sure you've got a recent version of the firmware (including bootcode.bin). To check if UART is supported in your current firmware:
$ strings bootcode.bin | grep BOOT_UART
BOOT_UART=0
To enable UART from bootcode.bin use:
sed -i -e "s/BOOT_UART=0/BOOT_UART=1/" bootcode.bin
Next, connect a suitable USB serial cable to your host computer (a Raspberry Pi will work, although I find the easiest path is to use a USB serial cable since it'll work out the box without any pesky config.txt settings). Use the standard pins 6, 8 and 10 (GND, GPIO14, GPIO15) on a Pi or CM board.
Then use screen on linux or a Mac or putty on windows to connect to the serial.
Setup your serial to receive at 119200-8-N-1, and then boot your Pi / Compute module. You should get an immediate serial output from the device as bootcode.bin runs.
Raspberry Pi 3B+
Raspberry Pi 3B
- DXF
Raspberry Pi Model B+
- DXF
Raspberry Pi Zero (v1.2)
Raspberry Pi PoE HAT
The Raspberry Pi 3 is powered by a +5.1V micro USB supply. Exactly how much current (mA) the Raspberry Pi requires is dependent on what you connect to it. We have found that purchasing a 2.5A power supply from a reputable retailer will provide you with ample power to run your Raspberry Pi. You can purchase the official Raspberry Pi Power Supply from our website, and you can learn more about the differing power requirements of the various models of the Raspberry Pi on our FAQ page.
Typically, the model B uses between 700-1000mA depending on what peripherals are connected; the model A can use as little as 500mA with no peripherals attached. The maximum power the Raspberry Pi can use is 1 Amp. If you need to connect a USB device that will take the power requirements above 1 Amp, then you must connect it to an externally-powered USB hub.
The power requirements of the Raspberry Pi increase as you make use of the various interfaces on the Raspberry Pi. The GPIO pins can draw 50mA safely, distributed across all the pins; an individual GPIO pin can only safely draw 16mA. The HDMI port uses 50mA, the camera module requires 250mA, and keyboards and mice can take as little as 100mA or over 1000mA! Check the power rating of the devices you plan to connect to the Pi and purchase a power supply accordingly.
Backpowering
Backpowering occurs when USB hubs do not provide a diode to stop the hub from powering against the host computer. Other hubs will provide as much power as you want out each port. Please also be aware that some hubs will backfeed the Raspberry Pi. This means that the hubs will power the Raspberry Pi through its USB cable input cable, without the need for a separate micro-USB power cable, and bypass the voltage protection. If you are using a hub that backfeeds to the Raspberry Pi and the hub experiences a power surge, your Raspberry Pi could potentially be damaged.
Page Contents
- Overview
The Raspberry Pi Model B is equipped with two USB2.0 ports. These are connected to the LAN9512 combo hub/Ethernet chip IC3, which is itself a USB device connected to the single upstream USB port on BCM2835.
On the Model A, the single USB2.0 port is directly wired to BCM2835.
The USB ports enable the attachment of peripherals such as keyboards, mice, webcams that provide the Pi with additional functionality.
There are some differences between the USB hardware on the Raspberry Pi and the USB hardware on desktop computers or laptop/tablet devices.
The USB host port inside the Pi is an On-The-Go (OTG) host as the application processor powering the Pi, BCM2835, was originally intended to be used in the mobile market: i.e. as the single USB port on a phone for connection to a PC, or to a single device. In essence, the OTG hardware is simpler than the equivalent hardware on a PC.
OTG in general supports communication to all types of USB device, but to provide an adequate level of functionality for most of the USB devices that one might plug into a Pi, the system software has to do more work.
In general, every device supported by Linux is possible to use with the Pi, subject to a few caveats detailed further down. Linux has probably the most comprehensive driver database for legacy hardware of any operating system (it can lag behind for modern device support as it requires open-source drivers for Linux to recognise the device by default).
If you have a device and wish to use it with a Pi, then plug it in. Chances are that it'll "just work". If you are running in a graphical interface (such as the LXDE desktop environment in Raspbian), then it's likely that an icon or similar will pop up announcing the new device.
If the device doesn't appear to work, then refer to the Troubleshooting section below.
The OTG hardware on Raspberry Pi has a simpler level of support for certain devices, which may present a higher software processing overhead. The Raspberry Pi also has only one root USB port: all traffic from all connected devices is funnelled down this bus, which operates at a maximum speed of 480mbps.
The USB specification defines three device speeds - Low, Full and High. Most mice and keyboards are Low-speed, most USB sound devices are Full-speed and most video devices (webcams or video capture) are High-speed.
Generally, there are no issues with connecting multiple High-speed USB devices to a Pi.
The software overhead incurred when talking to Low- and Full-speed devices means that there are soft limitations on the number of simultaneously active Low- and Full-speed devices. Small numbers of these types of devices connected to a Pi will cause no issues.
USB devices have defined power requirements, in units of 100mA from 100mA to 500mA. The device advertises its own power requirements to the USB host when it is first connected. In theory, the actual power consumed by the device should not exceed its stated requirement.
The USB ports on a Raspberry Pi have a design loading of 100mA each - sufficient to drive "low-power" devices such as mice and keyboards. Devices such as WiFi adapters, USB hard drives, USB pen drives all consume much more current and should be powered from an external hub with its own power supply. While it is possible to plug a 500mA device into a Pi and have it work with a sufficiently powerful supply, reliable operation is not guaranteed.
In addition, hotplugging high-power devices into the Pi's USB ports may cause a brownout which can cause the Pi to reset.
See Power for more information.
1. Interoperability between the Raspberry Pi and USB3.0 hubs
There is an issue with USB3.0 hubs in conjunction with the use of Full- or Low-speed devices (most mice, most keyboards) and the Raspberry Pi. A bug in most USB3.0 hub hardware means that the Raspberry Pi cannot talk to Full- or Low-speed
devices connected to a USB3.0 hub.
USB2.0 high-speed devices, including USB2.0 hubs, operate correctly when connected via a USB3.0 hub.
Avoid connecting Low- or Full-speed devices into a USB3.0 hub. As a workaround, plug a USB2.0 hub into the downstream port of the USB3.0 hub and connect the low-speed device, or use a USB2.0 hub between the Pi and the USB3.0 hub, then plug low-speed devices into the USB2.0 hub.
2. USB1.1 webcams
Old webcams may be Full-speed devices. Because these devices transfer a lot of data and incur additional software overhead, reliable operation is not guaranteed. As a workaround, try to use the camera at a lower resolution.
3. Esoteric USB sound cards
Expensive "audiophile" sound cards typically use far more bandwidth than is necessary to stream audio playback. Reliable operation with 96kHz/192kHz DACs is not guaranteed.
As a workaround, forcing the output stream to be CD quality (44.1kHz/48kHz 16-bit) will reduce the stream bandwidth to reliable levels.
4. Single-TT USB hubs
USB2.0 and 3.0 hubs have a mechanism for talking to Full- or Low-speed devices connected to their downstream ports called a Transaction Translator. This device buffers high-speed requests from the host (i.e. the Pi) and transmits them at Full-
or Low-speed to the downstream device. Two configurations of hub are allowed by the USB specification: Single-TT (one TT for all ports) and Multi-TT (one TT per port).
Because of the OTG hardware limitations, if too many Full- or Low-speed devices are plugged into a single-TT hub, unreliable operation of the devices may occur. It is recommended to use a Multi-TT hub to interface with multiple lower-speed
devices.
As a workaround, spread lower-speed devices out between the Pi's own USB port and the single-TT hub.
IF YOUR DEVICE DOESN'T WORK AT ALL
The first step is to see if it is detected at all. There are two commands that can be entered into a terminal for this: lsusb and dmesg. The first will print out all devices attached to USB, whether they are actually recognised by a device driver or not, and the second will print out the kernel message buffer (which can be quite big after booting - try doing sudo dmesg -C then plug in your device and retype dmesg to see new messages).
As an example with a USB pendrive:
pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 005: ID 05dc:a781 Lexar Media, Inc.
pi@raspberrypi ~ $ dmesg
... Stuff that happened before ...
[ 8904.228539] usb 1-1.3: new high-speed USB device number 5 using dwc_otg
[ 8904.332308] usb 1-1.3: New USB device found, idVendor=05dc, idProduct=a781
[ 8904.332347] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 8904.332368] usb 1-1.3: Product: JD Firefly
[ 8904.332386] usb 1-1.3: Manufacturer: Lexar
[ 8904.332403] usb 1-1.3: SerialNumber: AACU6B4JZVH31337
[ 8904.336583] usb-storage 1-1.3:1.0: USB Mass Storage device detected
[ 8904.337483] scsi1 : usb-storage 1-1.3:1.0
[ 8908.114261] scsi 1:0:0:0: Direct-Access Lexar JD Firefly 0100 PQ: 0 ANSI: 0 CCS
[ 8908.185048] sd 1:0:0:0: [sda] 4048896 512-byte logical blocks: (2.07 GB/1.93 GiB)
[ 8908.186152] sd 1:0:0:0: [sda] Write Protect is off
[ 8908.186194] sd 1:0:0:0: [sda] Mode Sense: 43 00 00 00
[ 8908.187274] sd 1:0:0:0: [sda] No Caching mode page present
[ 8908.187312] sd 1:0:0:0: [sda] Assuming drive cache: write through
[ 8908.205534] sd 1:0:0:0: [sda] No Caching mode page present
[ 8908.205577] sd 1:0:0:0: [sda] Assuming drive cache: write through
[ 8908.207226] sda: sda1
[ 8908.213652] sd 1:0:0:0: [sda] No Caching mode page present
[ 8908.213697] sd 1:0:0:0: [sda] Assuming drive cache: write through
[ 8908.213724] sd 1:0:0:0: [sda] Attached SCSI removable disk
In this case, there are no error messages in dmesg and the pendrive is detected by the usb-storage driver. If your device did not have a driver available, then typically only the first 6 new lines will appear in the dmesg printout.
If a device enumerates without any errors, but doesn't appear to do anything, then it is likely there are no drivers installed for it. Search around, based on the manufacturer's name for the device or the USB IDs that are displayed in lsusb (e.g. 05dc:a781). The device may not be supported with default Linux drivers - and you may need to download or compile your own third-party software.
IF YOUR DEVICE HAS INTERMITTENT BEHAVIOUR
Poor quality power is the most common cause of devices not working, disconnecting or generally being unreliable.
- If you are using an external powered hub, try swapping the power adapter supplied with the hub for another compatible power supply with the same voltage rating and polarity.
- Check to see if the problem resolves itself if you remove other devices from the hub's downstream ports.
- Temporarily plug the device directly into the Pi and see if the behaviour improves.
General Purpose Input/Output pins on the Raspberry Pi
Overview
This page expands on the technical features of the GPIO pins available on BCM2835 in general. For usage examples, see GPIO usage. When reading this page, reference should be made to the BCM2835 ARM peripherals data sheet, section 6.
GPIO pins can be configured as either general-purpose input, general-purpose output, or as one of up to six special alternate settings, the functions of which are pin-dependent.
There are three GPIO banks on BCM2835.
Each of the three banks has its own VDD input pin. On Raspberry Pi, all GPIO banks are supplied from 3.3V. Connection of a GPIO to a voltage higher than 3.3V will likely destroy the GPIO block within the SoC.
A selection of pins from Bank 0 is available on the P1 header on Raspberry Pi.
GPIO pads
The GPIO connections on the BCM2835 package are sometimes referred to in the peripherals data sheet as "pads" — a semiconductor design term meaning 'chip connection to outside world'.
The pads are configurable CMOS push-pull output drivers/input buffers. Register-based control settings are available for:
- Internal pull-up / pull-down enable/disable
- Output drive strength
- Input Schmitt-trigger filtering
POWER-ON STATES
All GPIO pins revert to general-purpose inputs on power-on reset. The default pull states are also applied, which are detailed in the alternate function table in the ARM peripherals datasheet. Most GPIOs have a default pull applied.
Interrupts
Each GPIO pin, when configured as a general-purpose input, can be configured as an interrupt source to the ARM. Several interrupt generation sources are configurable:
- Level-sensitive (high/low)
- Rising/falling edge
- Asynchronous rising/falling edge
Level interrupts maintain the interrupt status until the level has been cleared by system software (e.g. by servicing the attached peripheral generating the interrupt).
The normal rising/falling edge detection has a small amount of synchronisation built into the detection. At the system clock frequency, the pin is sampled with the criteria for generation of an interrupt being a stable transition within a three-cycle window, i.e. a record of '1 0 0' or '0 1 1'. Asynchronous detection bypasses this synchronisation to enable the detection of very narrow events.
Alternative functions
Almost all of the GPIO pins have alternative functions. Peripheral blocks internal to BCM2835 can be selected to appear on one or more of a set of GPIO pins, for example the I2C busses can be configured to at least 3 separate locations. Pad control, such as drive strength or Schmitt filtering, still applies when the pin is configured as an alternate function.
Voltage specifications
The following table gives the various voltage specifications for the GPIO pins, it was extracted from the Compute Module datasheet here.
Symbol | Parameter | Conditions | Min | Typical | Max | Unit |
---|---|---|---|---|---|---|
VIL | Input Low Voltage | VDD IO = 1.8V | - | - | 0.6 | V |
VDD IO = 2.7V | - | - | 0.8 | V | ||
VDD IO = 3.3V | - | - | 0.9 | V | ||
VIH | Input high voltage¹ | VDD IO = 1.8V | 1 | - | - | V |
VDD IO = 2.7V | 1.3 | - | - | V | ||
VDD IO = 3.3V | 1.6 | - | - | V | ||
IIL | Input leakage current | TA = +85◦C | - | - | 5 | µA |
CIN | Input capacitance | - | - | 5 | - | pF |
VOL | Output low voltage² | VDD IO = 1.8V, IOL = -2mA | - | - | 0.2 | V |
VDD IO = 2.7V, IOL = -2mA | - | - | 0.15 | V | ||
VDD IO = 3.3V, IOL = -2mA | - | - | 0.14 | V | ||
VOH | Output high voltage² | VDD IO = 1.8V, IOH = 2mA | 1.6 | - | - | V |
VDD IO = 2.7V, IOH = 2mA | 2.5 | - | - | V | ||
VDD IO = 3.3V, IOH = 2mA | 3 | - | - | V | ||
IOL | Output low current³ | VDD IO = 1.8V, VO = 0.4V | 12 | - | - | mA |
VDD IO = 2.7V, VO = 0.4V | 17 | - | - | mA | ||
VDD IO = 3.3V, VO = 0.4V | 18 | - | - | mA | ||
IOH | Output high current³ | VDD IO = 1.8V, VO = 1.4V | 10 | - | - | mA |
VDD IO = 2.7V, VO = 2.3V | 16 | - | - | mA | ||
VDD IO = 3.3V, VO = 2.3V | 17 | - | - | mA | ||
RPU | Pullup resistor | - | 50 | - | 65 | kΩ |
RPD | Pulldown resistor | - | 50 | - | 65 | kΩ |
¹ Hysteresis enabled
² Default drive strength (8mA)
³ Maximum drive strength (16mA)
Page Contents
- Overview
- Software
- Hardware
The Raspberry Pi is equipped with one SPI bus that has 2 chip selects.
The SPI master driver is disabled by default on Raspbian. To enable it, use raspi-config, or ensure the line dtparam=spi=on isn't commented out in /boot/config.txt, and reboot. If the SPI driver was loaded, you should see the device /dev/spidev0.0.
The SPI bus is available on the P1 Header:
MOSI P1-19
MISO P1-21
SCLK P1-23 P1-24 CE0
GND P1-25 P1-26 CE1
WIRINGPI
WiringPi includes a library which can make it easier to use the Raspberry Pi's on-board SPI interface. Accesses the hardware registers directly.
BCM2835 LIBRARY
This is a C library for Raspberry Pi (RPi). It provides access to GPIO and other IO functions on the Broadcom BCM 2835 chip. Accesses the hardware registers directly.
USE SPIDEV FROM C
There's a loopback test program in the Linux documentation that can be used as a starting point. See the Troubleshooting section. Uses the Linux spidev driver to access the bus.
SHELL
# Write binary 1, 2 and 3
echo -ne "\x01\x02\x03" > /dev/spidev0.0
The BCM2835 on the Raspberry Pi has 3 SPI Controllers. Only the SPI0 controller is available on the header. Chapter 10 in the BCM2835 ARM Peripherals datasheet describes this controller.
MASTER MODES
Signal name abbreviations
SCLK - Serial CLocK
CE - Chip Enable (often called Chip Select)
MOSI - Master Out Slave In
MISO - Master In Slave Out
MOMI - Master Out Master In
STANDARD MODE
In Standard SPI master mode the peripheral implements the standard 3 wire serial protocol (SCLK, MOSI and MISO).
BIDIRECTIONAL MODE
In bidirectional SPI master mode the same SPI standard is implemented, except that a single wire is used for data (MOMI) instead of the two used in standard mode (MISO and MOSI). In this mode, the MOSI pin serves as MOMI pin.
LOSSI MODE (LOW SPEED SERIAL INTERFACE)
The LoSSI standard allows issuing of commands to peripherals (LCD) and to transfer data to and from them. LoSSI commands and parameters are 8 bits long, but an extra bit is used to indicate whether the byte is a command or parameter/data. This extra bit is set high for a data and low for a command. The resulting 9-bit value is serialized to the output. LoSSI is commonly used with MIPI DBI type C compatible LCD controllers.
Note:
Some commands trigger an automatic read by the SPI controller, so this mode can't be used as a multipurpose 9-bit SPI.
TRANSFER MODES
- Polled
- Interrupt
- DMA
SPEED
The CDIV (Clock Divider) field of the CLK register sets the SPI clock speed:
SCLK = Core Clock / CDIV
If CDIV is set to 0, the divisor is 65536. The divisor must be a power of 2. Odd numbers rounded down. The maximum SPI clock rate is of the APB clock.
Errata: "must be a power of 2" probably should be "must be a multiple of 2"
See the Linux driver section for more info.
CHIP SELECT
Setup and Hold times related to the automatic assertion and de-assertion of the CS lines when operating in DMA mode are as follows:
The CS line will be asserted at least 3 core clock cycles before the msb of the first byte of the transfer.
The CS line will be de-asserted no earlier than 1 core clock cycle after the trailing edge of the final clock pulse.
The default Linux driver is spi-bcm2708.
The following information was valid 2014-07-05.
SPEED
The driver supports the following speeds:
cdiv speed
2 125.0 MHz
4 62.5 MHz
8 31.2 MHz
16 15.6 MHz
32 7.8 MHz
64 3.9 MHz
128 1953 kHz
256 976 kHz
512 488 kHz
1024 244 kHz
2048 122 kHz
4096 61 kHz
8192 30.5 kHz
16384 15.2 kHz
32768 7629 Hz
When asking for say 24 MHz, the actual speed will be 15.6 MHz.
Forum post: SPI has more speeds
SUPPORTED MODE BITS
SPI_CPOL - Clock polarity
SPI_CPHA - Clock phase
SPI_CS_HIGH - Chip Select active high
SPI_NO_CS - 1 device per bus, no Chip Select
SPI_3WIRE - Bidirectional mode, data in and out pin shared
Bidirectional or "3-wire" mode is supported by the spi-bcm2835 kernel module. Please note that in this mode, either the tx or rx field of the spi_transfer struct must be a NULL pointer, since only half-duplex communication is possible. Otherwise, the transfer will fail. The spidev_test.c source code does not consider this correctly, and therefore does not work at all in 3-wire mode.
SUPPORTED BITS PER WORD
8 - Normal
9 - This is supported using LoSSI mode.
TRANSFER MODES
Only interrupt mode is supported.
DEPRECATED WARNING
The following appears in the kernel log:
bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated
SPI DRIVER LATENCY
This thread discusses latency problems.
DMA CAPABLE DRIVER
This is a fork of spi-bcm2708 which enables DMA support for SPI client drivers that support DMA.
https://github.com/notro/spi-bcm2708 (wiki)
LOOPBACK TEST
This can be used to test SPI send and receive. Put a wire between MOSI and MISO. It does not test CE0 and CE1.
wget https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.10.y/Documentation/spi/spidev_test.c
gcc -o spidev_test spidev_test.c
./spidev_test -D /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D
DPI (PARALLEL DISPLAY INTERFACE)
An up-to-24-bit parallel RGB interface is available on all Raspberry Pi boards with the 40 way header (A+, B+, Pi2, Pi3, Zero) and Compute Module. This interface allows parallel RGB displays to be attached to the Raspberry Pi GPIO either in RGB24 (8 bits for red, green and blue) or RGB666 (6 bits per colour) or RGB565 (5 bits red, 6 green, and 5 blue).
This interface is controlled by the GPU firmware and can be programmed by a user via special config.txt parameters and by enabling the correct Linux Device Tree overlay.
GPIO pins
One of the alternate functions selectable on bank 0 of the Raspberry Pi GPIO is DPI (Display Parallel Interface) which is a simple clocked parallel interface (up to 8 bits of R, G and B; clock, enable, hsync, and vsync). This interface is available as alternate function 2 (ALT2) on GPIO bank 0:
Note that there are various ways that the colour values can be presented on the DPI output pins in either 565, 666, or 24-bit modes (see the following table and the output_format part of the dpi_output_format parameter below):
Disable other GPIO peripherals
Note that all other peripheral overlays that use conflicting GPIO pins must be disabled. In config.txt, take care to comment out or invert any dtparams that enable I2C or SPI:
dtparam=i2c_arm=off
dtparam=spi=off
Controlling output format
The output format (clock, colour format, sync polarity, enable) can be controlled with a magic number (unsigned integer or hex value prefixed with 0x) passed to the dpi_output_format parameter in config.txt created from the following fields:
output_format = (dpi_output_format >> 0) & 0xf;
rgb_order = (dpi_output_format >> 4) & 0xf;
output_enable_mode = (dpi_output_format >> 8) & 0x1;
invert_pixel_clock = (dpi_output_format >> 9) & 0x1;
hsync_disable = (dpi_output_format >> 12) & 0x1;
vsync_disable = (dpi_output_format >> 13) & 0x1;
output_enable_disable = (dpi_output_format >> 14) & 0x1;
hsync_polarity = (dpi_output_format >> 16) & 0x1;
vsync_polarity = (dpi_output_format >> 17) & 0x1;
output_enable_polarity = (dpi_output_format >> 18) & 0x1;
hsync_phase = (dpi_output_format >> 20) & 0x1;
vsync_phase = (dpi_output_format >> 21) & 0x1;
output_enable_phase = (dpi_output_format >> 22) & 0x1;
output_format:
1: DPI_OUTPUT_FORMAT_9BIT_666
2: DPI_OUTPUT_FORMAT_16BIT_565_CFG1
3: DPI_OUTPUT_FORMAT_16BIT_565_CFG2
4: DPI_OUTPUT_FORMAT_16BIT_565_CFG3
5: DPI_OUTPUT_FORMAT_18BIT_666_CFG1
6: DPI_OUTPUT_FORMAT_18BIT_666_CFG2
7: DPI_OUTPUT_FORMAT_24BIT_888
rgb_order:
1: DPI_RGB_ORDER_RGB
2: DPI_RGB_ORDER_BGR
3: DPI_RGB_ORDER_GRB
4: DPI_RGB_ORDER_BRG
output_enable_mode:
0: DPI_OUTPUT_ENABLE_MODE_DATA_VALID
1: DPI_OUTPUT_ENABLE_MODE_COMBINED_SYNCS
invert_pixel_clock:
0: RGB Data changes on rising edge and is stable at falling edge
1: RGB Data changes on falling edge and is stable at rising edge.
hsync/vsync/output_enable_polarity:
0: default for HDMI mode
1: inverted
hsync/vsync/oe phases:
0: DPI_PHASE_POSEDGE
1: DPI_PHASE_NEGEDGE
NB the single bit fields all act as an "invert default behaviour".
Controlling timings and resolutions
In firmware dated August 2018 or later, the hdmi_timings config.txt entry that was previously used to set up the DPI timings has be superceded by a new dpi_timings parameter. If the dpi_timings parameter is not present, the system will fall back to using the hdmi_timings parameter to ensure backwards compatibility. If neither are present and a custom mode is requested, then a default set of parameters for VGAp60 is used.
The dpi_group and dpi_mode config.txt parameters are used to set either predetermined modes (DMT or CEA modes as used by HDMI) or a user can generate custom modes.
To generate a custom DPI mode, start here.
If you set up a custom DPI mode, then in config.txt use:
dpi_group=2
dpi_mode=87
This will tell the driver to use the custom dpi_timings (older firmware uses hdmi_timings) timings for the DPI panel.
Theb dpi_timings parameters are specified as a space-delimited set of parameters:
<h_sync_polarity> = invert hsync polarity
<h_front_porch> = horizontal forward padding from DE acitve edge
<h_sync_pulse> = hsync pulse width in pixel clocks
<h_back_porch> = vertical back padding from DE active edge
<v_active_lines> = vertical pixels height (lines)
<v_sync_polarity> = invert vsync polarity
<v_front_porch> = vertical forward padding from DE active edge
<v_sync_pulse> = vsync pulse width in pixel clocks
<v_back_porch> = vertical back padding from DE active edge
<v_sync_offset_a> = leave at zero
<v_sync_offset_b> = leave at zero
<pixel_rep> = leave at zero
<frame_rate> = screen refresh rate in Hz
<interlaced> = leave at zero
<pixel_freq> = clock frequency (width*height*framerate)
<aspect_ratio> = *
* The aspect ratio can be set to one of eight values (choose closest for your screen):
HDMI_ASPECT_4_3 = 1
HDMI_ASPECT_14_9 = 2
HDMI_ASPECT_16_9 = 3
HDMI_ASPECT_5_4 = 4
HDMI_ASPECT_16_10 = 5
HDMI_ASPECT_15_9 = 6
HDMI_ASPECT_21_9 = 7
HDMI_ASPECT_64_27 = 8
Overlays
A Linux Device Tree overlay is used to switch the GPIO pins into the correct mode (alt function 2). As previously mentioned, the GPU is responsible for driving the DPI display. Hence there is no Linux driver; the overlay simply sets the GPIO alt functions correctly.
A 'full fat' DPI overlay (dpi24.dtb) is provided which sets all 28 GPIOs to ALT2 mode, providing the full 24 bits of colour bus as well as the h and v-sync, enable and pixel clock. Note this uses all of the bank 0 GPIO pins.
A second overlay (vga666.dtb) is provided for driving VGA monitor signals in 666 mode which don't need the clock and DE pins (GPIO 0 and 1) and only require GPIOs 4-21 for colour (using mode 5).
These overlays are fairly trivial and a user can edit them to create a custom overlay to enable just the pins required for their specific use case. For example, if one was using a DPI display using vsync, hsync, pclk, and de but in RGB565 mode (mode 2), then the dpi24.dtb overlay could be edited so that GPIOs 20-27 were not switched to DPI mode and hence could be used for other purposes.
Example config.txt settings
GERT VGA666 ADAPTOR
This setup is for the Gert VGA adaptor.
Note that the instructions provided in the documentation in the above GitHub link are somewhat out of date, so please use the settings below.
dtoverlay=vga666
enable_dpi_lcd=1
display_default_lcd=1
dpi_group=2
dpi_mode=82
800X480 LCD PANEL
Note: this was tested with Adafruit's DPI add-on board and 800x480 LCD panel.
dtoverlay=dpi24
overscan_left=0
overscan_right=0
overscan_top=0
overscan_bottom=0
framebuffer_width=800
framebuffer_height=480
enable_dpi_lcd=1
display_default_lcd=1
dpi_group=2
dpi_mode=87
dpi_output_format=0x6f005
dpi_timings=800 0 40 48 88 480 0 13 3 32 0 0 0 60 0 32000000 6
If there is no kernel driver available, and a program needs to access a peripheral address directly with mmap, it needs to know where in the virtual memory map the peripheral bus segment has been placed. This varies according to which model of Raspberry Pi is being used, so there are three helper function available to provide platform independence. Note: please use these functions rather than hardcoded values, as this will ensure future compatibility.
unsigned bcm_host_get_peripheral_address()
This returns the ARM-side physical address where peripherals are mapped. This is 0x20000000 on the Pi Zero, Pi Zero W, and the first generation of the Raspberry Pi and Compute Module, and 0x3f000000 on the Pi 2, Pi 3 and Compute Module 3.
unsigned bcm_host_get_peripheral_size()
This returns the size of the peripheral's space, which is 0x01000000 for all models.
unsigned bcm_host_get_sdram_address()
This returns the bus address of the SDRAM. This is 0x40000000 on the Pi Zero, Pi Zero W, and the first generation of the Raspberry Pi and Compute Module (GPU L2 cached), and 0xC0000000 on the Pi 2, Pi 3 and Compute Module 3 (uncached).
Building a C program using these functions
The include file and library are installed by default on a Raspbian system.
Add the following line to your C program:
#include <bcm_host.h>
Link with:
-lbcm_host
So a simple command line compile might be:
cc myfile.c -I/opt/vc/include -L/opt/vc/lib -lbcm_host -o myfile
All Raspberry Pi product has undergone extensive compliance testing, and copies of the relevent certificates and conformity documents are available to download from here.
Flammability rating
The PCBs used in Raspberry Pi devices adhere to UL94-V0. Note that this applies to the PCBs only.
The Raspberry Pi Integrator Programme
The programme provides access to the same test engineers who worked on our Raspberry Pis during their compliance testing. It connects the user to a dedicated team at UL that assesses and tests the user’s product, facilitated by their in-depth knowledge of Raspberry Pi. The team at UL work closely with the Raspberry Pi engineering team, so any unexpected issues that may arise during testing can be resolved quickly. Through the programme, UL will streamline the testing and certification process, which will in turn decrease the amount of time necessary to launch the product. Our Integrator Programme is openly available, it comes with no added cost beyond the usual testing fees at UL, and there are companies already taking advantage of it.
Get your product on the market more quickly
We have put the Integrator Programme in place in the hope of eliminating the burden of navigating complicated compliance issues and making it easier for companies to bring new, exciting products to consumers. With simplified testing, companies and individuals can get products to market in less time and with lower overhead costs.
Each distinct Raspberry Pi model revision has a unique revision code. You can look up a Raspberry Pi's revision code by running:
cat /proc/cpuinfo
The last three lines show the hardware type, the revision code, and the Pi's unique serial number. For example:
Hardware : BCM2835
Revision : a02082
Serial : 00000000765fc593
Old-style revision codes
The first set of Raspberry Pi revisions were given sequential hex revision codes from 0002 to 0015:Code | Model | Revision | RAM | Manufacturer |
---|---|---|---|---|
2 | B | 1 | 256 MB | Egoman |
3 | B | 1 | 256 MB | Egoman |
4 | B | 2 | 256 MB | Sony UK |
5 | B | 2 | 256 MB | Qisda |
6 | B | 2 | 256 MB | Egoman |
7 | A | 2 | 256 MB | Egoman |
8 | A | 2 | 256 MB | Sony UK |
9 | A | 2 | 256 MB | Qisda |
000d | B | 2 | 512 MB | Egoman |
000e | B | 2 | 512 MB | Sony UK |
000f | B | 2 | 512 MB | Egoman |
10 | B+ | 1 | 512 MB | Sony UK |
11 | CM1 | 1 | 512 MB | Sony UK |
12 | A+ | 1.1 | 256 MB | Sony UK |
13 | B+ | 1.2 | 512 MB | Embest |
14 | CM1 | 1 | 512 MB | Embest |
15 | A+ | 1.1 | 256 MB / 512 MB | Embest |
New-style revision codes
With the launch of the Raspberry Pi 2, new-style revision codes were introduced. Rather than being sequential, each bit of the hex code represents a piece of information about the revision:
uuuuuuuuFMMMCCCCPPPPTTTTTTTTRRRR
Part | Represents | Options |
---|---|---|
uuuuuuuu | Unused | Unused |
F | New flag | 1: new-style revision |
0: old-style revision | ||
MMM | Memory size | 0: 256 MB |
1: 512 MB | ||
2: 1 GB | ||
CCCC | Manufacturer | 0: Sony UK |
1: Egoman | ||
2: Embest | ||
3: Sony Japan | ||
4: Embest | ||
5: Stadium | ||
PPPP | Processor | 0: BCM2835 |
1: BCM2836 | ||
2: BCM2837 | ||
TTTTTTTT | Type | 0: A |
1: B | 2: A+ | 3: B+ | 4: 2B | 5: Alpha (early prototype) | 6: CM1 | 8: 3B | 9: Zero | a: CM3 | c: Zero W | d: 3B+ |
RRRR | Revision | 0, 1, 2, etc. |
New-style revision codes in use:
Code | Model | Revision | RAM | Manufacturer |
---|---|---|---|---|
900021 | A+ | 1.1 | 512 MB | Sony UK |
900032 | B+ | 1.2 | 512 MB | Sony UK |
900092 | Zero | 1.2 | 512 MB | Sony UK |
920092 | Zero | 1.2 | 512 MB | Embest |
900093 | Zero | 1.3 | 512 MB | Sony UK |
9000c1 | Zero W | 1.1 | 512 MB | Sony UK |
920093 | Zero | 1.3 | 512 MB | Embest |
a01040 | 2B | 1 | 1 GB | Sony UK |
a01041 | 2B | 1.1 | 1 GB | Sony UK |
a02082 | 3B | 1.2 | 1 GB | Sony UK |
a020a0 | CM3 | 1 | 1 GB | Sony UK |
a21041 | 2B | 1.1 | 1 GB | Embest |
a22042 | 2B (with BCM2837) | 1.2 | 1 GB | Embest |
a22082 | 3B | 1.2 | 1 GB | Embest |
a32082 | 3B | 1.2 | 1 GB | Sony Japan |
a52082 | 3B | 1.2 | 1 GB | Stadium |
a020d3 | 3B+ | 1.3 | 1 GB | Sony UK |
OTP register and bit definitions
All SoCs used by the Raspberry Pi range have a inbuilt One-Time Programmable (OTP) memory block.
It is 66 32-bit values long, although only a few locations have factory-programmed data.
The vcgencmd to display the contents of the OTP is:
vcgencmd otp_dump
OTP REGISTERS
This list contains the publicly available information on the registers. If a register or bit is not defined here, then it is not public.
17 – bootmode register
- Bit 1: sets the oscillator frequency to 19.2MHz
- Bit 3: enables pull ups on the SDIO pins
- Bit 19: enables GPIO bootmode
- Bit 20: sets the bank to check for GPIO bootmode
- Bit 21: enables booting from SD card
- Bit 22: sets the bank to boot from
- Bit 28: enables USB device booting
- Bit 29: enables USB host booting (ethernet and mass storage)
18 – copy of bootmode register
28 – serial number
29 – ~(serial number)
30 – revision number
64/65 – MAC address; if set, system will use this in preference to the automatically generated address based on the serial number
66 – advanced boot register
- Bits 0-6: GPIO for ETH_CLK output pin
- Bit 7: enables ETH_CLK output
- Bits 8-14: GPIO for LAN_RUN output pin
- Bit 15: enables LAN_RUN output
- Bit 24: extends USB HUB timeout parameter
- Bit 25: ETH_CLK frequency:
- 0 - 25MHz
- 1 - 24MHz
Frequency management and thermal control
All Raspberry Pi models perform a degree of thermal management to avoid overheating under heavy load. The SoCs have an internal temperature sensor, which software on the GPU polls to ensure that temperatures do not exceed a predefined limit; this is 85°C on all models. It is possible to set this to a lower value, but not to a higher one. As the device approaches the limit, various frequencies and sometimes voltages used on the chip (ARM, GPU) are reduced. This reduces the amount of heat generated, keeping the temperature under control.
With firmware from 12 September 2016 or later, when the core temperature is between 80°C and 85°C, a warning icon showing a red half-filled thermometer will be displayed, and the ARM cores will be progressively throttled back. If the temperature reaches 85°C, an icon showing a fully-filled thermometer will be displayed, and both the ARM cores and the GPU will be throttled back. See the page on warning icons for images of the icons.
For Raspberry Pi 3 Model B+, the PCB technology has been changed to provide better heat dissipation and increased thermal mass. In addition, a soft temperature limit has been introduced, with the goal of maximising the time for which a device can "sprint" before reaching the hard limit at 85'C. When the soft limit is reached, the clock speed is reduced from 1.4GHz to 1.2GHz, and the operating voltage is reduced slightly. This reduces the rate of temperature increase: we trade a short period at 1.4GHz for a longer period at 1.2GHz. By default, the soft limit is 60°C, and this can be changed via the temp_soft_limit setting in config.txt.
HEATSINKS
Whilst heatsinks are not necessary to prevent overheating damage to the SoC (the thermal throttling mechanism handles that), a heatsink or small fan will help if you wish to reduce the amount of thermal throttling that takes place. Depending on the exact circumstances, mounting the Pi vertically can also help with heat dissipation, as doing so can improve air flow.
MEASURING TEMPERATURE
Due to the architecture of the SoCs used on the Raspberry Pi range, and the use of the upstream temperature monitoring code in the Raspbian distribtution, Linux-based temperature measurements can be inaccurate. There is a gencmd that can provide an accurate and instantaneous reading of the current SoC temperature, as it communicates with the GPU directly:
vcgencmd measure_temp