Note: Guide not yet tested in the SFU Surrey Linux Lab (SUR4080). Some changes may be needed.



Similar documents
Workshop on Scientific Applications for the Internet of Things (IoT) March

bigbluebutton Open Source Web Conferencing

VM-Series Firewall Deployment Tech Note PAN-OS 5.0

netkit lab single-host Università degli Studi Roma Tre Dipartimento di Informatica e Automazione Computer Networks Research Group

Building a Penetration Testing Virtual Computer Laboratory

Setting up a Raspberry Pi as a WiFi access point

Virtual Systems with qemu

Introduction to NetGUI

BASIC TCP/IP NETWORKING

How to Create, Setup, and Configure an Ubuntu Router with a Transparent Proxy.

Lab 1: Introduction to the network lab

Comodo MyDLP Software Version 2.0. Installation Guide Guide Version Comodo Security Solutions 1255 Broad Street Clifton, NJ 07013

Change Log. 2 per vices corporation

Procedure to Create and Duplicate Master LiveUSB Stick

HOWTO: Set up a Vyatta device with ThreatSTOP in router mode

This howto is also a bit old now. But I thought of uploading it in the howtos section, as it still works.

How To Install Openstack On Ubuntu (Amd64)

CELLTRACKS ANALYZER II. Networking Guide J40169EN

CDH installation & Application Test Report

SI455 Advanced Computer Networking. Lab2: Adding DNS and Servers (v1.0) Due 6 Feb by start of class

Linux TCP/IP Network Management

VoIP Laboratory B How to re flash an IP04

Ultra Thin Client TC-401 TC-402. Users s Guide

HOWTO: Set up a Vyatta device with ThreatSTOP in bridge mode

Introduction. Created by Richard Bell 10/29/2014

Guideline for setting up a functional VPN

NAS 249 Virtual Machine Configuration with VirtualBox

Debugging Network Communications. 1 Check the Network Cabling

McAfee Asset Manager Sensor

Setting Up A High-Availability Load Balancer (With Failover and Session Support) With Perlbal/Heartbeat On Debian Etch

Using VirtualBox ACHOTL1 Virtual Machines

CS 326e F2002 Lab 1. Basic Network Setup & Ethereal Time: 2 hrs

USER MANUAL GUIMGR Graphical User Interface Manager for FRM301/FRM401 Media Racks

SATO Network Interface Card Configuration Instructions

Linux Networking. How Networking Works Configuring Networking in Linux Using redhat-config-network Network debugging Wireless networking IPv6

[HOW TO RECOVER AN INFINITI/EVOLUTION MODEM IDX ] 1

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

AutoDownload: SQL Server and Network Trouble Shooting

APPLICATION NOTE. How to build pylon applications for ARM

IP Address: the per-network unique identifier used to find you on a network

Corso di Configurazione e Gestione di Reti Locali

Network Interface Failover using FONA

Operating System Installation Guidelines

System Area Manager. Remote Management

Accessing RCS IBM Console in Windows Using Linux Virtual Machine

Lab 3 Routing Information Protocol (RIPv1) on a Cisco Router Network

Moxa Device Manager 2.0 User s Guide

The embedded Linux quick start guide lab notes

LockView CompX Database & Network Configuration & Installation Manual

Version Author(s) Web Description

3.1 Connecting to a Router and Basic Configuration

TCP/IP Network Essentials. Linux System Administration and IP Services

10 STEPS TO YOUR FIRST QNX PROGRAM. QUICKSTART GUIDE Second Edition

Create a virtual machine at your assigned virtual server. Use the following specs

The Barracuda Network Connector. System Requirements. Barracuda SSL VPN

Connections and wiring Diagram

Prestige 623R-T. Quick Start Guide. ADSL Dual-link Router. Version 3.40

LAB THREE STATIC ROUTING

LockView 4.2 CompX Database & Network Configuration & Installation Manual

ACP ThinManager Tech Notes Troubleshooting Guide

Wireless Mobile Broadband Setup Guide for Linux OS

integration tools setup guide SIM 3 Remote Guide to controlling a SIM 3 Audio Analyzer remotely over a network connection from a laptop

Virtual machine W4M- Galaxy: Installation guide

NetPoint Configuration Guide. for thin clients

Link Link sys E3000 sys RE1000

Pwn Plug Community Edition 1.1 Installation Guide

