2. Prep The SD Card

2. Prep The SD Card

Before You Begin

The SD Card is the hard drive of the GoPiGo Robot. We will insert it into the Raspberry Pi (the green board).

This will have basic information on preparing your SD Card for working with the BrickPi. A standard installation of Raspbian will not work without some modification; there are some modifications that must be made to operate the BrickPi.  Click on one of the three options below to setup your SD Card.

Caution

A note of caution: never remove the SD card while the robot is powered on. The BrickPi case is designed to prevent the SD card from being knocked out. Removing or inserting the SD card while the BrickPi is powered can corrupt the SD Card.

If you bought an SD Card from Dexter Industries:

If you installed the Dexter Industries SD card for your BrickPi, you can skip this step: your SD card is already configured!   Please make sure you’re using the latest version of the BrickPi image.

The SD Card from Dexter Industries comes packaged in a plastic jewel case. The microSD Card comes inserted in an SD Card adapter. Remove the microSD card from the adapter.

Hold the microSD Card from the sides, careful not to touch the metal on the card with your fingers. Turn the microSD Card so that the metal pins are facing down, towards the Raspberry Pi. Insert the miscroSD card into the metal slot on the Raspberry Pi until you hear a “click”. When you hear the “click” the microSD Card is properly inserted.

You can expand your Dexter Industries SD Card by running the command in the command line:

sudo raspi-config

And choose “Expand the rootfs” to use all available space on the SD Card.

Note:  If the version you are using the current version or anything after 2015.11 (for example, 2015.11.09), your username is “pi”, your password is “robots1234” and your hostname is “dex.local”.  If the software is before 2015.11 (for example, 2015.03.15) your login credentials are username “pi” and your password is “raspberry” and the hostname is “raspberrypi”.  If you have the older software, we encourage you to upgrade for free.

Download and use our operating system on your own SD Card:

If you want to download and use our modified Raspbian image on a dedicated SD card we have step by step instructions on installing the Raspbian for Robots Image to an SD Card here for both Mac and PC.

Our operating system comes with all of the software installed to get the BrickPi up and running, including the example programs.

After you have installed the operating system, hold the microSD Card from the sides, careful not to touch the metal on the card with your fingers. Turn the microSD Card so that the metal pins are facing down, towards the Raspberry Pi. Insert the miscroSD card into the metal slot on the Raspberry Pi until you hear a “click”. When you hear the “click” the microSD Card is properly inserted.

You can expand the memory on your Dexter Industries SD Card by running the command in the command line:

sudo raspi-config

And choose “Expand the rootfs” to use all available space on the SD Card.

Note:  Your username is “pi”, your password is “robots1234” and your hostname is “dex.local”.

Modify your own image:

If you want to use your own Raspbian installation, you must make changes yourself to the Raspberry Pi.

You can download and run our install script which will automatically download and install all the packages and dependencies required for BrickPi to your existing Raspberry Pi operating system.

1). Open the Terminal and clone the Dexter Industries BrickPi Repository

git clone https://github.com/DexterInd/BrickPi.git

2). A folder named BrickPi should appear in you current working directory

3). Open it and go to Setup Files directory

cd “BrickPi/Setup Files”

4). The install script is called install.sh . Make it executable

sudo chmod +x install.sh

5). Run the install script

sudo ./install.sh

6). Follow the onscreen instructions and the script will install all the dependencies and will Restart upon completion. Your Raspbian should now be ready to run BrickPi.

 

The following are the modifications that were made to a Raspbian Wheezy image from the Raspbery Pi foundation “wheezy” (found here). We recommend only experienced users make these changes to their images! Communications Summary BrickPi makes use of the following interfaces:

  • Serial  – Serial is used to send motor power levels and sensor commands, as well as receive encoder values from Sensor Ports 1-4, and Motor Ports A-D.  Serial is sent and received on GPIO 14 (UART0-TX) and GPIO 15 (UART0-RX) of the Raspberry Pi board.
  • I2C – (AKA SMBUS) Is used to control sensor Port 5.  I2C is sent and received on GPIO0 (I2C0-SDA) and GPIO1 (I2C0-SCL) pins of the Raspberry Pi board.
  • GPIO – GPIO commands (on and off) are used to turn the two lights on and off.  LED1 is controlled on GPIO21, and LED2 is controlled on GPIO18.

Setup Wiring Pi You will need wiringPi to be installed on the RPi. Get the modified version from our github repository here: https://github.com/DexterInd/BrickPi/tree/master/Setup%20Files This modified version supports higher baud rates.

  1. Unzip the file to RPi desktop and then open the terminal.
  2. Navigate to the wiringPi directory by entering:  cd /home/pi/Desktop/wiringPi
  3. Change permissions for build file to execute by entering:  chmod 777 build
  4. Now, excute the build file by entering: ./build

The wiringPi Library should be set up automatically. Reference: https://projects.drogon.net/raspberry-pi/wiringpi/i2c-library/ Set the UART Clock Speed You will need to increase the UART clock speed.

  1. Open up /boot/config.txt by entering: cd /boot sudo nano config.txt
  2. Check if a property named init_uart_clock exists.
  3. Either create (if the line does not exist) or change (if the line exists) line: init_uart_clock=32000000

Fast I2C Setup In order to use an I2C  sensor on Port 5, you need to install and load I2C.

  1. To install I2C, enter:  sudo apt-get install libi2c-dev
  2. To load and set speed(in k baud), enter: gpio load i2c 10

Enable Serial Pins In order to use the Raspberry Pi’s serial port, we need to disable getty.

  1. Open the file by entering: sudo nano /etc/inittab
  2. Now, find the line that says “T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100”
  3. And comment it out by adding # in front of it
  4. Save the file and exit.

We need to prevent the Raspberry Pi from sending out data to the serial ports when it boots.  To do this:

  1. Open the command line.
  2. Enter: sudo nano /boot/cmdline.txt
  3. Find the following content and delete it:  console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
  4. Now, reboot the RaspberryPi.

Serial for Python If you want to use the Python language or Scratch language you will need the Serial library for python.

  1. Open the Command Line
  2. Install Serial for Python by entering:  sudo apt-get install python-serial

Enable GPIO Pin Access You may need to access the GPIO Pins of RaspberryPi (for example, to use LEDs on BrickPi).  You may need the RPi.GPIO Library.  This package has been installed on Raspbian for some time and if you already have it installed, skip this step.

  1. Open the Command Line
  2. To install the GPIO library, enter:  sudo apt-get install python-rpi.gpio

A link for Reference, Usage & Examples.

Successful Bootup

This is a video of what a successful bootup with Raspbian for Robots and the Raspberry Pi looks like.

Questions?  Ask on the BrickPi forum here.