Connecting Your BeagleBone - Getting Started with the BeagleBone - BeagleBone For Dummies (2015)

BeagleBone For Dummies (2015)

Part I

Getting Started with the BeagleBone

Chapter 3

Connecting Your BeagleBone

In This Chapter

arrow Connecting your BeagleBone via USB and installing drivers

arrow Blinking the onboard LEDs

arrow Controlling your BeagleBone remotely via SSH and serial

The BeagleBone was designed in such a way to be both easy and inexpensive to set up. With just a computer and a Mini USB cable, you can start programming your BeagleBone right off the bat.

This chapter presents multiple ways to accomplish something that we’ve found to be quite useful: controlling your BeagleBone remotely. We prefer to program the BeagleBone by connecting a USB cable to a computer or having an Ethernet cable connected to a router.

Connecting your BeagleBone to a terminal enables you to do things such as run scripts, install software, and manage files.

Connecting via USB

If your BeagleBone is running the OS through the microSD card, insert it before powering up your BeagleBone. Then follow these steps to set up your BeagleBone:

1. Using the Mini USB cable that came with your board, connect your BeagleBone to your computer.

After a few seconds, a drive called BeagleBone Getting Started should appear in your computer’s file system. Your BeagleBone comes with everything you need to get started: the drivers for its setup, as well as documentation and project examples.

2. Go to your file system, and double-click the BeagleBone Getting Started disk.

3. Open the file called START.htm in your default web browser (see Figure 3-1).

Figure 3-1: START.htm selected in Windows 8.1.

Installing drivers

With the file you just opened on your web browser, click Step 2: Install Drivers in the menu on the left side of the web page (see Figure 3-2). Use the appropriate installation method based on your OS (Windows or Mac OS X).

If you’re using Linux, it isn’t necessary to install the drivers.

· Windows: If you’re using Windows, we recommend that you try to install the drivers for the 64-bit version. If that installation fails, you’re running a 32-bit version, so install the 32-bit drivers. Doing things this way guarantees that you won’t install 32-bit drivers on a 64-bit machine.

· Macintosh: In Mac OS X, you have to install the network and serial drivers. This process is very straightforward. After you open each driver file, you click the Next button until the installation is finished.

Figure 3-2: Installing the drivers.

Browsing to your BeagleBone

After your drivers are installed, you need to open an URL on your web browser. Enter 192.168.7.2 in the address bar.

We recommend that you use only Google Chrome or Mozilla Firefox, because other web browsers don’t offer some JavaScript functionalities that the BeagleBone requires. Both web browsers are free to download at their official websites: https://www.google.com/chrome/browser and https://www.mozilla.org.

If everything is working properly, you should see a green box at the top of the screen that says Your board is connected! (see Figure 3-3).

Figure 3-3: A web page hosted by a BeagleBone.

Blinking the onboard LEDs

On the leftmost menu of the web page, click BoneScript (refer to Figure 3-3). A new page with a couple of BoneScript examples opens.

Try your first blink-an-LED project. Don’t worry about the programming; you don’t need to understand it at this point. We just want to give you a glimpse of what you should be capable of doing with your BeagleBone by the time you work your way through more of this book. For now, just sit back, click the Run button (see Figure 3-4), and watch the magic happen — by looking at your board, of course.

Figure 3-4: Running BoneScript examples.

The first example (refer to Figure 3-4) turns ON all four USR LEDs. Take a look at Figure 3-5 to see where they’re located.

Figure 3-5: BeagleBone Black’s four USR LEDs turned on.

The second example (refer to Figure 3-4) should turn all four USR LEDs off, and the last example (also shown in Figure 3-4) returns the LEDs to their default state. They blink in the way they normally do from the moment you power up the BeagleBone.

If nothing occurs when you click the Run button in all three examples, something must be wrong! Make sure that your BeagleBone is connected to your computer. If it still doesn’t work, it may be because the browser you’re using doesn’t support these features. In that case, use Chrome or Firefox as recommended earlier.

