RaspberryPi
michal6103@gmail.com
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?
Raspberry Pi Foundation
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
Hardware
Geek’s guide
rPi Atmel edition
Models
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)
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
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
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
OS
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
How to install
• FAT32, just extract it there
• Disk image – just dd it there
• Most distros have Win/Mac/Lin installers
Micro SD - Partitions
• diskpart
• list disk
• select diskn
• list partition
• select partitionn
• delete partition
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
Hardware
Hacker’s guide
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
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
VA API, CUDA and others like OpenCL
• OpenMAX
• QPU Assembly
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
Dude I just want to build media center…
… more nerdy stuff at the end
Mediacenter
Distros
• No raspi-config here
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
Tuners
• H.264 encode/decode [DVB-S2]
• Licenses:
• MPEG2 decode [DVB-T, DVB-S]
• VC-1
• Tuners:
http://elinux.org/RPi_VerifiedPeripherals#USB_TV_Tuners_and_DVB_
devices
Audio
• Outputs:
• HDMI
• Analog
• I2S {HATs}
• USB soundcards
• MP3 soft decoding stereo
• AC3 , DTS, PCM pass-through
• Multichannel PCM not supported by all receivers – select 2.0 output
IR Remote
• Xbian mappings = Pain
• Kodi
• remote.xml
• Lircmap.xml
• lircd.conf
• USB IR stuff
• LIRC DT overlay – config.txt
• LIRC daemon
• HDMI-CEC
• CEC enabled HDMI cable – pin13
GPIO
GPIO
GPIO Permissions
• MMAP – root access
• SYSFS
• pigpio
• gpio-admin
GPIO performance
Language Library Tested / version Square wave
Shell /proc/mem access 2015-02-14 2.8 kHz
Shell / gpio utility WiringPi gpio utility 2015-02-15 / 2.25 40 Hz
Python RPi.GPIO 2015-02-15 / 0.5.10 70 kHz
Python wiringpi2 bindings 2015-02-15 / latest github 28 kHz
Ruby wiringpi bindings 2015-02-15 / latest gem (1.1.0) 21 kHz
C Native library 2015-02-15 / latest RaspPi 22 MHz
C BCM 2835 2015-02-15 / 1.38 5.4 MHz
C wiringPi 2015-02-15 / 2.25 4.1 – 4.6 MHz
Perl BCM 2835 2015-02-15 / 1.9 48 kHz
http://codeandlife.com/2012/07/03/benchmarking-raspberry-pi-gpio-speed/
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,
How to access it?
• http://elinux.org/RPi_GPIO_Code_Samples
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)
I am hacker, I hack!!!!
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
Camera
• RAW - Bayer pattern
• Image Sensor Pipeline
• 5Mpx
• fixed-focus
• 1080p30
• 720p60
• VGAp90 – slowmo
Camera
• Standard and NoIR
• 250mA
• HW acceleration
• JPEG
• H.264
• V4L2 API
• raspistill
• raspivid
• Python
• OpenCV
• Timelapse, slowmo
• Motion detection
MMAL - Multi-Media Abstraction Layer
• Accelerated:
• Encoding
• Filters - Blur, Sobel, YUV ….
• Multiplexing
• http://www.jvcref.com/files/PI/documentation/html/
• http://blog.oklahome.net/2014/09/what-ive-learned-about-mmal-
raspberry.html
Camera and Python
• Python:
• https://github.com/waveform80/picamera/tree/release-1.8
• PIL, OpenCV objects
• Stream – network, circular, H.264
• Overlaying
• Examples included: http://picamera.readthedocs.org/en/release-
1.10/
Simple stream from camera
• sudo modprobe bcm2835-v4l2
• cvlc v4l2:///dev/video0 --v4l2-width 1920 --v4l2-height 1080 --v4l2-
chroma h264 --sout '#standard{access=http,mux=ts,dst=0.0.0.0:12345}'
:demux=264
Babymonitor
Display
• https://www.raspberrypi.org/blog/the-eagerly-awaited-raspberry-pi-
display/
• RGB 800×480 display @60fps
• 24-bit colour
• FT5406 10 point capacitive touchscreen
• 70 degree viewing angle
• Metal-backed display with mounting holes for the Pi
Display
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
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
https://www.raspberrypi.org/magpi-
issues/Projects_Book_v1.pdf
Hardware
Nerd’s guide – You know the licenses and how it works…
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
Wait what?
Videocore IV GPU
Wait what? Where is ThreadX, RTOS?
• BCM2835 – VPU is primary, CPU is “coprocessor”
• VPU is running ThreadX RTOS, then starts ARM and stuff
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
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/
Down the rabbit hole
• https://github.com/hermanhermitage
So much flexibility in your solution feels like
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/
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
Config.txt is new BIOS settings
https://www.raspberrypi.org/documentation/configuration/config-
txt.md
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
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
Q&A
Future session
• Baking Pi or one of projects
Thank you for your time
GPS modules
• http://elinux.org/RPi_VerifiedPeripherals#USB_GPS_devices
• SPI, I2C
• Text protocols

