Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Raspberry Pi tutorial


Published on


課程使用Raspberry Pi結合ARM mbed Cloud來實現一個物聯網解決方案。你會了解M2M(Machine-to-Machine)網路協定,包含CoAP、MQTT、LWM2M等協定,並藉由Raspberry Pi連接 Cloud。 Raspberry Pi的部份教你連接一些感測器,包含GPIO、數位界面I2C的溫溼度感測器、類比感測器如光感應器等,並將這些感測器成為定義為不同的Resource Path並註冊在mbed cloud中。
本課程將採用Node.js撰寫WebAPP,使用HTTP/RESTful API存取Resource。在實作WebAPP中,除了後端Node.js,你也將會看到後端如何與前端瀏覽器之間要如何溝通的方式,如AJAX或WebSocket

Published in: Education

Raspberry Pi tutorial

  1. 1. Raspberry Pi tutorials
  2. 2. Outline Introduction to Raspberry Pi About Linux BSP Misc (backup OS image, vcgencmd, …) Raspberry Pi Education Kit
  4. 4. Raspberry Pi (Model B+)
  5. 5. Hardware Spec. SoC:BroadcomBCM2835(CPU,GPU DSP,SDRAM, USB) CPU:ARM1176JZF-S核心(ARM11系列)700MHz GPU: Broadcom VideoCore IV, OpenGL ES 2.0, 1080p 30 h.264/MPEG-4 AVC RAM: 256MByte (Rev A), 512 MByte (Rev B) OS:Raspbian Linux, GNU/Linux(Debian, Fedora, Arch Linux ARM), Android,…
  6. 6. Video Codec Video Codec for MPEG2 and VC-1 need License You will need to provide your device's internal 16-digit serial number as part of your order. Your serial number is not the number printed on your board.
  7. 7. RaspPi pinout (Model B+) you can learn Linux driver http://
  8. 8. Rasp Pi Software Architecture
  9. 9. SoC BCM2835 Address Map Peripherals are mapped into the kernel virtual address space starting at address 0xF2000000. #define BCM2835_PERI_BASE 0x20000000 #define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000)
  10. 10. Linux BSP Bootloader with Device Tree support Kernel with Device Tree support Drivers for SoC and board components SoC machine specific layer Root file system for software developers GNU cross compiler for ARM architecture xxx Build Environment
  11. 11. Pi’s SD Card Layout 3 Embedded Linux components Boot code Linux Kernel Root File system Boot code kernel Root FileSystem mmcblock0p1 /boot mmcblock0p2 / You can access “boot code partition “ in windows , because it is FAT32
  12. 12. lsblk & fdisk -l
  13. 13. /boot Bootcode • bootcode.bin (Binary) • start.elf (Binary) • fixup.dat (Binary) • config.txt (read before arm) Linux kernel boot command • cmdline.txt dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
  14. 14. RaspPi Startup: GPU --> CPU First stage bootloader --> boot from SD card, and automatically mount SDcard FAT32 Partition Second stage bootloader (bootcode.bin) – Read GPU Firmware (start.elf) on SD card and write to GPU, and then boot GPU GPU firmware (start.elf) - Once loaded, this allows the GPU to start up the ARM. • An additional file, fixup.dat, is used to configure the SDRAM partition between the GPU and the ARM. At this point, the CPU is release from reset and execution is transferred over. Linux code - Kernel.img (note: boot parameters: /boot/cmdline.txt)
  15. 15. /proc/cmdline Linux Kernel boot parameters dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1080 bcm2708.boardrev=0xe bcm2708.serial=0x67da1f2e smsc95xx.macaddr=B8:27:EB:DA:1F:2E sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait More about RPI BCM2708 Parameters
  16. 16. Linux booting flow 1. Boot up with Broadcom Bootcode 2. Initialize the system and peripherals. 3. Launch linux kernel 4. Mount initird (initial ramdisk), if any 5. Mount the real root filesystem 6. Execute init and launch shell Embedded Linux Course Execute init Mount rootfs Start kernel Boot code ARM Linux GPU
  17. 17. Root File system There are two components to a running Linux system: the kernel and the root file system Root file system : mounted as the root directory (/) To work properly, the root filesystem should include a minimum set of files to support the system 1) runtime shared libraries from the toolchain : /lib/*.so 2) system configuration files : /etc/* 3) /dev 4) … Applications Shared Library Linux Kernel Root filesystem 2-17 Embedded Linux Course
  18. 18. Root File System Layout Embedded Linux Course / ├── bin ├── boot ├── dev ├── etc ├── home ├── lib ├──init ├──firmware ├── modules/<kernel_ver> ├── modprobe.d ├── lost+found ├── media ├── mnt ├── opt ├── proc ├── root ├── run ├── sbin ├── selinux ├── srv ├── sys ├── tmp ├── usr └── var
  19. 19. Filesystem Hierarchy Standard (FHS) 2-19 Embedded Linux Course Directory Description bin Essential command binaries boot Static files of the boot loader dev Device files etc Host-specific system configuration lib Essential shared libraries and kernel modules media Mount point for removeable media mnt Mount point for mounting a filesystem temporarily opt Add-on application software packages sbin Essential system binaries tmp Temporary files usr Secondary hierarchy var Variable data Root File System Layout
  20. 20. Mount Edit /etc/fstab Check “mount” status,, run mount command
  21. 21. Cat /proc/filesystems (support by your kernel)
  22. 22. MISC
  23. 23. /boot/config.txt  like PC BIOS setting
  24. 24. Module Blacklist /etc/modprobe.d/raspi-blacklist.conf Raspbian configuration files that prevents them from being loaded automatically (the normal setting)
  25. 25. Load I2C Driver Module The I2C ports need to be enabled in Raspbian before they can be used. $sudo nano /etc/modules $sudo nano /etc/modprobe.d/raspi-blacklist.conf remove a '#' character to this line ​To install the I2C utilities: $sudo apt-get install i2c-tools $sudo reboot i2c-bcm2708 i2c-dev # blacklist i2c-bcm2708
  26. 26. Access EEPROM Using I2c-tools i2cdetect -y 1 EEPROM read/write using i2cset/i2cget open source I2c-tools
  27. 27. Screen Shot
  28. 28. Run a script on start up sudo nano /etc/rc.local Make sure not to miss the & character at the end, otherwise the script will not run in the background and will make the booting process get stuck in a loop!
  29. 29. Backing up your Operating System image BACKUP sudo dd bs=4M if=/dev/sdb of=raspbian.img Restore you system from SD card sudo dd bs=4M if=raspbian.img of=/dev/sdb
  30. 30. Communicate with VC ( Broadcom Video Core) vcgencmd :Command exported from GPU Firmware See root@raspberrypi:/home# vcgencmd commands commands="vcos, ap_output_control, ap_output_post_processing, vchi_test_init, vchi_test_exit, pm_set_policy, pm_get_status, pm_show_stats, pm_start_logging, pm_stop_logging, version, commands, set_vll_dir, led_control, set_backlight, set_logging, get_lcd_info, set_bus_arbiter_mode, cache_flush, otp_dump, codec_enabled, get_camera, get_mem, measure_clock, measure_volts, measure_temp, get_config, hdmi_ntsc_freqs, hdmi_status_show, pwm_speedup, force_audio, render_bar, disk_notify, inuse_notify, sus_suspend, sus_status, sus_is_enabled, sus_stop_test_thread, egl_platform_switch, mem_validate, mem_oom, mem_reloc_stats, file, vctest_memmap, vctest_start, vctest_stop, vctest_set, vctest_get"
  31. 31. vcgencmd Examples
  32. 32. Raspberry Pi Education Kit Read more :
  33. 33. References http://