Connecting via SSH over USB

SSH (which stands for secure shell) is a method of establishing a communication with another computer securely. All data sent via SSH is encrypted. SSH is based on a Unix shell, so it allows you to access your BeagleBone files from a remote machine by using terminal commands. It has grown to be one of the most popular methods for communication between different devices.

Unix was an operating system that originated in the mid-1960s, with a few characteristics that made it quite appealing: portability, multitasking, and multiuser capability, and a few more advanced concepts. Today, many OSes are based on Unix; the most prominent are Linux and Mac OS X.

Windows

If you use Windows, you need to download and install a free application called PuTTY. Here’s how to install it:

1. Open your web browser.

2. Go to www.putty.org.

3. Click the putty.exe file to download it.

4. Run the putty.exe file to install the software.

With PuTTY installed, power up your BeagleBone and follow these steps:

1. Connect your BeagleBone to your computer by using a Mini USB cable.

2. Open PuTTY.

3. In the PuTTY Configuration dialog box, select SSH.

4. Type 192.168.7.2 as the host.

The port needs to remain at the default number, which is 22. The dialog box should have the settings shown in Figure 3-6.

5. Click Open.

6. When you’re asked to log in, type root and press Enter.

7. When you’re asked to type a password, press Enter.

By default, no password is set.

When you connect your computer to your BeagleBone for the first time, you’re prompted by a message warning you that you’re attempting to establish a connection with an unknown host. This message just means that your computer and the BeagleBone aren’t friends yet. Simply click OK to proceed.

Figure 3-6: PuTTY settings for establishing an SSH communication over USB.

Mac OS X and Linux

In Mac OS X and Linux, you can use the default terminal window to establish an SSH communication, because SSH comes in all Unix-based OSes. Follow these steps:

1. Connect your BeagleBone to your computer by using a Mini USB cable.

2. Open a new window, as follows:

· On a Mac, navigate to /Applications/Utilities and double-click Terminal to open a new terminal window.

· In Linux, press Ctrl+Alt+T to open a new terminal window.

3. Type sudo ssh root@192.168.7.2.

4. Enter your computer password, and type yes.

5. When you’re asked to type a password, press Enter or Return.

By default, no password is set.

Your terminal window should look like Figure 3-7.

Figure 3-7: Connecting a BeagleBone via SSH over USB by using the Mac Terminal application.

When you connect your computer to your BeagleBone for the very first time, you’re prompted by a message warning you that you’re attempting to establish a connection with an unknown host. This message just means that your computer and the BeagleBone aren’t friends yet. Simply click OK to proceed.

Connecting via SSH over Ethernet

Having an Ethernet cable connected to your BeagleBone ensures that you have access to the Internet. This access is really handy, as you may need to install or update an application or work on Internet-related projects.

Establishing this type of communication also enables you to access your BeagleBone from any other devices as long as you remain connected to the same network.

Simply open your terminal window or PuTTY, and you can establish an SSH connection in a similar fashion to the method you use to connect via USB, as described in the following sections.

Windows

If you haven’t downloaded it yet, you need a free application called PuTTY to establish an SSH connection using a Windows PC. Refer to the instructions earlier in this chapter in the “Connecting via SSH over USB” section

With PuTTY installed, you need to power up your BeagleBone and follow these steps:

1. Power up your BeagleBone with a Mini USB cable or with a 5V DC power supply.

Any time that it is possible, it’s recommended that you power your BeagleBone with a DC power supply so that you are guaranteed to not have any issues with power. Make sure that the outer ring of the plug is ground and the center is 5V. You can find more information about this in Chapter 1.

2. Connect an Ethernet cable from your router to your BeagleBone.

3. Open PuTTY.

4. In the PuTTY Configuration dialog box, select SSH.

5. Type beaglebone as the host.

