Introduction: Galileo - Connect to Linux OS With an Ethernet Cable

I wrote a 'quick start' instructable for Galileo a while back and this is a second installment that covers how to connect directly to the underlying Linux operating system and thereby gain access to all sorts of powerful tools. I'm going to cover basics of using an ethernet cable along with a SSH program such as Telnet to interact with the Galileo system from your computer.

I'm attempting to write the simple set of instructions that I wish I would have had when I first started this experiment. Disclaimer: I'm still learning this stuff, so there may be better ways of doing this, but this is a snapshot of what has worked for me so far.

Skills required:

  • If you have just a small bit of unix experience, then you're at or above my level.
  • Basic Arduino skills.
  • How to connect the board, write a basic sketch, and upload it.

Here's a high level look at what we'll cover:

  • Set up a microSD card with proper Linux files
  • Set up network connection to the Galileo
  • Connect using Telnet or other SSH program like PuTTY

I'm going to assume you've already gone through the basic getting started stuff with Galileo. Note to Arduino experts using the Galileo for the first time: Don't skip the getting started portion. You'll want to update the firmware.

What you will need:

  • Ethernet cable
  • MicroSD card and some means of copying files to it from your computer. Some computers have built in slots for various types of SD cards. I use an adapter that plugs into a USB port on my computer and has slots for various card types.

Step 1: Copy the Proper Linux Files to the MicroSD Card

Do not connect the Galileo to your computer with a USB cable yet. We'll do this in Step 2.