OpenCPN Garmin Radar Plugin

TimeIPS Server. IPS256T Virtual Machine. Installation Guide

Configuring your network settings to use Google Public DNS

1 Basic Configuration of Cisco 2600 Router. Basic Configuration Cisco 2600 Router

Virtual Appliance for VMware Server. Getting Started Guide. Revision Warning and Disclaimer

Connecting to Cisco VPN From Ubuntu Linux LTS i386/amd64 Revised Jun 10, 2012 by r.a.parks.

c. Securely insert the Ethernet cable from your cable or DSL modem into the Internet port (B) on the WGT634U. Broadband modem

Setting up WiFi with BeagleBone Black

Additional Requirements for ARES-G2 / RSA-G2. One Ethernet 10 Base T/100 Base TX network card required for communication with the instrument.

1 PC to WX64 direction connection with crossover cable or hub/switch

Classroom Management network FAQ and troubleshooting

Quick Installation Guide

Linksys Gateway SPA2100-SU Manual

Quick Note 53. Ethernet to W-WAN failover with logical Ethernet interface.

Pre-lab and In-class Laboratory Exercise 10 (L10)

Virtual Appliances. Virtual Appliances: Setup Guide for Umbrella on VMWare and Hyper-V. Virtual Appliance Setup Guide for Umbrella Page 1

FI8910W Quick Installation Guide. Indoor MJPEG Pan/Tilt Wireless IP Camera

Written by Saif ur Rab Monday, 07 December :19 - Last Updated Monday, 27 December :19

Adafruit's Raspberry Pi Lesson 3. Network Setup

new Business Online Technical Troubleshooting Guide

User Manual. Onsight Management Suite Version 5.1. Another Innovation by Librestream

Linux Terminal Server Project

Setting Up Your FTP Server

LOCKSS on LINUX. Installation Manual and the OpenBSD Transition 02/17/2011

Recommended Network Setup

Local Caching Servers (LCS): User Manual

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

BeagleBone Black: Installing Operating Systems

SevOne NMS Download Installation and Implementation Guide

PC/POLL SYSTEMS Version 7 Polling SPS2000 Cash Register TCP/IP Communications

Moxa Device Manager 2.3 User s Manual

Introduction to Operating Systems

SNAKE OS for Str8132-Based NAS USER MANUAL. Snake OS version ( ) Authors: Douglas Gazineu Jarko Papalitsas José Maciel Miguel Moreto

ODP REGIONAL NODE DEPLOYMENT QUICK GUIDE FOR TRAININGS

Transcription:

Quick Start Guide for BeagleBone Black by Brian Fraser Last update: Oct 28, 2015 This document guides the user through: 1. Installing Ubuntu in a virtual machine. 2. Connecting to the target using serial port and SSH. 3. Cross compile and run on the target. Table of Contents 1. Host OS Setup...2 2. Screen...4 3. Network Setup...6 3.1 Wired Ethernet Network...6 3.2 Ethernet over USB...9 3.2.1Initial Connection between Host and Target...9 3.2.2Connecting Target to Internet...10 3.3 Direct Ethernet Connection (Optional)...12 3.4 Linux Network Commands...14 4. Connecting via SSH and NFS...15 4.1 SSH...15 4.2 NFS...15 5. Cross-compile Setup...16 5.1 Setup folders...16 5.2 Build for Host vs Target...16 5.3 Running via NFS...17 Note: Guide not yet tested in the SFU Surrey Linux Lab (SUR4080). Some changes may be needed. Formatting: 1. Commands starting with $ are Linux console commands on the host PC: $ echo "Hello world!" 2. Commands starting with # are Linux commands on the target (BeagleBone Black): # echo "Hello embedded world!" 3. Almost all commands are case sensitive. Revision History: Sept 12: Update names for USB devices when working with Zen cape. Sept 16: Updated directions for finding correct DNS to add. Oct 4: Changed DNS recommendation to just always use 8.8.8.8 Oct 28: Significantly updated the Direct Ethernet Connection (Optional) section. Generated 09/09/14 1 / 18