The port needs to remain at the default number, which is 22.

Your dialog box should have the settings shown in Figure 3-8.

6. Click Open.

7. When you’re asked to log in, type root and press Enter.

8. When you’re asked to type a password, press Enter.

By default, no password is set.

When you connect your computer to your BeagleBone for the very first time, you’re prompted by a message warning you that you’re attempting to establish a connection with an unknown host. This message just means that your computer and the BeagleBone aren’t friends yet. Simply click OK to proceed.

Figure 3-8: PuTTY settings for establishing an SSH communication over Ethernet.

Mac OS X and Linux

In Mac OS X and Linux, you can use the default terminal window to establish an SSH communication, because SSH comes in all Unix-based OSes. Follow these steps:

1. Power up your BeagleBone with a Mini USB cable or with a 5V DC power supply.

Any time that it is possible, it’s recommended that you power your BeagleBone with a DC power supply so that you are guaranteed to not have any issues with power. Make sure that the outer ring of the plug is ground and the center is 5V. You can find more information about this in Chapter 1.

2. Connect an Ethernet cable from your router to your BeagleBone.

3. Open a new window, as follows:

· On a Mac, navigate to /Applications/Utilities and double-click Terminal to open a new Terminal window.

· In Linux, press Ctrl+Alt+T to open a new terminal window.

4. Type sudo ssh root@beaglebone.local.

5. Enter your computer password, and type yes.

6. When you’re asked to type a password, press Enter or Return.

By default, no password is set.

The window should look like Figure 3-9.

Figure 3-9: Connecting a BeagleBone via SSH over Ethernet by using the Linux terminal in Ubuntu.

When you connect your computer to your BeagleBone for the very first time, you’re prompted by a message warning you that you’re attempting to establish a connection with an unknown host. This message just means that your computer and the BeagleBone aren’t friends yet. Simply click OK to proceed.

Connecting the Original BeagleBone via Serial over USB

Note: If you’re working with a BeagleBone Black, skip to the next section, as the following instructions are specific to the Original BeagleBone.

The serial port is a way to send data between your Original BeagleBone and another device. Establishing a serial communication between your computer and your Original BeagleBone requires a Mini USB cable, which comes with the board.

For most applications, we think that connecting the Original BeagleBone via SSH over USB is the way to go. Still, it’s useful to know about this connection technique because it enables you to send data to and from many devices other than PCs, which may be useful if you’re experiencing booting problems or networking issues. You can see what’s happening to your board right after plugging in the power with a serial debugger.

At this point, you should have the Original BeagleBone drivers installed. Go back to section “Installing drivers” at the beginning of this chapter if that isn’t the case.

Windows

Before you power up your board, you need to download and install a free application called PuTTY on your computer. Refer to the instructions in the “Connecting via SSH over USB” section earlier in this chapter.

With PuTTY installed, you can establish a serial communication with your Original BeagleBone. Follow these steps:

1. Connect your Original BeagleBone to your computer with a Mini USB cable.

2. Open PuTTY.

3. In the PuTTY Configuration dialog box, select Serial.

4. Type the name of your Original BeagleBone’s serial port.

Open Device Manager to see the serial port’s name. Press Windows+R, type devmgmt.msc, and press Enter. The name of your BeagleBone’s serial port is listed below Ports.

5. Type 115200 in the Speed field.

At this point, the dialog box should look similar to Figure 3-10.

Figure 3-10: PuTTY settings for establishing a serial communication over USB.

6. Click Open.

7. Press Enter.

If you don’t press Enter, you’re left with a blank screen and a blinking cursor.

8. When you’re asked to log in, type root and press Enter.

9. When you’re asked to type a password, press Enter.

By default, no password is set.

Mac OS X and Linux

In Mac OS X and Linux, you can use the default terminal window to establish a serial communication. Follow these steps:

1. Connect your Original BeagleBone to your computer with a Mini USB cable.

