11 Replies Latest reply on Jun 10, 2016 2:52 PM by FGT

    Galileo 1 Connection Through Ethernet Cable

    FGT

      Hi,

       

      Just sharing my experiments related to the subject of this discussion: Galileo 1 Connection through Ethernet Cable.

       

      Maybe you already know everything, but maybe I'm losing something and you'll be able to suggest/fix some mistake I eventually make.

       

      Every subsequent post will be a specific experiment: direct connection, with/out SD card, connection to a router, etc.

       

      Fernando.

        • 1. Re: Galileo 1 Connection Through Ethernet Cable
          FGT

          First experiment: Galileo firmware already updated, No SD card, direct connection to a laptop, serial cable.

           

          Once started, I have the Yocto console via the serial cable.

           

          It's not relevant whether the Ethernet cable is connected at startup or not.

           

          Without the Ethernet cable connected to the laptop, the laptop Ethernet interface is not "up", no IP assigned/shown.

           

          Once the Ethernet cable is connected to the laptop, the laptop Ethernet interface is assigned an IP, which in my case is 169.254.72.151

           

          At the Galileo:

          root@clanton:~#  cat /sys/firmware/board_data/flash_version

          0x01000400

          root@clanton:~# ifconfig -a

          eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:00

                    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)

                    Interrupt:41 Base address:0x8000

           

          lo        Link encap:Local Loopback

                    inet addr:127.0.0.1  Mask:255.0.0.0

                    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)

           

          i.e. the eth0 is not "up & running".

           

          issuing the command for the eth0 interface, i.e.

           

          root@clanton:~# ifconfig eth0 169.254.72.152 netmask 255.255.255.0 up

          (optional, just to check previous command result)

          root@clanton:~# ifconfig -a

          eth0      Link encap:Ethernet  HWaddr 98:4F:EE:01:0E:99

                    inet addr:169.254.72.152  Bcast:169.254.72.255  Mask:255.255.255.0

                    UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

                    RX packets:8 errors:0 dropped:0 overruns:0 frame:0

                    TX packets:4 errors:0 dropped:0 overruns:0 carrier:0

                    collisions:0 txqueuelen:1000

                    RX bytes:886 (886.0 B)  TX bytes:232 (232.0 B)

                    Interrupt:41 Base address:0x8000

           

          lo        Link encap:Local Loopback

                    inet addr:127.0.0.1  Mask:255.0.0.0

                    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)

           

          it's possible to ping from a windows command line. And issuing the command for the telnet server at the Galileo, i.e.

           

          root@clanton:~# telnetd -l /bin/sh

           

          it's possible to connect via a telnet client to the Galileo, e.g. using PuTTY and setting IP (169.254.72.152 in this case) and telnet, another console is obtained, via the telnet client.

           

          All of this is possible if a serial cable is available, since the commands ifconfig-telnetd have to be run in the Galileo. The next post will be about using a sketch so that it is possible to avoid using the serial cable. Actually, it is documented at Intel the site, but I'll post anyway for the sake of "completeness".

           

          Once the power is lost, the eth0 configuration and telnet server are lost, nothing of this is persistent.

           

          HTH,

           

          Fernando.

          • 2. Re: Galileo 1 Connection Through Ethernet Cable
            FGT

            Second experiment: Galileo firmware already updated, No SD card, direct connection to a laptop, no serial cable.

             

            Given that it is not always possible to have a serial cable (that for the Galileo Gen 1 is pretty "strange"... or at least it is for me) I've used an Arduino sketch to set the eth0 interface and start the telnet server in the Galileo. Also, this avoids to remember to carry the serial cable along with the Galileo card. More specifically, the "initial" sketch for setting eth0 and starting the telnet server is:

             

            /*
              Sketch running on Intel Galileo
            
              Starts Ethernet-TCP/IP with a specific IP
            
              Starts telnetd so that it's possible to use PuTTY telnet client
            
              Blinks the LED (pin 13) so that it's clear when the card completed the boot process
            
              Fernando G. Tinetti
            */
            
            
            /***************************************************************/
            void setup()
            {
              // Start Ethertnet-TCP/IP subsistem
              system("ifconfig eth0 169.254.72.152 netmask 255.255.0.0 up");  // Use your IP here
            
              // Start telnet server
              system("telnetd -l /bin/sh");
            
              // initialize digital pin 13 as an output.
              pinMode(13, OUTPUT);
            }
            
            void loop()
            {
              digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
              delay(1000);              // wait for a second
              digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
              delay(1000);              // wait for a second
            }
            
            
            
            
            
            
            
            
            
            

             

            Once this sketch is uploaded to the Galileo card, it is possible to use the telnet client (e.g.PuTTY telnet).

             

            This is the "initial" sketch since I usually add the lines

             

              // Start Ethertnet-TCP/IP subsistem

              system("ifconfig eth0 169.254.72.152 netmask 255.255.0.0 up");  // Use your IP here

              // Start telnet server

              system("telnetd -l /bin/sh");

             

            to almost all sketches in Galileo, so that I have the telnet available for a command line.

             

            Again, without SD card the sketch is not persistent, so the eth0 and telnet server are "lost" once the Galileo card is turned off.

             

            HTH,

             

            Fernando.

            • 3. Re: Galileo 1 Connection Through Ethernet Cable
              FGT

              Third and Fourth experiments: similar to the first and second experiments respectively, but the Ethernet cable connected to the home wifi router.

               

              Everything works as in the first and second experiments, except:

              a) The laptop Ethernet is not used, so every network connection goes through the wifi router

              b) The IP assigned to the Galileo eth0 should be in the wifi LAN, in my case 192.168.0.X

              c) The IP assigned to the Galileo eth0 should not be in conflict with any other IP assigned by the wifi DHCP. It is not necessarily known every assigned IP by the wifi router DHCP in advance, but in my case they were all below 100, so I used 192.168.0.100 in every example (given in the previous posts).

               

              The interesting point in this case is that every computer and wifi device such as mobile phones and tablets at home are now able to interact with the Galileo, not only my laptop as in the previous examples. Having a fixed IP is very useful in case a web server is run, which is straightforward, taking into account the examples in the Arduino IDE.

               

              Since no SD card is used, every setting is lost once the Galileo card is turned off.

               

              HTH,

               

              Fernando.

              • 4. Re: Galileo 1 Connection Through Ethernet Cable
                FGT

                Fifth experiment: Galileo firmware already updated, SD card, direct connection to a laptop, no serial cable.

                 

                Having set the SD card so that sketches are made persistent (as described in the Intel documentation) let the card to be set with the sketch of the second experiment without loading the sketch every time it restarts (as a is standard in Arduino, actually). Thus, eth0 and the telnet server are always "up & running", it is not needed the micro USB anymore, just the Ethernet cable connected to the laptop and the SD card plugged in.

                 

                HTH,

                 

                Fernando.

                • 5. Re: Galileo 1 Connection Through Ethernet Cable
                  FGT

                  Sixth experiment: Galileo firmware already updated, SD card, Ethernet cable connected to the home wifi router, no serial cable.

                   

                  Using the SD card and the Galileo connected to the home wifi router (which includes a DHCP server), implies the Galileo eth0 gets an IP address automatically by the first time (according to the sequence of experiments in this thread). This is because the yocto in the SD card connects to the DCHP server, as shown in the boot process with:

                   

                  Sending discover...

                  Sending select for 192.168.0.15...

                  Lease of 192.168.0.15 obtained, lease time 3600

                   

                  I don't know how is handled the DHCP lease time, though. The eth0 IP is also confirmed with

                   

                  root@clanton:~# ifconfig

                  eth0      Link encap:Ethernet  HWaddr 98:4F:EE:01:0E:99

                            inet addr:192.168.0.15  Bcast:192.168.0.255  Mask:255.255.255.0

                            inet6 addr: fe80::9a4f:eeff:fe01:e99/64 Scope:Link

                            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

                            RX packets:634 errors:0 dropped:0 overruns:0 frame:0

                            TX packets:28 errors:0 dropped:0 overruns:0 carrier:0

                            collisions:0 txqueuelen:1000

                            RX bytes:39612 (38.6 KiB)  TX bytes:4015 (3.9 KiB)

                            Interrupt:40 Base address:0xc000

                   

                  The telnet server is not running, but the sshd (ssh server) is, so it is possible have a terminal-command line with a ssh client (again, PuTTY can be used as client, this time setting ssh as protocol and the corresponding IP). The only "problem" is that the IP received by DHCP is not know in advance (at least not by default). Beyond scanning for "new IP" whenever the Galileo is turned on, it is possible to use a sketch so set a fixed IP. Otherwise, if the Galileo card is going to be used as a client (sending data/status to some server) then it is not necessary to know the Galileo specific IP. Furthermore, the DNS in the Galileo is already running (also available in the SD card yocto) so it is possible to take advantage of this service in the Galileo too, without any specific effort, it's already running.

                   

                  HTH;

                   

                  Fernando.

                  • 6. Re: Galileo 1 Connection Through Ethernet Cable
                    FGT

                    The SD card referred to in the previous experiments uses the so called (for short) uclibc image. The current SD image to use now is the so called (for short) egclibc image... There are some descriptions in this forum and at Intel site/s so I'll not go further on similarities/differences, beyond that a) they are different and the b) the egclibc is the current one.

                     

                    The egclibc image does not include telnet (at least the current egclibc image), which is assumed to be included in the previous posts in this thread. This is not really a problem, though, since the egclibc does include ssh (at least the current egclibc image), so instead of using a telnet client you one should use a ssh client (just another option of PuTTY, in my case).

                     

                    Another difference among yocto images: the Ethernet interface is not named eth0. In my case it is enp0s20f6:avahi, and the assigned name can be known by using ifconfig, as always.

                     

                    All the previous experiments can be carried out with the egclibc image, taking into account differences described above (e.g. no telnetd usage).

                    HTH,

                     

                    Fernando.

                    • 7. Re: Galileo 1 Connection Through Ethernet Cable
                      FGT

                      I've seen some XDK developers have to use the serial console to set/know the IP... I would use a static IP in case there is some server (e.g. HTTP) running in Galileo. There are several alternatives I think. I've seen two of them:

                      a) ifconfig

                      b) connman

                      I've used a), as described at https://communities.intel.com/thread/100013

                       

                      HTH,

                       

                      Fernando.

                      • 8. Re: Galileo 1 Connection Through Ethernet Cable
                        FGT

                        I forgot in the previous post: there should be an image with a predefined IP set, so the serial console is never necessary. The computer connected to the Galileo should have another IP in the same LAN, which is simple to do, and the connectivity should be complete. As far as I know, the same tool to write the image in the SD card can be used to obtain the image from the SD card (with yocto setting a fixed IP).

                         

                        Fernando.

                        • 9. Re: Galileo 1 Connection Through Ethernet Cable
                          FGT

                          A Galileo web server ... mixing several simple ideas... attached with some explanations and code

                           

                          HTH.

                           

                          Fernando.

                          • 10. Re: Galileo 1 Connection Through Ethernet Cable
                            Xiaoyu

                            Hi Fernando,

                            Thanks for your great work! I'm new to Galileo and just get started, I noticed the 6th experiment, it's quite like what I got so far, (boot from SD card, Ethernet cable connected to the home wifi router) but also with a serial cable so that I can note down the IP address and later practice ssh. However when I tried ssh the IP address with Putty, there was no response. Then I ping "www.google.com" from the board, it failed either. Could you advise on that? Is there anything I miss to setup the Ethernet function? Thanks so much.

                             

                            Regards,

                            Xiaoyu

                            • 11. Re: Galileo 1 Connection Through Ethernet Cable
                              FGT

                              Hi Xiaoyu,

                               

                              You are welcome,

                              I noticed the 6th experiment, it's quite like what I got so far, (boot from SD card, Ethernet cable connected to the home wifi router) but also with a serial cable so that I can note down the IP address and later practice ssh. However when I tried ssh the IP address with Putty, there was no response.

                              Hmmm... this is strange... pls tell me:

                              a) The result of ping from the PC with PuTTY (just use command line ping)

                              b) Check you do not have any sketch or setting an IP other than the one you see with ifconfig in the serial console

                              c) The output of

                              ps | grep ssh

                               

                              Then I ping "www.google.com" from the board, it failed either. Could you advise on that? Is there anything I miss to setup the Ethernet function? Thanks so much.

                              This is rather usual, since the standard yocto image does not set DNS servers, so there is no way of resolving any name server IP. There are some threads in this forum about setting DNS server in case you need to resolve DNS names.

                               

                              HTH,

                               

                              Fernando.

                              1 of 1 people found this helpful