1. Host OS Setup 1. Linux Ubuntu 14.04, 64bit, is the supported OS on the host PC for this class. Other versions of Linux or Unix derivatives may work, but are not supported by the instructor and TA. You can download Ubuntu from its official site: http://www.ubuntu.com/download Also, a copy is available locally at SFU via http://mirror.cs.surrey.sfu.ca. 2. If you are running a non-linux OS, you may install Ubuntu in a virtual machine (VM). However, note that running inside a VM means one extra level of configuration is required. You may find it easier to run Linux natively on your computer as Ubuntu often installs well alongside existing operating systems. Under Windows or Mac OS, you can use VM Player or VirtualBox (both free). This YouTube playlist features three videos showing how to install a VM. I recommend VMWare over VM Player (I find VM Player sometimes messes up which USB devices are mapped to my VM which forces me to reboot the computer). If you do use VM Player, some students have found problems if you plug any USB 2.0 hardware into a USB 3.0 slot on your computer. If you are having USB problems, try rebooting your VM and your host OS, and switching the port you are plugging the device into ensuring it is a USB 2.0 device). To run a virtual machine in the SFU Lab (SUR 4080), install a VirtualBox VM on a USB 3.0 memory stick (3.0 is faster than USB 2.0). 1 Note that you cannot complete the assignments in the lab without a virtual machine setup because you do not have root permissions on the lab computers. We'll need root permissions to setup file sharing and install/upgrade programs. 3. If you install Linux in a VM: Make the virtual hard drive large (>60gig). This gives plenty of room for extra build tools, libraries, and such. If you are installing to a flash drive, make the VM's hard drive no bigger than the free space on the flash drive. This will ensure that Linux is not trying to over-use the space on the flash disk. Give it as much RAM, video RAM, and processor access as possible; this will speed up 1 Notes on VM setup in the CSIL Surrey Labs: In Oracle VM VirtualBox Manager create a VM (or use an existing one), right-click on it and select Show in Explorer. Copy the entire folder onto your USB stick. Best to have your USB stick formatted to exfat so that it can be read under either Windows or Linux. On a different PC you want to develop on, in the VM Manager select Machine Add, and browse to your VM's folder on your USB stick. Note that you must be extra careful never to pull the USB stick when the VM is running because this could corrupt the state of your VM. You may also find it faster to shut-down and fully restart the VM than having the VM suspend to disk. Plus, this is one less thing to go wrong with writing to the USB drive. Note the top two USB ports on the front of the lab PCs are USB 3.0; the others are 2.0. When switching a VM between computers, some settings may need to be updated such as the network adapter used for bridging, shared folders, and so forth. Generated 09/09/14 2 / 18

Linux. Also enable 3d graphics acceleration for improved performance. 4. Troubleshooting: If having problems with Ubuntu's apt-get and dependencies, try following this guide: http://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies-afteradding-a-ppa Note that if using the software-properties-gtk tool, you may need to run it with sudo from the command line: $ sudo software-properties-gtk Generated 09/09/14 3 / 18

2. Screen Screen is a tool which allows you to interact with a serial port through Linux. 1. Zen Cape's TTL to USB setup: Connect the micro USB cable to the Zen Cape (same end as the Ethernet connection). This is the TTL serial to USB adapter. If using a virtual machine, you may need to map the adapter to the VM. In VMWare Player: Find the icon in upper right (on the tool bar) which reads future devices ft230x basic uart. Right click it, and select the connect option. In Linux, just after connecting the device you can see if it has been configured correctly by typing: $ dmesg This shows messages produced by the kernel. You should see the last few lines being: [51279.545848] usb 2-2.1: new full-speed USB device number 11 using uhci_hcd [51279.784710] usb 2-2.1: New USB device found, idvendor=0403, idproduct=6015 [51279.784714] usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [51279.784716] usb 2-2.1: Product: FT230X Basic UART [51279.784717] usb 2-2.1: Manufacturer: FTDI [51279.784718] usb 2-2.1: SerialNumber: DA01Q7JI [51279.793719] ftdi_sio 2-2.1:1.0: FTDI USB Serial Device converter detected [51279.793751] usb 2-2.1: Detected FT-X [51279.793776] usb 2-2.1: Number of endpoints 2 [51279.793779] usb 2-2.1: Endpoint 1 MaxPacketSize 64 [51279.793780] usb 2-2.1: Endpoint 2 MaxPacketSize 64 [51279.793781] usb 2-2.1: Setting MaxPacketSize 64 [51279.797846] usb 2-2.1: FTDI USB Serial Device converter now attached to ttyusb0 This shows that the device is connected to /dev/ttyusb0. If you have multiple devices connected, yours may connect to ttyusb1 or higher. 2. Check /dev/ttyusb0 exists with the following command (expected output shown on next line): $ ls -al /dev/ttyusb0 crw-rw---- 1 root dialout 188, 0 Sep 1 09:57 /dev/ttyusb0 3. Install the Screen program: $ sudo apt-get install screen 4. Start Screen with the following command: $ sudo screen /dev/ttyusb0 115200 Where /dev/ttyusb0 is the port. May be ttyusb1, etc. 115200 is the baud rate, or the speed of the connection. 115200 is the default serial port speed for the BeagleBone Black. NOTE: If in SFU labs, you do not have root permission to host OS. Do not try any sudo commands in the host OS in the lab! Our IT staff will be automatically notified and they may contact you about it. Use sudo only on your PC or in the VM. Generated 09/09/14 4 / 18

