Ethernet Access and Remote Control with Intel Galileo Prepared By
Total Page:16
File Type:pdf, Size:1020Kb
Ethernet Access and Remote Control with Intel Galileo Prepared by Derrick Anang For EECE456 Embedded Systems Design Lab Instructor: Dr. Charles Kim Electrical and Computer Engineering Howard University Class Web: www.mwftr.com/emblab.html 1 INTEL® GALILEO ∗ Intel® Galileo Gen2 Board A microcontroller board based on the Intel® Quark SoC X1000 application processor (a 32-bit Intel® Pentium brand system on a chip). The 32-bit processor can run at up to 400MHz and has a 512KB SRAM built in. This board functions as a fully featured, cost-effective development platform which complements with the Arduino software to provide an advanced compute functionality. It basically serves as an interface between the Arduino Software (IDE) and the Grove system components. ∗ It comes with an on-board 10/100 Mb/s Ethernet connector port. ∗ This on-board Ethernet port is accessible via Linux and Arduino IDE using the Ethernet Library. 2 GETTING STARTED HARDWARE COMPONENTS ∗ Intel® Galileo Gen 2 Board ∗ Micro-SD Card ∗ USB to 6-pin FTDI Serial Cable ∗ Ethernet Cable ∗ Grove Starter Kit ∗ An Ethernet Switch or Wi-Fi Router with a free Ethernet port (connects Galileo board to the Local Access Network (LAN) being used) ∗ Micro B to Type A USB Cable ∗ 12 VDC, 1.5A Power Supply 3 SOFTWARE COMPONENTS ∗ Arduino Integrated Development Environment (IDE) for Galileo ∗ Intel XDK IoT Edition (Download link: http://software.intel.com/en- us/html5/xdk-iot) ∗ Terminal Emulator e.g. PuTTy (http://www.putty.org/)or Bonjour Browser for Mac OS, link: (http://www.tildesoft.com/files/BonjourBrowser.dmg) ∗ FTDI Driver Installer for Windows, link: (http://www.ftdichip.com/Drivers/D2XX.htm) ∗ Yocto Boot Image (http://iotdk.intel.com/images/iot-devkit- latest-mmcblkp0.direct.bz2) ∗ WinRAR or 7-Zip Extractor (http://www.7-zip.org/) ∗ Win32 Disk Imager (http://sourceforge.net/projects/win32diskimager/) ∗ Bonjour ( http://support.apple.com/downloads/DL999/en_US/BonjourPSSetup.exe) 4 CONNECTING GALILEO BOARD TO COMPUTER WINDOWS ∗ Download the compressed Yocto Boot Image from the link given under software components. ∗ Using WinRAR or 7-Zip Extractor, extract the components of the boot image to a source folder. In the image below, WinRAR Extractor is used. The extract option (in the red box ) is used to extract files to a source folder. 5 CONNECTING GALILEO BOARD TO COMPUTER ∗ Insert the micro-SD Card into the appropriate card slot of your Windows System. ∗ Download the Win32 Disk Imager utility and install it as an Administrator. After a successful installation, run the Win32 Disk Imager as an Administrator. ∗ Ensure that you have selected the correct Device Drive corresponding to your inserted micro-SD card for writing. ∗ Under “Image File”, open source folder location where boot image is stored and select the extracted boot image. ∗ After, click on “Write” to write boot image to micro-SD card. ∗ Wait thoroughly for write process to be complete before exiting. 6 7 CONNECTING GALILEO BOARD TO COMPUTER ∗ Make sure the Galileo Board is unplugged. ∗ Place the prepared micro-SD Card in the micro-SD card slot on the Galileo Board. ∗ Connect the correspondent FTDI Serial Cable in the appropriate port on the board the connect the other side to the USB port on your computer. Note: the lines on the FTDI cable are color coded. Black is for Ground so make sure it corresponds to the Ground Pin on the FTDI port on the board. 8 CONNECTING GALILEO BOARD TO COMPUTER ∗ Connect the Ethernet Cable to the Ethernet connector port on your Galileo Board and connect the other side to your LAN such as a router port. ∗ Connect your computer to your LAN for example using another router port. 9 CONNECTING GALILEO BOARD TO COMPUTER ∗ Notice in the above image that both computer and Galileo share the same LAN subnet which comes from the red Ethernet cable to the router box ∗ Connect the power cable to the Galileo Board and connect to electrical power to start it up. ∗ The on-board LED labeled ‘SD’ should blink which indicates there is activity with the micro-SD card. Wait for LED to stop blinking. 10 CONNECTING GALILEO BOARD TO COMPUTER ∗ Full setup should look like this: 11 DISCOVERING THE BOARD’S IP ADDRESS ∗ First, you need to find which serial port your Windows system recognizes as connected to the Galileo board. ∗ Open ‘Start’ then click on ‘Devices and Printers’. A USB Serial entry displayed by a CPU-like icon appears, double click on it to see the ‘COM’ number assigned to the board. 12 DISCOVERING THE BOARD’S IP ADDRESS ∗ Run ‘PuTTy’ software to open a serial connection with the board. ∗ Set the following configurations: Under ‘Category’, choose ‘Session’ and look for the various options under ‘Connection Type’ Choose ‘Serial’ Under ‘Serial Line’, type in the ‘COM’ number assigned to board e.g. COM6 Under ‘Speed’ type 115200 Under ‘Category’ again, go down and choose ‘Serial’ which can be found under ‘SSH’ sub-category. Confirm the ‘COM’ number under ‘Serial line to connect to’. Speed = 115200, Data bits = 8 , Stop Bits = 1, Parity = 1 Then click on ‘Open’. 13 14 15 DISCOVERING THE BOARD’S IP ADDRESS ∗ If nothing appears when you click ‘Open’, hit the enter button on your keyboard. ∗ Type in ‘root’ as the username. The password is empty so leave it. ∗ Using the command ‘ip a’, identify the IP address being used by the board. It should be listed as ‘inet’ inside the second listed entry. 16 17 ETHERNET ∗ Unplug the power source from the Galileo board. ∗ While the board is off, remove the micro-SD card from the micro-SD socket. ∗ Also, unplug the Serial FTDI cable from Galileo Board while leaving the Ethernet cable plugged in. ∗ Connect the Micro B to Type A USB cable to the Galileo Board and then to a USB port on your computer. ∗ Plug in the power source to turn the Galileo board back on. ∗ Run the Arduino IDE software. Ensure the ‘Port’ and ‘Board’ selections are correct. ∗ Open an Ethernet sketch such as the one below. 18 #include <SPI.h> #include <Ethernet.h> // MAC address for the Galileo (there’s a sticker on the Ethernet connector) byte mac[] = { 0x??, 0x??, 0x??, 0x??, 0x??, 0x?? }; //the IP address for the Galileo: (will be used if there’s no DHCP server on your network) byte ip[] = { ???, ???, ???, ??? }; void setup() { delay(5000); Serial.println("Attempting to configure Ethernet using DHCP"); if (Ethernet.begin(mac) == 0) { Serial.begin(9600); Serial.println("Failed to configure Ethernet using DHCP"); Serial.println("Attempting to configure Ethernet using Static IP"); Ethernet.begin(mac, ip); Serial.println(" Please check ifconfig"); } else Serial.println("Sounds good"); system("ifup eth0"); // load Ethernet interface! } 19 void loop () {} ENTERING IP AND MAC ADDRESSES ∗ In above sketch, it can be seen that the columns for entering the IP and MAC addresses are represented with yellow question marks. ∗ Let us first begin with the MAC address. The MAC address for your Galileo board is printed on a sticker that’s on the Ethernet connector on the board. It’s a sequence of 12 digits. It should read like this ‘MAC: ############’. ∗ In the above code, the MAC address is specified as a series of hex formatted numbers. Just place the numbers after each “0x” in the code with two numbers from your MAC address. 20 21 ∗ In the above image, the MAC address can be seen on the sticker placed on the Ethernet connector. ∗ MAC address is 984FEE016FAF. ∗ Therefore, in the sketch code it will be represented like this: byte mac[] = { 0x98, 0x4F, 0xEE, 0x01, 0x6F, 0xAF}; ∗ After the MAC address is configured, you have to configure the IP address using the address you found earlier being used by the board. ∗ With that address, the IP address input should look like this: byte ip [] = { 192, 168, 70, 138}; or IPAddress ip(192, 168, 70, 138); ∗ Your sketch code is then ready to upload. ∗ Compile and upload the code to the board. ∗ Using a web browser on your computer, open the assigned IP address using the raw figures without all the ‘www...com’ business. ∗ Browser should display whatever content you have in the sketch code. 22 CONNECTING USING INTEL XDK IoT EDITION ∗ Unplug power source from Galileo board. ∗ While off, disconnect the Micro B to Type A USB cable from the board. ∗ Insert the micro-SD card with the boot image back into micro-SD port. ∗ Plug in the power source to turn the Galileo board back on. ∗ Run the ‘Intel XDK IoT Edition’ software. ∗ Click on ‘Start A New Project’. ∗ Under ‘Internet of Things Embedded Application’, click on ‘Templates’ then choose ‘Blank Template’. After, click ‘Continue’. ∗ Choose directory to save your project then assign a project name. ∗ A pop-up window appears offering to give you a tour. Simply choose ‘No, thanks’. 23 24 25 26 ∗ A window like the one below should appear. ∗ After the board is finished booting, it will be running the Intel XDK app daemon. ∗ Click on the IoT device dropdown. If you don’t see an IP address and a port after a separator, click on ‘Rescan for devices’ and the IDE will try to find the device on the network. 27 ∗ If the device is still not listed check to make sure that the Galileo board is on the same subnet network. ∗ Also, download and install Bonjour from the link given under software components. Follow the instructions to automatically detect the compatible devices connected on the LAN. ∗ If the IDE identifies the device, select it and connect IDE with device. The default port number is 58888. Type in ‘root’ as username. Leave the password column blank then connect with the device.