3 Replies Latest reply on Feb 21, 2014 10:32 AM by AlexT_Intel

    Galileo - switching from static to DHCP not working properly

    Enrico204

      I've discovered an "unwanted behavior" (bug I think) when you switch from static to DHCP address; step to reproduce:

      1. Send a sketch to Galileo with Ethernet.begin(mac, ip)  (static address)

      2. Galileo has the right (static) IP

      3. Modify the sketch to use DHCP (eg. remove ip parameter) and send it to Galileo

      4. Galileo starts the sketch and still use the old (static) IP address

      4a. You can resend the sketch more and more, but still...

      5. Cold reboot Galileo (unplug USB, unplug power, plug power, plug USB, resend sketch) and now DHCP works

       

      I don't have any Wireshark capture right now. I suppose that Galileo isn't requesting DHCP address on step 4 even if it's istructed to do so.

        • 1. Re: Galileo - switching from static to DHCP not working properly
          AlexT_Intel

          Well, that's because Galileo doesn't really re-initialize the network each time you restart the sketch. Network is configured, as it is usually in UNIX, during the board boot process and sketch just uses the existing connection. And due to that fact, the DHCP->static switching is possible on the fly (as well as trying different static IPs), but static->DHCP would require restarting the DHCP daemon on the board.

           

          But you still can do this from the sketch, though that won't be your conventional Arduino aproach. You'd need to issue the restart command to DHCP daemon using the system() function. Probably the simplest way would be to restart the "networking" service, which would take care of all the things.

           

          Like this:

          system("/etc/init.d/networking restart");

          That would restart the networking subsystem and it will get back to the DHCP (provided you haven't changed anything in the default network setup).

           

          Hope this helps.

          • 2. Re: Galileo - switching from static to DHCP not working properly
            Enrico204

            Well I think that this can be managed by firmware (on-board Linux itself?) when new sketch is loaded, either rebooting network on new sketch or by matching the sketch configuration (eg. if sketch is in DHCP, check if daemon is running; else stop daemon if running and setup fixed IP).

             

            I know that this can be an unusual condition (and this behavior is noticeable only when flashing), but I think that Arduino-like approach is better than actual "mechanism"/"workaround" (you called this board "Arduino Galileo"...).

            • 3. Re: Galileo - switching from static to DHCP not working properly
              AlexT_Intel

              Make no mistake - I'm not saying the current behavior is good or the only possible :-) I just wanted to help you get past that problem and explain what the reason is.

               

              I think what you describe should be doable and indeed would bring the actual behavior closer to the one demonstrated by native Arduino libraries, which should be a good thing for sure. Hopefully that will get corrected in future releases.