If you want to use Screen inside the host OS in the lab, you should have access to /dev/ttyusb0 already so just type the command without sudo. 5. Press Enter to see text on the serial port if you are connecting to a target device which is already running. User name is root and there is no password (Just press enter). Note that the root user's home directory is /root/, whereas most other users (such as one named brian) would be in the folder /home/brian/. This is the normal way Linux works with home directories. 6. Screen commands: Help: Ctrl-A then? Quit: Ctrl-A then \ 7. Trouble shooting After launching Screen, if you immediately see the message: [screen is terminating] it may mean that you do not have access to /dev/ttyusb0. Either change the permissions on /dev/ttyusb0 to be read/write by all users, or launch screen with sudo. Note that in the SFU labs, you do not have sudo (root) access. If you briefly see the following message at the bottom of the screen: Cannot exec 'ttyusb0': No such file or directory it likely means that you have not correctly connected the Zen Cape's USB to TTL serial adapter, or if you are using a virtual machine, that you have not mapped it to the virtual machine correctly. For the virtual machine, try disconnecting the USB to TTL adapter from the VM, and then reconnecting it. If your Screen session locks up or begins dropping characters or corrupting text, here are some things to try: In a VM, disconnect the USB to TTL adapter from the VM and/or physically disconnect the USB cable. Perhaps try plugging it back into another USB slot. Ensure Screen is running with the correct baud rate (115200). Ensure your VM has more than the minimum video memory (if there's a setting for this). Try increasing its access to 3D acceleration and the number of CPU cores (if possible). Try closing the screen session (Ctrl-A then \), and restarting the screen session. Sometimes under VirtualBox it seems that closing screen also locks up, but it then resolves within a minute and successfully quits screen. If trying to reconnect gives the error: Failed to attach the USB device FTDI TTL232R- 3V3... and... is busy with a previous request, with VirtualBox then you may need to kill the VBoxSVC.exe process in the Host OS, and/or reboot the host OS. Generated 09/09/14 5 / 18

3. Network Setup You need to have an internet connection to both your Linux development OS (host PC) and the BBB. Plus, you need to have your development OS be able to connect to your BBB (we'll use SSH), and your BBB be able to connect to your development OS (we'll use NFS). There are a couple ways you can connect your devices. 1. Have your development computer and your BBB plugged into the same wired network, such as a home Ethernet network (see section 3.1). 2. Have your BBB connect to your development computer using Ethernet over USB, and your development computer connect to the internet via WiFi or wired Ethernet (see section 3.2). 3. Have your BBB directly connected to your development computer via a single Ethernet cable (not recommended) (see section 3.3). See the necessary section below for the option you are using. Section 3.4 covers some useful Linux networking commands. 3.1 Wired Ethernet Network This section assumes you are connecting your BBB to the same wired network that your development PC is connected to. 1. If using a virtual machine on the development computer, completely shutdown (power down, not just close/suspend) your virtual machine and change the network adapter type to Bridged instead of Network Address Translation (NAT). Under VMWare Player, select the VM and then Edit Virtual Machine Settings Network Adapter Bridged. OK to Replicate physical network connection state. Restart the VM. 2. Connect an Ethernet cable to the target board and have it get an IP address from your network's DHCP server (likely your home router). The board should automatically acquire a IP address in a few seconds (~30), but you may need to re-run either dhclient or udhcpc (depending on which is installed) to force it. You may need to reboot the target to have it acquire an IP address at startup: # reboot 3. Check the IP address of the target board using the serial connection: # ifconfig Generated 09/09/14 6 / 18

[root@bfraser-beagle ~]# ifconfig eth0 Link encap:ethernet HWaddr c8:a0:30:aa:dd:a0 inet addr:192.168.0.145 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::caa0:30ff:feaa:dda0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:22 errors:0 dropped:0 overruns:0 frame:0 TX packets:53 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4176 (4.0 KiB) TX bytes:9945 (9.7 KiB) Interrupt:40 lo Link encap:local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) usb0 Link encap:ethernet HWaddr 6a:41:80:a7:bf:db inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Look for eth0's inet addr:, such as: inet addr:192.168.0.145 (Highlighted in above example) If you do not see eth0, it means the board has likely not yet found an IP address. Wait up to a minute longer for it to get an IP address. If it does not, double check all Ethernet cable connections and reboot the target. You may see (and ignore) some messages on the target such as: [ 24.172268] net eth0: phy 4a101000.mdio:01 not found on slave 1 [ 29.810445] libphy: PHY 4a101000.mdio:01 not found 4. Check the IP address of the Host PC: $ ifconfig Generated 09/09/14 7 / 18

$ ifconfig eth0 Link encap:ethernet HWaddr 00:0c:29:7f:47:bc inet addr:192.168.0.114 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe7f:47bc/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:196832 errors:0 dropped:0 overruns:0 frame:0 TX packets:5079 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:41734380 (41.7 MB) TX bytes:1109534 (1.1 MB) lo Link encap:local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:747 errors:0 dropped:0 overruns:0 frame:0 TX packets:747 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:277191 (277.1 KB) TX bytes:277191 (277.1 KB) Find eth0's IP address, such as: inet addr:192.168.0.114 If running in a virtual machine, check the host OS's IP address as well: under Windows run ipconfig from the command line. 5. The addresses of the host and target (and host OS if running a VM) should be on the same subnet (have the first couple octets the same). If they are not the same then check the troubleshooting section below. Note that if your target device is plugged into a different network than your host PC they will be on different subnets. This may be the case in the SFU labs. 6. From the host PC, ping the Target. Command and output shown below. Press Ctrl-C to stop the pinging as needed. Replace the IP address with whatever address your target has. $ ping 192.168.0.145 PING 192.168.0.145 (192.168.0.145) 56(84) bytes of data. 64 bytes from 192.168.0.145: icmp_seq=1 ttl=64 time=1.10 ms 64 bytes from 192.168.0.145: icmp_seq=2 ttl=64 time=0.585 ms 64 bytes from 192.168.0.145: icmp_seq=3 ttl=64 time=0.492 ms ^C --- 192.168.0.145 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2001ms rtt min/avg/max/mdev = 0.492/0.727/1.105/0.270 ms 7. From the target, ping the host PC using your serial terminal. Command and output shown below. Press Ctrl-C to stop the pinging as needed. Replace the IP address with whatever address your host has. # ping 192.168.0.114 PING 192.168.0.114 (192.168.0.114) 56(84) bytes of data. 64 bytes from 192.168.0.114: icmp_req=1 ttl=64 time=1.49 ms 64 bytes from 192.168.0.114: icmp_req=2 ttl=64 time=0.619 ms 64 bytes from 192.168.0.114: icmp_req=3 ttl=64 time=0.620 ms 64 bytes from 192.168.0.114: icmp_req=4 ttl=64 time=0.707 ms ^C --- 192.168.0.114 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 0.619/0.861/1.499/0.370 ms Generated 09/09/14 8 / 18

8. Ensure your target and host can both access the internet: $ ping google.ca # ping google.ca If the ping fails, double check your network setup. 9. Troubleshooting: If the VM is not on same subnet as host OS, then make sure the VM's network adapter is configured for Bridged mode, instead of NAT. NAT uses the host OS's IP address for access to the network which will work fine for outgoing connections (such as browsing to Google), but not work for incoming connections (such as running an NFS server). You may need to restart the VM if you make any changes. If your target board (BBB) is on a different subnet than your host PC, double check that your host PC and target board are plugged into the same network. For example, you could have a problem if the host PC is connecting to a wireless network but the target device is connecting to a completely separate wired network. Reboot the target device to have it acquire a new IP address. 3.2 Ethernet over USB Expected setup is your host PC (in a VM or not) is connected to the Internet via WiFi or Ethernet; host connected to target via a serial cable, and using a USB cable between host and target for emulated Ethernet. No Ethernet cable is required. 3.2.1 Initial Connection between Host and Target 1. If using a VM: Configure your VM's network connection to use NAT (Network Address Translation). Launch the VM. Ensure that inside the VM you are able to access the Internet by pinging Google (for example). $ ping google.ca 2. Connect the USB mini cable from the host to the target (connection is on the BBB, to the left of the Ethernet port). This cable was included with the BBB. Note that USB mini port will also power the target so to physically cycle the power you may need to disconnect both the USB and the power connector. You can run with just the USB power for most operations; however, the full power plug is needed to power the device when it is reflashing the system image or powering any external devices (such as USB devices). The USB cable required is a USB-A (host side) to USB-Mini (target side). It is not the USB- Micro cable which connects to the Zen Cape, nor a TTL232-to-USB cable if you have one. 3. If using a VM, map the USB connection to the VM. In VMware, use the Player button in the top left, go to Removable Devices Linux Foundation BeagleBoneBlack, and select to Connect. Generated 09/09/14 9 / 18

In Virtual Box, via VM's menu at the very top of the window select Devices USB Devices Circuitco BeagleBoneBlack 4. Check the network connection with ifconfig. It should show eth1 with an IP address 192.168.7.1. $ ifconfig The target will default to have a fixed IP address of 192.168.7.2 via the emulated USB network connection (usb0). 5. Ping the host from the target, and the target from the host (via your serial connection) to ensure a working connection: $ ping 192.168.7.2 # ping 192.168.7.1 See previous section for more details on the commands. 6. Troubleshooting If the target reboots, the host will lose the Ethernet connection eth1. The connection will come back when the board finishes rebooting. If software on the target stops working, the Ethernet connection on the host may disappear. If unable to ping between the devices, run ifconfig on each to ensure correct IP addresses. Target's usb0 connection should be IP address 192.168.7.2. Host's eth1 connection should be IP address 192.168.7.1. 3.2.2 Connecting Target to Internet 2 By following the above steps, you'll be able to ping between the host and the target. However, the target will not yet be able to access the internet. This section configures the host to allow the target to access the internet through its network connection. 1. Ensure your host PC (the Linux VM, likely) has access to the internet: $ ping google.ca 2. On the host PC, you should have two network adapters, likely named eth0 (actual network connection) and eth1 (virtual connection to target). Find them with: 2 Directions from Molloy (2014) Exploring BeagleBone, Ch2. Generated 09/09/14 10 / 18

$ ifconfig eth0 Link encap:ethernet HWaddr 08:00:27:a3:83:38 inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fea3:8338/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2391 errors:0 dropped:0 overruns:0 frame:0 TX packets:707 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2670933 (2.6 MB) TX bytes:85463 (85.4 KB) eth1 Link encap:ethernet HWaddr c8:a0:30:aa:dd:a2 inet addr:192.168.7.1 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::caa0:30ff:feaa:dda2/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3 errors:0 dropped:0 overruns:0 frame:0 TX packets:46 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:626 (626.0 B) TX bytes:10416 (10.4 KB) lo Link encap:local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:352 errors:0 dropped:0 overruns:0 frame:0 TX packets:352 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:27358 (27.3 KB) TX bytes:27358 (27.3 KB) 3. On the host, use the iptables program to configure the Linux kernel firewall rules: $ sudo iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE $ sudo iptables --append FORWARD --in-interface eth1 -j ACCEPT 4. Turn on IP forwarding: $ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" 5. Configure the target to use the host (via Ethernet over USB) as the default gateway: # route add default gw 192.168.7.1 You can check this succeeded by viewing the routing tables on the target using route: # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default brian-virtualbo 0.0.0.0 UG 0 0 0 usb0 192.168.7.0 * 255.255.255.252 U 0 0 0 usb0 6. Check the target has an internet connection: # ping 8.8.8.8 This should successfully ping the server. Note, you won't yet be able to ping google.ca! 7. These settings will not persist between reboots, so you must re-do all of these steps each time you reboot in order to re-enable the settings. You may be able to edit the /etc/network/interfaces file to make these settings permanent. Consult guides online for more information. 8. Configure a DNS: Generated 09/09/14 11 / 18

Append a new domain nameserver (DNS) to the end of etc/resolve.conf: # echo "nameserver 8.8.8.8" >> /etc/resolv.conf Where 8.8.8.8 is a free public DNS owned by Google. View the /etc/resolv.conf file to ensure it looks reasonable: # cat /etc/resolv.conf domain Home search Home nameserver 8.8.8.8 Test with: # ping google.ca Note that this step won't need to be repeated after a reboot as the /etc/resolve.conf file is persistent. 9. Trouble shooting: If you rebooted either your target or host, you'll need to redo the settings on that device as the settings are not persistent. If you get the error message: ping: unknown host google.ca when trying to ping google.ca, then you don't have a DNS server setup correctly. Double check you have completed the DNS steps above. 3.3 Direct Ethernet Connection (Optional) You can directly connect the target device to a host PC using an Ethernet cable (or crossover). You may skip this section if you are connecting the BBB through either a wired Ethernet connection to a switch/router which supports DHCP, or using Ethernet over USB. If using a virtual machine, it is recommended that you use only Oracle VM VirtualBox for this configuration, otherwise it may not be possible to give your host PC and your target internet access. Expected connection is your PC (or virtual machine) is connected to the web via either WiFi or Ethernet, and you are going to connect an Ethernet cable directly from your PC to the target. (i.e., the target is connected to the host only, not to any network such as a router). 1. On the target, via a serial connection, set it to a static IP address: # ifconfig eth0 192.168.2.2 Note that this will revert back to DHCP when the target is rebooted. You can make the change permanent by editing /etc/network/interfaces and adding: auto eth0 iface eth0 inet static address 192.168.2.2 netmask 255.255.255.0 network 192.168.2.0 broadcast 192.168.2.255 After changing the file, restart networking on the board (or reboot) # /etc/init.d/networking restart 2. Edit the settings for your virtual machine. Generated 09/09/14 12 / 18

Virtual Box: You must have your VM powered down, not just suspended. Right click the VM in your Oracle VM VirtualBox Manager and select Settings. Under Network, enable Adapter 1 and set to NAT. This adapter will give your VM access to the internet through your host OS. Under Networking, enable Adapter 2 and set to Bridged. In the Name drop-down select your Ethernet adapter. This adapter will be the connection to the target. Launch your virtual machine. VM Ware Click the Player button in the top left, and select Manage, then Virtual Machine Settings. On the Hardware tab, select Add..., and add a new Network Adapter Change new network adapter to: Network Connection: Bridged Check Replicate physical network connection state Under Configure Adapters, only check the wired Ethernet adapter on your computer (ensure it's not a wireless one, and not a BlueTooth one) Press OK. 3. On the host (inside your VM), edit the /etc/network/interfaces file and add: auto eth1 iface eth1 inet static address 192.168.2.1 netmask 255.255.255.0 network 192.168.2.0 broadcast 192.168.2.255 4. Restart the networking: $ sudo /etc/init.d/networking restart 5. Test your host's internet settings on the host: Run ifconfig. eth0 will likely have an IP address in the range of 10.0.2.15 and eth1 should have an IP address of 192.168.2.1. Ping Google to prove you have a good internet connection. $ ping google.ca See troubleshooting below if there are any problems. 6. Ping the target from the host, and the host from the target. # ping 192.168.2.1 $ ping 192.168.2.2 Generated 09/09/14 13 / 18

7. Troubleshooting Run ifconfig on the target and host to ensure they have the correct addresses. If your VM cannot access the Internet (say pinging Google or installing via apt-get), then ensure that your host OS (Windows, for example) has a good connection to the Internet. Ensure your VM has the correct network adapters installed. In VirtualBox, check that it has enabled the network connection: In the VM's menu, select Devices Network Ensure that two network connections are listed and that both are enabled (filled background around the icon). Check that the network cable connected correctly. Check that the connection is enabled in Linux. If ifconfig does not show eth0 (on the target) or eth1 (on the host), then enable the adapter using a command such as: $ sudo ifconfig eth0 up Double check the VM's networking settings. Ensure you select NAT and Bridged correctly. For more information on configuring the network settings, see: https://help.ubuntu.com/community/networkconfigurationcommandline/automatic 3.4 Linux Network Commands Here are some useful Linux commands for working with Ethernet (may need root access): Display Ethernet configuration information: $ ifconfig or $ ip addr Turn off, and turn on Ethernet connection (to cause it to redetect it): $ sudo ifconfig eth0 down $ sudo ifconfig eth0 up Or: $ sudo ifdown eth0 $ sudo ifup eth0 Run DHCP to acquire an IP address (only on some systems): $ dhclient Force a new (static) IP address: $ ifconfig eth0 192.168.0.212 Configure a static IP at boot for Debian based (Ubuntu) systems edit /etc/network/interfaces and set contents to: Generated 09/09/14 14 / 18

auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.47.200 netmask 255.255.255.0 broadcast 192.168.47.255 gateway 192.168.47.2 dns-nameservers 192.168.47.2 Restart networking: $ sudo service networking restart Generated 09/09/14 15 / 18

4. Connecting via SSH and NFS 4.1 SSH 1. SSH from your host PC to the target device: $ ssh root@192.168.7.2 Where the IP address is the address of the target device (BBB). You can find this by running ifconfig on the target via the serial connection. The root@ tells SSH we want to connect as a specific user, the user named root, rather than the user name we logged into the host PC with. The root password is empty, so just hit enter. You may be asked to accept a security certificate; type yes. If you have made significant changes to the target device (such as reinstalling its operating system or file system), it may require you to remove a saved security certificate from the host PC before allowing you to SSH to the target. It will give you the command to execute in the error message. 2. Via the SSH connection, you can do anything would do via the serial connection. For example: # echo I am connected via SSH # cd /proc # cat uptime # cat cpuinfo 4.2 NFS Follow the steps in the NFS guide posted on the course website. Generated 09/09/14 16 / 18

5. Cross-compile Setup 5.1 Setup folders 1. On the host PC, create a directory for your work and for downloading (public): $ cd ~ $ mkdir -p cmpt433/work $ mkdir -p cmpt433/public Change /public to have global read/write permissions: $ chmod a+rw cmpt433/public Make sure none of your source code, makefiles, or the like is in the public directory. This directory can be read by everyone, so someone could take your work and hand it in, causing great problems for both students! It is OK, though, to have compiled programs and downloadable images (for U-Boot, the kernel, and the file system) in the public directory. 2. Install the cross-compiler and required tools: $ sudo apt-get install gcc-arm-linux-gnueabi $ sudo apt-get install binutils-arm-linux-gnueabi 3. Check tools installed with the following. It should display the compiler's version info: $ arm-linux-gnueabi-gcc --version arm-linux-gnueabi-gcc (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 5.2 Build for Host vs Target 1. Create a new directory, called myapps, inside your work folder for all the applications you'll be writing: $ cd ~/cmpt433/work $ mkdir myapps 2. Create a quickstart folder inside myapps. 3. Create a helloworld.c program inside the quickstart folder. Use the gedit editor built into Ubuntu to edit the program. Note that the & at the end of a command makes it execute in the background, which here allows you to keep using your terminal while gedit is running. $ gedit helloworld.c & 4. Write the hello world program in C and save the file: #include <stdio.h> int main(char* args[]) { printf("hello embedded world!\n"); return 0; } 5. Compile and run the program for the host OS: $ gcc helloworld.c -o helloworld_host $./helloworld_host Generated 09/09/14 17 / 18

6. Compile the program for the target OS (Angstrom on the BBB): $ arm-linux-gnueabi-gcc helloworld.c -o helloworld_target Try running the helloworld_target application on the host OS. What happens? 7. Analyze the two executables you have just compiled using readelf: $ readelf -h helloworld_host Machine: Advanced Micro Devices X86-64 Flags: 0x0 $ readelf -h helloworld_target Machine: ARM Flags: 0x5000202, has entry point, Version5 EABI, soft-float ABI Use this in the future when you need to identify which OS an executable is compiled for. 5.3 Running via NFS 1. Complete the NFS guide posted on the website to map the ~/cmpt433/public folder on the target board. 2. On the host PC, copy the helloworld_target executable to the ~/cmpt433/public/ folder. $ cd ~/cmpt433/work/myapps/quickstart $ cp helloworld_target ~/cmpt433/public/ 3. On the target, change to the mounted NFS folder: # cd /mnt/remote 4. On the target, run the executable: #./helloworld_target 5. Congratulations! You've done some embedded development! 6. Repeat these steps for the helloworld_host executable and see the result. Should the host version work on the target? Generated 09/09/14 18 / 18