Skip to content

Latest commit

 

History

History
224 lines (163 loc) · 5.25 KB

03-peripherals.md

File metadata and controls

224 lines (163 loc) · 5.25 KB

Guide to Cross Compilation for a Raspberry Pi

  1. Start
  2. Setup XCS and RPi
  3. Setup RPi Network and SSH
  4. > Setup RPi Peripherals
  5. Setup Cross-compile environment
  6. Cross-compile and Install Userland
  7. Cross-compile and Install OpenCV
  8. Cross-compile and Install ROS
  9. Compile and Install OpenCV
  10. Compile and Install ROS
  11. Remote ROS (RPi node and XCS master)
  12. ROS package development (RPi/XCS)
  13. Compile and Install WiringPi

4. Setup RPi Peripherals

While not relevant for cross-compilation, this page describes how to setup i2c peripherals or the pi-camera. It is added to this guide for completeness to start you own projects.

Table of Contents

  1. Prerequisites
  2. Setup i2c
  3. i2c: RTC
  4. i2c: MCP23017 IO Expander
  5. Setup Camera
  6. Next

Prerequisites

  • Setup of XCS and RPi
  • Setup of RPi Network and SSH

Setup i2c

Source: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

  1. Connect to the RPi to install dependencies

    XCS~$ ssh rpizero-local
    RPI~$ sudo apt-get install python2.7 python3 python-smbus python3-smbus python-dev python3-dev i2c-tools
    
  2. Edit boot.txt so i2c is loaded upon startup

    RPI~$ sudo nano /boot/config.txt
    

    Add the following lines to the bottom of the file

    #enable i2c
    dtparam=i2c1=on
    dtparam=i2c_arm=on
    
  3. Edit modules so the i2c kernel is loaded

    RPI~$ sudo nano /etc/modules
    

    Add the following lines to the bottom of the file

    #load i2c
    i2c-bcm2708
    i2c-dev
    
  4. Allow pi-user to use i2c

    RPI~$ sudo adduser pi i2c
    
  5. Shutdown RPi and disconnect from the power supply

    RPI~$ sudo shutdown now
    
  6. Connect your i2c device and powerup.

  7. Check if an i2c device is found:

    RPI~$ sudo i2cdetect -y 1
       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
      00:          -- -- -- -- -- -- -- -- -- -- -- -- --
      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
      70: -- -- -- -- -- -- -- --  
    

    The number shown is the i2c address of the device you connected.

i2c: RTC

Source: https://thepihut.com/collections/raspberry-pi-hats/products/rtc-pizero

  1. Ensure that the RTC is attached to the RPi and that i2cdetect lists it as a i2c device.

  2. Edit boot.txt so the RTC is loaded upon startup

    XCS~$ ssh rpizero-local
    RPI~$ sudo nano /boot/config.txt
    

    Add the following lines to the bottom of the file

    #enable rtc
    dtoverlay=i2c-rtc,ds1307
    
  3. Edit modules so the RTC kernel is loaded

    RPI~$ sudo nano /etc/modules
    

    Add the following lines to the bottom of the file

    #load rtc
    rtc-ds1307
    
  4. Allow (re)setting of the hw-clock

    RPI~$ sudo nano /lib/udev/hwclock-set
    

    Comment out these lines:

    # if [ -e /run/systemd/system ] ; then
    # exit 0
    # fi
    
  5. Reboot to load RTC

    RPI~$ sudo reboot now
    
  6. Reading and setting the hwclock can be done by:

    • Reading:
    RPI~$ sudo hwclock -r
    
    • Writing:
    RPI~$ sudo date -s "Fri Jan 20 10:53:40 CET 2017"
    RPI~$ sudo hwclock -w  
    

i2c: MCP23017 IO Expander

Source: https://www.kiwi-electronics.nl/io-pi-zero

..

Setup Camera

  1. Shutdown RPi and disconnect from the power supply

  2. Connect the camera and powerup.

  3. After powerup, login via SSH and enable camera

    XCS~$ ssh rpizero-local
    RPI~$ sudo raspi-config
    

    Goto Interfacing options > Camera > Select and reboot

  4. To test the camera, login with SSH with X-server enabled:

    XCS~$ ssh -X rpizero-local
    

    Take note on the message on login. If you see "Warning: untrusted X11 forwarding setup failed: xauth key data not generated" you might need to use the "-Y" instead of "-X" option.

  5. Install the links2 image viewer

    RPI~$ sudo apt-get install links2
    
  6. Test the camera

    RPI~$ raspistill -v -o test.jpg
    
  7. View the preview.

    RPI~$ links2 -g test.jpg
    

    Depending on the speed of the connection, this might take a while.

    If you see a message similar to:

    Could not initialize any graphics driver. Tried the following drivers:
    x:
    Can't open display "(null)"
    fb:
    Could not get VT mode.
    

    you should review the "ssh"-login-message and might need to use the "-Y" instead of "-X" option of ssh as noted above.

Next

Having installed the peripherals, it is time to setup the cross-compilation environment.