1 2 3 Previous Next 31 Replies Latest reply on Jul 19, 2015 10:25 PM by telnet

    Using Galileo Linux over Ethernet(Telnet)


      Hi Guys,


      Here's a cheap/easy way of using Galileo Linux, the only additional cable required is an Ethernet cable.


      How to - Use Galileo Linux with only an Ethernet cable directly connected between laptop and Galileo…


      1. Attach the Ethernet cable directly from the Galileo to your Laptop.
      2. Create a new sketch. In the setup function –
        1. Start the telnet server on Galileo (system("telnetd -l /bin/sh");)
        2. Give Galileo eth0 an IP address in the Link Local Address range 169.254.x.x (system("ifconfig eth0 netmask up");)
      3. Link Local Automatic addressing will assign your Windows or Mac an IP address, usually taking no longer than a minute. http://en.wikipedia.org/wiki/Link-local_address .
      4. Use putty or any Telnet client to connect to Galileo using the IP address you assigned to Galileo eth0.




      How to – Use Galileo Linux using an Ethernet cable and a home network Router(DHCP server)


      1. Attach Galileo to your router(DHCP server) using an Ethernet cable.
      2. Create a new sketch –
        1. In setup function - Start the telnet server on Galileo (system("telnetd -l /bin/sh");)
        2. In Loop - Call ifconfig and redirect the output to ttyGS0 (system("ifconfig eth0 > /dev/ttyGS0");)  so you can view Galileo’s IP address on the serial Monitor. We call this in the loop function because the serial monitor closes on sketch upload
      3. Use putty or any Telnet client to connect to Galileo using the IP address returned on the Serial Monitor from ifconfig.


        • 1. Re: Using Galileo Linux over Ethernet(Telnet)

          Thank you Mak3r.  Works for me.  However when I connect I don't get the "Poky....."  message on the top of you terminal.


          Also for those going to test this out, I was confused at first. Yes you still need to use the USB cable to Galileo board to upload your sketch.  After wards though you can take it out even after reboot since the sketch is now persistent.


          Using method #2, it takes about a 10-15 secs before the board reconnects to my network again after a power



          Did a quick script on python and so far it works. Now if only someone would posts how to access those headers/pins/IOs from python itself.

          • 2. Re: Using Galileo Linux over Ethernet(Telnet)

            Makki- I can sort you out there.

            On Galileo, controlling GPIOs from userspace is done using the sysfs interface which I'll leave you to read up on independently.

            Give me some time to gather the necessary diagrams and I'll post them here- you'll need them because they detail the mappings between userspace GPIOs and physical pins on the arduino header, and also which muxes need to be set to enable a particular GPIO.

            • 3. Re: Using Galileo Linux over Ethernet(Telnet)

              it appears I can't attach files to forum posts, so here is a temporary link to a PDF of the pin mappings diagram


              I think it's good for 30 days or something, it will do until we figure out a better way to share files here.


              This diagram warrants a bit of explanation. below is a simple example of controlling a GPIO from the linux command prompt (let's use gpio3 as an example).


              echo "3" > /sys/class/gpio/export                    //write a "3" to the export file, which reserves gpio3 for use

              echo "out" > /sys/class/gpio/gpio3/direction   //sets gpio3 as an output

              echo "1" > /sys/class/gpio/gpio3/value           //sets gpio3 high

              echo "0" > /sys/class/gpio/gpio3/value           //sets gpio3 low

              echo "3" > /sys/class/gpio/unexport               //unexport gpio3- can now be used by something/someone else


              now, this holds true for Galileo, except for one small detail;

              most of the I/Os are behind a mux to allow multiple functions for one pin (no native pin muxing on Quark).

              In practice, this means that if you want to set one GPIO to high, you actually have to export and perform a write operation on two GPIOs.

              Let's walk through an example of this with the I/O mapping PDF. We're going to set pin 0 on the arduino header to high.

              Take a look at the first table, labelled "I/O Mappings". in the first column labelled "Arduino IDE ID" we have all the pin numbers from the arduino header. Take the first value which is IO0- this is the pin we're looking for. Now follow along in the row until you come to the '"Linux" column- which contains a value of 50.

              This means that pin 0 on the arduino header corresponds to gpio50 in sysfs (/sys/class/gpio/gpio50).

              However, if we want to access this pin, we first have to set the appropriate mux value. So, now look at the "I/O function muxing" table- the first two colums are "0" and "1". under the "1" column, find IO0, and follow the row along to the "Linux GPIO ID" column, which contains a value of 40.

              So, now we know that, in order to set IO0 high, we need to first set gpio40 high and then gpio50.


              echo "40" > /sys/class/gpio/export                    //write a "40" to the export file, which reserves gpio40 for use

              echo "out" > /sys/class/gpio/gpio40/direction    //sets gpio40 as an output

              echo "1" > /sys/class/gpio/gpio40/value            //sets gpio40 high

              echo "50" > /sys/class/gpio/export                    //write a "50" to the export file, which reserves gpio50 for use

              echo "out" > /sys/class/gpio/gpio50/direction    //sets gpio50 as an output

              echo "1" > /sys/class/gpio/gpio50/value            //sets gpio50 high

              • 4. Re: Using Galileo Linux over Ethernet(Telnet)

                Thank you arduino_4_life. I would assume the best place for that file is in the documents section of this forum.

                I will try those tonight.

                • 5. Re: Using Galileo Linux over Ethernet(Telnet)

                  The IO Mappings file has been uploaded to the document forum:





                  • 6. Re: Using Galileo Linux over Ethernet(Telnet)

                    arduino_4_life/Jorge I was trying this out today to drive the onboard led using this:


                    MUX control:

                    echo "55" > /sys/class/gpio/export

                    echo "out" > /sys/class/gpio/gpio55/direction

                    echo "1" > /sys/class/gpio/gpio55/value


                    Turn LED IO13 on:

                    echo "39" > /sys/class/gpio/export                  
                    echo "out" > /sys/class/gpio/gpio39/direction  

                    echo "1" > /sys/class/gpio/gpio39/value    


                    It doesn't seem to work. Anything I am missing here?

                    • 7. Re: Using Galileo Linux over Ethernet(Telnet)

                      The onboard LED is not actually controlled by pin 13- from an Arduino sketch, toggling pin 13 will toggle the onboard LED, however if you want to do it from linux then you need to use gpio3 (this one's not mentioned in the IO mapping doc)


                      No mux needs to be set for this-


                      echo 3 > /sys/class/gpio/export

                      echo out > /sys/class/gpio/gpio3/direction

                      echo 1 > /sys/class/gpio/gpio3/value



                      • 8. Re: Using Galileo Linux over Ethernet(Telnet)

                        I tried to get this tutorial to work on a Mac last night and was having some issues. I followed the steps in the Getting Started pdf to load the Clanton image onto my SD card, and then connected the Galileo through ethernet to my Macbook.


                        Using the Network settings in System Preferences, I was able to set up a connection to Galileo through ethernet with an IP address of 169.254.x.x.  This connection works when running the WebClient (http://arduino.cc/en/Tutorial/WebClient) sketch; I am able to Get and display HTTP code from a website.


                        I am unable to SSH using the command ssh root@169.254.x.x or ssh 169.254.x.x ; I get "connection refused on port 22".  I can successfully ping the IP address and there is 0% packet loss. I looked into it more and I'm not sure if Linux or SSH is running properly on the board.  I see the SD light blink for about a minute, which is supposed to indicate booting from the SD, but when I load a sketch through USB and then look at the contents of the SD card, there are no additional directories created (i.e. no \sketch).  It just has the files I initially loaded.


                        The SD card is named BOOTME, and I've tried erasing it and formatting it in FAT32 and FAT16. It's a Sandisk 16GB SDHC microSD card.


                        Any ideas?


                        I was also wondering if the IP address you assign in the sketch should be the same as the IP address the computer assigns in the Network settings menu to the ethernet port, or if it should be different.  I am not too familiar with networking, so docs or further clarification would be really helpful.

                        • 9. Re: Using Galileo Linux over Ethernet(Telnet)
                          Clayton Hofrock

                          I had this same problem, not being able to connect via ssh, but other things were working. I think I figured out the fix, but I never tried it.


                          Just because the Ethernet is up and running does not mean the ssh service is up and running. If you have a Linux console up and running (via serial cable) then you should be able to run this command and see if the service is up and running:


                          $ sudo /etc/init.d/ssh status


                          If you do not have a serial cable, and do not have Linux console up and running, you should be able to start the ssh by executing a liunx command from within an Arduino sketch. Just add this line to the setup function for one of the sketches that is working properly (WebClient)


                          system("sudo service ssh start")


                          I have not tried this, but I am fairly sure it should work.

                          • 10. Re: Using Galileo Linux over Ethernet(Telnet)

                            Thanks, this is what I was looking for.  I will try the Arduino sketch and post later.

                            • 11. Re: Using Galileo Linux over Ethernet(Telnet)

                              I just tried to ssh into my Galileo, and it worked straight away- heres what I did;

                              (I'm using a Centrino mPCIe wifi card- if you're using a direct ethernet connection then you can skip step 1)


                              1. upload the 'Connect with WPA' WiFi example sketch


                              2. once you're connected to your WiFi network, upload another sketch with these two lines in the 'loop' function;

                                  ( don't worry, the network connection will persist even after you've uploaded a new sketch)


                                       system("ifconfig > /dev/ttyGS0");



                              and open up the Serial Monitor to see the results. We're looking for an IP address- mine is called 'wlan0 inet addr', if you're using ethernet it'll be 'eth0'.


                              3. open puTTY, or another terminal emulator or SSH client, and connect to 'root@' on port 22 (replace IP address with the one you got from step 2), and viola!

                              • 12. Re: Using Galileo Linux over Ethernet(Telnet)

                                I tried the Arduino sketch from chofrock and wasn't successful - still got "Port 22 connection refused". 


                                To debug, since I don't have the proper serial cable, I tried to use another Arduino as a serial-to-USB converter without any luck.  I plugged TX from Galileo into RX of Arduino 2, and RX from Galileo into TX of Arduino 2, and connected the GNDs together.  Then I plugged Arduino 2 into my laptop via USB, but I was unable to connect to the device in the serial monitor.  Has anyone used Arduino as a serial-to-USB successfully?


                                Also, when I run a sketch when booting from the SD, should a /sketch directory be created in the SD root (none is being created)? And should the card be formatted to FAT16 or FAT32?


                                I will try arduino_4_life's method tonight.

                                • 13. Re: Using Galileo Linux over Ethernet(Telnet)

                                  I tried this:


                                  echo 3 > /sys/class/gpio/export

                                  echo out > /sys/class/gpio/gpio3/direction

                                  echo 1 > /sys/class/gpio/gpio3/value


                                  and the first command gave 'device error: device or resource busy'. I saw that the /sys/class/gpio/gpio3 directory was already created so tried commands 2 and 3 out - worked ok. I could merrily turn the light on and off setting the value to 0 and 1. I thought I'd put this here since others may find the same. Perhaps the latest clanton image has these already created/exported?


                                  Today a blinking light - next month control of the heating system - I have great plans for my little board!



                                  • 14. Re: Using Galileo Linux over Ethernet(Telnet)

                                    I had the same issue (SSH connection refused but ping was responding)

                                    The way to make it work was to upgrade board firmware (was 732 out of the box and 782 after upgrade)



                                    1 2 3 Previous Next