Copy the proper Linux files to the microSD card.

  • Plug the microSD card into your computer (or the adapter that's connected to your computer).
  • Download the compressed file that contains the Linux image
  • Unzip the contents onto to the microSD card. If you don't have winzip or some other program capable of unzipping a .7z file, you can use this program: http://www.7-zip.org/

Step 2: Power Up the Galileo and Get It Connected

Next, we'll get the Galileo up and running. It's important to follow these steps in the order shown below.

  • Make sure the Galileo is off and everything is unplugged
  • plug the microSD card into the Galileo
  • plug the power cord into the Galileo and wait for the USB light to come on (the very first time may take a minute or so. This is normal)
  • plug the USB cable into the USB client connector on the board (the other end goes to your computer)
  • plug an ethernet cable into the Galileo and attach the other end to your router, or directly to your computer

Step 3: Enable the Network Connectivity on the Galileo

The next step is to enable the network connectivity on the Galileo. We will write a simple Arduino sketch to do this part.

Double check that the Arduino editor is set to use the proper serial port (under [tools] -> [serial port])

If you plugged the ethernet cable into a router, use the following code...

#include <Ethernet.h>

// the media access control (ethernet hardware) address for the Galileo:<br>byte mac[] =   { 0x98, 0x4F, 0xEE, 0x00, 0x4D, 0x0F }; // <--- MAC: 984FEE004D0F<br>//the IP address for the Galileo:<br>byte staticIp[] = { 199, 158, 1, 98 };   <br>void setup()<br>{<br>    Serial.begin(9600);<br>    Serial.println("Attempting to start Ethernet");<br>    if (Ethernet.begin(mac) == 0) {<br>        Serial.println("Failed to configure Ethernet using DHCP");<br>        Serial.println("Attempting to configure Ethernet using Static IP");<br>        Ethernet.begin(mac, ip);<br>    }<br>    Serial.print("Galileo IP address: ");<br>    Serial.println(Ethernet.localIP());<br>    system("telnetd -l /bin/sh");  // Start the telnet server<br>}<br><br>void loop () {}

You will need to make a couple of minor changes to the code above. Update the mac address and static ip. 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. The sticker will say MAC: ############
In the code above, the MAC address is specified as a series of hex formatted numbers. Just replace the numbers after each "0x" in the code with two numbers from your MAC address. Then update the static ip address as well (If your router has DHCP enabled, this last step may not be required.) Alternatively... if you plugged the ethernet cable directly into your computer, then use this code....

void setup()
{
  // put your setup code here, to run once:
  system("telnetd -l /bin/sh"); //Start the telnet server on Galileo
  system("ifconfig eth0 169.254.1.1 netmask 255.255.0.0 up");
 
}
void loop(){} 

In this case, you can update the code to use any static ip address you want. You'll need to take note of it though because you need that address when you connect via Telnet (or some other SSH program such as PuTTY).

FYI: A portion of the code samples above came from here:

https://communities.intel.com/thread/46335

and some of it came from here:

https://communities.intel.com/thread/45455

Step 4: Upload the Sketch and Give It a Try

That's it for the code changes. The next step is to upload the sketch and give it a try.

Upload the sketch (CTRL+L).
Display the 'serial monitor' in the Arduino IDE. [Tools] -->[serial monitor] Or press: CTRL+SHIFT+M
Press the reset button on the Galileo board. (it's a small button near the microSD card)
Wait approximately one minute for the board to reboot

Connecting with a router

If you're using the router approach, you should see a message in the serial monitor window that indicates the Galileo's assigned ip address. This will either be an address that your router dynamically assigned (via DHCP), or the staticIp address that you hard-coded in the sketch. Side note: For some reason, the ip address in the serial monitor window gets printed with some spaces between the first and second half. Don't include those spaces when providing the ip address to other programs. Include just the digits and dots.

Connecting directly to your computer

If you connected the ethernet cable directly to your computer, you already know the static ip address that was used in the code.

Tip: A quick way to confirm that the Galileo is connected to the network is to 'ping' its address from a cmd window.

Here's how:

  • [WIN]+R
  • cmd
  • ping [IpAddress]

If you see some 'reply' messages right away, you're in great shape. Continue to the next step.

If you see some sort of 'timeout' message or 'destination unreachable' messages, then you may have typed the wrong IP address. Sometimes the system can get goofed up waiting for a response. If you double checked the ip address and still get an error, you can try unplugging the ethernet cable, reset the Galileo, and re-connect the ethernet cable after the re-initialization is complete.
The detailed steps are:

  • unplug the ethernet cable.
  • press the reset button on the Galileo
  • wait a full minute for the system to reinitialiize
  • re-connect the ethernet cable
    Then try to ping it again.

Step 5: Connect to the Linux Operating System That's Running on the Galileo

Now you can connect to the Linux operating system that's running on the Galileo using a SSH program such as Telnet or PuTTY. I'm going to use Telnet.

Telnet is an accessory program that's included with Windows. On newer versions of Windows, it's not enabled by default but it's easy to enable it if needed. Here's how:

  • Go to control panel
  • Programs -> Programs and features
  • Turn Windows Features on or off
  • Check 'Telnet client' and click ok to close the dialog.

Now return to cmd window where we did the ping operation and run Telnet.

We want to open a connection to the Galileo. The syntax is "open [ipAddress]"

In the cmd window, type:
telnet open [ipAddress]

Now you can run basic unix shell commands. For example, you can list the files and directories like this:

ls -l

The Arduino compatible pins on the board can be manipulated through file operations. Here's an interesting bit of info on that...

https://communities.intel.com/message/209773#20977...

Side note: If you use PuTTY, the connection starts with a request to log in. Just type root and press enter. You're in. Not much security there... err ah... no security.

Comments

author
Michael_of_SI (author)2015-06-21

Thank you for the contribution! The dynamic IP code has a small error in it:

Ethernet.begin(mac, ip);

... should be

Ethernet.begin(mac, staticIp);

(also, the code block has HTML <br> sequences in it, instead of line wraps)

author
Vijayenthiran (author)2015-06-16

Hi,

I followed all the steps correctly, I am trying to access the Linux via Ethernet connected to my laptop. The ping to the Galileo was successful. But I couldn't open the telnet connection. What should I do to fix it?

1.PNG2.PNG
author
vinaysagark (author)2015-03-01

i tried to do the step 4 but its not working. when i try to upload that file error message is coming like no such device. how can i over come this pbm?

Untitled.png
author
kurt-beheydt (author)vinaysagark2015-03-19

replace

Ethernet.begin(mac, ip);

with

Ethernet.begin(mac, staticIp);

author
prantik.sarkar85 (author)2014-12-03

Bravo...

author
prantik.sarkar85 (author)2014-12-03

Good Job