The document discusses the boot process of the Raspberry Pi. It begins with a first stage bootloader in the ROM that mounts the FAT32 partition on the SD card. It then loads a second stage bootloader (bootcode.bin) which initializes RAM and PLLs. This bootloader parses config.txt and loads a third stage (the RTOS binary start.elf). The RTOS is launched, it splits RAM between the GPU and ARM, loads config.txt and cmdline.txt, and hands over to the operating system.
2. Q&A
• Did anyone used microcontrollers or SoCs
• Atmel
• PIC
• Z80, …
• Any experiences with embedded systems or devboards?
• Arduino style…
• Raspberry/Orange/Banana Pi, Humming board, Beaglebone,Odroid
• Who plans to build a media center?
• Who has kids?
4. Why Raspberry Pi and the Foundation
• Inspired by ZX Spectrum
• Cheap computer for every child
• Educational reasons – kids do not know how to code
• People happen to be consumers, RPF wants to inspire makers
• Accidental price
• 2006 model build on Atmel ATmega644
• Broadcom employees changed stuff
• Language of choice Python, later Scratch
• Many other languages and tools
9. Raspberry Pi Model B+
• Announced on 14th July 2014
• Broadcom BCM2835 SoC, with ARM1176JZF-S 700 MHz
processor
• VideoCore IV dual-core 250 MHz GPU
• 512 MB SDRAM - shared by the GPU and CPU
• MicroSD card slot for boot and storage
• 4 x USB 2.0 ports (via on-board 5 port hub)
• RJ45 10/100 MBit/s Ethernet port
• HDMI and Composite video, audio through TRRS jack
• 40 pin GPIO, I2C, SPI, UART interface connector
• CSI (camera) and DSI (display) connectors
• 4 squarely positioned mounting holes
• 600 mA (3.0 W)
10. Raspberry Pi 2 Model B
• Announced on 2nd Feb 2015
• Broadcom BCM2836 SoC, with quad-core ARM Cortex-A7 900 MHz processor
• Ubuntu Core
• Windows 10 IOT Core
• VideoCore IV dual-core 250 MHz GPU
• 1 GB SDRAM - shared by the GPU and CPU
• MicroSD card slot for boot and storage
• 4 x USB 2.0 ports (via on-board 5 port hub)
• RJ45 10/100 MBit/s Ethernet port
• HDMI and Composite video, audio through TRRS jack
• 40 pin GPIO Interface connector
• CSI (camera) and DSI (display) connectors
• 4 squarely positioned mounting holes
11. Power – chief culprit
• Micro USB 5V, 1A
• Poly-fuse is problem of the past
• 5.25V is OK for USB
• http://www.modmypi.com/raspberry-pi/accessories/power-supplies/5v-2a-
ultra-hq-usb-power-supply-eu
• USB Power
• max_usb_current=1
• USB output current limit from 600mA to double that, 1200mA
12. Micro SD Card
• SD, SDHC, SDXC, UHC, all of them except the ones that do not work.
• Boot partition FAT32
• Max. around 20MB/s
• http://elinux.org/RPi_SD_cards
14. B+ is ARMv6 a.k.a ARM11
• General purpose
• NOOBS - installer
• Raspbian
• Ubuntu Mate, Ubuntu Core (rPi2 only)
• Pidora, Arch and other unofficial
• Mediacenter
• OSMC
• Openelec
• Xbian
• Other obscure OSes
• Windows 10 IOT Core (rPi2 only)
• RISC OS
15. How to install
• FAT32, just extract it there
• Disk image – just dd it there
• Most distros have Win/Mac/Lin installers
16. Micro SD - Partitions
• diskpart
• list disk
• select diskn
• list partition
• select partitionn
• delete partition
17. Notifications and monitoring
• Red square: over-temperature
• Rainbow square: under-voltage
• /sys/class/thermal/thermal_zone0/temp
• /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
• Core temp below 70 degrees
• Voltage above 4.8V, across test pads PP3 (GND) and PP7 (VCC) or PP1( VCC before polyfuse)
• Brown-out detector will at VCC <= 4.65V switch off the power LED
• Watchdog – config.txt
• sudo apt-get install watchdog
• sudo update-rc.d watchdog defaults
• sudo vim /etc/watchdog.conf
19. What is really in BCM2835 SoC?
• ARM1176JZF-S 700 MHz processor – secondary processor
• Dualcore Videocore IV CPU @250MHz with SIMD Parallel Pixel Units
(PPU) which runs scalar (integer and float) and vector (integer only)
programs – primary processor
• Image Sensor Pipeline (ISP) providing lens shading, statistics and
distortion correction
• 12 QPU units which provide 24 GFLOPS compute performance for
coordinate, vertex and pixel shaders
20. Broadcom VideoCore IV @ 250 MHz
• OpenGL ES 2.0 - OpenGL is a 3D library
• OpenVG - OpenVG is a 2D vector drawing library
• EGL - EGL is an interface between OpenGL ES or OpenVG and the
underlying native platform window system.
• OpenMAX IL - OpenMAX API’s used for audio, video, and still images
processing
• Inside Videcore - https://www.raspberrypi.org/magpi-
issues/MagPi35.pdf page 35
21. VA API, CUDA and others like OpenCL
• OpenMAX
• QPU Assembly
22. Broadcom VideoCore IV @ 250 MHz
• MPEG-2 (license)
• VC-1 (license)
• 1080p30 H.264/MPEG-4 AVC high-profile decoder and encoder
• How to encode
https://www.raspberrypi.org/forums/viewtopic.php?t=72435
23. Dude I just want to build media center…
… more nerdy stuff at the end
26. What can it play
• Bundled acceleration
• H.264 (up to High Profile) up to 1080P
• MPEG-4 up to 1080P. This includes XviD and DivX (but not the older 3.xx DivX).
• Licenses: http://www.raspberrypi.com/license-keys/
• MPEG-2
• VC1
• GPU assisted:
• MJPEG, VP6, VP8 and OGG Theora. Limited to DVD resolutions.
• No acceleration:
• DivX 3, msmpeg, sorenson spark on the ARM. Should work for SD resolutions.
• DTS audio decode works well in recent builds
• TrueHD audio is CPU intensive and may require overclocking
34. Python GPIO
• import RPi.GPIO as GPIO
• Default and will be always supported
• MMAP - Script must be root or write access to /dev/mem
• Kind of abandoned, SPI, PWM missing
• from gpiozero import …
• New and cool
• Focused on beginners
• Examples with wiring diagrams
• import wiringpi2
• Wiringpi wrapper
• Stable, most complete
• import pigpio
• Daemon, no-root for users
• PWM, I2C, SPI, UART, waveforms,
35. How to access it?
• http://elinux.org/RPi_GPIO_Code_Samples
36. GPIO - Blink
• Interactive pinout diagram http://pinout.xyz/
• GPIO zero
from gpiozero import LED
from time import sleep
led = LED(17)
while True:
led.on()
sleep(1)
led.off()
sleep(1)
38. Custom GPIO pin setup
• pins_rev1 Rev1 pin setup. There are some difference because of the moved I2C pins
• pins_rev2 Rev2 pin setup. This includes the additional codec pins on P5
• pins_bplus1 Model B+ rev 1.1, including the full 40pin connector
• pins_bplus2 Model B+ rev 1.2, swapping the low-power and lan-run pins
• pins_aplus Model A+, lacking ethernet
• pins_2b1 Pi 2 Model B rev 1.0, controls the SMPS via I2C0
• pins_2b2 Pi 2 Model B rev 1.1, controls the SMPS via software I2C on 42&43
• pins_cm The Compute Module, note the default for this is the default for the chip so can
be a useful source of information about default pullups / downs on the chip.
• https://www.raspberrypi.org/documentation/configuration/pin-configuration.md
47. Movies are watched and robot is built.
Now what?
• Baking Pi – ASM, bare metal
• https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/
• Low level graphics – C, framebuffer in Linux
• http://raspberrycompote.blogspot.ie/2012/12/low-level-graphics-on-
raspberry-pi-part_9509.html
• Bare metal examples – C, bare metal
• https://github.com/dwelch67/raspberrypi
• Programming AudioVideo on the Raspberry Pi GPU – C, linux
• https://jan.newmarch.name/RPi/index.html
48. Projects
• Baby monitor
• https://github.com/silvanmelchior/RPi_Cam_Web_Interface
• Vertical plotter WIP
• Video1: https://plus.google.com/u/0/+MichalSedlak/posts/ZjMeC3qguMV
• Video2: https://plus.google.com/photos/photo/116922401464380915458/6059538975170772338
• Plotter: https://github.com/michal6103/droopy
• Renderer: https://github.com/michal6103/droopy-web
• Ambient light WIP Raspberry for server side only, client NodeMCU
• PWM, APA102
• https://github.com/michal6103/striplight
• Hyperion – Opensourced Amblight – waiting for Xbian SPI module
• Video: https://www.youtube.com/watch?v=lnx_futkSQ8
• https://github.com/tvdzwan/hyperion/wiki
• Future:
• Fairy tails audio box, controlled by RFID card for kids
• OpenCV and Box2D voleyball
• Lemon power source
• Speed radar
51. Broadcom VideoCore IV @ 250 MHz
• On 28 February 2014, release of full documentation for the VideoCore
IV's 3D subsystem ->
http://www.broadcom.com/docs/support/videocore/VideoCoreIV-
AG100-R.pdf
• Only a minor part of Broadcom’s software released as open source
• All acceleration is done using a firmware for VPU
• The entire SoC itself is managed / initialized by a ThreadX. RTOS that
is loaded into the Videocore's VPU during bootup
53. Wait what? Where is ThreadX, RTOS?
• BCM2835 – VPU is primary, CPU is “coprocessor”
• VPU is running ThreadX RTOS, then starts ARM and stuff
54. Yeah … I got it … What?
• The VideoCore is a custom processor, but is general-purpose enough
to run ThreadX
• The QPU units have been specially tailored to 3D tasks.
• The Videocore runs a RTOS
• RTOS API/ABI translates high-level 3D instructions (e.g. from OpenGL) into
commands for the QPU units
• The bootcode.bin acts as bootloader , start.elf contains the RTOS
• https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=78414
55. Cool, what does it mean?
• You can write write software for bare hardware
• Any language you like for ARM, in case it is C or assembly
• Assembler and C toolchain for the VideoCore IV
• https://github.com/hermanhermitage/videocoreiv/
• https://github.com/hermanhermitage/videocoreiv/wiki/VideoCore-IV-Programmers-
Manual
• Assembler for QPUs
• https://github.com/hermanhermitage/videocoreiv-qpu
• http://petewarden.com/2014/08/07/how-to-optimize-raspberry-pi-code-using-its-gpu/
58. How does it boot?
• First stage bootloader in ROM, ran by RISC core on VPU
• Mount FAT32 on SD Card
• VPU loads second-stage bootloader from the SD Card - bootcode.bin
• Second-stage bootloader bootcode.bin
• loaded into the L2 cache as we do not have RAM yet
• inits the RAM and the PLLs
• Parse config.txt for memory split
• third-stage bootloader loaded from SD Card - start.elf {RTOS binary}
• RTOS is launched
• Splits RAM – GPU/ARM {fixup.dat}
• Loads config.txt from SD card
• Loads cmdline.txt
• Loading kernel.img
• Powering on the ARM core {reset 0}
• Hurray Linux
• https://thekandyancode.wordpress.com/2013/09/21/how-the-raspberry-pi-boots-up/
59. Overclock
• raspi-config
• Multiple settings in config.txt
• Turbo mode does not break warranty
• https://www.raspberrypi.org/blog/introducing-turbo-mode-up-to-50-
more-performance-for-free/
• SD card problems when overclocked – no after Nov 11 2013
60. Config.txt is new BIOS settings
https://www.raspberrypi.org/documentation/configuration/config-
txt.md
61. Device trees are the PnP
• Just read this:
https://raw.githubusercontent.com/raspberrypi/firmware/master/boot/overlays/README
• Maybe this: https://www.raspberrypi.org/documentation/configuration/device-tree.md
• Info about devices
• Text file compiled to binary blob
• OS neutral
• Configuration parameters
• Forget about modprobe
• Overlays
• raspi-config for some devices
• Non-dt kernels - ATAGs
62. Device trees
• config.txt
• dtoverlay=lirc-rpi,gpio_out_pin=17
• spi - Set to "on" to enable the spi interfaces (off)
• random - Set to "on" to enable the hardware random number generator
(off)
• uart0 - Set to "off" to disable uart0 (on)
• watchdog - Set to "on" to enable the hardware watchdog (off)
• Other devices and HATs
• HATs identified by DTB stored in EEPROM