2. Open a new window, as follows:

· On a Mac, navigate to /Applications/Utilities and double-click Terminal to open a new Terminal window.

· In Linux, press Ctrl+Alt+T to open a new terminal window.

3. Type sudo screen /dev/tty.usbserial-*B 115200.

4. Type your computer password, and press Enter or Return.

5. Press Enter or Return again.

If you don’t press Enter or Return, you’ll be left with a blank screen and a blinking cursor.

6. When you’re asked to log in, type root and press Enter or Return.

7. When you’re asked to type a password, press Enter or Return.

By default, no password is set (see Figure 3-11).

Figure 3-11: Linux terminal with a serial communication established with an Original BeagleBone.

Connecting the BeagleBone Black via Serial over USB

The serial port is a way to send data between the BeagleBone Black and another device. Establishing a serial communication between your computer and your BeagleBone Black requires a USB-to-TTL Serial cable (see Figure 3-12).

Figure 3-12: USB-to-TTL Serial cable.

For most applications, we think that connecting the BeagleBone Black via SSH over USB is the way to go. This connection technique allows you to send data to and from many devices other than PCs, which may be useful if you’re experiencing booting problems or networking issues. You can see what’s happening to your board right after plugging in the power with a serial debugger.

Windows

Before you power up your board, you need to make a few connections and install PuTTY. For instructions on installing PuTTY, see the “Connecting via SSH over USB” section earlier in this chapter.

1. Connect the USB side of the TTL cable to your computer.

2. Connect the wires to the J1 headers on your BeagleBone Black as shown in Figure 3-13:

· Black wire to Pin 1

· Green wire to Pin 4

· White wire to Pin 5

With PuTTY installed, you can establish a serial communication with your BeagleBone Black. Follow these steps:

1. Open PuTTY.

2. In the PuTTY Configuration dialog box, select Serial.

3. Type the name of your BeagleBone Black’s serial port.

Open Device Manager to see the serial port’s name. Press Windows+R, type devmgmt.msc, and press Enter. The name of your BeagleBone’s serial port is listed below Ports.

4. Type 115200 in the Speed field.

5. Click Open.

6. Power on your BeagleBone Black with a Mini USB cable.

You see all sorts of information about the booting process (see Figure 3-14).

7. When you’re asked to log in, type root and press Enter.

8. When you’re asked to type a password, press Enter.

By default, no password is set.

Figure 3-13: BeagleBone Black connected to a USB-to-TTL Serial cable.

Figure 3-14: Establishing serial communication over USB.

Mac OS X and Linux

In Mac OS X and Linux, you can use the default terminal window to establish a serial communication. With your BeagleBone Black unplugged, follow these steps:

1. Open a new window, as follows:

· On a Mac, navigate to /Applications/Utilities and double-click Terminal to open a new Terminal window.

· In Linux, press Ctrl+Alt+T to open a new terminal window.

2. Type ls /dev/tty*.

3. Connect the USB side of the TTL cable to your computer.

4. Connect the wires to J1 headers on your BeagleBone Black as shown in Figure 3-13, earlier in this chapter:

· Black wire to Pin 1

· Green wire to Pin 4

· White wire to Pin 5

5. Type ls /dev/tty*.

Now you can see a new device connected to your computer — in Figure 3-15, ttyUSB0.

To establish the serial communication, follow these steps:

1. Type sudo screen /dev/ttyUSB0 115200.

2. Power on your BeagleBone Black with a Mini USB cable.

You see all sorts of information about the booting process (see Figure 3-16).

3. Enter your computer password, and press Enter or Return.

4. When you’re asked to log in, type root and press Enter or Return.

5. When you’re asked to type a password, press Enter or Return.

By default, no password is set.

Figure 3-15: Detecting a new device connected on Linux terminal.

Figure 3-16: Linux terminal with a serial communication with a BeagleBone Black.