Raspberry Pi Introduction

  • 1.
  • 2.
    Q&A • Did anyoneused 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?
  • 3.
  • 4.
    Why Raspberry Piand 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
  • 5.
  • 6.
  • 7.
  • 9.
    Raspberry Pi ModelB+ • 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 2Model 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 – chiefculprit • 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
  • 13.
  • 14.
    B+ is ARMv6a.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
  • 18.
  • 19.
    What is reallyin 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, CUDAand 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 justwant to build media center… … more nerdy stuff at the end
  • 24.
  • 25.
  • 26.
    What can itplay • 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
  • 27.
    Tuners • H.264 encode/decode[DVB-S2] • Licenses: • MPEG2 decode [DVB-T, DVB-S] • VC-1 • Tuners: http://elinux.org/RPi_VerifiedPeripherals#USB_TV_Tuners_and_DVB_ devices
  • 28.
    Audio • Outputs: • HDMI •Analog • I2S {HATs} • USB soundcards • MP3 soft decoding stereo • AC3 , DTS, PCM pass-through • Multichannel PCM not supported by all receivers – select 2.0 output
  • 29.
    IR Remote • Xbianmappings = Pain • Kodi • remote.xml • Lircmap.xml • lircd.conf • USB IR stuff • LIRC DT overlay – config.txt • LIRC daemon • HDMI-CEC • CEC enabled HDMI cable – pin13
  • 30.
  • 31.
  • 32.
    GPIO Permissions • MMAP– root access • SYSFS • pigpio • gpio-admin
  • 33.
    GPIO performance Language LibraryTested / version Square wave Shell /proc/mem access 2015-02-14 2.8 kHz Shell / gpio utility WiringPi gpio utility 2015-02-15 / 2.25 40 Hz Python RPi.GPIO 2015-02-15 / 0.5.10 70 kHz Python wiringpi2 bindings 2015-02-15 / latest github 28 kHz Ruby wiringpi bindings 2015-02-15 / latest gem (1.1.0) 21 kHz C Native library 2015-02-15 / latest RaspPi 22 MHz C BCM 2835 2015-02-15 / 1.38 5.4 MHz C wiringPi 2015-02-15 / 2.25 4.1 – 4.6 MHz Perl BCM 2835 2015-02-15 / 1.9 48 kHz http://codeandlife.com/2012/07/03/benchmarking-raspberry-pi-gpio-speed/
  • 34.
    Python GPIO • importRPi.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 accessit? • 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)
  • 37.
    I am hacker,I hack!!!!
  • 38.
    Custom GPIO pinsetup • 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
  • 39.
    Camera • RAW -Bayer pattern • Image Sensor Pipeline • 5Mpx • fixed-focus • 1080p30 • 720p60 • VGAp90 – slowmo
  • 40.
    Camera • Standard andNoIR • 250mA • HW acceleration • JPEG • H.264 • V4L2 API • raspistill • raspivid • Python • OpenCV • Timelapse, slowmo • Motion detection
  • 41.
    MMAL - Multi-MediaAbstraction Layer • Accelerated: • Encoding • Filters - Blur, Sobel, YUV …. • Multiplexing • http://www.jvcref.com/files/PI/documentation/html/ • http://blog.oklahome.net/2014/09/what-ive-learned-about-mmal- raspberry.html
  • 42.
    Camera and Python •Python: • https://github.com/waveform80/picamera/tree/release-1.8 • PIL, OpenCV objects • Stream – network, circular, H.264 • Overlaying • Examples included: http://picamera.readthedocs.org/en/release- 1.10/
  • 43.
    Simple stream fromcamera • sudo modprobe bcm2835-v4l2 • cvlc v4l2:///dev/video0 --v4l2-width 1920 --v4l2-height 1080 --v4l2- chroma h264 --sout '#standard{access=http,mux=ts,dst=0.0.0.0:12345}' :demux=264
  • 44.
  • 45.
    Display • https://www.raspberrypi.org/blog/the-eagerly-awaited-raspberry-pi- display/ • RGB800×480 display @60fps • 24-bit colour • FT5406 10 point capacitive touchscreen • 70 degree viewing angle • Metal-backed display with mounting holes for the Pi
  • 46.
  • 47.
    Movies are watchedand 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
  • 49.
  • 50.
    Hardware Nerd’s guide –You know the licenses and how it works…
  • 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
  • 52.
  • 53.
    Wait what? Whereis ThreadX, RTOS? • BCM2835 – VPU is primary, CPU is “coprocessor” • VPU is running ThreadX RTOS, then starts ARM and stuff
  • 54.
    Yeah … Igot 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 doesit 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/
  • 56.
    Down the rabbithole • https://github.com/hermanhermitage
  • 57.
    So much flexibilityin your solution feels like
  • 58.
    How does itboot? • 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 • Multiplesettings 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 newBIOS settings https://www.raspberrypi.org/documentation/configuration/config- txt.md
  • 61.
    Device trees arethe 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
  • 63.
  • 64.
    Future session • BakingPi or one of projects
  • 65.
    Thank you foryour time
  • 66.